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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/DisplayItemListPaintTest.h" 6 #include "core/paint/DisplayItemListPaintTest.h"
7 7
8 #include "core/layout/LayoutText.h" 8 #include "core/layout/LayoutText.h"
9 #include "core/layout/line/InlineTextBox.h" 9 #include "core/layout/line/InlineTextBox.h"
10 #include "core/page/FocusController.h" 10 #include "core/page/FocusController.h"
11 #include "core/paint/DeprecatedPaintLayerPainter.h" 11 #include "core/paint/DeprecatedPaintLayerPainter.h"
12 #include "core/paint/LayerClipRecorder.h"
13 #include "core/paint/LayoutObjectDrawingRecorder.h" 12 #include "core/paint/LayoutObjectDrawingRecorder.h"
14 #include "core/paint/ScopeRecorder.h"
15 #include "platform/graphics/GraphicsContext.h" 13 #include "platform/graphics/GraphicsContext.h"
16 #include "platform/graphics/paint/DrawingDisplayItem.h" 14 #include "platform/graphics/paint/DrawingDisplayItem.h"
17 15
18 namespace blink { 16 namespace blink {
19 17
20 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret) 18 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret)
21 { 19 {
22 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>"); 20 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
23 document().page()->focusController().setActive(true); 21 document().page()->focusController().setActive(true);
24 document().page()->focusController().setFocused(true); 22 document().page()->focusController().setFocused(true);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), 83 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
86 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), 84 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)),
87 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground))); 85 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)));
88 } 86 }
89 87
90 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret ) 88 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret )
91 { 89 {
92 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>"); 90 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
93 document().page()->focusController().setActive(true); 91 document().page()->focusController().setActive(true);
94 document().page()->focusController().setFocused(true); 92 document().page()->focusController().setFocused(true);
93 DeprecatedPaintLayer& rootLayer = *layoutView().layer();
95 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen tElement()->layoutObject())->layer(); 94 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen tElement()->layoutObject())->layer();
96 Element& div = *toElement(document().body()->firstChild()); 95 Element& div = *toElement(document().body()->firstChild());
97 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje ct(); 96 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje ct();
98 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject( ))->firstTextBox(); 97 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject( ))->firstTextBox();
99 98
100 document().view()->updateAllLifecyclePhases(); 99 document().view()->updateAllLifecyclePhases();
101 100
102 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 4, 101 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 6,
102 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
103 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), 103 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
104 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), 104 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
105 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 105 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
106 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); 106 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
107 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
107 108
108 div.focus(); 109 div.focus();
109 document().view()->updateAllLifecyclePhases(); 110 document().view()->updateAllLifecyclePhases();
110 111
111 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5, 112 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 7,
113 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
112 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), 114 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
113 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), 115 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
114 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 116 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
115 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! 117 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New!
116 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); 118 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
119 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
117 } 120 }
118 121
119 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout) 122 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout)
120 { 123 {
121 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA A BBBBBBBBBB</div>"); 124 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA A BBBBBBBBBB</div>");
125 DeprecatedPaintLayer& rootLayer = *layoutView().layer();
122 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen tElement()->layoutObject())->layer(); 126 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen tElement()->layoutObject())->layer();
123 Element& div = *toElement(document().body()->firstChild()); 127 Element& div = *toElement(document().body()->firstChild());
124 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo utObject()); 128 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo utObject());
125 LayoutText& text = *toLayoutText(divBlock.firstChild()); 129 LayoutText& text = *toLayoutText(divBlock.firstChild());
126 InlineTextBox& firstTextBox = *text.firstTextBox(); 130 InlineTextBox& firstTextBox = *text.firstTextBox();
127 131
128 document().view()->updateAllLifecyclePhases(); 132 document().view()->updateAllLifecyclePhases();
129 133
130 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 4, 134 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 6,
135 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
131 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), 136 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
132 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), 137 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
133 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)), 138 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)),
134 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); 139 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
140 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
135 141
136 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); 142 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
137 document().view()->updateAllLifecyclePhases(); 143 document().view()->updateAllLifecyclePhases();
138 144
139 LayoutText& newText = *toLayoutText(divBlock.firstChild()); 145 LayoutText& newText = *toLayoutText(divBlock.firstChild());
140 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); 146 InlineTextBox& newFirstTextBox = *newText.firstTextBox();
141 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); 147 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();
142 148
143 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5, 149 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 7,
150 TestDisplayItem(rootLayer, DisplayItem::BeginSubsequence),
144 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground), 151 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
145 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), 152 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
146 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), 153 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)),
147 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 154 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
148 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); 155 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence),
149 } 156 TestDisplayItem(rootLayer, DisplayItem::EndSubsequence));
150
151 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
152 {
153 setBodyInnerHTML(
154 "<div id='container1' style='position: relative; width: 200px; height: 2 00px; background-color: blue'>"
155 " <div id='content1' style='width: 100px; height: 100px; background-col or: red'></div>"
156 "</div>"
157 "<div id='container2' style='position: relative; width: 200px; height: 2 00px; background-color: blue'>"
158 " <div id='content2' style='width: 100px; height: 100px; background-col or: green'></div>"
159 "</div>");
160 document().view()->updateAllLifecyclePhases();
161
162 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen tElement()->layoutObject())->layer();
163 LayoutObject& container1 = *document().getElementById("container1")->layoutO bject();
164 DeprecatedPaintLayer& container1Layer = *toLayoutBoxModelObject(container1). layer();
165 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec t();
166 LayoutObject& container2 = *document().getElementById("container2")->layoutO bject();
167 DeprecatedPaintLayer& container2Layer = *toLayoutBoxModelObject(container2). layer();
168 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec t();
169
170 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 11,
171 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
172 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
173 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
174 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
175 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
176 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
177 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence),
178 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
179 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
180 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
181 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
182
183 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 1 00px; height: 100px; background-color: green");
184 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean();
185
186 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(rootDisplayItemList().newD isplayItems(), 8,
187 TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingTyp e(DisplayItem::BoxDecorationBackground)),
188 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
189 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
190 TestDisplayItem(container1, DisplayItem::drawingTypeToCachedDrawingType( DisplayItem::BoxDecorationBackground)),
191 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
192 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
193 TestDisplayItem(container2Layer, DisplayItem::CachedSubsequence),
194 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
195
196 compositeForSlimmingPaintV2();
197
198 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 11,
199 TestDisplayItem(layoutView(), DisplayItem::BoxDecorationBackground),
200 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence),
201 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence),
202 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
203 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
204 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence),
205 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence),
206 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
207 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
208 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence),
209 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence));
210 } 157 }
211 158
212 } // namespace blink 159 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698