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

Unified Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Created 4 years, 2 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/loader/FrameLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
index 2f5cb59e411da8e91ee9429f0fdbc7964f29a154..6c794de14cd1d55246ee7497918e5c9b3c5b83be 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -272,9 +272,9 @@ void FrameLoader::saveScrollState() {
if (ScrollableArea* layoutScrollableArea =
m_frame->view()->layoutViewportScrollableArea())
- m_currentItem->setScrollPoint(layoutScrollableArea->scrollPosition());
- m_currentItem->setVisualViewportScrollPoint(
- m_frame->host()->visualViewport().visibleRect().location());
+ m_currentItem->setScrollOffset(layoutScrollableArea->scrollOffset());
+ m_currentItem->setVisualViewportScrollOffset(toScrollOffset(
+ m_frame->host()->visualViewport().visibleRect().location()));
if (m_frame->isMainFrame())
m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor());
@@ -420,9 +420,9 @@ void FrameLoader::setHistoryItemStateForCommit(
!equalIgnoringFragmentIdentifier(oldItem->url(), m_currentItem->url())))
return;
m_currentItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber());
- m_currentItem->setScrollPoint(oldItem->scrollPoint());
- m_currentItem->setVisualViewportScrollPoint(
- oldItem->visualViewportScrollPoint());
+ m_currentItem->setScrollOffset(oldItem->scrollOffset());
+ m_currentItem->setVisualViewportScrollOffset(
+ oldItem->visualViewportScrollOffset());
m_currentItem->setPageScaleFactor(oldItem->pageScaleFactor());
m_currentItem->setScrollRestorationType(oldItem->scrollRestorationType());
@@ -1323,8 +1323,8 @@ void FrameLoader::restoreScrollPositionAndViewState() {
// completes because that may be because the page will never reach its
// previous height
bool canRestoreWithoutClamping =
- view->layoutViewportScrollableArea()->clampScrollPosition(
- m_currentItem->scrollPoint()) == m_currentItem->scrollPoint();
+ view->layoutViewportScrollableArea()->clampScrollOffset(
+ m_currentItem->scrollOffset()) == m_currentItem->scrollOffset();
bool canRestoreWithoutAnnoyingUser =
!documentLoader()->initialScrollState().wasScrolledByUser &&
(canRestoreWithoutClamping || !m_frame->isLoading() ||
@@ -1332,29 +1332,34 @@ void FrameLoader::restoreScrollPositionAndViewState() {
if (!canRestoreWithoutAnnoyingUser)
return;
- if (shouldRestoreScroll)
- view->layoutViewportScrollableArea()->setScrollPosition(
- m_currentItem->scrollPoint(), ProgrammaticScroll);
+ if (shouldRestoreScroll) {
+ view->layoutViewportScrollableArea()->setScrollOffset(
+ m_currentItem->scrollOffset(), ProgrammaticScroll);
+ }
// For main frame restore scale and visual viewport position
if (m_frame->isMainFrame()) {
- FloatPoint visualViewportOffset(m_currentItem->visualViewportScrollPoint());
+ ScrollOffset visualViewportOffset(
+ m_currentItem->visualViewportScrollOffset());
// If the visual viewport's offset is (-1, -1) it means the history item
// is an old version of HistoryItem so distribute the scroll between
// the main frame and the visual viewport as best as we can.
- if (visualViewportOffset.x() == -1 && visualViewportOffset.y() == -1)
+ if (visualViewportOffset.width() == -1 &&
+ visualViewportOffset.height() == -1) {
visualViewportOffset =
- FloatPoint(m_currentItem->scrollPoint() - view->scrollPosition());
+ m_currentItem->scrollOffset() - view->scrollOffset();
+ }
VisualViewport& visualViewport = m_frame->host()->visualViewport();
- if (shouldRestoreScale && shouldRestoreScroll)
+ if (shouldRestoreScale && shouldRestoreScroll) {
visualViewport.setScaleAndLocation(m_currentItem->pageScaleFactor(),
- visualViewportOffset);
- else if (shouldRestoreScale)
+ FloatPoint(visualViewportOffset));
+ } else if (shouldRestoreScale) {
visualViewport.setScale(m_currentItem->pageScaleFactor());
- else if (shouldRestoreScroll)
- visualViewport.setLocation(visualViewportOffset);
+ } else if (shouldRestoreScroll) {
+ visualViewport.setLocation(FloatPoint(visualViewportOffset));
+ }
if (ScrollingCoordinator* scrollingCoordinator =
m_frame->page()->scrollingCoordinator())

Powered by Google App Engine
This is Rietveld 408576698