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

Unified Diff: third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/fixed-using-top.html

Issue 2002623003: Exclude position:absolute elements when picking an anchor for ScrollAnchoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/LayoutTests/fast/layout/scroll-anchoring/fixed-using-top.html
diff --git a/third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/fixed-using-top.html b/third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/fixed-using-top.html
new file mode 100644
index 0000000000000000000000000000000000000000..b08d12c4addd10c8180640a6ecc495a3eab1e3e7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/layout/scroll-anchoring/fixed-using-top.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="resources/scroll-anchoring-test.js"></script>
+<style>
+ body {
+ margin: 0px;
+ height: 1500px;
+ }
+ #a {
+ height: 200px;
+ }
+ #b {
+ position: absolute;
+ left: 50px;
+ height:200px;
+ width: 200px;
+ background-color: #fcc;
+ }
+</style>
+
+<div id="a"></div>
+<div id="b"></div>
+
+<script>
+internals.runtimeFlags.scrollAnchoringEnabled = true;
+
+// We start of by scrolling #b out of the viewport by 20px. The scroll handler
+// fixes #b to the viewport by updating its style.top value. This triggers
+// layout during which we anchor to #b. Because the scroll handler moves #b
+// back into the viewport, we make an incorrect adjustment. This adjustment
+// fires the handler and triggers another layout as #b is scrolled out of the
+// viewport.
+
+// The current solution here is for ScrollAnchor to not anchor to absolute
+// positioned elements.
+
+var b = document.querySelector('#b');
+// The initial position of b relative to the document.
+var initialTop = 200;
+
+onscroll = function() {
+ var y = scrollY;
+ if (y > initialTop)
+ b.style.top = (y + 10) + 'px';
+ else
+ b.style.top = '';
+};
+
+promise_test(function() {
+ var scrollBy = initialTop + 20;
+ return Promise.resolve()
+ .then(() => { eventSender.continuousMouseScrollBy(0, -scrollBy); })
+ .then(() => scrollSettlesAt(scrollBy));
+}, "Scroll anchoring position fixed using scroll top");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698