| 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> |
| 8 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| 9 #include "core/html/HTMLElement.h" | 11 #include "core/html/HTMLElement.h" |
| 12 #include "core/layout/LayoutBoxModelObject.h" |
| 10 #include "core/layout/LayoutObject.h" | 13 #include "core/layout/LayoutObject.h" |
| 11 #include "core/loader/EmptyClients.h" | 14 #include "core/loader/EmptyClients.h" |
| 12 #include "core/page/Page.h" | 15 #include "core/page/Page.h" |
| 13 #include "core/testing/DummyPageHolder.h" | 16 #include "core/testing/DummyPageHolder.h" |
| 14 #include "platform/RuntimeEnabledFeatures.h" | 17 #include "platform/RuntimeEnabledFeatures.h" |
| 15 #include "platform/geometry/IntSize.h" | 18 #include "platform/geometry/IntSize.h" |
| 16 #include "platform/graphics/paint/PaintArtifact.h" | 19 #include "platform/graphics/paint/PaintArtifact.h" |
| 17 #include "platform/heap/Handle.h" | 20 #include "platform/heap/Handle.h" |
| 18 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 21 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include <memory> | |
| 22 | 24 |
| 23 using testing::_; | 25 using testing::_; |
| 24 using testing::AnyNumber; | 26 using testing::AnyNumber; |
| 25 | 27 |
| 26 namespace blink { | 28 namespace blink { |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 class MockChromeClient : public EmptyChromeClient { | 31 class MockChromeClient : public EmptyChromeClient { |
| 30 public: | 32 public: |
| 31 MockChromeClient() : m_hasScheduledAnimation(false) {} | 33 MockChromeClient() : m_hasScheduledAnimation(false) {} |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 132 |
| 131 // NoOverflowInIncrementVisuallyNonEmptyPixelCount tests fail if the number of | 133 // NoOverflowInIncrementVisuallyNonEmptyPixelCount tests fail if the number of |
| 132 // pixels is calculated in 32-bit integer, because 65536 * 65536 would become 0 | 134 // pixels is calculated in 32-bit integer, because 65536 * 65536 would become 0 |
| 133 // if it was calculated in 32-bit and thus it would be considered as empty. | 135 // if it was calculated in 32-bit and thus it would be considered as empty. |
| 134 TEST_P(FrameViewTest, NoOverflowInIncrementVisuallyNonEmptyPixelCount) { | 136 TEST_P(FrameViewTest, NoOverflowInIncrementVisuallyNonEmptyPixelCount) { |
| 135 EXPECT_FALSE(document().view()->isVisuallyNonEmpty()); | 137 EXPECT_FALSE(document().view()->isVisuallyNonEmpty()); |
| 136 document().view()->incrementVisuallyNonEmptyPixelCount(IntSize(65536, 65536)); | 138 document().view()->incrementVisuallyNonEmptyPixelCount(IntSize(65536, 65536)); |
| 137 EXPECT_TRUE(document().view()->isVisuallyNonEmpty()); | 139 EXPECT_TRUE(document().view()->isVisuallyNonEmpty()); |
| 138 } | 140 } |
| 139 | 141 |
| 142 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) { |
| 143 // When using root layer scrolling there is no concept of viewport constrained |
| 144 // objects, so skip this test. |
| 145 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 146 return; |
| 147 |
| 148 document().body()->setInnerHTML( |
| 149 "<style>.container { height: 200%; }" |
| 150 "#sticky { position: sticky; top: 0; height: 50px; }</style>" |
| 151 "<div class='container'><div id='sticky'></div></div>"); |
| 152 document().view()->updateAllLifecyclePhases(); |
| 153 |
| 154 LayoutBoxModelObject* sticky = toLayoutBoxModelObject( |
| 155 document().getElementById("sticky")->layoutObject()); |
| 156 |
| 157 EXPECT_TRUE( |
| 158 document().view()->viewportConstrainedObjects()->contains(sticky)); |
| 159 |
| 160 // Making the element non-sticky should remove it from the set of |
| 161 // viewport-constrained objects. |
| 162 document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, |
| 163 "position: relative"); |
| 164 document().view()->updateAllLifecyclePhases(); |
| 165 |
| 166 EXPECT_FALSE( |
| 167 document().view()->viewportConstrainedObjects()->contains(sticky)); |
| 168 |
| 169 // And making it sticky again should put it back in that list. |
| 170 document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, ""); |
| 171 document().view()->updateAllLifecyclePhases(); |
| 172 |
| 173 EXPECT_TRUE( |
| 174 document().view()->viewportConstrainedObjects()->contains(sticky)); |
| 175 } |
| 176 |
| 140 } // namespace | 177 } // namespace |
| 141 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |