Title: [95608] trunk
Revision
95608
Author
[email protected]
Date
2011-09-21 04:01:43 -0700 (Wed, 21 Sep 2011)

Log Message

Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=68081
Fix scroll in page scaling mode.

Reviewed by Simon Fraser.

The following things are done in this patch:
1. Rename Frame::pageScaleFactor() to Frame::frameScaleFactor() to better
   reflect its purpose.
2. Frame::frameScaleFactor() returns the scale factor of this frame with
   respect to the container. So for the main frame it'll return the scale
   factor of the page, inner frames will return 1.0
3. scrollBy(), scrollX() and scrollY() to take into account of the frame
   scale factor, causing incorrect coordinates reported to _javascript_.

Tests: fast/events/scale-and-scroll-body.html
       fast/events/scale-and-scroll-iframe-body.html
       fast/events/scale-and-scroll-iframe-window.html
       fast/events/scale-and-scroll-window.html

* html/HTMLBodyElement.cpp:
(WebCore::adjustForZoom):
(WebCore::HTMLBodyElement::setScrollLeft):
(WebCore::HTMLBodyElement::setScrollTop):
* loader/HistoryController.cpp:
(WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::scrollX):
(WebCore::DOMWindow::scrollY):
(WebCore::DOMWindow::scrollTo):
* page/Frame.cpp:
(WebCore::Frame::frameScaleFactor): Return page's scale factor if this is
                                    main frame, otherwise 1.0
* page/Frame.h:
* page/FrameView.cpp:
(WebCore::FrameView::applyOverflowToViewport):
(WebCore::FrameView::scrollXForFixedPosition):
(WebCore::FrameView::scrollYForFixedPosition):

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=68081
Add layout test for page scale and scrolling.

Reviewed by Simon Fraser.

Add tests to cover the following cases:
1. Scale and scroll window
2. Scale and scroll document.body
3. Scale and scroll iframe's contentWindow
4. Scale and scroll iframe's contentDocument.body

* fast/events/scale-and-scroll-body-expected.png: Added.
* fast/events/scale-and-scroll-body-expected.txt: Added.
* fast/events/scale-and-scroll-body.html: Added.
* fast/events/scale-and-scroll-iframe-body-expected.png: Added.
* fast/events/scale-and-scroll-iframe-body-expected.txt: Added.
* fast/events/scale-and-scroll-iframe-body.html: Added.
* fast/events/scale-and-scroll-iframe-window-expected.png: Added.
* fast/events/scale-and-scroll-iframe-window-expected.txt: Added.
* fast/events/scale-and-scroll-iframe-window.html: Added.
* fast/events/scale-and-scroll-window-expected.png: Added.
* fast/events/scale-and-scroll-window-expected.txt: Added.
* fast/events/scale-and-scroll-window.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (95607 => 95608)


--- trunk/LayoutTests/ChangeLog	2011-09-21 10:16:53 UTC (rev 95607)
+++ trunk/LayoutTests/ChangeLog	2011-09-21 11:01:43 UTC (rev 95608)
@@ -1,3 +1,29 @@
+2011-09-20  Alpha Lam  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=68081
+        Add layout test for page scale and scrolling.
+
+        Reviewed by Simon Fraser.
+
+        Add tests to cover the following cases:
+        1. Scale and scroll window
+        2. Scale and scroll document.body
+        3. Scale and scroll iframe's contentWindow
+        4. Scale and scroll iframe's contentDocument.body
+
+        * fast/events/scale-and-scroll-body-expected.png: Added.
+        * fast/events/scale-and-scroll-body-expected.txt: Added.
+        * fast/events/scale-and-scroll-body.html: Added.
+        * fast/events/scale-and-scroll-iframe-body-expected.png: Added.
+        * fast/events/scale-and-scroll-iframe-body-expected.txt: Added.
+        * fast/events/scale-and-scroll-iframe-body.html: Added.
+        * fast/events/scale-and-scroll-iframe-window-expected.png: Added.
+        * fast/events/scale-and-scroll-iframe-window-expected.txt: Added.
+        * fast/events/scale-and-scroll-iframe-window.html: Added.
+        * fast/events/scale-and-scroll-window-expected.png: Added.
+        * fast/events/scale-and-scroll-window-expected.txt: Added.
+        * fast/events/scale-and-scroll-window.html: Added.
+
 2011-09-21  Philippe Normand  <[email protected]>
 
         Unreviewed, GTK rebaseline, skip some flaky worker tests and 2

