Implement EventSender.scalePageBy()
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Aug 2011 02:01:31 +0000 (02:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Aug 2011 02:01:31 +0000 (02:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=58013

Patch by Kentaro Hara <haraken@google.com> on 2011-08-03
Reviewed by Darin Fisher.

Implemented EventSender.scalePageBy(f, x, y), which scales a page by a factor of f
and then sets a scroll position to (x, y). Enabled the tests that had been waiting
for the implementation of EventSender.scalePageBy(f, x, y).

Source/WebKit/chromium:

Tests: compositing/scaling/tiled-layer-recursion.html
       fast/repaint/scale-page-shrink.html
       fast/dom/Element/scale-page-client-rects.html
       fast/dom/Range/scale-page-client-rects.html
       fast/events/scroll-in-scaled-page-with-overflow-hidden.html
       fast/dom/Element/scale-page-bounding-client-rect.html
       fast/dom/Range/scale-page-bounding-client-rect.html

* public/WebView.h:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::scalePage): A wrapper method for scalePage() in WebCore.
* src/WebViewImpl.h:

Tools:

Tests: compositing/scaling/tiled-layer-recursion.html
       fast/repaint/scale-page-shrink.html
       fast/dom/Element/scale-page-client-rects.html
       fast/dom/Range/scale-page-client-rects.html
       fast/events/scroll-in-scaled-page-with-overflow-hidden.html
       fast/dom/Element/scale-page-bounding-client-rect.html
       fast/dom/Range/scale-page-bounding-client-rect.html

* DumpRenderTree/chromium/EventSender.cpp:
(EventSender::EventSender): Added bindings for scalePageBy().
(EventSender::scalePageBy): A wrapper method for scalePage() in WebView.
* DumpRenderTree/chromium/EventSender.h:
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::resetTestController): Resets the scale factor to 1.

LayoutTests:

* platform/chromium-linux/compositing/scaling/tiled-layer-recursion-expected.png: Added.
* platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png: Added.
* platform/chromium-linux/fast/repaint/scale-page-shrink-expected.txt: Added.
* platform/chromium-mac/fast/dom/Element/scale-page-bounding-client-rect-expected.txt: Removed.
* platform/chromium-mac/fast/dom/Range/scale-page-bounding-client-rect-expected.txt: Removed.
* platform/chromium-win/fast/dom/Element/scale-page-bounding-client-rect-expected.txt: Removed.
* platform/chromium-win/fast/dom/Element/scale-page-client-rects-expected.txt: Removed.
* platform/chromium-win/fast/dom/Range/scale-page-bounding-client-rect-expected.txt: Removed.
* platform/chromium-win/fast/dom/Range/scale-page-client-rects-expected.txt: Removed.
* platform/chromium/test_expectations.txt: Enabled one test. Enabled two tests for chromium-linux.

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium-linux/compositing/scaling/tiled-layer-recursion-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-mac/fast/dom/Element/scale-page-bounding-client-rect-expected.txt [deleted file]
LayoutTests/platform/chromium-mac/fast/dom/Range/scale-page-bounding-client-rect-expected.txt [deleted file]
LayoutTests/platform/chromium-win/fast/dom/Element/scale-page-bounding-client-rect-expected.txt [deleted file]
LayoutTests/platform/chromium-win/fast/dom/Element/scale-page-client-rects-expected.txt [deleted file]
LayoutTests/platform/chromium-win/fast/dom/Range/scale-page-bounding-client-rect-expected.txt [deleted file]
LayoutTests/platform/chromium-win/fast/dom/Range/scale-page-client-rects-expected.txt [deleted file]
LayoutTests/platform/chromium/test_expectations.txt
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebView.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/EventSender.cpp
Tools/DumpRenderTree/chromium/EventSender.h
Tools/DumpRenderTree/chromium/TestShell.cpp

