OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 |
| 7 #include "core/paint/DisplayItemListPaintTest.h" |
| 8 #include "platform/graphics/GraphicsContext.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 12 using DeprecatedPaintLayerPainterTestForSlimmingPaintV2 = DisplayItemListPaintTe
stForSlimmingPaintV2; |
| 13 |
| 14 TEST_F(DeprecatedPaintLayerPainterTestForSlimmingPaintV2, CachedSubsequence) |
| 15 { |
| 16 setBodyInnerHTML( |
| 17 "<div id='container1' style='position: relative; width: 200px; height: 2
00px; background-color: blue'>" |
| 18 " <div id='content1' style='width: 100px; height: 100px; background-col
or: red'></div>" |
| 19 "</div>" |
| 20 "<div id='container2' style='position: relative; width: 200px; height: 2
00px; background-color: blue'>" |
| 21 " <div id='content2' style='width: 100px; height: 100px; background-col
or: green'></div>" |
| 22 "</div>"); |
| 23 document().view()->updateAllLifecyclePhases(); |
| 24 |
| 25 DeprecatedPaintLayer& rootLayer = *layoutView().layer(); |
| 26 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen
tElement()->layoutObject())->layer(); |
| 27 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); |
| 28 DeprecatedPaintLayer& container1Layer = *toLayoutBoxModelObject(container1).
layer(); |
| 29 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec
t(); |
| 30 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); |
| 31 DeprecatedPaintLayer& container2Layer = *toLayoutBoxModelObject(container2).
layer(); |
| 32 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec
t(); |
| 33 |
| 34 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 13, |
| 35 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence), |
| 36 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), |
| 37 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
| 38 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
| 39 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
| 40 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
| 41 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
| 42 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence), |
| 43 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
| 44 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), |
| 45 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
| 46 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence), |
| 47 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence)); |
| 48 |
| 49 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 1
00px; height: 100px; background-color: green"); |
| 50 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(LayoutRect::infiniteRect
()); |
| 51 |
| 52 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(rootDisplayItemList().newD
isplayItems(), 10, |
| 53 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence), |
| 54 TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingTyp
e(DisplayItem::BoxDecorationBackground)), |
| 55 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
| 56 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
| 57 TestDisplayItem(container1, DisplayItem::drawingTypeToCachedDrawingType(
DisplayItem::BoxDecorationBackground)), |
| 58 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
| 59 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
| 60 TestDisplayItem(container2Layer, DisplayItem::CachedSubsequence), |
| 61 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence), |
| 62 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence)); |
| 63 |
| 64 compositeForSlimmingPaintV2(); |
| 65 |
| 66 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 13, |
| 67 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence), |
| 68 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), |
| 69 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
| 70 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
| 71 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
| 72 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
| 73 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
| 74 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence), |
| 75 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
| 76 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), |
| 77 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
| 78 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence), |
| 79 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence)); |
| 80 |
| 81 // Repeated painting should just generate the root cached subsequence. |
| 82 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(); |
| 83 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(rootDisplayItemList().newD
isplayItems(), 1, |
| 84 TestDisplayItem(rootLayer, DisplayItem::CachedSubsequence)); |
| 85 |
| 86 compositeForSlimmingPaintV2(); |
| 87 |
| 88 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 13, |
| 89 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence), |
| 90 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), |
| 91 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
| 92 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
| 93 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
| 94 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
| 95 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
| 96 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence), |
| 97 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
| 98 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), |
| 99 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
| 100 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence), |
| 101 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence)); |
| 102 } |
| 103 |
| 104 TEST_F(DeprecatedPaintLayerPainterTestForSlimmingPaintV2, CachedSubsequenceOnInt
erestRectChange) |
| 105 { |
| 106 setBodyInnerHTML( |
| 107 "<div id='container1' style='position: relative; width: 200px; height: 2
00px; background-color: blue'></div>" |
| 108 "<div id='container2' style='position: absolute; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" |
| 109 " <div id='content2' style='position: relative; top: 200px; width: 100p
x; height: 100px; background-color: green'></div>" |
| 110 "</div>" |
| 111 "<div id='container3' style='position: absolute; z-index: 2; left: 300px
; top: 0; width: 200px; height: 200px; background-color: blue'></div>"); |
| 112 rootDisplayItemList().invalidateAll(); |
| 113 |
| 114 DeprecatedPaintLayer& rootLayer = *layoutView().layer(); |
| 115 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen
tElement()->layoutObject())->layer(); |
| 116 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); |
| 117 DeprecatedPaintLayer& container1Layer = *toLayoutBoxModelObject(container1).
layer(); |
| 118 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); |
| 119 DeprecatedPaintLayer& container2Layer = *toLayoutBoxModelObject(container2).
layer(); |
| 120 LayoutObject& container3 = *document().getElementById("container3")->layoutO
bject(); |
| 121 DeprecatedPaintLayer& container3Layer = *toLayoutBoxModelObject(container3).
layer(); |
| 122 |
| 123 document().view()->updateAllLifecyclePhases(LayoutRect(0, 0, 400, 300)); |
| 124 |
| 125 // Container1 is fully in the interest rect; |
| 126 // Container2 is partly (including its stacking chidren) in the interest rec
t; |
| 127 // Content2 is out of the interest rect and output nothing; |
| 128 // Container3 is fully in the interest rect. |
| 129 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 14, |
| 130 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence), |
| 131 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), |
| 132 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
| 133 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
| 134 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
| 135 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
| 136 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence), |
| 137 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
| 138 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
| 139 TestDisplayItem(container3Layer, DisplayItem::BeginSubsequence), |
| 140 TestDisplayItem(container3, DisplayItem::BoxDecorationBackground), |
| 141 TestDisplayItem(container3Layer, DisplayItem::EndSubsequence), |
| 142 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence), |
| 143 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence)); |
| 144 |
| 145 // Container1 becomes partly in the interest rect, but uses cached subsequen
ce |
| 146 // because it was fully painted before; |
| 147 // Container2's intersection with the interest rect changes; |
| 148 // Content2 is out of the interest rect and outputs nothing; |
| 149 // Container3 becomes out of the interest rect and outputs nothing. |
| 150 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(LayoutRect(0, 100, 300,
300)); |
| 151 |
| 152 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(rootDisplayItemList().newD
isplayItems(), 9, |
| 153 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence), |
| 154 TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingTyp
e(DisplayItem::BoxDecorationBackground)), |
| 155 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
| 156 TestDisplayItem(container1Layer, DisplayItem::CachedSubsequence), |
| 157 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence), |
| 158 TestDisplayItem(container2, DisplayItem::drawingTypeToCachedDrawingType(
DisplayItem::BoxDecorationBackground)), |
| 159 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
| 160 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence), |
| 161 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence)); |
| 162 |
| 163 compositeForSlimmingPaintV2(); |
| 164 |
| 165 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 11, |
| 166 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence), |
| 167 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), |
| 168 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
| 169 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
| 170 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
| 171 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
| 172 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence), |
| 173 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
| 174 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
| 175 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence), |
| 176 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence)); |
| 177 } |
| 178 |
| 179 } // namespace blink |
OLD | NEW |