From fba1550dc92fbf3fc21b98253122b1ee5e24bd5c Mon Sep 17 00:00:00 2001 From: "akling@apple.com" Date: Tue, 17 Jun 2014 19:00:42 +0000 Subject: [PATCH] Avoid synchronous layout in window.scrollTo(0,0) when already at (0,0) Going from 0,0 to 0,0 is a no-op since there is no way a layout will affect the current scroll position. We don't send scroll events when moving to the previous position, so this change is not observable. Reviewed by Anders Carlsson. * page/DOMWindow.cpp: (WebCore::DOMWindow::scrollTo): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170063 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 16 ++++++++++++++++ Source/WebCore/page/DOMWindow.cpp | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index a869dbe..03af14c 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2014-06-17 Andreas Kling + + Avoid synchronous layout in window.scrollTo(0,0) when already at (0,0) + + + Going from 0,0 to 0,0 is a no-op since there is no way a layout will + affect the current scroll position. + + We don't send scroll events when moving to the previous position, + so this change is not observable. + + Reviewed by Anders Carlsson. + + * page/DOMWindow.cpp: + (WebCore::DOMWindow::scrollTo): + 2014-06-17 Alex Christensen Fix css jit register usage on armv7. diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp index 029be46..ae791c1 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -1479,12 +1479,15 @@ void DOMWindow::scrollTo(int x, int y) const if (!isCurrentlyDisplayedInFrame()) return; - document()->updateLayoutIgnorePendingStylesheets(); - RefPtr view = m_frame->view(); if (!view) return; + if (!x && !y && view->contentsScrollPosition() == IntPoint(0, 0)) + return; + + document()->updateLayoutIgnorePendingStylesheets(); + IntPoint layoutPos(view->mapFromCSSToLayoutUnits(x), view->mapFromCSSToLayoutUnits(y)); view->setContentsScrollPosition(layoutPos); } -- 1.8.3.1