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