Added: trunk/LayoutTests/fast/events/scale-and-scroll-body-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-body-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/events/scale-and-scroll-body-expected.txt (0 => 95608)


--- trunk/LayoutTests/fast/events/scale-and-scroll-body-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scale-and-scroll-body-expected.txt	2011-09-21 11:01:43 UTC (rev 95608)
@@ -0,0 +1,5 @@
+PASS window.document.body.scrollTop is 100
+PASS window.document.body.scrollLeft is 100
+PASS window.scrollX is 100
+PASS window.scrollY is 100
+
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-body-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/events/scale-and-scroll-body.html (0 => 95608)


--- trunk/LayoutTests/fast/events/scale-and-scroll-body.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scale-and-scroll-body.html	2011-09-21 11:01:43 UTC (rev 95608)
@@ -0,0 +1,51 @@
+<html>
+<head>
+    <style>
+        ::-webkit-scrollbar {
+            width: 0px;
+            height: 0px;
+        }
+    </style>
+    <script>
+      window.enablePixelTesting = true;
+
+      function scroll() {
+          // The page scale, as set by EventSender.scalePageBy should not be apparent
+          // to _javascript_. So, we expect scrolling to (100,100) to be page coordinates, rather
+          // than device pixels.
+          document.body.scrollLeft = 100;
+          document.body.scrollTop = 100;
+
+          shouldBe("window.document.body.scrollTop", "100");
+          shouldBe("window.document.body.scrollLeft", "100");
+          shouldBe("window.scrollX", "100");
+          shouldBe("window.scrollY", "100");
+      }
+
+      function scaleWithEventSender() {
+          var scaleFactor = 2.0;
+          var scaleOffset = 0;
+          if (window.eventSender) {
+             eventSender.scalePageBy(scaleFactor, scaleOffset, scaleOffset);
+          }
+      }
+
+      function test() {
+          scaleWithEventSender();
+          scroll();
+      }
+    </script>
+    <script src=""
+</head>
+<body style="width:2000px; height:2000px; margin:0px;" _onload_="test();">
+    <div style="left:0; top:0; width:100px; height:100px; position:absolute; background:yellow;"></div>
+    <div style="left:100px; top:0; width:100px; height:100px; position:absolute; background:green;"></div>
+    <div style="left:200px; top:0; width:100px; height:100px; position:absolute; background:blue;"></div>
+
+    <div style="left:0; top:100px; width:100px; height:100px; position:absolute; background: green;"></div>
+    <div style="left:100px; top:100px; width:100px; height:100px; position:absolute; background:blue;"></div>
+    <div style="left:200px; top:100px; width:100px; height:100px; position:absolute; background:yellow;"></div>
+
+    <div id="console"></div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-body.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.txt (0 => 95608)


--- trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.txt	2011-09-21 11:01:43 UTC (rev 95608)
@@ -0,0 +1,6 @@
+
+PASS frame.contentDocument.body.scrollTop is 100
+PASS frame.contentDocument.body.scrollLeft is 100
+PASS frame.contentWindow.scrollX is 100
+PASS frame.contentWindow.scrollY is 100
+
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body.html (0 => 95608)


--- trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body.html	2011-09-21 11:01:43 UTC (rev 95608)
@@ -0,0 +1,62 @@
+<html>
+<head>
+    <style>
+        ::-webkit-scrollbar {
+            width: 0px;
+            height: 0px;
+        }
+    </style>
+    <script>
+        window.enablePixelTesting = true;
+
+        function scroll() {
+            window.scrollTo(0, 100);
+            var frame = document.getElementById('frame');
+            frame.contentDocument.body.scrollTop = 100;
+            frame.contentDocument.body.scrollLeft = 100;
+
+            shouldBe("frame.contentDocument.body.scrollTop", "100");
+            shouldBe("frame.contentDocument.body.scrollLeft", "100");
+            shouldBe("frame.contentWindow.scrollX", "100");
+            shouldBe("frame.contentWindow.scrollY", "100");
+        }
+
+        function scaleWithEventSender() {
+            var scaleFactor = 0.5;
+            var scaleOffset = 0;
+            if (window.eventSender) {
+                 eventSender.scalePageBy(scaleFactor, scaleOffset, scaleOffset);
+            }
+        }
+
+        function test() {
+            scaleWithEventSender();
+            scroll();
+        }
+    </script>
+    <script src=""
+</head>
+<body _onload_="test();" style="height: 2000px">
+    <iframe id="frame" style="width:400px; height: 400px; position: absolute; top: 100px;"></iframe>
+    <div id="console"></div>
+
+    <script>
+        var frame = document.getElementById('frame');
+        var doc = frame.contentDocument.open();
+        doc.write("<div style='left:0; top:0; width:100px; height:100px; position:absolute; background:yellow;'></div>");
+        doc.write("<div style='left:100px; top:0; width:100px; height:100px; position:absolute; background:green;'></div>");
+        doc.write("<div style='left:200px; top:0; width:100px; height:100px; position:absolute; background:blue;'></div>");
+        doc.write("<div style='left:300px; top:0; width:100px; height:100px; position:absolute; background:green;'></div>");
+        doc.write("<div style='left:400px; top:0; width:100px; height:100px; position:absolute; background:blue;'></div>");
+
+        doc.write("<div style='left:0; top:100px; width:100px; height:100px; position:absolute; background: green;'></div>");
+        doc.write("<div style='left:100px; top:100px; width:100px; height:100px; position:absolute; background:blue;'></div>");
+        doc.write("<div style='left:200px; top:100px; width:100px; height:100px; position:absolute; background:green;'></div>");
+        doc.write("<div style='left:300px; top:100px; width:100px; height:100px; position:absolute; background:blue;'></div>");
+        doc.write("<div style='left:400px; top:100px; width:100px; height:100px; position:absolute; background:green;'></div>");
+        doc.close();
+        frame.contentDocument.body.style.width = "2000px";
+        frame.contentDocument.body.style.height = "2000px";
+    </script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-body.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.txt (0 => 95608)


--- trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.txt	2011-09-21 11:01:43 UTC (rev 95608)
@@ -0,0 +1,5 @@
+PASS frame.contentDocument.body.scrollTop is 100
+PASS frame.contentDocument.body.scrollLeft is 100
+PASS frame.contentWindow.scrollX is 100
+PASS frame.contentWindow.scrollY is 100
+
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window.html (0 => 95608)


--- trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window.html	2011-09-21 11:01:43 UTC (rev 95608)
@@ -0,0 +1,61 @@
+<html>
+<head>
+    <style>
+        ::-webkit-scrollbar {
+            width: 0px;
+            height: 0px;
+        }
+    </style>
+    <script>
+        window.enablePixelTesting = true;
+
+        function scroll() {
+            window.scrollTo(0, 100);
+            var frame = document.getElementById('frame');
+            frame.contentWindow.scrollTo(100,100);
+
+            shouldBe("frame.contentDocument.body.scrollTop", "100");
+            shouldBe("frame.contentDocument.body.scrollLeft", "100");
+            shouldBe("frame.contentWindow.scrollX", "100");
+            shouldBe("frame.contentWindow.scrollY", "100");
+        }
+
+        function scaleWithEventSender() {
+            var scaleFactor = 0.5;
+            var scaleOffset = 0;
+            if (window.eventSender) {
+                 eventSender.scalePageBy(scaleFactor, scaleOffset, scaleOffset);
+            }
+        }
+
+        function test() {
+            scaleWithEventSender();
+            scroll();
+        }
+    </script>
+    <script src=""
+</head>
+<body _onload_="test();" style="height: 2000px">
+    <div id="console"></div>
+    <iframe id="frame" style="width:400px; height: 400px; position: absolute; top: 100px;"></iframe>
+
+    <script>
+        var frame = document.getElementById('frame');
+        var doc = frame.contentDocument.open();
+        doc.write("<div style='left:0; top:0; width:100px; height:100px; position:absolute; background:yellow;'></div>");
+        doc.write("<div style='left:100px; top:0; width:100px; height:100px; position:absolute; background:green;'></div>");
+        doc.write("<div style='left:200px; top:0; width:100px; height:100px; position:absolute; background:blue;'></div>");
+        doc.write("<div style='left:300px; top:0; width:100px; height:100px; position:absolute; background:green;'></div>");
+        doc.write("<div style='left:400px; top:0; width:100px; height:100px; position:absolute; background:blue;'></div>");
+
+        doc.write("<div style='left:0; top:100px; width:100px; height:100px; position:absolute; background: green;'></div>");
+        doc.write("<div style='left:100px; top:100px; width:100px; height:100px; position:absolute; background:blue;'></div>");
+        doc.write("<div style='left:200px; top:100px; width:100px; height:100px; position:absolute; background:green;'></div>");
+        doc.write("<div style='left:300px; top:100px; width:100px; height:100px; position:absolute; background:blue;'></div>");
+        doc.write("<div style='left:400px; top:100px; width:100px; height:100px; position:absolute; background:green;'></div>");
+        doc.close();
+        frame.contentDocument.body.style.width = "2000px";
+        frame.contentDocument.body.style.height = "2000px";
+    </script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-iframe-window.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/events/scale-and-scroll-window-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-window-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/events/scale-and-scroll-window-expected.txt (0 => 95608)


