| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/layout/LayoutObject.h" | 5 #include "core/layout/LayoutObject.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" |
| 7 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
| 8 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 9 #include "core/layout/api/LayoutAPIShim.h" | 10 #include "core/layout/api/LayoutAPIShim.h" |
| 11 #include "platform/JSONValues.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 13 |
| 12 namespace blink { | 14 namespace blink { |
| 13 | 15 |
| 14 class LayoutObjectTest : public RenderingTest { | 16 class LayoutObjectTest : public RenderingTest { |
| 15 public: | 17 public: |
| 16 LayoutObjectTest() | 18 LayoutObjectTest() |
| 17 : RenderingTest(SingleChildFrameLoaderClient::create()) {} | 19 : RenderingTest(SingleChildFrameLoaderClient::create()) {} |
| 18 protected: | 20 protected: |
| 19 LayoutView& layoutView() const { return *toLayoutView(LayoutAPIShim::layoutO
bjectFrom(document().layoutViewItem())); } | 21 LayoutView& layoutView() const { return *toLayoutView(LayoutAPIShim::layoutO
bjectFrom(document().layoutViewItem())); } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 " <div style='column-span: all'>" | 119 " <div style='column-span: all'>" |
| 118 " <div id='overflow-clip-layer' style='height: 100px; overflow: hidde
n'></div>" | 120 " <div id='overflow-clip-layer' style='height: 100px; overflow: hidde
n'></div>" |
| 119 " </div>" | 121 " </div>" |
| 120 "</div>"); | 122 "</div>"); |
| 121 | 123 |
| 122 LayoutObject* overflowClipObject = getLayoutObjectByElementId("overflow-clip
-layer"); | 124 LayoutObject* overflowClipObject = getLayoutObjectByElementId("overflow-clip
-layer"); |
| 123 LayoutBlock* columns = toLayoutBlock(getLayoutObjectByElementId("columns")); | 125 LayoutBlock* columns = toLayoutBlock(getLayoutObjectByElementId("columns")); |
| 124 EXPECT_EQ(columns->layer(), overflowClipObject->paintingLayer()); | 126 EXPECT_EQ(columns->layer(), overflowClipObject->paintingLayer()); |
| 125 } | 127 } |
| 126 | 128 |
| 129 TEST_F(LayoutObjectTest, TraverseNonCompositingDescendantsInPaintOrder) |
| 130 { |
| 131 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 132 return; |
| 133 |
| 134 enableCompositing(); |
| 135 setBodyInnerHTML( |
| 136 "<style>div { width: 10px; height: 10px; background-color: green; }</sty
le>" |
| 137 "<div id='container' style='position: fixed'>" |
| 138 " <div id='normal-child'></div>" |
| 139 " <div id='stacked-child' style='position: relative'></div>" |
| 140 " <div id='composited-stacking-context' style='will-change: transform'>
" |
| 141 " <div id='normal-child-of-composited-stacking-context'></div>" |
| 142 " <div id='stacked-child-of-composited-stacking-context' style='posit
ion: relative'></div>" |
| 143 " </div>" |
| 144 " <div id='composited-non-stacking-context' style='backface-visibility:
hidden'>" |
| 145 " <div id='normal-child-of-composited-non-stacking-context'></div>" |
| 146 " <div id='stacked-child-of-composited-non-stacking-context' style='p
osition: relative'></div>" |
| 147 " <div id='non-stacked-layered-child-of-composited-non-stacking-conte
xt' style='overflow: scroll'></div>" |
| 148 " </div>" |
| 149 "</div>"); |
| 150 |
| 151 document().view()->setTracksPaintInvalidations(true); |
| 152 getLayoutObjectByElementId("container")->invalidateDisplayItemClientsIncludi
ngNonCompositingDescendants(PaintInvalidationSubtree); |
| 153 std::unique_ptr<JSONArray> invalidations = document().view()->trackedObjectP
aintInvalidationsAsJSON(); |
| 154 document().view()->setTracksPaintInvalidations(false); |
| 155 |
| 156 ASSERT_EQ(4u, invalidations->size()); |
| 157 String s; |
| 158 JSONObject::cast(invalidations->at(0))->get("object")->asString(&s); |
| 159 EXPECT_EQ(getLayoutObjectByElementId("container")->debugName(), s); |
| 160 JSONObject::cast(invalidations->at(1))->get("object")->asString(&s); |
| 161 EXPECT_EQ(getLayoutObjectByElementId("normal-child")->debugName(), s); |
| 162 JSONObject::cast(invalidations->at(2))->get("object")->asString(&s); |
| 163 EXPECT_EQ(getLayoutObjectByElementId("stacked-child")->debugName(), s); |
| 164 JSONObject::cast(invalidations->at(3))->get("object")->asString(&s); |
| 165 EXPECT_EQ(getLayoutObjectByElementId("stacked-child-of-composited-non-stacki
ng-context")->debugName(), s); |
| 166 } |
| 167 |
| 127 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |