Avoid synchronous layout in window.scrollTo(0,0) when already at (0,0)
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jun 2014 19:00:42 +0000 (19:00 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jun 2014 19:00:42 +0000 (19:00 +0000)
<https://webkit.org/b/133893>

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
Source/WebCore/page/DOMWindow.cpp

index a869dbe..03af14c 100644 (file)
@@ -1,3 +1,19 @@
+2014-06-17  Andreas Kling  <akling@apple.com>
+
+        Avoid synchronous layout in window.scrollTo(0,0) when already at (0,0)
+        <https://webkit.org/b/133893>
+
+        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  <achristensen@webkit.org>
 
         Fix css jit register usage on armv7.
index 029be46..ae791c1 100644 (file)
@@ -1479,12 +1479,15 @@ void DOMWindow::scrollTo(int x, int y) const
     if (!isCurrentlyDisplayedInFrame())
         return;
 
-    document()->updateLayoutIgnorePendingStylesheets();
-
     RefPtr<FrameView> 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);
 }