--- trunk/LayoutTests/fast/events/scale-and-scroll-window-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scale-and-scroll-window-expected.txt	2011-09-21 11:01:43 UTC (rev 95608)
@@ -0,0 +1,5 @@
+PASS window.document.body.scrollTop is 100
+PASS window.document.body.scrollLeft is 100
+PASS window.scrollX is 100
+PASS window.scrollY is 100
+
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-window-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/events/scale-and-scroll-window.html (0 => 95608)


--- trunk/LayoutTests/fast/events/scale-and-scroll-window.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scale-and-scroll-window.html	2011-09-21 11:01:43 UTC (rev 95608)
@@ -0,0 +1,50 @@
+<html>
+<head>
+    <style>
+        ::-webkit-scrollbar {
+            width: 0px;
+            height: 0px;
+        }
+    </style>
+    <script>
+      window.enablePixelTesting = true;
+
+      function scroll() {
+          // The page scale, as set by EventSender.scalePageBy should not be apparent
+          // to _javascript_. So, we expect scrolling to (100,100) to be page coordinates, rather
+          // than device pixels.
+          window.scrollTo(100,100);
+
+          shouldBe("window.document.body.scrollTop", "100");
+          shouldBe("window.document.body.scrollLeft", "100");
+          shouldBe("window.scrollX", "100");
+          shouldBe("window.scrollY", "100");
+      }
+
+      function scaleWithEventSender() {
+          var scaleFactor = 2.0;
+          var scaleOffset = 0;
+          if (window.eventSender) {
+             eventSender.scalePageBy(scaleFactor, scaleOffset, scaleOffset);
+          }
+      }
+
+      function test() {
+          scaleWithEventSender();
+          scroll();
+      }
+    </script>
+    <script src=""
+</head>
+<body style="width:2000px; height:2000px; margin:0px;" _onload_="test();">
+    <div style="left:0; top:0; width:100px; height:100px; position:absolute; background:yellow;"></div>
+    <div style="left:100px; top:0; width:100px; height:100px; position:absolute; background:green;"></div>
+    <div style="left:200px; top:0; width:100px; height:100px; position:absolute; background:blue;"></div>
+
+    <div style="left:0; top:100px; width:100px; height:100px; position:absolute; background: green;"></div>
+    <div style="left:100px; top:100px; width:100px; height:100px; position:absolute; background:blue;"></div>
+    <div style="left:200px; top:100px; width:100px; height:100px; position:absolute; background:yellow;"></div>
+
+    <div id="console"></div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/scale-and-scroll-window.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (95607 => 95608)


