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

Side by Side Diff: Source/core/paint/DisplayItemListPaintTest.cpp

Issue 1145993002: Refactor root element background painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase, adding back TestExpectation Created 5 years, 6 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
« no previous file with comments | « Source/core/paint/BoxPainter.cpp ('k') | Source/core/paint/FrameSetPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "platform/graphics/paint/DisplayItemList.h" 6 #include "platform/graphics/paint/DisplayItemList.h"
7 7
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/layout/LayoutText.h" 9 #include "core/layout/LayoutText.h"
10 #include "core/layout/LayoutView.h" 10 #include "core/layout/LayoutView.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } \ 84 } \
85 } while (false); 85 } while (false);
86 86
87 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret) 87 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret)
88 { 88 {
89 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>"); 89 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
90 document().page()->focusController().setActive(true); 90 document().page()->focusController().setActive(true);
91 document().page()->focusController().setFocused(true); 91 document().page()->focusController().setFocused(true);
92 LayoutView& layoutView = *document().layoutView(); 92 LayoutView& layoutView = *document().layoutView();
93 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); 93 DeprecatedPaintLayer& rootLayer = *layoutView.layer();
94 LayoutObject& htmlLayoutObject = *document().documentElement()->layoutObject ();
95 Element& div = *toElement(document().body()->firstChild()); 94 Element& div = *toElement(document().body()->firstChild());
96 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje ct(); 95 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje ct();
97 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject( ))->firstTextBox(); 96 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject( ))->firstTextBox();
98 97
99 GraphicsContext context(&rootDisplayItemList()); 98 GraphicsContext context(&rootDisplayItemList());
100 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 8 00, 600), PaintBehaviorNormal, LayoutSize()); 99 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 8 00, 600), PaintBehaviorNormal, LayoutSize());
101 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting Info, PaintLayerPaintingCompositingAllPhases); 100 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting Info, PaintLayerPaintingCompositingAllPhases);
102 rootDisplayItemList().commitNewDisplayItems(); 101 rootDisplayItemList().commitNewDisplayItems();
103 102
104 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2, 103 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2,
105 TestDisplayItem(htmlLayoutObject, DisplayItem::BoxDecorationBackground), 104 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
106 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground))); 105 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)));
107 106
108 div.focus(); 107 div.focus();
109 document().view()->updateLayoutAndStyleForPainting(); 108 document().view()->updateLayoutAndStyleForPainting();
110 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(htmlLayoutObject.displa yItemClient())); 109 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView.displayItemC lient()));
111 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divLayoutObject.displa yItemClient())); 110 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divLayoutObject.displa yItemClient()));
112 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(textInlineBox.displayIt emClient())); 111 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(textInlineBox.displayIt emClient()));
113 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting Info, PaintLayerPaintingCompositingAllPhases); 112 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting Info, PaintLayerPaintingCompositingAllPhases);
114 rootDisplayItemList().commitNewDisplayItems(); 113 rootDisplayItemList().commitNewDisplayItems();
115 114
116 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, 115 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3,
117 TestDisplayItem(htmlLayoutObject, DisplayItem::BoxDecorationBackground), 116 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
118 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 117 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
119 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! 118 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New!
120 } 119 }
121 120
122 TEST_F(DisplayItemListPaintTest, InlineRelayout) 121 TEST_F(DisplayItemListPaintTest, InlineRelayout)
123 { 122 {
124 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA A BBBBBBBBBB</div>"); 123 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA A BBBBBBBBBB</div>");
125 LayoutView& layoutView = *document().layoutView(); 124 LayoutView& layoutView = *document().layoutView();
126 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); 125 DeprecatedPaintLayer& rootLayer = *layoutView.layer();
127 LayoutObject& htmlObject = *document().documentElement()->layoutObject();
128 Element& div = *toElement(document().body()->firstChild()); 126 Element& div = *toElement(document().body()->firstChild());
129 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo utObject()); 127 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo utObject());
130 LayoutText& text = *toLayoutText(divBlock.firstChild()); 128 LayoutText& text = *toLayoutText(divBlock.firstChild());
131 InlineTextBox& firstTextBox = *text.firstTextBox(); 129 InlineTextBox& firstTextBox = *text.firstTextBox();
132 DisplayItemClient firstTextBoxDisplayItemClient = firstTextBox.displayItemCl ient(); 130 DisplayItemClient firstTextBoxDisplayItemClient = firstTextBox.displayItemCl ient();
133 131
134 GraphicsContext context(&rootDisplayItemList()); 132 GraphicsContext context(&rootDisplayItemList());
135 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 8 00, 600), PaintBehaviorNormal, LayoutSize()); 133 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 8 00, 600), PaintBehaviorNormal, LayoutSize());
136 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting Info, PaintLayerPaintingCompositingAllPhases); 134 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting Info, PaintLayerPaintingCompositingAllPhases);
137 rootDisplayItemList().commitNewDisplayItems(); 135 rootDisplayItemList().commitNewDisplayItems();
138 136
139 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2, 137 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2,
140 TestDisplayItem(htmlObject, DisplayItem::BoxDecorationBackground), 138 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
141 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground))); 139 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)));
142 140
143 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); 141 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
144 document().view()->updateLayoutAndStyleForPainting(); 142 document().view()->updateLayoutAndStyleForPainting();
145 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(htmlObject.displayItemC lient())); 143 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView.displayItemC lient()));
146 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divBlock.displayItemCl ient())); 144 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divBlock.displayItemCl ient()));
147 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstTextBoxDisplayIte mClient)); 145 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstTextBoxDisplayIte mClient));
148 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting Info, PaintLayerPaintingCompositingAllPhases); 146 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting Info, PaintLayerPaintingCompositingAllPhases);
149 rootDisplayItemList().commitNewDisplayItems(); 147 rootDisplayItemList().commitNewDisplayItems();
150 148
151 LayoutText& newText = *toLayoutText(divBlock.firstChild()); 149 LayoutText& newText = *toLayoutText(divBlock.firstChild());
152 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); 150 InlineTextBox& newFirstTextBox = *newText.firstTextBox();
153 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); 151 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();
154 152
155 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, 153 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3,
156 TestDisplayItem(htmlObject, DisplayItem::BoxDecorationBackground), 154 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
157 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), 155 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)),
158 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground))); 156 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)));
159 } 157 }
160 158
161 } // namespace blink 159 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/BoxPainter.cpp ('k') | Source/core/paint/FrameSetPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698