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