Chromium Code Reviews| 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/frame/FrameView.h" | 5 #include "core/frame/FrameView.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| 11 #include "core/html/HTMLElement.h" | 11 #include "core/html/HTMLElement.h" |
| 12 #include "core/layout/LayoutBoxModelObject.h" | 12 #include "core/layout/LayoutBoxModelObject.h" |
| 13 #include "core/layout/LayoutObject.h" | 13 #include "core/layout/LayoutObject.h" |
| 14 #include "core/loader/EmptyClients.h" | 14 #include "core/loader/EmptyClients.h" |
| 15 #include "core/page/Page.h" | 15 #include "core/page/Page.h" |
| 16 #include "core/paint/PaintLayer.h" | |
| 16 #include "core/testing/DummyPageHolder.h" | 17 #include "core/testing/DummyPageHolder.h" |
| 17 #include "platform/RuntimeEnabledFeatures.h" | 18 #include "platform/RuntimeEnabledFeatures.h" |
| 18 #include "platform/geometry/IntSize.h" | 19 #include "platform/geometry/IntSize.h" |
| 19 #include "platform/graphics/paint/PaintArtifact.h" | 20 #include "platform/graphics/paint/PaintArtifact.h" |
| 20 #include "platform/heap/Handle.h" | 21 #include "platform/heap/Handle.h" |
| 21 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 22 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 25 |
| 25 using testing::_; | 26 using testing::_; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 | 133 |
| 133 // NoOverflowInIncrementVisuallyNonEmptyPixelCount tests fail if the number of | 134 // NoOverflowInIncrementVisuallyNonEmptyPixelCount tests fail if the number of |
| 134 // pixels is calculated in 32-bit integer, because 65536 * 65536 would become 0 | 135 // pixels is calculated in 32-bit integer, because 65536 * 65536 would become 0 |
| 135 // if it was calculated in 32-bit and thus it would be considered as empty. | 136 // if it was calculated in 32-bit and thus it would be considered as empty. |
| 136 TEST_P(FrameViewTest, NoOverflowInIncrementVisuallyNonEmptyPixelCount) { | 137 TEST_P(FrameViewTest, NoOverflowInIncrementVisuallyNonEmptyPixelCount) { |
| 137 EXPECT_FALSE(document().view()->isVisuallyNonEmpty()); | 138 EXPECT_FALSE(document().view()->isVisuallyNonEmpty()); |
| 138 document().view()->incrementVisuallyNonEmptyPixelCount(IntSize(65536, 65536)); | 139 document().view()->incrementVisuallyNonEmptyPixelCount(IntSize(65536, 65536)); |
| 139 EXPECT_TRUE(document().view()->isVisuallyNonEmpty()); | 140 EXPECT_TRUE(document().view()->isVisuallyNonEmpty()); |
| 140 } | 141 } |
| 141 | 142 |
| 143 // This test addresses http://crbug.com/696173, in which a call to | |
| 144 // FrameView::updateLayersAndCompositingAfterScrollIfNeeded during layout caused | |
| 145 // a crash as the code was incorrectly assuming that the ancestor overflow layer | |
| 146 // would always be valid. | |
| 147 TEST_P(FrameViewTest, ViewportConstrainedObjectsHandledCorrectlyDuringLayout) { | |
| 148 // When using root layer scrolling there is no concept of viewport constrained | |
| 149 // objects, so skip this test. | |
| 150 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | |
|
flackr
2017/02/27 16:42:09
Don't we run into the same problem with updateLaye
flackr
2017/02/27 16:43:14
Nevermind, on that we update top-down so you didn'
bokan
2017/02/28 13:07:44
I'm not sure I understand why we can't run this wi
smcgruer
2017/02/28 13:13:47
I guess its black-box testing. FrameView::updateLa
| |
| 151 return; | |
| 152 | |
| 153 document().body()->setInnerHTML( | |
| 154 "<style>.container { height: 200%; }" | |
| 155 "#sticky { position: sticky; top: 0; height: 50px; }</style>" | |
| 156 "<div class='container'><div id='sticky'></div></div>"); | |
| 157 document().view()->updateAllLifecyclePhases(); | |
| 158 | |
| 159 LayoutBoxModelObject* sticky = toLayoutBoxModelObject( | |
| 160 document().getElementById("sticky")->layoutObject()); | |
| 161 | |
| 162 // Deliberately invalidate the ancestor overflow layer. This approximates | |
| 163 // http://crbug.com/696173, in which the ancestor overflow layer can be null | |
| 164 // during layout. | |
| 165 sticky->layer()->updateAncestorOverflowLayer(nullptr); | |
| 166 | |
| 167 // This call should not crash. | |
| 168 document().view()->setScrollOffset(ScrollOffset(0, 100), ProgrammaticScroll); | |
| 169 } | |
| 170 | |
| 142 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) { | 171 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) { |
| 143 // When using root layer scrolling there is no concept of viewport constrained | 172 // When using root layer scrolling there is no concept of viewport constrained |
| 144 // objects, so skip this test. | 173 // objects, so skip this test. |
| 145 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 174 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 146 return; | 175 return; |
| 147 | 176 |
| 148 document().body()->setInnerHTML( | 177 document().body()->setInnerHTML( |
| 149 "<style>.container { height: 200%; }" | 178 "<style>.container { height: 200%; }" |
| 150 "#sticky { position: sticky; top: 0; height: 50px; }</style>" | 179 "#sticky { position: sticky; top: 0; height: 50px; }</style>" |
| 151 "<div class='container'><div id='sticky'></div></div>"); | 180 "<div class='container'><div id='sticky'></div></div>"); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 169 // And making it sticky again should put it back in that list. | 198 // And making it sticky again should put it back in that list. |
| 170 document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, ""); | 199 document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, ""); |
| 171 document().view()->updateAllLifecyclePhases(); | 200 document().view()->updateAllLifecyclePhases(); |
| 172 | 201 |
| 173 EXPECT_TRUE( | 202 EXPECT_TRUE( |
| 174 document().view()->viewportConstrainedObjects()->contains(sticky)); | 203 document().view()->viewportConstrainedObjects()->contains(sticky)); |
| 175 } | 204 } |
| 176 | 205 |
| 177 } // namespace | 206 } // namespace |
| 178 } // namespace blink | 207 } // namespace blink |
| OLD | NEW |