index bbcc89f0cabcd27e86506404f691ad433dba9f8b..56756cece9bd2106b7caa96ff099bea92397443e 100644 (file)
@@ -1,3 +1,25 @@
+2011-08-03  Kentaro Hara  <haraken@google.com>
+
+        Implement EventSender.scalePageBy()
+        https://bugs.webkit.org/show_bug.cgi?id=58013
+
+        Reviewed by Darin Fisher.
+
+        Implemented EventSender.scalePageBy(f, x, y), which scales a page by a factor of f
+        and then sets a scroll position to (x, y). Enabled the tests that had been waiting
+        for the implementation of EventSender.scalePageBy(f, x, y).
+
+        * platform/chromium-linux/compositing/scaling/tiled-layer-recursion-expected.png: Added.
+        * platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png: Added.
+        * platform/chromium-linux/fast/repaint/scale-page-shrink-expected.txt: Added.
+        * platform/chromium-mac/fast/dom/Element/scale-page-bounding-client-rect-expected.txt: Removed.
+        * platform/chromium-mac/fast/dom/Range/scale-page-bounding-client-rect-expected.txt: Removed.
+        * platform/chromium-win/fast/dom/Element/scale-page-bounding-client-rect-expected.txt: Removed.
+        * platform/chromium-win/fast/dom/Element/scale-page-client-rects-expected.txt: Removed.
+        * platform/chromium-win/fast/dom/Range/scale-page-bounding-client-rect-expected.txt: Removed.
+        * platform/chromium-win/fast/dom/Range/scale-page-client-rects-expected.txt: Removed.
+        * platform/chromium/test_expectations.txt: Enabled one test. Enabled two tests for chromium-linux.
+
 2011-08-03  Ian Henderson  <ianh@apple.com>
 
         Draw rectangular box shadow for elements with border-radius if no corners are visible
