fast/dom/scroll-element-to-rect.html fails on WK1 Mac port
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2011 00:45:20 +0000 (00:45 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2011 00:45:20 +0000 (00:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68815

Source/WebCore:

Reviewed by Dan Bernstein.

FrameView::scrollElementToRect() was incorrectly using Element::boundsInWindowSpace(),
which is window-relative (not web view-relative), and has flipped coordinates
in WebKit1.

Change to use Node::getRect() which is what the author intended.

* dom/Element.h:
* page/FrameView.cpp:
(WebCore::FrameView::scrollElementToRect):

LayoutTests:

Reviewed by Dan Bernstein.

Fix these tests to not throw errors when window.internals is not available.

* fast/dom/scroll-element-to-rect-centered.html:
* fast/dom/scroll-element-to-rect.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96278 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/scroll-element-to-rect-centered.html
LayoutTests/fast/dom/scroll-element-to-rect.html
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.h
Source/WebCore/page/FrameView.cpp

index 996af00..11e93e2 100644 (file)
@@ -1,3 +1,15 @@
+2011-09-28  Simon Fraser  <simon.fraser@apple.com>
+
+        fast/dom/scroll-element-to-rect.html fails on WK1 Mac port
+        https://bugs.webkit.org/show_bug.cgi?id=68815
+
+        Reviewed by Dan Bernstein.
+        
+        Fix these tests to not throw errors when window.internals is not available.
+
+        * fast/dom/scroll-element-to-rect-centered.html:
+        * fast/dom/scroll-element-to-rect.html:
+
 2011-09-28  Ryosuke Niwa  <rniwa@webkit.org>
 
         Qt rebsaeline after r96257. It seems like the difference is coming from the font used in select element.
index 5c5df82..61464ef 100644 (file)
@@ -9,10 +9,10 @@
     </body>
     <script src="../js/resources/js-test-pre.js"></script>
     <script>
-      if (window.internals) {
-        var box = document.getElementById('textbox');
+      var box = document.getElementById('textbox');
+      if (window.internals)
         window.internals.scrollElementToRect(box, 50, 30, 200, 250);
-      }
+
       var rect = box.getBoundingClientRect();
       var computedLeft = 50 + Math.floor((200 - rect.width) / 2);
       var computedTop = 30 + Math.floor((250 - rect.height) / 2);
index 77623ba..a7e05e5 100644 (file)
@@ -8,10 +8,10 @@
     </body>
     <script src="../js/resources/js-test-pre.js"></script>
     <script>
-      if (window.internals) {
-        var box = document.getElementById('textbox');
+         var box = document.getElementById('textbox');
+      if (window.internals)
         window.internals.scrollElementToRect(box, 0, 0, 300, 300);
-      }
+
       var rect = box.getBoundingClientRect();
       var computedLeft = Math.floor((300 - rect.width) / 2);
       var computedTop = Math.floor((300 - rect.height) / 2);
index 0153c8a..038e172 100644 (file)
@@ -1,3 +1,20 @@
+2011-09-28  Simon Fraser  <simon.fraser@apple.com>
+
+        fast/dom/scroll-element-to-rect.html fails on WK1 Mac port
+        https://bugs.webkit.org/show_bug.cgi?id=68815
+
+        Reviewed by Dan Bernstein.
+        
+        FrameView::scrollElementToRect() was incorrectly using Element::boundsInWindowSpace(),
+        which is window-relative (not web view-relative), and has flipped coordinates
+        in WebKit1.
+        
+        Change to use Node::getRect() which is what the author intended.
+
+        * dom/Element.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollElementToRect):
+
 2011-09-28  Peter Beverloo  <peter@chromium.org>
 
         Don't clamp cubic-bezier timing functions between 0 and 1
index d2a876f..32d3ed6 100644 (file)
@@ -166,6 +166,7 @@ public:
     virtual int scrollWidth();
     virtual int scrollHeight();
 
+    // Note that the 'window space' has a flipped coordinate system on some platforms.
     LayoutRect boundsInWindowSpace();
 
     PassRefPtr<ClientRectList> getClientRects();
index 6c7c658..d123318 100644 (file)
@@ -1638,7 +1638,7 @@ void FrameView::scrollElementToRect(Element* element, const IntRect& rect)
 {
     m_frame->document()->updateLayoutIgnorePendingStylesheets();
 
-    LayoutRect bounds = element->boundsInWindowSpace();
+    LayoutRect bounds = element->getRect();
     int centeringOffsetX = (rect.width() - bounds.width()) / 2;
     int centeringOffsetY = (rect.height() - bounds.height()) / 2;
     scrollBy(IntSize(bounds.x() - centeringOffsetX - rect.x(), bounds.y() - centeringOffsetY - rect.y()));