--- trunk/Source/WebCore/ChangeLog	2011-09-21 10:16:53 UTC (rev 95607)
+++ trunk/Source/WebCore/ChangeLog	2011-09-21 11:01:43 UTC (rev 95608)
@@ -1,3 +1,43 @@
+2011-09-20  Alpha Lam  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=68081
+        Fix scroll in page scaling mode.
+
+        Reviewed by Simon Fraser.
+
+        The following things are done in this patch:
+        1. Rename Frame::pageScaleFactor() to Frame::frameScaleFactor() to better
+           reflect its purpose.
+        2. Frame::frameScaleFactor() returns the scale factor of this frame with
+           respect to the container. So for the main frame it'll return the scale
+           factor of the page, inner frames will return 1.0
+        3. scrollBy(), scrollX() and scrollY() to take into account of the frame
+           scale factor, causing incorrect coordinates reported to _javascript_.
+
+        Tests: fast/events/scale-and-scroll-body.html
+               fast/events/scale-and-scroll-iframe-body.html
+               fast/events/scale-and-scroll-iframe-window.html
+               fast/events/scale-and-scroll-window.html
+
+        * html/HTMLBodyElement.cpp:
+        (WebCore::adjustForZoom):
+        (WebCore::HTMLBodyElement::setScrollLeft):
+        (WebCore::HTMLBodyElement::setScrollTop):
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::scrollX):
+        (WebCore::DOMWindow::scrollY):
+        (WebCore::DOMWindow::scrollTo):
+        * page/Frame.cpp:
+        (WebCore::Frame::frameScaleFactor): Return page's scale factor if this is
+                                            main frame, otherwise 1.0
+        * page/Frame.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::applyOverflowToViewport):
+        (WebCore::FrameView::scrollXForFixedPosition):
+        (WebCore::FrameView::scrollYForFixedPosition):
+
 2011-09-21  Andras Becsi  <[email protected]>
 
         [Qt] Remove Qt specific code from css/SelectorChecker.cpp

Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (95607 => 95608)


--- trunk/Source/WebCore/html/HTMLBodyElement.cpp	2011-09-21 10:16:53 UTC (rev 95607)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp	2011-09-21 11:01:43 UTC (rev 95608)
@@ -267,7 +267,7 @@
 static int adjustForZoom(int value, Document* document)
 {
     Frame* frame = document->frame();
-    float zoomFactor = frame->pageZoomFactor() * frame->pageScaleFactor();
+    float zoomFactor = frame->pageZoomFactor() * frame->frameScaleFactor();
     if (zoomFactor == 1)
         return value;
     // Needed because of truncation (rather than rounding) when scaling up.
@@ -295,7 +295,7 @@
     FrameView* view = frame->view();
     if (!view)
         return;
-    view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZoomFactor() * frame->pageScaleFactor()), view->scrollY()));
+    view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZoomFactor() * frame->frameScaleFactor()), view->scrollY()));
 }
 
 int HTMLBodyElement::scrollTop()
@@ -317,7 +317,7 @@
     FrameView* view = frame->view();
     if (!view)
         return;
-    view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor() * frame->pageScaleFactor())));
+    view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor() * frame->frameScaleFactor())));
 }
 
 int HTMLBodyElement::scrollHeight()

Modified: trunk/Source/WebCore/loader/HistoryController.cpp (95607 => 95608)


--- trunk/Source/WebCore/loader/HistoryController.cpp	2011-09-21 10:16:53 UTC (rev 95607)
+++ trunk/Source/WebCore/loader/HistoryController.cpp	2011-09-21 11:01:43 UTC (rev 95608)
@@ -86,7 +86,7 @@
     else
         item->setScrollPoint(m_frame->view()->scrollPosition());
 
-    item->setPageScaleFactor(m_frame->pageScaleFactor());
+    item->setPageScaleFactor(m_frame->frameScaleFactor());
     
     // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
     m_frame->loader()->client()->saveViewStateToItem(item);

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (95607 => 95608)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2011-09-21 10:16:53 UTC (rev 95607)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2011-09-21 11:01:43 UTC (rev 95608)
@@ -1143,7 +1143,7 @@
 
     m_frame->document()->updateLayoutIgnorePendingStylesheets();
 
-    return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
+    return static_cast<int>(view->scrollX() / (m_frame->pageZoomFactor() * m_frame->frameScaleFactor()));
 }
 
 int DOMWindow::scrollY() const
@@ -1157,7 +1157,7 @@
 
     m_frame->document()->updateLayoutIgnorePendingStylesheets();
 
-    return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor());
+    return static_cast<int>(view->scrollY() / (m_frame->pageZoomFactor() * m_frame->frameScaleFactor()));
 }
 
 bool DOMWindow::closed() const
@@ -1384,8 +1384,8 @@
     if (!view)
         return;
 
-    int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor());
-    int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor());
+    int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor() * m_frame->frameScaleFactor());
+    int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor() * m_frame->frameScaleFactor());
     view->setScrollPosition(IntPoint(zoomedX, zoomedY));
 }
 

Modified: trunk/Source/WebCore/page/Frame.cpp (95607 => 95608)


--- trunk/Source/WebCore/page/Frame.cpp	2011-09-21 10:16:53 UTC (rev 95607)
+++ trunk/Source/WebCore/page/Frame.cpp	2011-09-21 11:01:43 UTC (rev 95608)
@@ -1023,10 +1023,12 @@
         page->backForward()->markPagesForFullStyleRecalc();
 }
 
-float Frame::pageScaleFactor() const
+float Frame::frameScaleFactor() const
 {
     Page* page = this->page();
-    if (!page)
+
+    // Main frame is scaled with respect to he container but inner frames are not scaled with respect to the main frame.
+    if (!page || page->mainFrame() != this)
         return 1;
     return page->pageScaleFactor();
 }

Modified: trunk/Source/WebCore/page/Frame.h (95607 => 95608)


--- trunk/Source/WebCore/page/Frame.h	2011-09-21 10:16:53 UTC (rev 95607)
+++ trunk/Source/WebCore/page/Frame.h	2011-09-21 11:01:43 UTC (rev 95608)
@@ -161,8 +161,8 @@
         float textZoomFactor() const { return m_textZoomFactor; }
         void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
 
-        // Convenience helper method that grabs the pageScaleFactor from Page.
-        float pageScaleFactor() const;
+        // Scale factor of this frame with respect to the container.
+        float frameScaleFactor() const;
 
 #if USE(ACCELERATED_COMPOSITING)
         void deviceOrPageScaleFactorChanged();

Modified: trunk/Source/WebCore/page/FrameView.cpp (95607 => 95608)


--- trunk/Source/WebCore/page/FrameView.cpp	2011-09-21 10:16:53 UTC (rev 95607)
+++ trunk/Source/WebCore/page/FrameView.cpp	2011-09-21 11:01:43 UTC (rev 95608)
@@ -525,9 +525,9 @@
     // use the root element.
 
     // To combat the inability to scroll on a page with overflow:hidden on the root when scaled, disregard hidden when
-    // there is a pageScaleFactor that is greater than one on the main frame.
+    // there is a frameScaleFactor that is greater than one on the main frame.
 
-    bool overrideHidden = m_frame->page() && m_frame->page()->mainFrame() == m_frame && m_frame->pageScaleFactor() > 1;
+    bool overrideHidden = m_frame->page() && m_frame->frameScaleFactor() > 1;
 
     switch (o->style()->overflowX()) {
         case OHIDDEN:
@@ -1349,14 +1349,14 @@
     if (!m_frame)
         return x;
 
-    float pageScaleFactor = m_frame->pageScaleFactor();
+    float frameScaleFactor = m_frame->frameScaleFactor();
 
     // When the page is scaled, the scaled "viewport" with respect to which fixed object are positioned
     // doesn't move as fast as the content view, so that when the content is scrolled all the way to the
     // end, the bottom of the scaled "viewport" touches the bottom of the real viewport.
-    float dragFactor = (contentsWidth() - visibleContentWidth * pageScaleFactor) / maxX;
+    float dragFactor = (contentsWidth() - visibleContentWidth * frameScaleFactor) / maxX;
 
-    return x * dragFactor / pageScaleFactor;
+    return x * dragFactor / frameScaleFactor;
 }
 
 LayoutUnit FrameView::scrollYForFixedPosition() const
@@ -1384,10 +1384,10 @@
     if (!m_frame)
         return y;
 
-    float pageScaleFactor = m_frame->pageScaleFactor();
-    float dragFactor = (contentsHeight() - visibleContentHeight * pageScaleFactor) / maxY;
+    float frameScaleFactor = m_frame->frameScaleFactor();
+    float dragFactor = (contentsHeight() - visibleContentHeight * frameScaleFactor) / maxY;
 
-    return y * dragFactor / pageScaleFactor;
+    return y * dragFactor / frameScaleFactor;
 }
 
 LayoutSize FrameView::scrollOffsetForFixedPosition() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to