| Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
|
| index 0490a8a6afbb8ad3ba708df11d3531821a2dae77..8592876c59a473c79c96efd8f18f93e8534dfe40 100644
|
| --- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
|
| @@ -8,6 +8,7 @@
|
| #include "core/frame/FrameView.h"
|
| #include "core/layout/LayoutBoxModelObject.h"
|
| #include "core/layout/LayoutTestHelper.h"
|
| +#include "core/layout/LayoutView.h"
|
| #include "core/paint/PaintLayer.h"
|
| #include <gtest/gtest.h>
|
|
|
| @@ -48,22 +49,13 @@ private:
|
| bool m_originalSlimmingPaintSynchronizedPaintingEnabled;
|
| };
|
|
|
| -static void printRect(IntRect rect)
|
| -{
|
| - fprintf(stderr, "[x=%d y=%d maxX=%d maxY=%d]\n", rect.x(), rect.y(), rect.maxX(), rect.maxY());
|
| -}
|
| -
|
| -static bool checkRectsEqual(const IntRect& expected, const IntRect& actual)
|
| -{
|
| - if (expected != actual) {
|
| - fprintf(stderr, "Expected: ");
|
| - printRect(expected);
|
| - fprintf(stderr, "Actual: ");
|
| - printRect(actual);
|
| - return false;
|
| - }
|
| - return true;
|
| -}
|
| +#define EXPECT_RECT_EQ(expected, actual) \
|
| + do { \
|
| + EXPECT_EQ(expected.x(), actual.x()); \
|
| + EXPECT_EQ(expected.y(), actual.y()); \
|
| + EXPECT_EQ(expected.width(), actual.width()); \
|
| + EXPECT_EQ(expected.height(), actual.height()); \
|
| + } while (false)
|
|
|
| TEST_F(CompositedLayerMappingTest, SimpleInterestRect)
|
| {
|
| @@ -73,7 +65,7 @@ TEST_F(CompositedLayerMappingTest, SimpleInterestRect)
|
| Element* element = document().getElementById("target");
|
| PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
|
| ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 200), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, TallLayerInterestRect)
|
| @@ -86,7 +78,7 @@ TEST_F(CompositedLayerMappingTest, TallLayerInterestRect)
|
| ASSERT_TRUE(paintLayer->graphicsLayerBacking());
|
| // Screen-space visible content rect is [8, 8, 200, 600]. Mapping back to local, adding 4000px in all directions, then
|
| // clipping, yields this rect.
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 4592), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 200, 4592), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, RotatedInterestRect)
|
| @@ -98,7 +90,7 @@ TEST_F(CompositedLayerMappingTest, RotatedInterestRect)
|
| Element* element = document().getElementById("target");
|
| PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
|
| ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 200), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, 3D90DegRotatedTallInterestRect)
|
| @@ -112,7 +104,7 @@ TEST_F(CompositedLayerMappingTest, 3D90DegRotatedTallInterestRect)
|
| Element* element = document().getElementById("target");
|
| PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
|
| ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 4000), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 200, 4000), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, 3D45DegRotatedTallInterestRect)
|
| @@ -124,7 +116,7 @@ TEST_F(CompositedLayerMappingTest, 3D45DegRotatedTallInterestRect)
|
| Element* element = document().getElementById("target");
|
| PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
|
| ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 4592), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 200, 4592), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, RotatedTallInterestRect)
|
| @@ -136,7 +128,7 @@ TEST_F(CompositedLayerMappingTest, RotatedTallInterestRect)
|
| Element* element = document().getElementById("target");
|
| PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
|
| ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 4000), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 200, 4000), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, WideLayerInterestRect)
|
| @@ -149,7 +141,7 @@ TEST_F(CompositedLayerMappingTest, WideLayerInterestRect)
|
| ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
|
| // Screen-space visible content rect is [8, 8, 800, 200] (the screen is 800x600).
|
| // Mapping back to local, adding 4000px in all directions, then clipping, yields this rect.
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 4792, 200), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 4792, 200), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, FixedPositionInterestRect)
|
| @@ -161,7 +153,7 @@ TEST_F(CompositedLayerMappingTest, FixedPositionInterestRect)
|
| Element* element = document().getElementById("target");
|
| PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
|
| ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 300, 400), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 300, 400), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, LayerOffscreenInterestRect)
|
| @@ -175,7 +167,7 @@ TEST_F(CompositedLayerMappingTest, LayerOffscreenInterestRect)
|
| PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
|
| ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
|
| // Offscreen layers are painted as usual.
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 200, 200), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, ScrollingLayerInterestRect)
|
| @@ -191,7 +183,7 @@ TEST_F(CompositedLayerMappingTest, ScrollingLayerInterestRect)
|
| ASSERT_TRUE(paintLayer->graphicsLayerBacking());
|
| // Offscreen layers are painted as usual.
|
| ASSERT_TRUE(paintLayer->compositedLayerMapping()->scrollingLayer());
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 195, 4592), computeInterestRect(paintLayer->graphicsLayerBackingForScrolling(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 195, 4592), computeInterestRect(paintLayer->graphicsLayerBackingForScrolling(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, ClippedBigLayer)
|
| @@ -205,7 +197,7 @@ TEST_F(CompositedLayerMappingTest, ClippedBigLayer)
|
| PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
|
| ASSERT_TRUE(paintLayer->graphicsLayerBacking());
|
| // Offscreen layers are painted as usual.
|
| - EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 4001, 4001), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject())));
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 4001, 4001), computeInterestRect(paintLayer->graphicsLayerBacking(), paintLayer->layoutObject()));
|
| }
|
|
|
| TEST_F(CompositedLayerMappingTest, ClippingMaskLayer)
|
| @@ -306,4 +298,38 @@ TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintScrollScena
|
| EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect, layerSize));
|
| }
|
|
|
| +TEST_F(CompositedLayerMappingTest, PreviousPaintInterestRectChange)
|
| +{
|
| + setBodyInnerHTML(
|
| + "<style>"
|
| + " ::-webkit-scrollbar { width: 0; height: 0; }"
|
| + " body { margin: 0; }"
|
| + "</style>"
|
| + "<div id='div' style='width: 100px; height: 10000px'>Text</div>");
|
| +
|
| + document().view()->updateAllLifecyclePhases();
|
| + GraphicsLayer* rootScrollingLayer = document().view()->layoutView()->layer()->graphicsLayerBackingForScrolling();
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), rootScrollingLayer->previousInterestRect());
|
| +
|
| + const int scrollStep = 200;
|
| + for (int i = 0; i < 10000 / scrollStep; ++i) {
|
| + document().view()->scrollBy(IntSize(0, scrollStep), UserScroll);
|
| + document().view()->updateAllLifecyclePhases();
|
| + }
|
| +
|
| + EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), rootScrollingLayer->previousInterestRect());
|
| +
|
| + for (int i = 0; i < 10000 / scrollStep; ++i) {
|
| + document().view()->scrollBy(IntSize(-scrollStep, -scrollStep), UserScroll);
|
| + document().view()->updateAllLifecyclePhases();
|
| + }
|
| +
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 800, 8600), rootScrollingLayer->previousInterestRect());
|
| +
|
| + // Partial invalidation and repaint should not change previous paint interest rect.
|
| + document().getElementById("div")->setTextContent("Change");
|
| + document().view()->updateAllLifecyclePhases();
|
| + EXPECT_RECT_EQ(IntRect(0, 0, 800, 8600), rootScrollingLayer->previousInterestRect());
|
| +}
|
| +
|
| } // namespace blink
|
|
|