[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jam at chromium.org jam at chromium.org
Wed Dec 22 14:00:00 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 64478e71bff2899815f08ba95ea21e2310b3a2d2
Author: jam at chromium.org <jam at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 1 07:32:27 2010 +0000

    2010-09-29  John Abd-El-Malek  <jam at chromium.org>
    
            Reviewed by NOBODY (OOPS!).
    
            [chromium] Changes to consolidate plugin zoom
            https://bugs.webkit.org/show_bug.cgi?id=46550
    
            * public/WebPlugin.h:
            (WebKit::WebPlugin::setZoomLevel):
            * public/WebPluginContainer.h:
            * public/WebView.h:
            * public/WebViewClient.h:
            (WebKit::WebViewClient::zoomLimitsChanged):
            (WebKit::WebViewClient::zoomLevelChanged):
            * src/FrameLoaderClientImpl.cpp:
            (WebKit::FrameLoaderClientImpl::createPlugin):
            * src/WebPluginContainerImpl.cpp:
            (WebKit::WebPluginContainerImpl::loadFrameRequest):
            (WebKit::WebPluginContainerImpl::zoomChanged):
            (WebKit::WebPluginContainerImpl::zoomLimitsChanged):
            * src/WebPluginContainerImpl.h:
            * src/WebViewImpl.cpp:
            (WebKit::WebViewImpl::WebViewImpl):
            (WebKit::WebViewImpl::zoomLevel):
            (WebKit::WebViewImpl::setZoomLevel):
            (WebKit::WebViewImpl::zoomLimitsChanged):
            (WebKit::WebViewImpl::fullFramePluginZoomLevelChanged):
            (WebKit::WebView::zoomLevelToZoomFactor):
            (WebKit::WebView::zoomFactorToZoomLevel):
            * src/WebViewImpl.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68869 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 7e222c9..611eec6 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,34 @@
+2010-09-29  John Abd-El-Malek  <jam at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        [chromium] Changes to consolidate plugin zoom
+        https://bugs.webkit.org/show_bug.cgi?id=46550
+
+        * public/WebPlugin.h:
+        (WebKit::WebPlugin::setZoomLevel):
+        * public/WebPluginContainer.h:
+        * public/WebView.h:
+        * public/WebViewClient.h:
+        (WebKit::WebViewClient::zoomLimitsChanged):
+        (WebKit::WebViewClient::zoomLevelChanged):
+        * src/FrameLoaderClientImpl.cpp:
+        (WebKit::FrameLoaderClientImpl::createPlugin):
+        * src/WebPluginContainerImpl.cpp:
+        (WebKit::WebPluginContainerImpl::loadFrameRequest):
+        (WebKit::WebPluginContainerImpl::zoomChanged):
+        (WebKit::WebPluginContainerImpl::zoomLimitsChanged):
+        * src/WebPluginContainerImpl.h:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::WebViewImpl):
+        (WebKit::WebViewImpl::zoomLevel):
+        (WebKit::WebViewImpl::setZoomLevel):
+        (WebKit::WebViewImpl::zoomLimitsChanged):
+        (WebKit::WebViewImpl::fullFramePluginZoomLevelChanged):
+        (WebKit::WebView::zoomLevelToZoomFactor):
+        (WebKit::WebView::zoomFactorToZoomLevel):
+        * src/WebViewImpl.h:
+
 2010-09-30  MORITA Hajime  <morrita at google.com>
 
         Reviewed by James Robinson.
diff --git a/WebKit/chromium/public/WebPlugin.h b/WebKit/chromium/public/WebPlugin.h
index 816d38b..b9f0e11 100644
--- a/WebKit/chromium/public/WebPlugin.h
+++ b/WebKit/chromium/public/WebPlugin.h
@@ -99,7 +99,7 @@ public:
     virtual WebString selectionAsMarkup() const { return WebString(); }
 
     // Used for zooming of full page plugins.
-    virtual void setZoomFactor(float scale, bool textOnly) { }
+    virtual void setZoomLevel(double level, bool textOnly) { }
 
     // Find interface.
     // Start a new search.  The plugin should search for a little bit at a time so that it
diff --git a/WebKit/chromium/public/WebPluginContainer.h b/WebKit/chromium/public/WebPluginContainer.h
index 66ef9ab..af20c66 100644
--- a/WebKit/chromium/public/WebPluginContainer.h
+++ b/WebKit/chromium/public/WebPluginContainer.h
@@ -78,6 +78,9 @@ public:
     virtual void loadFrameRequest(
         const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData) = 0;
 
+    // Notifies that the zoom level has changed.
+    virtual void zoomLevelChanged(double zoomLevel) = 0;
+
     virtual WebPlugin* plugin() = 0;
     virtual void setPlugin(WebPlugin*) = 0;
 
diff --git a/WebKit/chromium/public/WebView.h b/WebKit/chromium/public/WebView.h
index 7a8a4af..c3192e9 100644
--- a/WebKit/chromium/public/WebView.h
+++ b/WebKit/chromium/public/WebView.h
@@ -36,6 +36,9 @@
 #include "WebVector.h"
 #include "WebWidget.h"
 
+// FIXME(jam): take this out after Chrome is updated
+#define ZOOM_LEVEL_IS_DOUBLE
+
 namespace WebKit {
 
 class WebAccessibilityObject;
@@ -54,6 +57,10 @@ struct WebPoint;
 
 class WebView : public WebWidget {
 public:
+    WEBKIT_API static const double textSizeMultiplierRatio;
+    WEBKIT_API static const double minTextSizeMultiplier;
+    WEBKIT_API static const double maxTextSizeMultiplier;
+
     // Controls the time that user scripts injected into the document run.
     enum UserScriptInjectAt {
         UserScriptInjectAtDocumentStart,
@@ -161,9 +168,11 @@ public:
     // Zoom ----------------------------------------------------------------
 
     // Returns the current zoom level.  0 is "original size", and each increment
-    // above or below represents zooming 20% larger or smaller to limits of 300%
-    // and 50% of original size, respectively.
-    virtual int zoomLevel() = 0;
+    // above or below represents zooming 20% larger or smaller to default limits
+    // of 300% and 50% of original size, respectively.  Only plugins use
+    // non whole-numbers, since they might choose to have specific zoom level so
+    // that fixed-width content is fit-to-page-width, for example.
+    virtual double zoomLevel() = 0;
 
     // Changes the zoom level to the specified level, clamping at the limits
     // noted above, and returns the current zoom level after applying the
@@ -173,7 +182,16 @@ public:
     // page will be zoomed. You can only have either text zoom or full page zoom
     // at one time.  Changing the mode while the page is zoomed will have odd
     // effects.
-    virtual int setZoomLevel(bool textOnly, int zoomLevel) = 0;
+    virtual double setZoomLevel(bool textOnly, double zoomLevel) = 0;
+
+    // Updates the zoom limits for this view.
+    virtual void zoomLimitsChanged(double minimumZoomLevel,
+                                   double maximumZoomLevel) = 0;
+
+    // Helper functions to convert between zoom level and zoom factor.  zoom
+    // factor is zoom percent / 100, so 300% = 3.0.
+    WEBKIT_API static double zoomLevelToZoomFactor(double zoomLevel);
+    WEBKIT_API static double zoomFactorToZoomLevel(double factor);
 
 
     // Media ---------------------------------------------------------------
diff --git a/WebKit/chromium/public/WebViewClient.h b/WebKit/chromium/public/WebViewClient.h
index 3b0e47a..b821e38 100644
--- a/WebKit/chromium/public/WebViewClient.h
+++ b/WebKit/chromium/public/WebViewClient.h
@@ -348,6 +348,17 @@ public:
     // Access the embedder API for device orientation services.
     virtual WebDeviceOrientationClient* deviceOrientationClient() { return 0; }
 
+
+    // Zoom ----------------------------------------------------------------
+
+    // Informs the browser that the zoom levels for this frame have changed from
+    // the default values.
+    virtual void zoomLimitsChanged(double minimumLevel, double maximumLevel) { }
+
+    // Informs the browser that the zoom level has changed as a result of an
+    // action that wasn't initiated by the client.
+    virtual void zoomLevelChanged() { }
+
 protected:
     ~WebViewClient() { }
 };
diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/WebKit/chromium/src/FrameLoaderClientImpl.cpp
index ba9c8fd..fb798f6 100644
--- a/WebKit/chromium/src/FrameLoaderClientImpl.cpp
+++ b/WebKit/chromium/src/FrameLoaderClientImpl.cpp
@@ -1411,14 +1411,6 @@ PassRefPtr<Widget> FrameLoaderClientImpl::createPlugin(
     if (!webPlugin->initialize(container.get()))
         return 0;
 
-    bool zoomTextOnly = m_webFrame->viewImpl()->zoomTextOnly();
-    float zoomFactor = zoomTextOnly ? m_webFrame->frame()->textZoomFactor() : m_webFrame->frame()->pageZoomFactor();
-    if (zoomFactor != 1) {
-        // There's a saved zoom level, so tell the plugin about it since
-        // WebViewImpl::setZoomLevel was called before the plugin was created.
-        webPlugin->setZoomFactor(zoomFactor, zoomTextOnly);
-    }
-
     // The element might have been removed during plugin initialization!
     if (!element->renderer())
         return 0;
diff --git a/WebKit/chromium/src/WebPluginContainerImpl.cpp b/WebKit/chromium/src/WebPluginContainerImpl.cpp
index 8d3db90..1458a4a 100644
--- a/WebKit/chromium/src/WebPluginContainerImpl.cpp
+++ b/WebKit/chromium/src/WebPluginContainerImpl.cpp
@@ -48,6 +48,7 @@
 #include "WebURLError.h"
 #include "WebURLRequest.h"
 #include "WebVector.h"
+#include "WebViewImpl.h"
 #include "WrappedResourceResponse.h"
 
 #include "EventNames.h"
@@ -348,6 +349,12 @@ void WebPluginContainerImpl::loadFrameRequest(
         SendReferrer);
 }
 
+void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel)
+{
+    WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->page());
+    view->fullFramePluginZoomLevelChanged(zoomLevel);
+}
+
 void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response)
 {
     // Make sure that the plugin receives window geometry before data, or else
diff --git a/WebKit/chromium/src/WebPluginContainerImpl.h b/WebKit/chromium/src/WebPluginContainerImpl.h
index 2a46e00..cf8eb36 100644
--- a/WebKit/chromium/src/WebPluginContainerImpl.h
+++ b/WebKit/chromium/src/WebPluginContainerImpl.h
@@ -83,6 +83,7 @@ public:
     virtual NPObject* scriptableObjectForElement();
     virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed);
     virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData);
+    virtual void zoomLevelChanged(double zoomLevel);
 
     // This cannot be null.
     WebPlugin* plugin() { return m_webPlugin; }
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index fd7dd3a..4083806 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -146,9 +146,10 @@ namespace WebKit {
 // zooms text in or out (ie., change by 20%).  The min and max values limit
 // text zoom to half and 3x the original text size.  These three values match
 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm
-static const double textSizeMultiplierRatio = 1.2;
-static const double minTextSizeMultiplier = 0.5;
-static const double maxTextSizeMultiplier = 3.0;
+const double WebView::textSizeMultiplierRatio = 1.2;
+const double WebView::minTextSizeMultiplier = 0.5;
+const double WebView::maxTextSizeMultiplier = 3.0;
+
 
 // The group name identifies a namespace of pages.  Page group is used on OSX
 // for some programs that use HTML views to display things that don't seem like
@@ -253,7 +254,8 @@ WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devTools
     , m_newNavigationLoader(0)
 #endif
     , m_zoomLevel(0)
-    , m_zoomTextOnly(false)
+    , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier))
+    , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier))
     , m_contextMenuAllowed(false)
     , m_doingDragAndDrop(false)
     , m_ignoreInputEvents(false)
@@ -1527,36 +1529,60 @@ void WebViewImpl::clearFocusedNode()
     }
 }
 
-int WebViewImpl::zoomLevel()
+double WebViewImpl::zoomLevel()
 {
     return m_zoomLevel;
 }
 
-int WebViewImpl::setZoomLevel(bool textOnly, int zoomLevel)
+double WebViewImpl::setZoomLevel(bool textOnly, double zoomLevel)
 {
-    float zoomFactor = static_cast<float>(
-        std::max(std::min(std::pow(textSizeMultiplierRatio, zoomLevel),
-                          maxTextSizeMultiplier),
-                 minTextSizeMultiplier));
+    if (zoomLevel < m_minimumZoomLevel)
+        m_zoomLevel = m_minimumZoomLevel;
+    else if (zoomLevel > m_maximumZoomLevel)
+        m_zoomLevel = m_maximumZoomLevel;
+    else
+        m_zoomLevel = zoomLevel;
+
     Frame* frame = mainFrameImpl()->frame();
+    WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame);
+    if (pluginContainer)
+        pluginContainer->plugin()->setZoomLevel(m_zoomLevel, textOnly);
+    else {
+        double zoomFactor = zoomLevelToZoomFactor(m_zoomLevel);
+        if (textOnly)
+            frame->setPageAndTextZoomFactors(1, zoomFactor);
+        else
+            frame->setPageAndTextZoomFactors(zoomFactor, 1);
+    }
+    return m_zoomLevel;
+}
 
-    float oldZoomFactor = m_zoomTextOnly ? frame->textZoomFactor() : frame->pageZoomFactor();
+void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel,
+                                    double maximumZoomLevel)
+{
+    m_minimumZoomLevel = minimumZoomLevel;
+    m_maximumZoomLevel = maximumZoomLevel;
+    m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel);
+}
 
-    if (textOnly)
-        frame->setPageAndTextZoomFactors(1, zoomFactor);
-    else
-        frame->setPageAndTextZoomFactors(zoomFactor, 1);
+void WebViewImpl::fullFramePluginZoomLevelChanged(double zoomLevel)
+{
+    if (zoomLevel == m_zoomLevel)
+        return;
 
-    if (oldZoomFactor != zoomFactor || textOnly != m_zoomTextOnly) {
-        WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame);
-        if (pluginContainer)
-            pluginContainer->plugin()->setZoomFactor(zoomFactor, textOnly);
-    }
+    m_zoomLevel = std::max(std::min(zoomLevel, m_maximumZoomLevel), m_minimumZoomLevel);
+    m_client->zoomLevelChanged();
+}
 
-    m_zoomLevel = zoomLevel;
-    m_zoomTextOnly = textOnly;
+double WebView::zoomLevelToZoomFactor(double zoomLevel)
+{
+    return std::pow(textSizeMultiplierRatio, zoomLevel);
+}
 
-    return m_zoomLevel;
+double WebView::zoomFactorToZoomLevel(double factor)
+{
+    // Since factor = 1.2^level, level = log(factor) / log(1.2)
+    return log(factor) / log(textSizeMultiplierRatio);
 }
 
 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
index 9c21e49..165d6c1 100644
--- a/WebKit/chromium/src/WebViewImpl.h
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -132,8 +132,10 @@ public:
     virtual void setFocusedFrame(WebFrame* frame);
     virtual void setInitialFocus(bool reverse);
     virtual void clearFocusedNode();
-    virtual int zoomLevel();
-    virtual int setZoomLevel(bool textOnly, int zoomLevel);
+    virtual double zoomLevel();
+    virtual double setZoomLevel(bool textOnly, double zoomLevel);
+    virtual void zoomLimitsChanged(double minimumZoomLevel,
+                                   double maximumZoomLevel);
     virtual void performMediaPlayerAction(
         const WebMediaPlayerAction& action,
         const WebPoint& location);
@@ -342,13 +344,17 @@ public:
 
     WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); }
 
-    bool zoomTextOnly() const { return m_zoomTextOnly; }
-
     // Returns true if the event leads to scrolling.
     static bool mapKeyCodeForScroll(int keyCode,
                                    WebCore::ScrollDirection* scrollDirection,
                                    WebCore::ScrollGranularity* scrollGranularity);
 
+    // Called by a full frame plugin inside this view to inform it that its
+    // zoom level has been updated.  The plugin should only call this function
+    // if the zoom change was triggered by the browser, it's only needed in case
+    // a plugin can update its own zoom, say because of its own UI.
+    void fullFramePluginZoomLevelChanged(double zoomLevel);
+
 private:
     friend class WebView;  // So WebView::Create can call our constructor
     friend class WTF::RefCounted<WebViewImpl>;
@@ -440,9 +446,11 @@ private:
 
     // Keeps track of the current zoom level. 0 means no zoom, positive numbers
     // mean zoom in, negative numbers mean zoom out.
-    int m_zoomLevel;
+    double m_zoomLevel;
+
+    double m_minimumZoomLevel;
 
-    bool m_zoomTextOnly;
+    double m_maximumZoomLevel;
 
     bool m_contextMenuAllowed;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list