summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwkorman <wkorman@chromium.org>2016-03-25 17:25:07 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-26 00:26:01 +0000
commitaad73e43d54fd67fc09f01570946c94667a3a81a (patch)
tree549330c848d8b20f3aa899e84da613b50cb253b6
parentdb5935f15f750739a5937e60e26b2ede16ba803d (diff)
downloadchromium_src-aad73e43d54fd67fc09f01570946c94667a3a81a.zip
chromium_src-aad73e43d54fd67fc09f01570946c94667a3a81a.tar.gz
chromium_src-aad73e43d54fd67fc09f01570946c94667a3a81a.tar.bz2
Correct visual rect for PageOverlay to reflect size of graphics layer.
BUG=529938,569211 Review URL: https://codereview.chromium.org/1833233002 Cr-Commit-Position: refs/heads/master@{#383418}
-rw-r--r--third_party/WebKit/Source/web/PageOverlay.cpp6
-rw-r--r--third_party/WebKit/Source/web/PageOverlay.h3
-rw-r--r--third_party/WebKit/Source/web/PageOverlayTest.cpp52
3 files changed, 40 insertions, 21 deletions
diff --git a/third_party/WebKit/Source/web/PageOverlay.cpp b/third_party/WebKit/Source/web/PageOverlay.cpp
index a1cfd0a..156ad70 100644
--- a/third_party/WebKit/Source/web/PageOverlay.cpp
+++ b/third_party/WebKit/Source/web/PageOverlay.cpp
@@ -97,6 +97,12 @@ void PageOverlay::update()
m_layer->setNeedsDisplay();
}
+LayoutRect PageOverlay::visualRect() const
+{
+ ASSERT(m_layer.get());
+ return LayoutRect(FloatPoint(), m_layer->size());
+}
+
IntRect PageOverlay::computeInterestRect(const GraphicsLayer* graphicsLayer, const IntRect&) const
{
return IntRect(IntPoint(), expandedIntSize(m_layer->size()));
diff --git a/third_party/WebKit/Source/web/PageOverlay.h b/third_party/WebKit/Source/web/PageOverlay.h
index 815552e..6eb1917 100644
--- a/third_party/WebKit/Source/web/PageOverlay.h
+++ b/third_party/WebKit/Source/web/PageOverlay.h
@@ -69,8 +69,7 @@ public:
// DisplayItemClient methods.
String debugName() const final { return "PageOverlay"; }
- // TODO(chrishtr): fix this.
- LayoutRect visualRect() const override { return LayoutRect(); }
+ LayoutRect visualRect() const override;
// GraphicsLayerClient implementation
IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const override;
diff --git a/third_party/WebKit/Source/web/PageOverlayTest.cpp b/third_party/WebKit/Source/web/PageOverlayTest.cpp
index 935ae39..bf2036c 100644
--- a/third_party/WebKit/Source/web/PageOverlayTest.cpp
+++ b/third_party/WebKit/Source/web/PageOverlayTest.cpp
@@ -46,6 +46,24 @@ void disableAcceleratedCompositing(WebSettings* settings)
settings->setAcceleratedCompositingEnabled(false);
}
+// PageOverlay that paints a solid color.
+class SolidColorOverlay : public PageOverlay::Delegate {
+public:
+ SolidColorOverlay(Color color) : m_color(color) { }
+
+ void paintPageOverlay(const PageOverlay& pageOverlay, GraphicsContext& graphicsContext, const WebSize& size) const override
+ {
+ if (DrawingRecorder::useCachedDrawingIfPossible(graphicsContext, pageOverlay, DisplayItem::PageOverlay))
+ return;
+ FloatRect rect(0, 0, size.width, size.height);
+ DrawingRecorder drawingRecorder(graphicsContext, pageOverlay, DisplayItem::PageOverlay, rect);
+ graphicsContext.fillRect(rect, m_color);
+ }
+
+private:
+ Color m_color;
+};
+
class PageOverlayTest : public ::testing::Test {
protected:
enum CompositingMode { AcceleratedCompositing, UnacceleratedCompositing };
@@ -62,6 +80,11 @@ protected:
WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); }
+ PassOwnPtr<PageOverlay> createSolidYellowOverlay()
+ {
+ return PageOverlay::create(webViewImpl(), new SolidColorOverlay(SK_ColorYELLOW));
+ }
+
template <typename OverlayType>
void runPageOverlayTestWithAcceleratedCompositing();
@@ -69,24 +92,6 @@ private:
FrameTestHelpers::WebViewHelper m_helper;
};
-// PageOverlay that paints a solid color.
-class SolidColorOverlay : public PageOverlay::Delegate {
-public:
- SolidColorOverlay(Color color) : m_color(color) { }
-
- void paintPageOverlay(const PageOverlay& pageOverlay, GraphicsContext& graphicsContext, const WebSize& size) const override
- {
- if (DrawingRecorder::useCachedDrawingIfPossible(graphicsContext, pageOverlay, DisplayItem::PageOverlay))
- return;
- FloatRect rect(0, 0, size.width, size.height);
- DrawingRecorder drawingRecorder(graphicsContext, pageOverlay, DisplayItem::PageOverlay, rect);
- graphicsContext.fillRect(rect, m_color);
- }
-
-private:
- Color m_color;
-};
-
template <bool(*getter)(), void(*setter)(bool)>
class RuntimeFeatureChange {
public:
@@ -107,7 +112,7 @@ TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing)
initialize(AcceleratedCompositing);
webViewImpl()->layerTreeView()->setViewportSize(WebSize(viewportWidth, viewportHeight));
- OwnPtr<PageOverlay> pageOverlay = PageOverlay::create(webViewImpl(), new SolidColorOverlay(SK_ColorYELLOW));
+ OwnPtr<PageOverlay> pageOverlay = createSolidYellowOverlay();
pageOverlay->update();
webViewImpl()->updateAllLifecyclePhases();
@@ -134,5 +139,14 @@ TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing)
graphicsContext.endRecording()->playback(&canvas);
}
+TEST_F(PageOverlayTest, PageOverlay_VisualRect)
+{
+ initialize(AcceleratedCompositing);
+ OwnPtr<PageOverlay> pageOverlay = createSolidYellowOverlay();
+ pageOverlay->update();
+ webViewImpl()->updateAllLifecyclePhases();
+ EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight), pageOverlay->visualRect());
+}
+
} // namespace
} // namespace blink