diff --git a/LayoutTests/platform/chromium-linux/compositing/scaling/tiled-layer-recursion-expected.png b/LayoutTests/platform/chromium-linux/compositing/scaling/tiled-layer-recursion-expected.png
new file mode 100644 (file)
index 0000000..74bd839
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/compositing/scaling/tiled-layer-recursion-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png b/LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png
new file mode 100644 (file)
index 0000000..cb06a36
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.txt b/LayoutTests/platform/chromium-linux/fast/repaint/scale-page-shrink-expected.txt
new file mode 100644 (file)
index 0000000..d1d4d33
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock (anonymous) at (0,0) size 784x20
+        RenderText {#text} at (0,0) size 686x19
+          text run at (0,0) width 686: "This test must be run in DumpRenderTree as a pixel test. There should not be visual aritfacts after scaling the page."
+      RenderBlock {DIV} at (0,20) size 500x500 [bgcolor=#008000]
diff --git a/LayoutTests/platform/chromium-mac/fast/dom/Element/scale-page-bounding-client-rect-expected.txt b/LayoutTests/platform/chromium-mac/fast/dom/Element/scale-page-bounding-client-rect-expected.txt
deleted file mode 100644 (file)
index 219babb..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-CONSOLE MESSAGE: line 12: Uncaught TypeError: Object [object Object] has no method 'scalePageBy'
-This test must be run via DumpRenderTree.
diff --git a/LayoutTests/platform/chromium-mac/fast/dom/Range/scale-page-bounding-client-rect-expected.txt b/LayoutTests/platform/chromium-mac/fast/dom/Range/scale-page-bounding-client-rect-expected.txt
deleted file mode 100644 (file)
index 206c895..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-CONSOLE MESSAGE: line 14: Uncaught TypeError: Object [object Object] has no method 'scalePageBy'
-This test must be run via DumpRenderTree.
diff --git a/LayoutTests/platform/chromium-win/fast/dom/Element/scale-page-bounding-client-rect-expected.txt b/LayoutTests/platform/chromium-win/fast/dom/Element/scale-page-bounding-client-rect-expected.txt
deleted file mode 100644 (file)
index 219babb..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-CONSOLE MESSAGE: line 12: Uncaught TypeError: Object [object Object] has no method 'scalePageBy'
-This test must be run via DumpRenderTree.
diff --git a/LayoutTests/platform/chromium-win/fast/dom/Element/scale-page-client-rects-expected.txt b/LayoutTests/platform/chromium-win/fast/dom/Element/scale-page-client-rects-expected.txt
deleted file mode 100644 (file)
index 219babb..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-CONSOLE MESSAGE: line 12: Uncaught TypeError: Object [object Object] has no method 'scalePageBy'
-This test must be run via DumpRenderTree.
diff --git a/LayoutTests/platform/chromium-win/fast/dom/Range/scale-page-bounding-client-rect-expected.txt b/LayoutTests/platform/chromium-win/fast/dom/Range/scale-page-bounding-client-rect-expected.txt
deleted file mode 100644 (file)
index 206c895..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-CONSOLE MESSAGE: line 14: Uncaught TypeError: Object [object Object] has no method 'scalePageBy'
-This test must be run via DumpRenderTree.
diff --git a/LayoutTests/platform/chromium-win/fast/dom/Range/scale-page-client-rects-expected.txt b/LayoutTests/platform/chromium-win/fast/dom/Range/scale-page-client-rects-expected.txt
deleted file mode 100644 (file)
index b6c80c2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-CONSOLE MESSAGE: line 15: Uncaught TypeError: Object [object Object] has no method 'scalePageBy'
-This test must be run via DumpRenderTree.
index 117f5504cf7a4bfd911ed912dcd48a3f66db7be9..0465fdbba19b8154c9be716e96c0b07bd2bf962f 100644 (file)
@@ -594,9 +594,9 @@ BUGCR8630 WIN LINUX : fast/text/font-initial.html = FAIL
 BUGCR24197 SKIP : fast/css/disabled-author-styles.html = FAIL
 
 // Needs eventSender.scalePageBy().
-BUGWK58013 : fast/repaint/scale-page-shrink.html = IMAGE+TEXT
-BUGWK58013 : fast/events/scroll-in-scaled-page-with-overflow-hidden.html = TEXT
-BUGWK58013 SKIP : compositing/scaling/tiled-layer-recursion.html = FAIL
+// These failures are going to be removed as a rebase line after the patch for bug 58013 is landed.
+BUGWK58013 WIN MAC : fast/repaint/scale-page-shrink.html = IMAGE+TEXT
+BUGWK58013 WIN MAC : compositing/scaling/tiled-layer-recursion.html = FAIL
 
 // -----------------------------------------------------------------
 // Inspector tests
index 3da53bc05c8d9e6ccdb263662d5bfc7017022794..d168ae9e8350aedb6e0f6e099b43e83f4667a427 100644 (file)
@@ -1,3 +1,27 @@
+2011-08-03  Kentaro Hara  <haraken@google.com>
+
+        Implement EventSender.scalePageBy()
+        https://bugs.webkit.org/show_bug.cgi?id=58013
+
+        Reviewed by Darin Fisher.
+
+        Implemented EventSender.scalePageBy(f, x, y), which scales a page by a factor of f
+        and then sets a scroll position to (x, y). Enabled the tests that had been waiting
+        for the implementation of EventSender.scalePageBy(f, x, y).
+
+        Tests: compositing/scaling/tiled-layer-recursion.html
+               fast/repaint/scale-page-shrink.html
+               fast/dom/Element/scale-page-client-rects.html
+               fast/dom/Range/scale-page-client-rects.html
+               fast/events/scroll-in-scaled-page-with-overflow-hidden.html
+               fast/dom/Element/scale-page-bounding-client-rect.html
+               fast/dom/Range/scale-page-bounding-client-rect.html
+
+        * public/WebView.h:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::scalePage): A wrapper method for scalePage() in WebCore.
+        * src/WebViewImpl.h:
+
 2011-08-03  Darin Fisher  <darin@chromium.org>
 
         [Chromium] Rename WEBKIT_API to WEBKIT_EXPORT.
index 201fd93eb7244e7efcfa80a4e50ed104877fc532..26599ac30199f8e45eaf6b4b3ca5e97cd6c070b8 100644 (file)
@@ -203,6 +203,11 @@ public:
     WEBKIT_EXPORT static double zoomLevelToZoomFactor(double zoomLevel);
     WEBKIT_EXPORT static double zoomFactorToZoomLevel(double factor);
 
+    // Scales a page by a factor of scaleFactor and then sets a scroll position to (x, y).
+    // scalePage() magnifies and shrinks a page without affecting layout.
+    // On the other hand, zooming affects layout of the page.
+    virtual void scalePage(float scaleFactor, WebPoint origin) = 0;
+
 
     // Media ---------------------------------------------------------------
 
index 166d8d441d3a10528cc1d2e67de8c6b6e0068e98..0cebd1329f6d6b052e0d35c4ed302518fa18f59a 100644 (file)
@@ -1841,6 +1841,18 @@ double WebView::zoomFactorToZoomLevel(double factor)
     return log(factor) / log(textSizeMultiplierRatio);
 }
 
