| 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" | 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 INSTANTIATE_TEST_CASE_P(All, PaintControllerPaintTestForSlimmingPaintV1AndV2, ::
testing::Bool()); | 18 INSTANTIATE_TEST_CASE_P(All, PaintControllerPaintTestForSlimmingPaintV1AndV2, ::
testing::Bool()); |
| 19 | 19 |
| 20 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, FullDocumentPaintingWith
Caret) | 20 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, FullDocumentPaintingWith
Caret) |
| 21 { | 21 { |
| 22 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 22 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
| 23 document().page()->focusController().setActive(true); | 23 document().page()->focusController().setActive(true); |
| 24 document().page()->focusController().setFocused(true); | 24 document().page()->focusController().setFocused(true); |
| 25 PaintLayer& rootLayer = *layoutView().layer(); | 25 PaintLayer& rootLayer = *layoutView().layer(); |
| 26 Element& div = *toElement(document().body()->firstChild()); | 26 Element& div = *toElement(document().body()->firstChild()); |
| 27 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); | 27 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); |
| 28 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); | 28 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); |
| 29 DisplayItemClientWrapper rootLayerClient(rootLayer.displayItemClientForNorma
lAndPositiveZOrderChildren()); |
| 29 | 30 |
| 30 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { | 31 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| 31 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 4, | 32 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 4, |
| 32 TestDisplayItem(layoutView(), backgroundType), | 33 TestDisplayItem(layoutView(), backgroundType), |
| 33 TestDisplayItem(rootLayer, subsequenceType), | 34 TestDisplayItem(rootLayerClient, DisplayItem::Subsequence), |
| 34 TestDisplayItem(textInlineBox, foregroundType), | 35 TestDisplayItem(textInlineBox, foregroundType), |
| 35 TestDisplayItem(rootLayer, endSubsequenceType)); | 36 TestDisplayItem(rootLayerClient, DisplayItem::EndSubsequence)); |
| 36 } else { | 37 } else { |
| 37 GraphicsContext context(rootPaintController()); | 38 GraphicsContext context(rootPaintController()); |
| 38 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 60
0), GlobalPaintNormalPhase, LayoutSize()); | 39 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 60
0), GlobalPaintNormalPhase, LayoutSize()); |
| 39 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo,
PaintLayerPaintingCompositingAllPhases); | 40 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo,
PaintLayerPaintingCompositingAllPhases); |
| 40 rootPaintController().commitNewDisplayItems(); | 41 rootPaintController().commitNewDisplayItems(); |
| 41 | 42 |
| 42 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, | 43 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, |
| 43 TestDisplayItem(layoutView(), backgroundType), | 44 TestDisplayItem(layoutView(), backgroundType), |
| 44 TestDisplayItem(textInlineBox, foregroundType)); | 45 TestDisplayItem(textInlineBox, foregroundType)); |
| 45 } | 46 } |
| 46 | 47 |
| 47 div.focus(); | 48 div.focus(); |
| 48 document().view()->updateAllLifecyclePhases(); | 49 document().view()->updateAllLifecyclePhases(); |
| 49 | 50 |
| 50 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { | 51 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| 51 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 5, | 52 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 5, |
| 52 TestDisplayItem(layoutView(), backgroundType), | 53 TestDisplayItem(layoutView(), backgroundType), |
| 53 TestDisplayItem(rootLayer, subsequenceType), | 54 TestDisplayItem(rootLayerClient, DisplayItem::Subsequence), |
| 54 TestDisplayItem(textInlineBox, foregroundType), | 55 TestDisplayItem(textInlineBox, foregroundType), |
| 55 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! | 56 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! |
| 56 TestDisplayItem(rootLayer, endSubsequenceType)); | 57 TestDisplayItem(rootLayerClient, DisplayItem::EndSubsequence)); |
| 57 } else { | 58 } else { |
| 58 GraphicsContext context(rootPaintController()); | 59 GraphicsContext context(rootPaintController()); |
| 59 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 60
0), GlobalPaintNormalPhase, LayoutSize()); | 60 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 60
0), GlobalPaintNormalPhase, LayoutSize()); |
| 60 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo,
PaintLayerPaintingCompositingAllPhases); | 61 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo,
PaintLayerPaintingCompositingAllPhases); |
| 61 rootPaintController().commitNewDisplayItems(); | 62 rootPaintController().commitNewDisplayItems(); |
| 62 | 63 |
| 63 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3, | 64 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3, |
| 64 TestDisplayItem(layoutView(), backgroundType), | 65 TestDisplayItem(layoutView(), backgroundType), |
| 65 TestDisplayItem(textInlineBox, foregroundType), | 66 TestDisplayItem(textInlineBox, foregroundType), |
| 66 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! | 67 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! |
| 67 } | 68 } |
| 68 } | 69 } |
| 69 | 70 |
| 70 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) | 71 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) |
| 71 { | 72 { |
| 72 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); | 73 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); |
| 73 PaintLayer& rootLayer = *layoutView().layer(); | 74 PaintLayer& rootLayer = *layoutView().layer(); |
| 74 Element& div = *toElement(document().body()->firstChild()); | 75 Element& div = *toElement(document().body()->firstChild()); |
| 75 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); | 76 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); |
| 76 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 77 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
| 77 InlineTextBox& firstTextBox = *text.firstTextBox(); | 78 InlineTextBox& firstTextBox = *text.firstTextBox(); |
| 79 DisplayItemClientWrapper rootLayerClient(rootLayer.displayItemClientForNorma
lAndPositiveZOrderChildren()); |
| 78 | 80 |
| 79 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { | 81 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| 80 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 4, | 82 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 4, |
| 81 TestDisplayItem(layoutView(), backgroundType), | 83 TestDisplayItem(layoutView(), backgroundType), |
| 82 TestDisplayItem(rootLayer, subsequenceType), | 84 TestDisplayItem(rootLayerClient, DisplayItem::Subsequence), |
| 83 TestDisplayItem(firstTextBox, foregroundType), | 85 TestDisplayItem(firstTextBox, foregroundType), |
| 84 TestDisplayItem(rootLayer, endSubsequenceType)); | 86 TestDisplayItem(rootLayerClient, DisplayItem::EndSubsequence)); |
| 85 } else { | 87 } else { |
| 86 GraphicsContext context(rootPaintController()); | 88 GraphicsContext context(rootPaintController()); |
| 87 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 60
0), GlobalPaintNormalPhase, LayoutSize()); | 89 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 60
0), GlobalPaintNormalPhase, LayoutSize()); |
| 88 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo,
PaintLayerPaintingCompositingAllPhases); | 90 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo,
PaintLayerPaintingCompositingAllPhases); |
| 89 rootPaintController().commitNewDisplayItems(); | 91 rootPaintController().commitNewDisplayItems(); |
| 90 | 92 |
| 91 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, | 93 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, |
| 92 TestDisplayItem(layoutView(), backgroundType), | 94 TestDisplayItem(layoutView(), backgroundType), |
| 93 TestDisplayItem(firstTextBox, foregroundType)); | 95 TestDisplayItem(firstTextBox, foregroundType)); |
| 94 } | 96 } |
| 95 | 97 |
| 96 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 98 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
| 97 document().view()->updateAllLifecyclePhases(); | 99 document().view()->updateAllLifecyclePhases(); |
| 98 | 100 |
| 99 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 101 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
| 100 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 102 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
| 101 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 103 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
| 102 | 104 |
| 103 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { | 105 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| 104 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 5, | 106 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 5, |
| 105 TestDisplayItem(layoutView(), backgroundType), | 107 TestDisplayItem(layoutView(), backgroundType), |
| 106 TestDisplayItem(rootLayer, subsequenceType), | 108 TestDisplayItem(rootLayerClient, DisplayItem::Subsequence), |
| 107 TestDisplayItem(newFirstTextBox, foregroundType), | 109 TestDisplayItem(newFirstTextBox, foregroundType), |
| 108 TestDisplayItem(secondTextBox, foregroundType), | 110 TestDisplayItem(secondTextBox, foregroundType), |
| 109 TestDisplayItem(rootLayer, endSubsequenceType)); | 111 TestDisplayItem(rootLayerClient, DisplayItem::EndSubsequence)); |
| 110 } else { | 112 } else { |
| 111 GraphicsContext context(rootPaintController()); | 113 GraphicsContext context(rootPaintController()); |
| 112 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 60
0), GlobalPaintNormalPhase, LayoutSize()); | 114 PaintLayerPaintingInfo paintingInfo(&rootLayer, LayoutRect(0, 0, 800, 60
0), GlobalPaintNormalPhase, LayoutSize()); |
| 113 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo,
PaintLayerPaintingCompositingAllPhases); | 115 PaintLayerPainter(rootLayer).paintLayerContents(&context, paintingInfo,
PaintLayerPaintingCompositingAllPhases); |
| 114 rootPaintController().commitNewDisplayItems(); | 116 rootPaintController().commitNewDisplayItems(); |
| 115 | 117 |
| 116 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3, | 118 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 3, |
| 117 TestDisplayItem(layoutView(), backgroundType), | 119 TestDisplayItem(layoutView(), backgroundType), |
| 118 TestDisplayItem(newFirstTextBox, foregroundType), | 120 TestDisplayItem(newFirstTextBox, foregroundType), |
| 119 TestDisplayItem(secondTextBox, foregroundType)); | 121 TestDisplayItem(secondTextBox, foregroundType)); |
| 120 } | 122 } |
| 121 } | 123 } |
| 122 | 124 |
| 123 } // namespace blink | 125 } // namespace blink |
| OLD | NEW |