[chromium] Expose settings value to conditionally enable pinch-zoom scaling in the...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Oct 2012 21:22:17 +0000 (21:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Oct 2012 21:22:17 +0000 (21:22 +0000)
flag defaults to disabled, so this change should be a no-op for scaling/scrolling behaviour.
https://bugs.webkit.org/show_bug.cgi?id=93292

Patch by Jeff Timanus <twiz@chromium.org> on 2012-10-03
Reviewed by James Robinson.

Source/Platform:

* chromium/public/WebCompositor.h:
(WebCompositor):
* chromium/public/WebCompositorSupport.h:
(WebKit::WebCompositorSupport::setPageScalePinchZoomEnabled):

Source/WebCore:

Tests:  Existing page-scale layout tests.

* page/Frame.cpp:
(WebCore::Frame::frameScaleFactor):
* page/Settings.cpp:
(WebCore::Settings::Settings):
* page/Settings.h:
(WebCore::Settings::setApplyPageScaleFactorInCompositor):
(WebCore::Settings::applyPageScaleFactorInCompositor):
(Settings):

Source/WebKit/chromium:

* public/WebSettings.h:
* src/NonCompositedContentHost.cpp:
(WebKit::NonCompositedContentHost::NonCompositedContentHost):
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setApplyPageScaleFactorInCompositor):
(WebKit):
(WebKit::WebSettingsImpl::applyPageScaleFactorInCompositor):
* src/WebSettingsImpl.h:
(WebSettingsImpl):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setPageScaleFactor):
(WebKit::WebViewImpl::applyScrollAndScale):

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

13 files changed:
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebCompositor.h
Source/Platform/chromium/public/WebCompositorSupport.h
Source/WebCore/ChangeLog
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebSettings.h
Source/WebKit/chromium/src/NonCompositedContentHost.cpp
Source/WebKit/chromium/src/WebSettingsImpl.cpp
Source/WebKit/chromium/src/WebSettingsImpl.h
Source/WebKit/chromium/src/WebViewImpl.cpp

index 8ad8619..ea7c900 100644 (file)
@@ -1,3 +1,16 @@
+2012-10-03  Jeff Timanus  <twiz@chromium.org>
+
+        [chromium] Expose settings value to conditionally enable pinch-zoom scaling in the Chromium compositor.  The
+        flag defaults to disabled, so this change should be a no-op for scaling/scrolling behaviour.
+        https://bugs.webkit.org/show_bug.cgi?id=93292
+
+        Reviewed by James Robinson.
+
+        * chromium/public/WebCompositor.h:
+        (WebCompositor):
+        * chromium/public/WebCompositorSupport.h:
+        (WebKit::WebCompositorSupport::setPageScalePinchZoomEnabled):
+
 2012-10-03  Harald Alvestrand  <hta@google.com>
 
         Add data passing to the GetStats interface of RTCPeerConnection
index 6a8a13e..32bf416 100644 (file)
@@ -55,6 +55,7 @@ public:
     WEBKIT_EXPORT static void setPerTilePaintingEnabled(bool);
     WEBKIT_EXPORT static void setPartialSwapEnabled(bool);
     WEBKIT_EXPORT static void setAcceleratedAnimationEnabled(bool);
+    WEBKIT_EXPORT static void setPageScalePinchZoomEnabled(bool);
 
 protected:
     virtual ~WebCompositor() { }
index d1439a7..1e4c6e2 100644 (file)
@@ -71,6 +71,7 @@ public:
     virtual void setPerTilePaintingEnabled(bool) { }
     virtual void setPartialSwapEnabled(bool) { }
     virtual void setAcceleratedAnimationEnabled(bool) { }
+    virtual void setPageScalePinchZoomEnabled(bool) { }
 
     // May return 0 if initialization fails.
     virtual WebLayerTreeView* createLayerTreeView(WebLayerTreeViewClient*, const WebLayer& root, const WebLayerTreeView::Settings&) { return 0; }
index edcf59d..b2feab7 100644 (file)
@@ -1,3 +1,22 @@
+2012-10-03  Jeff Timanus  <twiz@chromium.org>
+
+        [chromium] Expose settings value to conditionally enable pinch-zoom scaling in the Chromium compositor.  The
+        flag defaults to disabled, so this change should be a no-op for scaling/scrolling behaviour.
+        https://bugs.webkit.org/show_bug.cgi?id=93292
+
+        Reviewed by James Robinson.
+
+        Tests:  Existing page-scale layout tests.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::frameScaleFactor):
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        * page/Settings.h:
+        (WebCore::Settings::setApplyPageScaleFactorInCompositor):
+        (WebCore::Settings::applyPageScaleFactorInCompositor):
+        (Settings):
+
 2012-10-03  Stephen Chenney  <schenney@chromium.org>
 
         Font data is purged while fonts are still using it
