Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(956)

Unified Diff: Source/core/paint/DisplayItemListPaintTest.cpp

Issue 1327563003: Don't cache subsequence whose layer is not fully contained by repaint rect (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/paint/DisplayItemListPaintTest.cpp
diff --git a/Source/core/paint/DisplayItemListPaintTest.cpp b/Source/core/paint/DisplayItemListPaintTest.cpp
index 13d142b5fc64a2ec75aecaed73d7ea14e96a0d34..da9eeb26a7236b1178e21bee4b00181eeb79bf04 100644
--- a/Source/core/paint/DisplayItemListPaintTest.cpp
+++ b/Source/core/paint/DisplayItemListPaintTest.cpp
@@ -92,6 +92,7 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret
setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>XYZ</div>");
document().page()->focusController().setActive(true);
document().page()->focusController().setFocused(true);
+ DeprecatedPaintLayer& rootLayer = *layoutView().layer();
DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()->layoutObject())->layer();
Element& div = *toElement(document().body()->firstChild());
LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObject();
@@ -99,26 +100,31 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret
document().view()->updateAllLifecyclePhases();
- EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 4,
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 6,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)),
- TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
div.focus();
document().view()->updateAllLifecyclePhases();
- EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 5,
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 7,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)),
TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New!
- TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
}
TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout)
{
setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAAA BBBBBBBBBB</div>");
+ DeprecatedPaintLayer& rootLayer = *layoutView().layer();
DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()->layoutObject())->layer();
Element& div = *toElement(document().body()->firstChild());
LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layoutObject());
@@ -127,11 +133,13 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout)
document().view()->updateAllLifecyclePhases();
- EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 4,
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 6,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)),
- TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
document().view()->updateAllLifecyclePhases();
@@ -140,12 +148,14 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout)
InlineTextBox& newFirstTextBox = *newText.firstTextBox();
InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();
- EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 5,
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 7,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)),
TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)),
- TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
}
TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
@@ -159,6 +169,7 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
"</div>");
document().view()->updateAllLifecyclePhases();
+ DeprecatedPaintLayer& rootLayer = *layoutView().layer();
DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()->layoutObject())->layer();
LayoutObject& container1 = *document().getElementById("container1")->layoutObject();
DeprecatedPaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer();
@@ -167,7 +178,8 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
DeprecatedPaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer();
LayoutObject& content2 = *document().getElementById("content2")->layoutObject();
- EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 11,
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 13,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
@@ -178,12 +190,14 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
- TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 100px; background-color: green");
- updateLifecyclePhasesToPaintForSlimmingPaintV2Clean();
+ updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(LayoutRect::infiniteRect());
- EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(rootDisplayItemList().newDisplayItems(), 8,
+ EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(rootDisplayItemList().newDisplayItems(), 10,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingType(DisplayItem::BoxDecorationBackground)),
TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
@@ -191,11 +205,35 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
TestDisplayItem(container2Layer, DisplayItem::CachedSubsequence),
- TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
compositeForSlimmingPaintV2();
- EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 11,
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 13,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
+ TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
+
+ // Repeated painting should just generate the root cached subsequence.
+ updateLifecyclePhasesToPaintForSlimmingPaintV2Clean();
+ EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(rootDisplayItemList().newDisplayItems(), 1,
+ TestDisplayItem(rootLayer, DisplayItem::CachedSubsequence));
+
+ compositeForSlimmingPaintV2();
+
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 13,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
@@ -206,7 +244,83 @@ TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
- TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
+}
+
+TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequenceOnInterestRectChange)
chrishtr 2015/09/09 17:23:45 Move to a new DeprecatedPaintLayerPainterTest.cpp
Xianzhu 2015/09/09 21:30:43 Done.
+{
+ setBodyInnerHTML(
+ "<div id='container1' style='position: relative; width: 200px; height: 200px; background-color: blue'></div>"
+ "<div id='container2' style='position: absolute; z-index: 1; width: 200px; height: 200px; background-color: blue'>"
+ " <div id='content2' style='position: relative; top: 200px; width: 100px; height: 100px; background-color: green'></div>"
+ "</div>"
+ "<div id='container3' style='position: absolute; z-index: 2; left: 300px; top: 0; width: 200px; height: 200px; background-color: blue'></div>");
+ rootDisplayItemList().invalidateAll();
+
+ DeprecatedPaintLayer& rootLayer = *layoutView().layer();
+ DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()->layoutObject())->layer();
+ LayoutObject& container1 = *document().getElementById("container1")->layoutObject();
+ DeprecatedPaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer();
+ LayoutObject& container2 = *document().getElementById("container2")->layoutObject();
+ DeprecatedPaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer();
+ LayoutObject& container3 = *document().getElementById("container3")->layoutObject();
+ DeprecatedPaintLayer& container3Layer = *toLayoutBoxModelObject(container3).layer();
+
+ document().view()->updateAllLifecyclePhases(LayoutRect(0, 0, 400, 300));
+
+ // Container1 is fully in the interest rect;
+ // Container2 is partly (including its stacking chidren) in the interest rect;
+ // Content2 is out of the interest rect and output nothing;
+ // Container3 is fully in the interest rect.
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 14,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
+ TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
+ TestDisplayItem(container3Layer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container3, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(container3Layer, DisplayItem::EndSubsequence),
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
+
+ // Container1 becomes partly in the interest rect, but uses cached subsequence
+ // because it was fully painted before;
+ // Container2's intersection with the interest rect changes;
+ // Content2 is out of the interest rect and outputs nothing;
+ // Container3 becomes out of the interest rect and outputs nothing.
+ updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(LayoutRect(0, 100, 300, 300));
+
+ EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(rootDisplayItemList().newDisplayItems(), 9,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingType(DisplayItem::BoxDecorationBackground)),
+ TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container1Layer, DisplayItem::CachedSubsequence),
+ TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container2, DisplayItem::drawingTypeToCachedDrawingType(DisplayItem::BoxDecorationBackground)),
+ TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
+
+ compositeForSlimmingPaintV2();
+
+ EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItems(), 11,
+ TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
+ TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence),
+ TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
+ TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
+ TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
+ TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698