| 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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 FullDocumentPaintingWithCaret) { | 29 FullDocumentPaintingWithCaret) { |
| 30 setBodyInnerHTML( | 30 setBodyInnerHTML( |
| 31 "<div id='div' contentEditable='true' style='outline:none'>XYZ</div>"); | 31 "<div id='div' contentEditable='true' style='outline:none'>XYZ</div>"); |
| 32 document().page()->focusController().setActive(true); | 32 document().page()->focusController().setActive(true); |
| 33 document().page()->focusController().setFocused(true); | 33 document().page()->focusController().setFocused(true); |
| 34 Element& div = *toElement(document().body()->firstChild()); | 34 Element& div = *toElement(document().body()->firstChild()); |
| 35 InlineTextBox& textInlineBox = | 35 InlineTextBox& textInlineBox = |
| 36 *toLayoutText(div.firstChild()->layoutObject())->firstTextBox(); | 36 *toLayoutText(div.firstChild()->layoutObject())->firstTextBox(); |
| 37 | 37 |
| 38 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 38 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 39 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, | 39 EXPECT_DISPLAY_LIST( |
| 40 TestDisplayItem(layoutView(), documentBackgroundType), | 40 rootPaintController().getDisplayItemList(), 4, |
| 41 TestDisplayItem(textInlineBox, foregroundType)); | 41 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 42 TestDisplayItem(layoutView(), documentBackgroundType), |
| 43 TestDisplayItem(textInlineBox, foregroundType), |
| 44 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); |
| 42 } else { | 45 } else { |
| 43 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, | 46 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, |
| 44 TestDisplayItem(layoutView(), documentBackgroundType), | 47 TestDisplayItem(layoutView(), documentBackgroundType), |
| 45 TestDisplayItem(textInlineBox, foregroundType)); | 48 TestDisplayItem(textInlineBox, foregroundType)); |
| 46 } | 49 } |
| 47 | 50 |
| 48 div.focus(); | 51 div.focus(); |
| 49 document().view()->updateAllLifecyclePhases(); | 52 document().view()->updateAllLifecyclePhases(); |
| 50 | 53 |
| 51 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 54 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 52 EXPECT_DISPLAY_LIST( | 55 EXPECT_DISPLAY_LIST( |
| 53 rootPaintController().getDisplayItemList(), 3, | 56 rootPaintController().getDisplayItemList(), 5, |
| 57 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 54 TestDisplayItem(layoutView(), documentBackgroundType), | 58 TestDisplayItem(layoutView(), documentBackgroundType), |
| 55 TestDisplayItem(textInlineBox, foregroundType), | 59 TestDisplayItem(textInlineBox, foregroundType), |
| 56 TestDisplayItem( | 60 TestDisplayItem( |
| 57 document().frame()->selection().caretDisplayItemClientForTesting(), | 61 document().frame()->selection().caretDisplayItemClientForTesting(), |
| 58 DisplayItem::kCaret)); // New! | 62 DisplayItem::kCaret), // New! |
| 63 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); |
| 59 } else { | 64 } else { |
| 60 EXPECT_DISPLAY_LIST( | 65 EXPECT_DISPLAY_LIST( |
| 61 rootPaintController().getDisplayItemList(), 3, | 66 rootPaintController().getDisplayItemList(), 3, |
| 62 TestDisplayItem(layoutView(), documentBackgroundType), | 67 TestDisplayItem(layoutView(), documentBackgroundType), |
| 63 TestDisplayItem(textInlineBox, foregroundType), | 68 TestDisplayItem(textInlineBox, foregroundType), |
| 64 TestDisplayItem( | 69 TestDisplayItem( |
| 65 document().frame()->selection().caretDisplayItemClientForTesting(), | 70 document().frame()->selection().caretDisplayItemClientForTesting(), |
| 66 DisplayItem::kCaret)); // New! | 71 DisplayItem::kCaret)); // New! |
| 67 } | 72 } |
| 68 } | 73 } |
| 69 | 74 |
| 70 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) { | 75 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, InlineRelayout) { |
| 71 setBodyInnerHTML( | 76 setBodyInnerHTML( |
| 72 "<div id='div' style='width:100px; height: 200px'>AAAAAAAAAA " | 77 "<div id='div' style='width:100px; height: 200px'>AAAAAAAAAA " |
| 73 "BBBBBBBBBB</div>"); | 78 "BBBBBBBBBB</div>"); |
| 74 Element& div = *toElement(document().body()->firstChild()); | 79 Element& div = *toElement(document().body()->firstChild()); |
| 75 LayoutBlock& divBlock = | 80 LayoutBlock& divBlock = |
| 76 *toLayoutBlock(document().body()->firstChild()->layoutObject()); | 81 *toLayoutBlock(document().body()->firstChild()->layoutObject()); |
| 77 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 82 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
| 78 InlineTextBox& firstTextBox = *text.firstTextBox(); | 83 InlineTextBox& firstTextBox = *text.firstTextBox(); |
| 79 | 84 |
| 80 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 85 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 81 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, | 86 EXPECT_DISPLAY_LIST( |
| 82 TestDisplayItem(layoutView(), documentBackgroundType), | 87 rootPaintController().getDisplayItemList(), 4, |
| 83 TestDisplayItem(firstTextBox, foregroundType)); | 88 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 89 TestDisplayItem(layoutView(), documentBackgroundType), |
| 90 TestDisplayItem(firstTextBox, foregroundType), |
| 91 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); |
| 84 } else { | 92 } else { |
| 85 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, | 93 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, |
| 86 TestDisplayItem(layoutView(), documentBackgroundType), | 94 TestDisplayItem(layoutView(), documentBackgroundType), |
| 87 TestDisplayItem(firstTextBox, foregroundType)); | 95 TestDisplayItem(firstTextBox, foregroundType)); |
| 88 } | 96 } |
| 89 | 97 |
| 90 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 98 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
| 91 document().view()->updateAllLifecyclePhases(); | 99 document().view()->updateAllLifecyclePhases(); |
| 92 | 100 |
| 93 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 101 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
| 94 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 102 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
| 95 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 103 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
| 96 | 104 |
| 97 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 105 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 98 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, | 106 EXPECT_DISPLAY_LIST( |
| 99 TestDisplayItem(layoutView(), documentBackgroundType), | 107 rootPaintController().getDisplayItemList(), 5, |
| 100 TestDisplayItem(newFirstTextBox, foregroundType), | 108 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 101 TestDisplayItem(secondTextBox, foregroundType)); | 109 TestDisplayItem(layoutView(), documentBackgroundType), |
| 110 TestDisplayItem(newFirstTextBox, foregroundType), |
| 111 TestDisplayItem(secondTextBox, foregroundType), |
| 112 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); |
| 102 } else { | 113 } else { |
| 103 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, | 114 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, |
| 104 TestDisplayItem(layoutView(), documentBackgroundType), | 115 TestDisplayItem(layoutView(), documentBackgroundType), |
| 105 TestDisplayItem(newFirstTextBox, foregroundType), | 116 TestDisplayItem(newFirstTextBox, foregroundType), |
| 106 TestDisplayItem(secondTextBox, foregroundType)); | 117 TestDisplayItem(secondTextBox, foregroundType)); |
| 107 } | 118 } |
| 108 } | 119 } |
| 109 | 120 |
| 110 TEST_P(PaintControllerPaintTestForSlimmingPaintV2, ChunkIdClientCacheFlag) { | 121 TEST_P(PaintControllerPaintTestForSlimmingPaintV2, ChunkIdClientCacheFlag) { |
| 111 setBodyInnerHTML( | 122 setBodyInnerHTML( |
| 112 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" | 123 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" |
| 113 " <div style='width: 100px; height: 100px; background-color: " | 124 " <div style='width: 100px; height: 100px; background-color: " |
| 114 "blue'></div>" | 125 "blue'></div>" |
| 115 " <div style='width: 100px; height: 100px; background-color: " | 126 " <div style='width: 100px; height: 100px; background-color: " |
| 116 "blue'></div>" | 127 "blue'></div>" |
| 117 "</div>"); | 128 "</div>"); |
| 129 PaintLayer& htmlLayer = |
| 130 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) |
| 131 ->layer(); |
| 118 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); | 132 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); |
| 119 LayoutObject& subDiv = *div.firstChild(); | 133 LayoutObject& subDiv = *div.firstChild(); |
| 120 LayoutObject& subDiv2 = *subDiv.nextSibling(); | 134 LayoutObject& subDiv2 = *subDiv.nextSibling(); |
| 121 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, | 135 EXPECT_DISPLAY_LIST( |
| 122 TestDisplayItem(layoutView(), documentBackgroundType), | 136 rootPaintController().getDisplayItemList(), 7, |
| 123 TestDisplayItem(subDiv, backgroundType), | 137 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 124 TestDisplayItem(subDiv2, backgroundType)); | 138 TestDisplayItem(layoutView(), documentBackgroundType), |
| 139 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 140 TestDisplayItem(subDiv, backgroundType), |
| 141 TestDisplayItem(subDiv2, backgroundType), |
| 142 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 143 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); |
| 125 | 144 |
| 126 // Verify that the background does not scroll. | 145 // Verify that the background does not scroll. |
| 127 const PaintChunk& backgroundChunk = rootPaintController().paintChunks()[0]; | 146 const PaintChunk& backgroundChunk = rootPaintController().paintChunks()[0]; |
| 128 EXPECT_FALSE(backgroundChunk.properties.propertyTreeState.transform() | 147 EXPECT_FALSE(backgroundChunk.properties.propertyTreeState.transform() |
| 129 ->isScrollTranslation()); | 148 ->isScrollTranslation()); |
| 130 | 149 |
| 131 const EffectPaintPropertyNode* effectNode = div.paintProperties()->effect(); | 150 const EffectPaintPropertyNode* effectNode = div.paintProperties()->effect(); |
| 132 EXPECT_EQ(0.5f, effectNode->opacity()); | 151 EXPECT_EQ(0.5f, effectNode->opacity()); |
| 133 | 152 |
| 134 const PaintChunk& chunk = rootPaintController().paintChunks()[1]; | 153 const PaintChunk& chunk = rootPaintController().paintChunks()[1]; |
| 135 EXPECT_EQ(*div.layer(), chunk.id->client); | 154 EXPECT_EQ(*div.layer(), chunk.id->client); |
| 136 EXPECT_EQ(effectNode, chunk.properties.propertyTreeState.effect()); | 155 EXPECT_EQ(effectNode, chunk.properties.propertyTreeState.effect()); |
| 137 | 156 |
| 138 EXPECT_FALSE(div.layer()->isJustCreated()); | 157 EXPECT_FALSE(div.layer()->isJustCreated()); |
| 139 // Client used by only paint chunks and non-cachaeable display items but not | 158 // Client used by only paint chunks and non-cachaeable display items but not |
| 140 // by any cacheable display items won't be marked as validly cached. | 159 // by any cacheable display items won't be marked as validly cached. |
| 141 EXPECT_FALSE(rootPaintController().clientCacheIsValid(*div.layer())); | 160 EXPECT_FALSE(rootPaintController().clientCacheIsValid(*div.layer())); |
| 142 EXPECT_FALSE(rootPaintController().clientCacheIsValid(div)); | 161 EXPECT_FALSE(rootPaintController().clientCacheIsValid(div)); |
| 143 EXPECT_TRUE(rootPaintController().clientCacheIsValid(subDiv)); | 162 EXPECT_TRUE(rootPaintController().clientCacheIsValid(subDiv)); |
| 144 } | 163 } |
| 145 | 164 |
| 146 TEST_P(PaintControllerPaintTestForSlimmingPaintV2, CompositingNoFold) { | 165 TEST_P(PaintControllerPaintTestForSlimmingPaintV2, CompositingNoFold) { |
| 147 setBodyInnerHTML( | 166 setBodyInnerHTML( |
| 148 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" | 167 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" |
| 149 " <div style='width: 100px; height: 100px; background-color: " | 168 " <div style='width: 100px; height: 100px; background-color: " |
| 150 "blue'></div>" | 169 "blue'></div>" |
| 151 "</div>"); | 170 "</div>"); |
| 171 PaintLayer& htmlLayer = |
| 172 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) |
| 173 ->layer(); |
| 152 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); | 174 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); |
| 153 LayoutObject& subDiv = *div.firstChild(); | 175 LayoutObject& subDiv = *div.firstChild(); |
| 154 | 176 |
| 155 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2, | 177 EXPECT_DISPLAY_LIST( |
| 156 TestDisplayItem(layoutView(), documentBackgroundType), | 178 rootPaintController().getDisplayItemList(), 6, |
| 157 TestDisplayItem(subDiv, backgroundType)); | 179 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), |
| 180 TestDisplayItem(layoutView(), documentBackgroundType), |
| 181 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), |
| 182 TestDisplayItem(subDiv, backgroundType), |
| 183 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), |
| 184 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); |
| 158 } | 185 } |
| 159 | 186 |
| 160 } // namespace blink | 187 } // namespace blink |
| OLD | NEW |