Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: third_party/WebKit/Source/core/frame/FrameViewTest.cpp

Issue 2706673002: Mark elements as viewport constrained when they become sticky positioned (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameViewTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameViewTest.cpp b/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
index a3f1cd19c6e9c4b71b5a3ca9f9483e5834121f6e..a182ea5f845aad0dc09f447fab842d1f2f14a124 100644
--- a/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameViewTest.cpp
@@ -4,9 +4,12 @@
#include "core/frame/FrameView.h"
+#include <memory>
+
#include "bindings/core/v8/ExceptionState.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLElement.h"
+#include "core/layout/LayoutBoxModelObject.h"
#include "core/layout/LayoutObject.h"
#include "core/loader/EmptyClients.h"
#include "core/page/Page.h"
@@ -18,7 +21,6 @@
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <memory>
using testing::_;
using testing::AnyNumber;
@@ -137,5 +139,40 @@ TEST_P(FrameViewTest, NoOverflowInIncrementVisuallyNonEmptyPixelCount) {
EXPECT_TRUE(document().view()->isVisuallyNonEmpty());
}
+TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) {
+ // When using root layer scrolling there is no concept of viewport constrained
+ // objects, so skip this test.
+ if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
+ return;
+
+ document().body()->setInnerHTML(
+ "<style>.container { height: 200%; }"
+ "#sticky { position: sticky; top: 0; height: 50px; }</style>"
+ "<div class='container'><div id='sticky'></div></div>");
+ document().view()->updateAllLifecyclePhases();
+
+ LayoutBoxModelObject* sticky = toLayoutBoxModelObject(
+ document().getElementById("sticky")->layoutObject());
+
+ EXPECT_TRUE(
+ document().view()->viewportConstrainedObjects()->contains(sticky));
+
+ // Making the element non-sticky should remove it from the set of
+ // viewport-constrained objects.
+ document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr,
+ "position: relative");
+ document().view()->updateAllLifecyclePhases();
+
+ EXPECT_FALSE(
+ document().view()->viewportConstrainedObjects()->contains(sticky));
+
+ // And making it sticky again should put it back in that list.
+ document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, "");
+ document().view()->updateAllLifecyclePhases();
+
+ EXPECT_TRUE(
+ document().view()->viewportConstrainedObjects()->contains(sticky));
+}
+
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698