| 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 "core/paint/DisplayItemListPaintTest.h" | 6 #include "core/paint/PaintControllerPaintTest.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/LayoutObjectDrawingRecorder.h" | 11 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 12 #include "core/paint/PaintLayerPainter.h" | 12 #include "core/paint/PaintLayerPainter.h" |
| 13 #include "platform/graphics/GraphicsContext.h" | 13 #include "platform/graphics/GraphicsContext.h" |
| 14 #include "platform/graphics/paint/DrawingDisplayItem.h" | 14 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret) | 18 TEST_F(PaintControllerPaintTest, FullDocumentPaintingWithCaret) |
| 19 { | 19 { |
| 20 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 20 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
| 21 document().page()->focusController().setActive(true); | 21 document().page()->focusController().setActive(true); |
| 22 document().page()->focusController().setFocused(true); | 22 document().page()->focusController().setFocused(true); |
| 23 PaintLayer& rootLayer = *layoutView().layer(); | 23 PaintLayer& rootLayer = *layoutView().layer(); |
| 24 Element& div = *toElement(document().body()->firstChild()); | 24 Element& div = *toElement(document().body()->firstChild()); |
| 25 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); | 25 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); |
| 26 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); | 26 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); |
| 27 | 27 |
| 28 GraphicsContext context(&rootDisplayItemList()); | 28 GraphicsContext context(&rootPaintController()); |
| 29 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600),
GlobalPaintNormalPhase, LayoutSize()); | 29 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600),
GlobalPaintNormalPhase, LayoutSize()); |
| 30 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, Pain
tLayerPaintingCompositingAllPhases); | 30 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, Pain
tLayerPaintingCompositingAllPhases); |
| 31 rootDisplayItemList().commitNewDisplayItems(); | 31 rootPaintController().commitNewDisplayItems(); |
| 32 | 32 |
| 33 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2, | 33 EXPECT_DISPLAY_LIST(rootPaintController().displayItems(), 2, |
| 34 TestDisplayItem(layoutView(), backgroundType), | 34 TestDisplayItem(layoutView(), backgroundType), |
| 35 TestDisplayItem(textInlineBox, foregroundType)); | 35 TestDisplayItem(textInlineBox, foregroundType)); |
| 36 | 36 |
| 37 div.focus(); | 37 div.focus(); |
| 38 document().view()->updateAllLifecyclePhases(); | 38 document().view()->updateAllLifecyclePhases(); |
| 39 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView().displayIte
mClient())); | 39 EXPECT_TRUE(rootPaintController().clientCacheIsValid(layoutView().displayIte
mClient())); |
| 40 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divLayoutObject.displa
yItemClient())); | 40 EXPECT_FALSE(rootPaintController().clientCacheIsValid(divLayoutObject.displa
yItemClient())); |
| 41 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(textInlineBox.displayIt
emClient())); | 41 EXPECT_TRUE(rootPaintController().clientCacheIsValid(textInlineBox.displayIt
emClient())); |
| 42 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, Pain
tLayerPaintingCompositingAllPhases); | 42 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, Pain
tLayerPaintingCompositingAllPhases); |
| 43 rootDisplayItemList().commitNewDisplayItems(); | 43 rootPaintController().commitNewDisplayItems(); |
| 44 | 44 |
| 45 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, | 45 EXPECT_DISPLAY_LIST(rootPaintController().displayItems(), 3, |
| 46 TestDisplayItem(layoutView(), backgroundType), | 46 TestDisplayItem(layoutView(), backgroundType), |
| 47 TestDisplayItem(textInlineBox, foregroundType), | 47 TestDisplayItem(textInlineBox, foregroundType), |
| 48 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! | 48 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! |
| 49 } | 49 } |
| 50 | 50 |
| 51 TEST_F(DisplayItemListPaintTest, InlineRelayout) | 51 TEST_F(PaintControllerPaintTest, InlineRelayout) |
| 52 { | 52 { |
| 53 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); | 53 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); |
| 54 PaintLayer& rootLayer = *layoutView().layer(); | 54 PaintLayer& rootLayer = *layoutView().layer(); |
| 55 Element& div = *toElement(document().body()->firstChild()); | 55 Element& div = *toElement(document().body()->firstChild()); |
| 56 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); | 56 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); |
| 57 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 57 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
| 58 InlineTextBox& firstTextBox = *text.firstTextBox(); | 58 InlineTextBox& firstTextBox = *text.firstTextBox(); |
| 59 DisplayItemClient firstTextBoxDisplayItemClient = firstTextBox.displayItemCl
ient(); | 59 DisplayItemClient firstTextBoxDisplayItemClient = firstTextBox.displayItemCl
ient(); |
| 60 | 60 |
| 61 GraphicsContext context(&rootDisplayItemList()); | 61 GraphicsContext context(&rootPaintController()); |
| 62 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600),
GlobalPaintNormalPhase, LayoutSize()); | 62 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 600),
GlobalPaintNormalPhase, LayoutSize()); |
| 63 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, Pain
tLayerPaintingCompositingAllPhases); | 63 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, Pain
tLayerPaintingCompositingAllPhases); |
| 64 rootDisplayItemList().commitNewDisplayItems(); | 64 rootPaintController().commitNewDisplayItems(); |
| 65 | 65 |
| 66 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 2, | 66 EXPECT_DISPLAY_LIST(rootPaintController().displayItems(), 2, |
| 67 TestDisplayItem(layoutView(), backgroundType), | 67 TestDisplayItem(layoutView(), backgroundType), |
| 68 TestDisplayItem(firstTextBox, foregroundType)); | 68 TestDisplayItem(firstTextBox, foregroundType)); |
| 69 | 69 |
| 70 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 70 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
| 71 document().view()->updateAllLifecyclePhases(); | 71 document().view()->updateAllLifecyclePhases(); |
| 72 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(layoutView().displayIte
mClient())); | 72 EXPECT_TRUE(rootPaintController().clientCacheIsValid(layoutView().displayIte
mClient())); |
| 73 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(divBlock.displayItemCl
ient())); | 73 EXPECT_FALSE(rootPaintController().clientCacheIsValid(divBlock.displayItemCl
ient())); |
| 74 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstTextBoxDisplayIte
mClient)); | 74 EXPECT_FALSE(rootPaintController().clientCacheIsValid(firstTextBoxDisplayIte
mClient)); |
| 75 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, Pain
tLayerPaintingCompositingAllPhases); | 75 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo, Pain
tLayerPaintingCompositingAllPhases); |
| 76 rootDisplayItemList().commitNewDisplayItems(); | 76 rootPaintController().commitNewDisplayItems(); |
| 77 | 77 |
| 78 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 78 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
| 79 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 79 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
| 80 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 80 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
| 81 | 81 |
| 82 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 3, | 82 EXPECT_DISPLAY_LIST(rootPaintController().displayItems(), 3, |
| 83 TestDisplayItem(layoutView(), backgroundType), | 83 TestDisplayItem(layoutView(), backgroundType), |
| 84 TestDisplayItem(newFirstTextBox, foregroundType), | 84 TestDisplayItem(newFirstTextBox, foregroundType), |
| 85 TestDisplayItem(secondTextBox, foregroundType)); | 85 TestDisplayItem(secondTextBox, foregroundType)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret
) | 88 TEST_F(PaintControllerPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret
) |
| 89 { | 89 { |
| 90 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 90 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
| 91 document().page()->focusController().setActive(true); | 91 document().page()->focusController().setActive(true); |
| 92 document().page()->focusController().setFocused(true); | 92 document().page()->focusController().setFocused(true); |
| 93 PaintLayer& rootLayer = *layoutView().layer(); | 93 PaintLayer& rootLayer = *layoutView().layer(); |
| 94 Element& div = *toElement(document().body()->firstChild()); | 94 Element& div = *toElement(document().body()->firstChild()); |
| 95 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); | 95 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); |
| 96 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); | 96 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); |
| 97 | 97 |
| 98 document().view()->updateAllLifecyclePhases(); | 98 document().view()->updateAllLifecyclePhases(); |
| 99 | 99 |
| 100 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 4, | 100 EXPECT_DISPLAY_LIST(rootPaintController().displayItems(), 4, |
| 101 TestDisplayItem(layoutView(), backgroundType), | 101 TestDisplayItem(layoutView(), backgroundType), |
| 102 TestDisplayItem(rootLayer, subsequenceType), | 102 TestDisplayItem(rootLayer, subsequenceType), |
| 103 TestDisplayItem(textInlineBox, foregroundType), | 103 TestDisplayItem(textInlineBox, foregroundType), |
| 104 TestDisplayItem(rootLayer, endSubsequenceType)); | 104 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 105 | 105 |
| 106 div.focus(); | 106 div.focus(); |
| 107 document().view()->updateAllLifecyclePhases(); | 107 document().view()->updateAllLifecyclePhases(); |
| 108 | 108 |
| 109 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 5, | 109 EXPECT_DISPLAY_LIST(rootPaintController().displayItems(), 5, |
| 110 TestDisplayItem(layoutView(), backgroundType), | 110 TestDisplayItem(layoutView(), backgroundType), |
| 111 TestDisplayItem(rootLayer, subsequenceType), | 111 TestDisplayItem(rootLayer, subsequenceType), |
| 112 TestDisplayItem(textInlineBox, foregroundType), | 112 TestDisplayItem(textInlineBox, foregroundType), |
| 113 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! | 113 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! |
| 114 TestDisplayItem(rootLayer, endSubsequenceType)); | 114 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout) | 117 TEST_F(PaintControllerPaintTestForSlimmingPaintV2, InlineRelayout) |
| 118 { | 118 { |
| 119 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); | 119 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); |
| 120 PaintLayer& rootLayer = *layoutView().layer(); | 120 PaintLayer& rootLayer = *layoutView().layer(); |
| 121 Element& div = *toElement(document().body()->firstChild()); | 121 Element& div = *toElement(document().body()->firstChild()); |
| 122 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); | 122 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); |
| 123 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 123 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
| 124 InlineTextBox& firstTextBox = *text.firstTextBox(); | 124 InlineTextBox& firstTextBox = *text.firstTextBox(); |
| 125 | 125 |
| 126 document().view()->updateAllLifecyclePhases(); | 126 document().view()->updateAllLifecyclePhases(); |
| 127 | 127 |
| 128 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 4, | 128 EXPECT_DISPLAY_LIST(rootPaintController().displayItems(), 4, |
| 129 TestDisplayItem(layoutView(), backgroundType), | 129 TestDisplayItem(layoutView(), backgroundType), |
| 130 TestDisplayItem(rootLayer, subsequenceType), | 130 TestDisplayItem(rootLayer, subsequenceType), |
| 131 TestDisplayItem(firstTextBox, foregroundType), | 131 TestDisplayItem(firstTextBox, foregroundType), |
| 132 TestDisplayItem(rootLayer, endSubsequenceType)); | 132 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 133 | 133 |
| 134 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 134 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
| 135 document().view()->updateAllLifecyclePhases(); | 135 document().view()->updateAllLifecyclePhases(); |
| 136 | 136 |
| 137 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 137 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
| 138 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 138 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
| 139 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 139 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
| 140 | 140 |
| 141 EXPECT_DISPLAY_LIST(rootDisplayItemList().displayItems(), 5, | 141 EXPECT_DISPLAY_LIST(rootPaintController().displayItems(), 5, |
| 142 TestDisplayItem(layoutView(), backgroundType), | 142 TestDisplayItem(layoutView(), backgroundType), |
| 143 TestDisplayItem(rootLayer, subsequenceType), | 143 TestDisplayItem(rootLayer, subsequenceType), |
| 144 TestDisplayItem(newFirstTextBox, foregroundType), | 144 TestDisplayItem(newFirstTextBox, foregroundType), |
| 145 TestDisplayItem(secondTextBox, foregroundType), | 145 TestDisplayItem(secondTextBox, foregroundType), |
| 146 TestDisplayItem(rootLayer, endSubsequenceType)); | 146 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace blink | 149 } // namespace blink |
| OLD | NEW |