+void WebViewImpl::scalePage(float scaleFactor, WebPoint origin)
+{
+    if (!page())
+        return;
+
+    Frame* frame = page()->mainFrame();
+    if (!frame)
+        return;
+
+    frame->scalePage(scaleFactor, origin);
+}
+
 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
                                            const WebPoint& location)
 {
index 448aec7a0862834e1d524eb212db40b51b3e04f1..ae3525f6df990be2b9b1ac4e58dd817a18dc79b4 100644 (file)
@@ -154,6 +154,7 @@ public:
     virtual double setZoomLevel(bool textOnly, double zoomLevel);
     virtual void zoomLimitsChanged(double minimumZoomLevel,
                                    double maximumZoomLevel);
+    virtual void scalePage(float scaleFactor, WebPoint origin);
     virtual void performMediaPlayerAction(
         const WebMediaPlayerAction& action,
         const WebPoint& location);
index 0d080b2a24d8e3582ec2d5d4e00b589040bb097e..c7edf78d65360420abb091706508a68bb74e9412 100644 (file)
@@ -1,3 +1,29 @@
+2011-08-03  Kentaro Hara  <haraken@google.com>
+
+        Implement EventSender.scalePageBy()
+        https://bugs.webkit.org/show_bug.cgi?id=58013
+
+        Reviewed by Darin Fisher.
+
+        Implemented EventSender.scalePageBy(f, x, y), which scales a page by a factor of f
+        and then sets a scroll position to (x, y). Enabled the tests that had been waiting
+        for the implementation of EventSender.scalePageBy(f, x, y).
+
+        Tests: compositing/scaling/tiled-layer-recursion.html
+               fast/repaint/scale-page-shrink.html
+               fast/dom/Element/scale-page-client-rects.html
+               fast/dom/Range/scale-page-client-rects.html
+               fast/events/scroll-in-scaled-page-with-overflow-hidden.html
+               fast/dom/Element/scale-page-bounding-client-rect.html
+               fast/dom/Range/scale-page-bounding-client-rect.html
+
+        * DumpRenderTree/chromium/EventSender.cpp:
+        (EventSender::EventSender): Added bindings for scalePageBy().
+        (EventSender::scalePageBy): A wrapper method for scalePage() in WebView.
+        * DumpRenderTree/chromium/EventSender.h:
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::resetTestController): Resets the scale factor to 1.
+
 2011-08-03  David Levin  <levin@chromium.org>
 
         Rename WEBKIT_API to WEBKIT_EXPORT in check-webkit-style.
index bfee0778289689379f98fc535d974591e7b77198..87fb524256ec77dcdd4e16860500e1dc6d975d32 100644 (file)
@@ -280,6 +280,7 @@ EventSender::EventSender(TestShell* shell)
     bindMethod("updateTouchPoint", &EventSender::updateTouchPoint);
     bindMethod("zoomPageIn", &EventSender::zoomPageIn);
     bindMethod("zoomPageOut", &EventSender::zoomPageOut);
+    bindMethod("scalePageBy", &EventSender::scalePageBy);
 
     // When set to true (the default value), we batch mouse move and mouse up
     // events so we can simulate drag & drop.
@@ -698,6 +699,18 @@ void EventSender::zoomPageOut(const CppArgumentList&, CppVariant* result)
     result->setNull();
 }
 
+void EventSender::scalePageBy(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() < 3 || !arguments[0].isNumber() || !arguments[1].isNumber() || !arguments[2].isNumber())
+        return;
+
+    float scaleFactor = static_cast<float>(arguments[0].toDouble());
+    int x = arguments[1].toInt32();
+    int y = arguments[2].toInt32();
+    webview()->scalePage(scaleFactor, WebPoint(x, y));
+    result->setNull();
+}
+
 void EventSender::mouseScrollBy(const CppArgumentList& arguments, CppVariant* result)
 {
     handleMouseWheel(arguments, result, false);
index 54b065033c68192c377218365539ec4798f91b3b..be62294b1de60ca5b6d030492dfc879f465b5fd0 100644 (file)
@@ -76,6 +76,7 @@ public:
     void textZoomOut(const CppArgumentList&, CppVariant*);
     void zoomPageIn(const CppArgumentList&, CppVariant*);
     void zoomPageOut(const CppArgumentList&, CppVariant*);
+    void scalePageBy(const CppArgumentList&, CppVariant*);
     void mouseScrollBy(const CppArgumentList&, CppVariant*);
     void continuousMouseScrollBy(const CppArgumentList&, CppVariant*);
     void scheduleAsynchronousClick(const CppArgumentList&, CppVariant*);
index 6f0b51ff9e7512789beba0f5917b8ceee7457b2b..f1b8d227013028609fa8fc989889ee1f74e059fd 100644 (file)
@@ -44,6 +44,7 @@
 #include "WebTestingSupport.h"
 #include "WebKit.h"
 #include "WebPermissions.h"
+#include "WebPoint.h"
 #include "WebRuntimeFeatures.h"
 #include "WebScriptController.h"
 #include "WebSettings.h"
@@ -265,6 +266,7 @@ void TestShell::resetTestController()
     m_drtDevToolsAgent->reset();
     if (m_drtDevToolsClient)
         m_drtDevToolsClient->reset();
+    webView()->scalePage(1, WebPoint(0, 0));
     webView()->mainFrame()->clearOpener();
 }