Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=68081
authorhclam@chromium.org <hclam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Sep 2011 13:30:59 +0000 (13:30 +0000)
committerhclam@chromium.org <hclam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Sep 2011 13:30:59 +0000 (13:30 +0000)
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):

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

Reviewed by Simon Fraser.

* WebProcess/Plugins/PluginView.cpp: Rename pageScaleFactor to frameScaleFactor.
(WebKit::PluginView::handleEvent):
(WebKit::PluginView::viewGeometryDidChange):
(WebKit::PluginView::clipRectInWindowCoordinates):

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.

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/scale-and-scroll-body-expected.png [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-body-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-body.html [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.png [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-iframe-body.html [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.png [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-iframe-window.html [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-window-expected.png [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-window-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/scale-and-scroll-window.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/html/HTMLBodyElement.cpp
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/FrameView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PluginView.cpp

index 596edc0..dbc6d7e 100644 (file)
@@ -1,3 +1,29 @@
+2011-09-22  Alpha Lam  <hclam@chromium.org>
+
+        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-22  Andreas Kling  <kling@webkit.org>
 
         CSS: Implement 'font' property in CSSComputedStyle.
diff --git a/LayoutTests/fast/events/scale-and-scroll-body-expected.png b/LayoutTests/fast/events/scale-and-scroll-body-expected.png
new file mode 100644 (file)
index 0000000..bb44032
Binary files /dev/null and b/LayoutTests/fast/events/scale-and-scroll-body-expected.png differ
diff --git a/LayoutTests/fast/events/scale-and-scroll-body-expected.txt b/LayoutTests/fast/events/scale-and-scroll-body-expected.txt
new file mode 100644 (file)
index 0000000..c1b847d
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/fast/events/scale-and-scroll-body.html b/LayoutTests/fast/events/scale-and-scroll-body.html
new file mode 100644 (file)
index 0000000..7a87ef4
--- /dev/null
@@ -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="../js/resources/js-test-pre.js"></script>
+</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>
diff --git a/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.png b/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.png
new file mode 100644 (file)
index 0000000..cbce315
Binary files /dev/null and b/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.png differ
diff --git a/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.txt b/LayoutTests/fast/events/scale-and-scroll-iframe-body-expected.txt
new file mode 100644 (file)
index 0000000..a1d8687
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/fast/events/scale-and-scroll-iframe-body.html b/LayoutTests/fast/events/scale-and-scroll-iframe-body.html
new file mode 100644 (file)
index 0000000..0a518c7
--- /dev/null
@@ -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="../js/resources/js-test-pre.js"></script>
+</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>
diff --git a/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.png b/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.png
new file mode 100644 (file)
index 0000000..cbce315
Binary files /dev/null and b/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.png differ
diff --git a/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.txt b/LayoutTests/fast/events/scale-and-scroll-iframe-window-expected.txt
new file mode 100644 (file)
index 0000000..8ea572e
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/fast/events/scale-and-scroll-iframe-window.html b/LayoutTests/fast/events/scale-and-scroll-iframe-window.html
new file mode 100644 (file)
index 0000000..41ceac7
--- /dev/null
@@ -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="../js/resources/js-test-pre.js"></script>
+</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>
diff --git a/LayoutTests/fast/events/scale-and-scroll-window-expected.png b/LayoutTests/fast/events/scale-and-scroll-window-expected.png
new file mode 100644 (file)
index 0000000..bb44032
Binary files /dev/null and b/LayoutTests/fast/events/scale-and-scroll-window-expected.png differ
diff --git a/LayoutTests/fast/events/scale-and-scroll-window-expected.txt b/LayoutTests/fast/events/scale-and-scroll-window-expected.txt
new file mode 100644 (file)
index 0000000..c1b847d
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/fast/events/scale-and-scroll-window.html b/LayoutTests/fast/events/scale-and-scroll-window.html
new file mode 100644 (file)
index 0000000..c555115
--- /dev/null
@@ -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="../js/resources/js-test-pre.js"></script>
+</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>
index 655e608..8da03e2 100644 (file)
@@ -1,3 +1,43 @@
+2011-09-22  Alpha Lam  <hclam@chromium.org>
+
+        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-22  Andreas Kling  <kling@webkit.org>
 
         CSS: Implement 'font' property in CSSComputedStyle.
index e42877f..d5bc623 100644 (file)
@@ -746,7 +746,7 @@ __ZN7WebCore5Frame17setPageZoomFactorEf
 __ZN7WebCore5Frame17setTextZoomFactorEf
 __ZN7WebCore5Frame23visiblePositionForPointERKNS_8IntPointE
 __ZN7WebCore5Frame25matchLabelsAgainstElementEP7NSArrayPNS_7ElementE
-__ZNK7WebCore5Frame15pageScaleFactorEv
+__ZNK7WebCore5Frame15frameScaleFactorEv
 __ZN7WebCore5Frame25setPageAndTextZoomFactorsEff
 __ZN7WebCore5Frame27resizePageRectsKeepingRatioERKNS_9FloatSizeES3_
 __ZN7WebCore5Frame28searchForLabelsBeforeElementEP7NSArrayPNS_7ElementEPmPb
index 038c56a..df3fcd8 100644 (file)
@@ -267,7 +267,7 @@ void HTMLBodyElement::setVLink(const String& value)
 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 @@ void HTMLBodyElement::setScrollLeft(int scrollLeft)
     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 @@ void HTMLBodyElement::setScrollTop(int scrollTop)
     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()
index 3c34e1c..3bbbfc3 100644 (file)
@@ -86,7 +86,7 @@ void HistoryController::saveScrollPositionAndViewStateToItem(HistoryItem* item)
     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);
index 2841fe7..47cb368 100644 (file)
@@ -1143,7 +1143,7 @@ int DOMWindow::scrollX() const
 
     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 @@ int DOMWindow::scrollY() const
 
     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 @@ void DOMWindow::scrollTo(int x, int y) const
     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));
 }
 
index f6dc740..7dce439 100644 (file)
@@ -1023,10 +1023,12 @@ void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor
         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();
 }
index bf24c36..6a62bd7 100644 (file)
@@ -161,8 +161,8 @@ namespace WebCore {
         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();
index f21277b..f38040b 100644 (file)
@@ -525,9 +525,9 @@ void FrameView::applyOverflowToViewport(RenderObject* o, ScrollbarMode& hMode, S
     // 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->page()->mainFrame() == m_frame && m_frame->frameScaleFactor() > 1;
 
     switch (o->style()->overflowX()) {
         case OHIDDEN:
@@ -1349,14 +1349,14 @@ LayoutUnit FrameView::scrollXForFixedPosition() const
     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 @@ LayoutUnit FrameView::scrollYForFixedPosition() const
     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
index 1b9e3d9..667877c 100644 (file)
@@ -1,3 +1,15 @@
+2011-09-22  Alpha Lam  <hclam@chromium.org>
+
+        https://bugs.webkit.org/show_bug.cgi?id=68081
+        Fix scroll in page scaling mode.
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/Plugins/PluginView.cpp: Rename pageScaleFactor to frameScaleFactor.
+        (WebKit::PluginView::handleEvent):
+        (WebKit::PluginView::viewGeometryDidChange):
+        (WebKit::PluginView::clipRectInWindowCoordinates):
+
 2011-09-22  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt] Redirection overflow errors have wrong error domain
index 9576fd2..8bd7494 100644 (file)
@@ -582,8 +582,8 @@ void PluginView::handleEvent(Event* event)
         if (currentEvent->type() == WebEvent::MouseDown)
             focusPluginElement();
         
-        // Adjust mouse coordinates to account for pageScaleFactor
-        WebMouseEvent eventWithScaledCoordinates(*static_cast<const WebMouseEvent*>(currentEvent), frame()->pageScaleFactor());
+        // Adjust mouse coordinates to account for frameScaleFactor
+        WebMouseEvent eventWithScaledCoordinates(*static_cast<const WebMouseEvent*>(currentEvent), frame()->frameScaleFactor());
         didHandleEvent = m_plugin->handleMouseEvent(eventWithScaledCoordinates);
     } else if (event->type() == eventNames().mousewheelEvent && currentEvent->type() == WebEvent::Wheel) {
         // We have a wheel event.
@@ -649,8 +649,8 @@ void PluginView::viewGeometryDidChange()
     // Get the frame rect in window coordinates.
     IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
     
-    // Adjust bounds to account for pageScaleFactor
-    frameRectInWindowCoordinates.scale(1 / frame()->pageScaleFactor());
+    // Adjust bounds to account for frameScaleFactor
+    frameRectInWindowCoordinates.scale(1 / frame()->frameScaleFactor());
     m_plugin->geometryDidChange(frameRectInWindowCoordinates, clipRectInWindowCoordinates());
 }
 
@@ -676,7 +676,7 @@ IntRect PluginView::clipRectInWindowCoordinates() const
     // Intersect the two rects to get the view clip rect in window coordinates.
     frameRectInWindowCoordinates.intersect(windowClipRect);
 
-    frameRectInWindowCoordinates.scale(1 / frame->pageScaleFactor());
+    frameRectInWindowCoordinates.scale(1 / frame->frameScaleFactor());
     return frameRectInWindowCoordinates;
 }