index 3fab620..a229226 100644 (file)
@@ -956,8 +956,9 @@ float Frame::frameScaleFactor() const
     Page* page = this->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)
+    if (!page || page->mainFrame() != this || page->settings()->applyPageScaleFactorInCompositor())
         return 1;
+
     return page->pageScaleFactor();
 }
 
index 30666c5..782958f 100644 (file)
@@ -293,6 +293,7 @@ Settings::Settings(Page* page)
     , m_windowFocusRestricted(true)
     , m_diagnosticLoggingEnabled(false)
     , m_scrollingPerformanceLoggingEnabled(false)
+    , m_applyPageScaleFactorInCompositor(false)
     , m_setImageLoadingSettingsTimer(this, &Settings::imageLoadingSettingsTimerFired)
     , m_incrementalRenderingSuppressionTimeoutInSeconds(defaultIncrementalRenderingSuppressionTimeoutInSeconds)
 {
index c18dfd7..bd91827 100644 (file)
@@ -633,6 +633,9 @@ namespace WebCore {
         void setDiagnosticLoggingEnabled(bool enabled) { m_diagnosticLoggingEnabled = enabled; }
         bool diagnosticLoggingEnabled() const { return m_diagnosticLoggingEnabled; }
 
+        void setApplyPageScaleFactorInCompositor(bool enabled) { m_applyPageScaleFactorInCompositor = enabled; }
+        bool applyPageScaleFactorInCompositor() const { return m_applyPageScaleFactorInCompositor; }
+
     private:
         explicit Settings(Page*);
 
@@ -818,9 +821,11 @@ namespace WebCore {
 
         bool m_scrollingPerformanceLoggingEnabled : 1;
 
+        bool m_applyPageScaleFactorInCompositor : 1;
+
         Timer<Settings> m_setImageLoadingSettingsTimer;
         void imageLoadingSettingsTimerFired(Timer<Settings>*);
-        
+
         double m_incrementalRenderingSuppressionTimeoutInSeconds;
 
 #if USE(AVFOUNDATION)
index fd40d77..f2af7b1 100644 (file)
@@ -1,3 +1,24 @@
+2012-10-03  Jeff Timanus  <twiz@chromium.org>
+
+        [chromium] Expose settings value to conditionally enable pinch-zoom scaling in the Chromium compositor.  The
+        flag defaults to disabled, so this change should be a no-op for scaling/scrolling behaviour.
+        https://bugs.webkit.org/show_bug.cgi?id=93292
+
+        Reviewed by James Robinson.
+
+        * public/WebSettings.h:
+        * src/NonCompositedContentHost.cpp:
+        (WebKit::NonCompositedContentHost::NonCompositedContentHost):
+        * src/WebSettingsImpl.cpp:
+        (WebKit::WebSettingsImpl::setApplyPageScaleFactorInCompositor):
+        (WebKit):
+        (WebKit::WebSettingsImpl::applyPageScaleFactorInCompositor):
+        * src/WebSettingsImpl.h:
+        (WebSettingsImpl):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::setPageScaleFactor):
+        (WebKit::WebViewImpl::applyScrollAndScale):
+
 2012-10-03  Hans Wennborg  <hans@chromium.org>
 
         Speech JavaScript API: Add SpeechRecognition.interimResults attribute
index 5ff206b..e816e11 100644 (file)
@@ -72,6 +72,7 @@ public:
     virtual void setAllowScriptsToCloseWindows(bool) = 0;
     virtual void setAllowUniversalAccessFromFileURLs(bool) = 0;
     virtual void setApplyDefaultDeviceScaleFactorInCompositor(bool) = 0;
+    virtual void setApplyPageScaleFactorInCompositor(bool) = 0;
     virtual void setAsynchronousSpellCheckingEnabled(bool) = 0;
     virtual void setAuthorAndUserStylesEnabled(bool) = 0;
     virtual void setCaretBrowsingEnabled(bool) = 0;
index d232398..f1b9c68 100644 (file)
@@ -32,6 +32,7 @@
 #include "GraphicsLayer.h"
 #include "GraphicsLayerChromium.h"
 #include "PlatformContextSkia.h"
+#include "Settings.h"
 #include "WebViewImpl.h"
 #include <public/WebContentLayer.h>
 #include <public/WebFloatPoint.h>
@@ -48,7 +49,7 @@ NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView)
     m_graphicsLayer->setName("non-composited content");
 #endif
     m_graphicsLayer->setDrawsContent(true);
-    m_graphicsLayer->setAppliesPageScale(true);
+    m_graphicsLayer->setAppliesPageScale(!m_webView->page()->settings()->applyPageScaleFactorInCompositor());
     WebContentLayer* layer = static_cast<WebCore::GraphicsLayerChromium*>(m_graphicsLayer.get())->contentLayer();
     layer->setUseLCDText(true);
     layer->layer()->setOpaque(true);
index 4cc3ef7..16bc431 100644 (file)
@@ -140,6 +140,11 @@ void WebSettingsImpl::setApplyDefaultDeviceScaleFactorInCompositor(bool applyDef
     m_applyDefaultDeviceScaleFactorInCompositor = applyDefaultDeviceScaleFactorInCompositor;
 }
 
+void WebSettingsImpl::setApplyPageScaleFactorInCompositor(bool applyPageScaleFactorInCompositor)
+{
+    m_settings->setApplyPageScaleFactorInCompositor(applyPageScaleFactorInCompositor);
+}
+
 void WebSettingsImpl::setTextAutosizingEnabled(bool enabled)
 {
 #if ENABLE(TEXT_AUTOSIZING)
@@ -653,4 +658,9 @@ void WebSettingsImpl::setGestureTapHighlightEnabled(bool enableHighlight)
     m_gestureTapHighlightEnabled = enableHighlight;
 }
 
+bool WebSettingsImpl::applyPageScaleFactorInCompositor() const
+{
+    return m_settings->applyPageScaleFactorInCompositor();
+}
+
 } // namespace WebKit
index e9e01bf..786ff97 100644 (file)
@@ -64,6 +64,7 @@ public:
     virtual void setAllowScriptsToCloseWindows(bool);
     virtual void setAllowUniversalAccessFromFileURLs(bool);
     virtual void setApplyDefaultDeviceScaleFactorInCompositor(bool);
+    virtual void setApplyPageScaleFactorInCompositor(bool);
     virtual void setAsynchronousSpellCheckingEnabled(bool);
     virtual void setAuthorAndUserStylesEnabled(bool);
     virtual void setCaretBrowsingEnabled(bool);
@@ -160,6 +161,7 @@ public:
     bool showPaintRects() const { return m_showPaintRects; }
     bool renderVSyncEnabled() const { return m_renderVSyncEnabled; }
     bool applyDefaultDeviceScaleFactorInCompositor() const { return m_applyDefaultDeviceScaleFactorInCompositor; }
+    bool applyPageScaleFactorInCompositor() const;
     bool gestureTapHighlightEnabled() { return m_gestureTapHighlightEnabled; }
     WebSize defaultTileSize() const { return m_defaultTileSize; }
     WebSize maxUntiledLayerSize() const { return m_maxUntiledLayerSize; }
index 316b165..9b13a96 100644 (file)
@@ -2749,8 +2749,20 @@ void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin)
     }
 
     scaleFactor = clampPageScaleFactorToLimits(scaleFactor);
-    WebPoint clampedOrigin = clampOffsetAtScale(origin, scaleFactor);
-    page()->setPageScaleFactor(scaleFactor, clampedOrigin);
+    WebPoint scrollOffset;
+    if (!m_page->settings()->applyPageScaleFactorInCompositor()) {
+        // If page scale is not applied in the compositor, then the scroll offsets should
+        // be modified by the scale factor.
+        scrollOffset = clampOffsetAtScale(origin, scaleFactor);
+    } else {
+        IntPoint offset = origin;
+        WebSize contentSize = mainFrame()->contentsSize();
+        offset.shrunkTo(IntPoint(contentSize.width - m_size.width, contentSize.height - m_size.height));
+        offset.clampNegativeToZero();
+        scrollOffset = offset;
+    }
+
+    page()->setPageScaleFactor(scaleFactor, scrollOffset);
     m_pageScaleFactorIsSet = true;
 }
 
@@ -3919,15 +3931,21 @@ void WebViewImpl::applyScrollAndScale(const WebSize& scrollDelta, float pageScal
         mainFrameImpl()->frameView()->scrollBy(scrollDelta);
     } else {
         // The page scale changed, so apply a scale and scroll in a single
-        // operation. The old scroll offset (and passed-in delta) are
-        // in the old coordinate space, so we first need to multiply them
-        // by the page scale delta.
+        // operation.
         WebSize scrollOffset = mainFrame()->scrollOffset();
         scrollOffset.width += scrollDelta.width;
         scrollOffset.height += scrollDelta.height;
-        WebPoint scaledScrollOffset(scrollOffset.width * pageScaleDelta,
-                                    scrollOffset.height * pageScaleDelta);
-        setPageScaleFactor(pageScaleFactor() * pageScaleDelta, scaledScrollOffset);
+
+        WebPoint scrollPoint(scrollOffset.width, scrollOffset.height);
+        if (!m_page->settings()->applyPageScaleFactorInCompositor()) {
+            // The old scroll offset (and passed-in delta) are in the old
+            // coordinate space, so we first need to multiply them by the page
+            // scale delta.
+            scrollPoint.x = scrollPoint.x * pageScaleDelta;
+            scrollPoint.y = scrollPoint.y * pageScaleDelta;
+        }
+
+        setPageScaleFactor(pageScaleFactor() * pageScaleDelta, scrollPoint);
         m_doubleTapZoomInEffect = false;
     }
 }