| 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 "core/paint/PaintControllerPaintTest.h" | 5 #include "core/paint/PaintControllerPaintTest.h" |
| 6 | 6 |
| 7 #include "core/editing/FrameCaret.h" | 7 #include "core/editing/FrameCaret.h" |
| 8 #include "core/editing/FrameSelection.h" | 8 #include "core/editing/FrameSelection.h" |
| 9 #include "core/layout/LayoutText.h" | 9 #include "core/layout/LayoutText.h" |
| 10 #include "core/layout/line/InlineTextBox.h" | 10 #include "core/layout/line/InlineTextBox.h" |
| 11 #include "core/page/FocusController.h" | 11 #include "core/page/FocusController.h" |
| 12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 12 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 13 #include "core/paint/ObjectPaintProperties.h" | 13 #include "core/paint/ObjectPaintProperties.h" |
| 14 #include "core/paint/PaintLayerPainter.h" | 14 #include "core/paint/PaintLayerPainter.h" |
| 15 #include "platform/graphics/GraphicsContext.h" | 15 #include "platform/graphics/GraphicsContext.h" |
| 16 #include "platform/graphics/paint/DrawingDisplayItem.h" | 16 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 INSTANTIATE_TEST_CASE_P(All, PaintControllerPaintTestForSlimmingPaintV1AndV2, ::
testing::Bool()); | 20 INSTANTIATE_TEST_CASE_P(All, PaintControllerPaintTestForSlimmingPaintV1AndV2, ::
testing::Bool()); |
| 21 | 21 |
| 22 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, FullDocumentPaintingWith
Caret) | 22 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, FullDocumentPaintingWith
Caret) |
| 23 { | 23 { |
| 24 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 24 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
| 25 document().page()->focusController().setActive(true); | 25 document().page()->focusController().setActive(true); |
| 26 document().page()->focusController().setFocused(true); | 26 document().page()->focusController().setFocused(true); |
| 27 Element& div = *toElement(document().body()->firstChild()); | 27 Element& div = *toElement(document().body()->firstChild()); |
| 28 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); | 28 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); |
| 29 | 29 |
| 30 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, | 30 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 31 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 6, |
| 32 TestDisplayItem(layoutView(), DisplayItem::kClipFrameToVisibleConten
tRect), |
| 33 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 34 TestDisplayItem(layoutView(), documentBackgroundType), |
| 35 TestDisplayItem(textInlineBox, foregroundType), |
| 36 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)
, |
| 37 TestDisplayItem(layoutView(), DisplayItem::clipTypeToEndClipType(Dis
playItem::kClipFrameToVisibleContentRect))); |
| 38 } else { |
| 39 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, |
| 31 TestDisplayItem(layoutView(), documentBackgroundType), | 40 TestDisplayItem(layoutView(), documentBackgroundType), |
| 32 TestDisplayItem(textInlineBox, foregroundType)); | 41 TestDisplayItem(textInlineBox, foregroundType)); |
| 42 } |
| 33 | 43 |
| 34 div.focus(); | 44 div.focus(); |
| 35 document().view()->updateAllLifecyclePhases(); | 45 document().view()->updateAllLifecyclePhases(); |
| 36 | 46 |
| 37 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, | 47 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 38 TestDisplayItem(layoutView(), documentBackgroundType), | 48 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 7, |
| 39 TestDisplayItem(textInlineBox, foregroundType), | 49 TestDisplayItem(layoutView(), DisplayItem::kClipFrameToVisibleConten
tRect), |
| 40 TestDisplayItem(*document().frame()->selection().m_frameCaret, DisplayIt
em::kCaret)); // New! | 50 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
TestDisplayItem(layoutView(), documentBackgroundType), |
| 51 TestDisplayItem(textInlineBox, foregroundType), |
| 52 TestDisplayItem(*document().frame()->selection().m_frameCaret, Displ
ayItem::kCaret), // New! |
| 53 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)
, |
| 54 TestDisplayItem(layoutView(), DisplayItem::clipTypeToEndClipType(Dis
playItem::kClipFrameToVisibleContentRect))); |
| 55 } else { |
| 56 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, |
| 57 TestDisplayItem(layoutView(), documentBackgroundType), |
| 58 TestDisplayItem(textInlineBox, foregroundType), |
| 59 TestDisplayItem(*document().frame()->selection().m_frameCaret, Displ
ayItem::kCaret)); // New! |
| 60 } |
| 41 } | 61 } |
| 42 | 62 |
| 43 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) | 63 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) |
| 44 { | 64 { |
| 45 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); | 65 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); |
| 46 Element& div = *toElement(document().body()->firstChild()); | 66 Element& div = *toElement(document().body()->firstChild()); |
| 47 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); | 67 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); |
| 48 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 68 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
| 49 InlineTextBox& firstTextBox = *text.firstTextBox(); | 69 InlineTextBox& firstTextBox = *text.firstTextBox(); |
| 50 | 70 |
| 51 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, | 71 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 52 TestDisplayItem(layoutView(), documentBackgroundType), | 72 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 6, |
| 53 TestDisplayItem(firstTextBox, foregroundType)); | 73 TestDisplayItem(layoutView(), DisplayItem::kClipFrameToVisibleConten
tRect), |
| 74 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 75 TestDisplayItem(layoutView(), documentBackgroundType), |
| 76 TestDisplayItem(firstTextBox, foregroundType), |
| 77 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)
, |
| 78 TestDisplayItem(layoutView(), DisplayItem::clipTypeToEndClipType(Dis
playItem::kClipFrameToVisibleContentRect))); |
| 79 } else { |
| 80 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, |
| 81 TestDisplayItem(layoutView(), documentBackgroundType), |
| 82 TestDisplayItem(firstTextBox, foregroundType)); |
| 83 } |
| 54 | 84 |
| 55 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 85 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
| 56 document().view()->updateAllLifecyclePhases(); | 86 document().view()->updateAllLifecyclePhases(); |
| 57 | 87 |
| 58 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 88 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
| 59 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 89 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
| 60 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 90 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
| 61 | 91 |
| 62 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, | 92 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 63 TestDisplayItem(layoutView(), documentBackgroundType), | 93 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 7, |
| 64 TestDisplayItem(newFirstTextBox, foregroundType), | 94 TestDisplayItem(layoutView(), DisplayItem::kClipFrameToVisibleConten
tRect), |
| 65 TestDisplayItem(secondTextBox, foregroundType)); | 95 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 96 TestDisplayItem(layoutView(), documentBackgroundType), |
| 97 TestDisplayItem(newFirstTextBox, foregroundType), |
| 98 TestDisplayItem(secondTextBox, foregroundType), |
| 99 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)
, |
| 100 TestDisplayItem(layoutView(), DisplayItem::clipTypeToEndClipType(Dis
playItem::kClipFrameToVisibleContentRect))); |
| 101 } else { |
| 102 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, |
| 103 TestDisplayItem(layoutView(), documentBackgroundType), |
| 104 TestDisplayItem(newFirstTextBox, foregroundType), |
| 105 TestDisplayItem(secondTextBox, foregroundType)); |
| 106 } |
| 66 } | 107 } |
| 67 | 108 |
| 68 TEST_F(PaintControllerPaintTestForSlimmingPaintV2, ChunkIdClientCacheFlag) | 109 TEST_F(PaintControllerPaintTestForSlimmingPaintV2, ChunkIdClientCacheFlag) |
| 69 { | 110 { |
| 70 setBodyInnerHTML( | 111 setBodyInnerHTML( |
| 71 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" | 112 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" |
| 72 " <div style='width: 100px; height: 100px; background-color: blue'></di
v>" | 113 " <div style='width: 100px; height: 100px; background-color: blue'></di
v>" |
| 73 " <div style='width: 100px; height: 100px; background-color: blue'></di
v>" | 114 " <div style='width: 100px; height: 100px; background-color: blue'></di
v>" |
| 74 "</div>"); | 115 "</div>"); |
| 75 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()
->layoutObject())->layer(); | 116 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()
->layoutObject())->layer(); |
| 76 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); | 117 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); |
| 77 LayoutObject& subDiv = *div.firstChild(); | 118 LayoutObject& subDiv = *div.firstChild(); |
| 78 LayoutObject& subDiv2 = *subDiv.nextSibling(); | 119 LayoutObject& subDiv2 = *subDiv.nextSibling(); |
| 79 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 7, | 120 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 11, |
| 121 TestDisplayItem(layoutView(), DisplayItem::kClipFrameToVisibleContentRec
t), |
| 122 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 80 TestDisplayItem(layoutView(), documentBackgroundType), | 123 TestDisplayItem(layoutView(), documentBackgroundType), |
| 81 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 124 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 82 TestDisplayItem(div, DisplayItem::kBeginCompositing), | 125 TestDisplayItem(div, DisplayItem::kBeginCompositing), |
| 83 TestDisplayItem(subDiv, backgroundType), | 126 TestDisplayItem(subDiv, backgroundType), |
| 84 TestDisplayItem(subDiv2, backgroundType), | 127 TestDisplayItem(subDiv2, backgroundType), |
| 85 TestDisplayItem(div, DisplayItem::kEndCompositing), | 128 TestDisplayItem(div, DisplayItem::kEndCompositing), |
| 86 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | 129 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 130 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence), |
| 131 TestDisplayItem(layoutView(), DisplayItem::clipTypeToEndClipType(Display
Item::kClipFrameToVisibleContentRect))); |
| 87 | 132 |
| 88 const EffectPaintPropertyNode* effectNode = div.objectPaintProperties()->eff
ect(); | 133 const EffectPaintPropertyNode* effectNode = div.objectPaintProperties()->eff
ect(); |
| 89 EXPECT_EQ(0.5f, effectNode->opacity()); | 134 EXPECT_EQ(0.5f, effectNode->opacity()); |
| 90 const PaintChunk& chunk = rootPaintController().paintChunks()[1]; | 135 const PaintChunk& chunk = rootPaintController().paintChunks()[2]; |
| 91 EXPECT_EQ(*div.layer(), chunk.id->client); | 136 EXPECT_EQ(*div.layer(), chunk.id->client); |
| 92 EXPECT_EQ(effectNode, chunk.properties.effect.get()); | 137 EXPECT_EQ(effectNode, chunk.properties.effect.get()); |
| 93 | 138 |
| 94 EXPECT_FALSE(div.layer()->isJustCreated()); | 139 EXPECT_FALSE(div.layer()->isJustCreated()); |
| 95 // Client used by only paint chunks and non-cachaeable display items but not
by any | 140 // Client used by only paint chunks and non-cachaeable display items but not
by any |
| 96 // cacheable display items won't be marked as validly cached. | 141 // cacheable display items won't be marked as validly cached. |
| 97 EXPECT_FALSE(rootPaintController().clientCacheIsValid(*div.layer())); | 142 EXPECT_FALSE(rootPaintController().clientCacheIsValid(*div.layer())); |
| 98 EXPECT_FALSE(rootPaintController().clientCacheIsValid(div)); | 143 EXPECT_FALSE(rootPaintController().clientCacheIsValid(div)); |
| 99 EXPECT_TRUE(rootPaintController().clientCacheIsValid(subDiv)); | 144 EXPECT_TRUE(rootPaintController().clientCacheIsValid(subDiv)); |
| 100 } | 145 } |
| 101 | 146 |
| 102 TEST_F(PaintControllerPaintTestForSlimmingPaintV2, CompositingFold) | 147 TEST_F(PaintControllerPaintTestForSlimmingPaintV2, CompositingFold) |
| 103 { | 148 { |
| 104 setBodyInnerHTML( | 149 setBodyInnerHTML( |
| 105 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" | 150 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" |
| 106 " <div style='width: 100px; height: 100px; background-color: blue'></di
v>" | 151 " <div style='width: 100px; height: 100px; background-color: blue'></di
v>" |
| 107 "</div>"); | 152 "</div>"); |
| 108 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()
->layoutObject())->layer(); | 153 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()
->layoutObject())->layer(); |
| 109 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); | 154 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); |
| 110 LayoutObject& subDiv = *div.firstChild(); | 155 LayoutObject& subDiv = *div.firstChild(); |
| 111 | 156 |
| 112 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 4, | 157 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 8, |
| 158 TestDisplayItem(layoutView(), DisplayItem::kClipFrameToVisibleContentRec
t), |
| 159 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 113 TestDisplayItem(layoutView(), documentBackgroundType), | 160 TestDisplayItem(layoutView(), documentBackgroundType), |
| 114 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), | 161 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 115 // The begin and end compositing display items have been folded into thi
s one. | 162 // The begin and end compositing display items have been folded into thi
s one. |
| 116 TestDisplayItem(subDiv, backgroundType), | 163 TestDisplayItem(subDiv, backgroundType), |
| 117 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); | 164 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 165 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence), |
| 166 TestDisplayItem(layoutView(), DisplayItem::clipTypeToEndClipType(Display
Item::kClipFrameToVisibleContentRect))); |
| 118 } | 167 } |
| 119 | 168 |
| 120 | 169 |
| 121 } // namespace blink | 170 } // namespace blink |
| OLD | NEW |