| OLD | NEW |
| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } \ | 82 } \ |
| 83 } while (false); | 83 } while (false); |
| 84 | 84 |
| 85 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret) | 85 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret) |
| 86 { | 86 { |
| 87 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 87 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
| 88 document().page()->focusController().setActive(true); | 88 document().page()->focusController().setActive(true); |
| 89 document().page()->focusController().setFocused(true); | 89 document().page()->focusController().setFocused(true); |
| 90 LayoutView& layoutView = *document().layoutView(); | 90 LayoutView& layoutView = *document().layoutView(); |
| 91 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); | 91 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); |
| 92 LayoutObject& htmlLayoutObject = *document().documentElement()->layoutObject
(); | |
| 93 Element& div = *toElement(document().body()->firstChild()); | 92 Element& div = *toElement(document().body()->firstChild()); |
| 94 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); | 93 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); |
| 95 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); | 94 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); |
| 96 | 95 |
| 97 GraphicsContext context(&rootDisplayItemList()); | 96 GraphicsContext context(&rootDisplayItemList()); |
| 98 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 8
00, 600), PaintBehaviorNormal, LayoutSize()); | 97 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 8
00, 600), PaintBehaviorNormal, LayoutSize()); |
| 99 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); | 98 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); |
| 100 rootDisplayItemList().commitNewDisplayItems(); | 99 rootDisplayItemList().commitNewDisplayItems(); |
| 101 | 100 |
| 102 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2, | 101 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2, |
| 103 TestDisplayItem(htmlLayoutObject, DisplayItem::BoxDecorationBackground), | 102 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 104 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); | 103 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); |
| 105 | 104 |
| 106 div.focus(); | 105 div.focus(); |
| 107 document().view()->updateLayoutAndStyleForPainting(); | 106 document().view()->updateLayoutAndStyleForPainting(); |
| 108 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(htmlLayoutObject.displa
yItemClient())); | 107 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView.displayItemC
lient())); |
| 109 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divLayoutObject.displa
yItemClient())); | 108 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divLayoutObject.displa
yItemClient())); |
| 110 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(textInlineBox.displayIt
emClient())); | 109 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(textInlineBox.displayIt
emClient())); |
| 111 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); | 110 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); |
| 112 rootDisplayItemList().commitNewDisplayItems(); | 111 rootDisplayItemList().commitNewDisplayItems(); |
| 113 | 112 |
| 114 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, | 113 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, |
| 115 TestDisplayItem(htmlLayoutObject, DisplayItem::BoxDecorationBackground), | 114 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 116 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), | 115 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), |
| 117 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! | 116 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! |
| 118 } | 117 } |
| 119 | 118 |
| 120 TEST_F(DisplayItemListPaintTest, InlineRelayout) | 119 TEST_F(DisplayItemListPaintTest, InlineRelayout) |
| 121 { | 120 { |
| 122 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); | 121 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); |
| 123 LayoutView& layoutView = *document().layoutView(); | 122 LayoutView& layoutView = *document().layoutView(); |
| 124 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); | 123 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); |
| 125 LayoutObject& htmlObject = *document().documentElement()->layoutObject(); | |
| 126 Element& div = *toElement(document().body()->firstChild()); | 124 Element& div = *toElement(document().body()->firstChild()); |
| 127 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); | 125 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); |
| 128 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 126 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
| 129 InlineTextBox& firstTextBox = *text.firstTextBox(); | 127 InlineTextBox& firstTextBox = *text.firstTextBox(); |
| 130 DisplayItemClient firstTextBoxDisplayItemClient = firstTextBox.displayItemCl
ient(); | 128 DisplayItemClient firstTextBoxDisplayItemClient = firstTextBox.displayItemCl
ient(); |
| 131 | 129 |
| 132 GraphicsContext context(&rootDisplayItemList()); | 130 GraphicsContext context(&rootDisplayItemList()); |
| 133 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 8
00, 600), PaintBehaviorNormal, LayoutSize()); | 131 DeprecatedPaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 8
00, 600), PaintBehaviorNormal, LayoutSize()); |
| 134 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); | 132 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); |
| 135 rootDisplayItemList().commitNewDisplayItems(); | 133 rootDisplayItemList().commitNewDisplayItems(); |
| 136 | 134 |
| 137 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2, | 135 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2, |
| 138 TestDisplayItem(htmlObject, DisplayItem::BoxDecorationBackground), | 136 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 139 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); | 137 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); |
| 140 | 138 |
| 141 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 139 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
| 142 document().view()->updateLayoutAndStyleForPainting(); | 140 document().view()->updateLayoutAndStyleForPainting(); |
| 143 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(htmlObject.displayItemC
lient())); | 141 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView.displayItemC
lient())); |
| 144 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divBlock.displayItemCl
ient())); | 142 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divBlock.displayItemCl
ient())); |
| 145 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstTextBoxDisplayIte
mClient)); | 143 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstTextBoxDisplayIte
mClient)); |
| 146 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); | 144 DeprecatedPaintLayerPainter(rootLayer).paintLayerContents(&context, painting
Info, PaintLayerPaintingCompositingAllPhases); |
| 147 rootDisplayItemList().commitNewDisplayItems(); | 145 rootDisplayItemList().commitNewDisplayItems(); |
| 148 | 146 |
| 149 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 147 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
| 150 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 148 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
| 151 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 149 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
| 152 | 150 |
| 153 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, | 151 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, |
| 154 TestDisplayItem(htmlObject, DisplayItem::BoxDecorationBackground), | 152 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
| 155 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), | 153 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), |
| 156 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); | 154 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); |
| 157 } | 155 } |
| 158 | 156 |
| 159 } // namespace blink | 157 } // namespace blink |
| OLD | NEW |