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

Unified Diff: third_party/WebKit/Source/web/ResizeViewportAnchor.cpp

Issue 1844013002: Fix main thread top controls scrolling to mirror CC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@propertyTreesBoundsDelta
Patch Set: Whitespace Created 4 years, 9 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/web/ResizeViewportAnchor.cpp
diff --git a/third_party/WebKit/Source/web/ResizeViewportAnchor.cpp b/third_party/WebKit/Source/web/ResizeViewportAnchor.cpp
index 8c79f083d325094e0a910dd469f64936fe9b733a..cac7353a972c926c4957e479e2b240f58fbf4f32 100644
--- a/third_party/WebKit/Source/web/ResizeViewportAnchor.cpp
+++ b/third_party/WebKit/Source/web/ResizeViewportAnchor.cpp
@@ -14,13 +14,46 @@ namespace blink {
ResizeViewportAnchor::ResizeViewportAnchor(FrameView& rootFrameView, VisualViewport& visualViewport)
: ViewportAnchor(rootFrameView, visualViewport)
- , m_visualViewportInDocument(rootFrameView.getScrollableArea()->visibleContentRectDouble().location())
+ , m_visualViewportInDocument(rootFrameView.getScrollableArea()->scrollPositionDouble())
{
}
ResizeViewportAnchor::~ResizeViewportAnchor()
{
- m_rootFrameView->getScrollableArea()->setScrollPosition(m_visualViewportInDocument, ProgrammaticScroll);
+ // TODO(bokan): Don't use RootFrameViewport::setScrollPosition since it
+ // assumes we can just set a sub-pixel precision offset on the FrameView.
+ // While we "can" do this, the offset that will be shipped to CC will be the
+ // truncated number and this class is used to handle TopControl movement
+ // which needs the two threads to match exactly pixel-for-pixel. We can
+ // replace this with RFV::setScrollPosition once Blink is sub-pixel scroll
+ // offset aware. crbug.com/414283.
+
+ ScrollableArea* rootViewport = m_rootFrameView->getScrollableArea();
+ ScrollableArea* layoutViewport =
+ m_rootFrameView->layoutViewportScrollableArea();
+
+ DoubleSize delta = m_visualViewportInDocument
+ - rootViewport->scrollPositionDouble();
+
+ m_visualViewport->move(toFloatSize(delta));
+
+ // Since the main thread FrameView has integer scroll offsets, scroll it to
+ // the next pixel and then we'll scroll the visual viewport again to
+ // compensate for the sub-pixel offset.
+ delta = m_visualViewportInDocument
+ - rootViewport->scrollPositionDouble();
+
+ IntSize layoutDelta = delta.height() < 0
+ ? flooredIntSize(delta)
+ : expandedIntSize(delta);
+
+ layoutViewport->setScrollPosition(
+ layoutViewport->scrollPosition() + layoutDelta,
+ ProgrammaticScroll);
+
+ delta = m_visualViewportInDocument
+ - rootViewport->scrollPositionDouble();
+ m_visualViewport->move(toFloatSize(delta));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698