Title: [114779] trunk/Source/WebKit
Revision
114779
Author
commit-qu...@webkit.org
Date
2012-04-20 14:19:52 -0700 (Fri, 20 Apr 2012)

Log Message

[BlackBerry] Expose WebViewportArguments to WebPageClient
https://bugs.webkit.org/show_bug.cgi?id=84471

Patch by Mike Lattanzio <mlattan...@rim.com> on 2012-04-20
Reviewed by Antonio Gomes.

Source/WebKit:

* PlatformBlackBerry.cmake:

Source/WebKit/blackberry:

Implement the ability for the WebPageClient to specify a fallback
virtual viewport to be used whenever a meta viewport tag is not
present in the HTML. This can drastically impact apparent layout.
This patch is designed to provide a classic "Column View" style of
layout without breaking the web by simply exposing meta viewport
arguments to WebPageClients.

Note: As a side effect of this change. the WebPagePrivate::
recomputeVirtualViewportFromViewportArguments method no longer
modifies the targetDensityDpi property of the m_viewportArguments.
However this does not affect the class because that property itself
means nothing to us. Only the computeViewportArguments method from
WebCore uses it, and the currentViewportArguments object we pass
into that method has the adjusted targetDensityDpi value as before.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPage::setUserViewportArguments):
(WebKit):
(BlackBerry::WebKit::WebPage::resetUserViewportArguments):
(BlackBerry::WebKit::WebPagePrivate::recomputeVirtualViewportFromViewportArguments):
* Api/WebPage.h:
(WebKit):
* Api/WebPage_p.h:
(WebPagePrivate):
* Api/WebViewportArguments.cpp: Added.
(WebKit):
(BlackBerry::WebKit:::d):
(BlackBerry::WebKit::WebViewportArguments::~WebViewportArguments):
(BlackBerry::WebKit::WebViewportArguments::initialScale):
(BlackBerry::WebKit::WebViewportArguments::setInitialScale):
(BlackBerry::WebKit::WebViewportArguments::minimumScale):
(BlackBerry::WebKit::WebViewportArguments::setMinimumScale):
(BlackBerry::WebKit::WebViewportArguments::maximumScale):
(BlackBerry::WebKit::WebViewportArguments::setMaximumScale):
(BlackBerry::WebKit::WebViewportArguments::width):
(BlackBerry::WebKit::WebViewportArguments::setWidth):
(BlackBerry::WebKit::WebViewportArguments::height):
(BlackBerry::WebKit::WebViewportArguments::setHeight):
(BlackBerry::WebKit::WebViewportArguments::targetDensityDpi):
(BlackBerry::WebKit::WebViewportArguments::setTargetDensityDpi):
(BlackBerry::WebKit::WebViewportArguments::userScalable):
(BlackBerry::WebKit::WebViewportArguments::setUserScalable):
(BlackBerry::WebKit::WebViewportArguments::operator==):
(BlackBerry::WebKit::WebViewportArguments::operator!=):
* Api/WebViewportArguments.h: Added.
(WebCore):
(WebKit):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (114778 => 114779)


--- trunk/Source/WebKit/ChangeLog	2012-04-20 21:17:54 UTC (rev 114778)
+++ trunk/Source/WebKit/ChangeLog	2012-04-20 21:19:52 UTC (rev 114779)
@@ -1,3 +1,12 @@
+2012-04-20  Mike Lattanzio  <mlattan...@rim.com>
+
+        [BlackBerry] Expose WebViewportArguments to WebPageClient
+        https://bugs.webkit.org/show_bug.cgi?id=84471
+
+        Reviewed by Antonio Gomes.
+
+        * PlatformBlackBerry.cmake:
+
 2012-04-20  Thiago Marcos P. Santos  <thiago.san...@intel.com>
 
         [EFL] Add Security Origin API

Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (114778 => 114779)


--- trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-04-20 21:17:54 UTC (rev 114778)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-04-20 21:19:52 UTC (rev 114779)
@@ -54,6 +54,7 @@
     blackberry/Api/WebPageCompositor.cpp
     blackberry/Api/WebPageGroupLoadDeferrer.cpp
     blackberry/Api/WebSettings.cpp
+    blackberry/Api/WebViewportArguments.cpp
     blackberry/WebCoreSupport/AboutData.cpp
     blackberry/WebCoreSupport/CacheClientBlackBerry.cpp
     blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (114778 => 114779)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-04-20 21:17:54 UTC (rev 114778)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-04-20 21:19:52 UTC (rev 114779)
@@ -115,6 +115,7 @@
 #include "WebKitVersion.h"
 #include "WebPageClient.h"
 #include "WebSocket.h"
+#include "WebViewportArguments.h"
 #include "npapi.h"
 #include "runtime_root.h"
 
@@ -278,6 +279,16 @@
     return reinterpret_cast<WebPage::BackForwardId>(item);
 }
 
+void WebPage::setUserViewportArguments(const WebViewportArguments& viewportArguments)
+{
+    d->m_userViewportArguments = *(viewportArguments.d);
+}
+
+void WebPage::resetUserViewportArguments()
+{
+    d->m_userViewportArguments = ViewportArguments();
+}
+
 WebPagePrivate::WebPagePrivate(WebPage* webPage, WebPageClient* client, const IntRect& rect)
     : m_webPage(webPage)
     , m_client(client)
@@ -3123,24 +3134,36 @@
 
 IntSize WebPagePrivate::recomputeVirtualViewportFromViewportArguments()
 {
-    static ViewportArguments defaultViewportArguments;
-    if (m_viewportArguments == defaultViewportArguments)
-        return IntSize();
+    static const ViewportArguments defaultViewportArguments;
 
+    // When calculating a virtual viewport for layout we prioritize the
+    // m_viewportArguments from WebCore over the m_userViewportArguments. We
+    // cannot assign m_viewportAguments = m_userViewportArguments because then
+    // subsequent changes to m_userViewportArguments would be ignored, thinking
+    // the m_viewportArguments had come from WebCore. Instead we make a copy.
+
+    ViewportArguments currentViewportArguments = m_viewportArguments;
+    if (currentViewportArguments == defaultViewportArguments) {
+        if (currentViewportArguments == m_userViewportArguments)
+            return IntSize();
+
+        currentViewportArguments = m_userViewportArguments;
+    }
+
     int desktopWidth = defaultMaxLayoutSize().width();
     int deviceWidth = Platform::Graphics::Screen::primaryScreen()->width();
     int deviceHeight = Platform::Graphics::Screen::primaryScreen()->height();
     FloatSize currentPPI = Platform::Graphics::Screen::primaryScreen()->pixelsPerInch(-1);
     int deviceDPI = int(roundf((currentPPI.width() + currentPPI.height()) / 2));
-    if (m_viewportArguments.targetDensityDpi == ViewportArguments::ValueAuto
+    if (currentViewportArguments.targetDensityDpi == ViewportArguments::ValueAuto
         && !Platform::DeviceInfo::instance()->isMobile()) {
         // If the content provider hasn't specified a target dpi and we have a large
         // screen we assume the content is fine and set the targetDensityDpi to our dpi.
         // On smaller screen mobile devices we skip this and use WebCore dpi scaling.
-        m_viewportArguments.targetDensityDpi = deviceDPI;
+        currentViewportArguments.targetDensityDpi = deviceDPI;
     }
 
-    ViewportAttributes result = computeViewportAttributes(m_viewportArguments, desktopWidth, deviceWidth, deviceHeight, deviceDPI, m_defaultLayoutSize);
+    ViewportAttributes result = computeViewportAttributes(currentViewportArguments, desktopWidth, deviceWidth, deviceHeight, deviceDPI, m_defaultLayoutSize);
     m_page->setDeviceScaleFactor(result.devicePixelRatio);
     return IntSize(result.layoutSize.width(), result.layoutSize.height());
 }

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (114778 => 114779)


--- trunk/Source/WebKit/blackberry/Api/WebPage.h	2012-04-20 21:17:54 UTC (rev 114778)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h	2012-04-20 21:19:52 UTC (rev 114779)
@@ -66,6 +66,7 @@
 class WebPageGroupLoadDeferrer;
 class WebPagePrivate;
 class WebSettings;
+class WebViewportArguments;
 
 enum _javascript_DataType { JSUndefined = 0, JSNull, JSBoolean, JSNumber, JSString, JSObject, JSException, JSDataTypeMax };
 
@@ -328,6 +329,9 @@
 
     void destroyWebPageCompositor();
 
+    void setUserViewportArguments(const WebViewportArguments&);
+    void resetUserViewportArguments();
+
 private:
     virtual ~WebPage();
 

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (114778 => 114779)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-04-20 21:17:54 UTC (rev 114778)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-04-20 21:19:52 UTC (rev 114779)
@@ -450,6 +450,7 @@
     int m_virtualViewportHeight;
     WebCore::IntSize m_defaultLayoutSize;
     WebCore::ViewportArguments m_viewportArguments; // We keep this around since we may need to re-evaluate the arguments on rotation.
+    WebCore::ViewportArguments m_userViewportArguments; // A fallback set of Viewport Arguments supplied by the WebPageClient
     bool m_didRestoreFromPageCache;
     ViewMode m_viewMode;
     LoadState m_loadState;

Added: trunk/Source/WebKit/blackberry/Api/WebViewportArguments.cpp (0 => 114779)


--- trunk/Source/WebKit/blackberry/Api/WebViewportArguments.cpp	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/Api/WebViewportArguments.cpp	2012-04-20 21:19:52 UTC (rev 114779)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "WebViewportArguments.h"
+
+#include "ViewportArguments.h"
+
+namespace BlackBerry {
+namespace WebKit {
+
+WebViewportArguments::WebViewportArguments()
+    :d(new WebCore::ViewportArguments(WebCore::ViewportArguments::ViewportMeta))
+{
+}
+
+WebViewportArguments::~WebViewportArguments()
+{
+    delete d;
+    d = 0;
+}
+
+float WebViewportArguments::initialScale() const
+{
+    return d->initialScale;
+}
+
+void WebViewportArguments::setInitialScale(float scale)
+{
+    d->initialScale = scale;
+}
+
+float WebViewportArguments::minimumScale() const
+{
+    return d->minimumScale;
+}
+
+void WebViewportArguments::setMinimumScale(float scale)
+{
+    d->minimumScale = scale;
+}
+
+float WebViewportArguments::maximumScale() const
+{
+    return d->maximumScale;
+}
+
+void WebViewportArguments::setMaximumScale(float scale)
+{
+    d->maximumScale = scale;
+}
+
+float WebViewportArguments::width() const
+{
+    return d->width;
+}
+
+void WebViewportArguments::setWidth(float width)
+{
+    d->width = width;
+}
+
+float WebViewportArguments::height() const
+{
+    return d->height;
+}
+
+void WebViewportArguments::setHeight(float height)
+{
+    d->height = height;
+}
+
+float WebViewportArguments::targetDensityDpi() const
+{
+    return d->targetDensityDpi;
+}
+
+void WebViewportArguments::setTargetDensityDpi(float dpi)
+{
+    d->targetDensityDpi = dpi;
+}
+
+float WebViewportArguments::userScalable() const
+{
+    return d->userScalable;
+}
+
+void WebViewportArguments::setUserScalable(float scalable)
+{
+    d->userScalable = scalable;
+}
+
+bool WebViewportArguments::operator==(const WebViewportArguments& other)
+{
+    return *d == *(other.d);
+}
+
+bool WebViewportArguments::operator!=(const WebViewportArguments& other)
+{
+    return !(*this == other);
+}
+
+} // namespace WebKit
+} // namespace BlackBerry

Added: trunk/Source/WebKit/blackberry/Api/WebViewportArguments.h (0 => 114779)


--- trunk/Source/WebKit/blackberry/Api/WebViewportArguments.h	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/Api/WebViewportArguments.h	2012-04-20 21:19:52 UTC (rev 114779)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef WebViewportArguments_h
+#define WebViewportArguments_h
+
+#include "BlackBerryGlobal.h"
+
+// Not for public API purpose.
+namespace WebCore {
+class ViewportArguments;
+}
+
+namespace BlackBerry {
+namespace WebKit {
+
+class WebPage;
+
+/**
+ * A class designed to expose a meta viewport fallback.
+ *
+ * This class simply wraps a WebCore::ViewportArguments. It can be
+ * instantiated by the WebPageClient and supplied to a WebPage to
+ * provide a userViewportArguments object that can be used whenever
+ * there is no meta viewport tag provided in any loaded html.
+ */
+class BLACKBERRY_EXPORT WebViewportArguments {
+public:
+    WebViewportArguments();
+    ~WebViewportArguments();
+
+    // This matches the enum found in WebCore::ViewportArguments
+    enum {
+        ValueAuto = -1,
+        ValueDesktopWidth = -2,
+        ValueDeviceWidth = -3,
+        ValueDeviceHeight = -4,
+        ValueDeviceDPI = -5,
+        ValueLowDPI = -6,
+        ValueMediumDPI = -7,
+        ValueHighDPI = -8
+    };
+
+    float initialScale() const;
+    void setInitialScale(float);
+
+    float minimumScale() const;
+    void setMinimumScale(float);
+
+    float maximumScale() const;
+    void setMaximumScale(float);
+
+    float width() const;
+    void setWidth(float);
+
+    float height() const;
+    void setHeight(float);
+
+    float targetDensityDpi() const;
+    void setTargetDensityDpi(float);
+
+    float userScalable() const;
+    void setUserScalable(float);
+
+    bool operator==(const WebViewportArguments &other);
+    bool operator!=(const WebViewportArguments &other);
+
+private:
+    WebViewportArguments(const WebViewportArguments&);
+    WebCore::ViewportArguments* d;
+
+private:
+    friend class WebPage;
+};
+
+} // namespace WebKit
+} // namespace BlackBerry
+
+#endif // WebViewportArguments_h

Modified: trunk/Source/WebKit/blackberry/ChangeLog (114778 => 114779)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-04-20 21:17:54 UTC (rev 114778)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-04-20 21:19:52 UTC (rev 114779)
@@ -1,3 +1,58 @@
+2012-04-20  Mike Lattanzio  <mlattan...@rim.com>
+
+        [BlackBerry] Expose WebViewportArguments to WebPageClient
+        https://bugs.webkit.org/show_bug.cgi?id=84471
+
+        Reviewed by Antonio Gomes.
+
+        Implement the ability for the WebPageClient to specify a fallback
+        virtual viewport to be used whenever a meta viewport tag is not
+        present in the HTML. This can drastically impact apparent layout.
+        This patch is designed to provide a classic "Column View" style of
+        layout without breaking the web by simply exposing meta viewport
+        arguments to WebPageClients.
+
+        Note: As a side effect of this change. the WebPagePrivate::
+        recomputeVirtualViewportFromViewportArguments method no longer
+        modifies the targetDensityDpi property of the m_viewportArguments.
+        However this does not affect the class because that property itself
+        means nothing to us. Only the computeViewportArguments method from
+        WebCore uses it, and the currentViewportArguments object we pass
+        into that method has the adjusted targetDensityDpi value as before.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPage::setUserViewportArguments):
+        (WebKit):
+        (BlackBerry::WebKit::WebPage::resetUserViewportArguments):
+        (BlackBerry::WebKit::WebPagePrivate::recomputeVirtualViewportFromViewportArguments):
+        * Api/WebPage.h:
+        (WebKit):
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+        * Api/WebViewportArguments.cpp: Added.
+        (WebKit):
+        (BlackBerry::WebKit:::d):
+        (BlackBerry::WebKit::WebViewportArguments::~WebViewportArguments):
+        (BlackBerry::WebKit::WebViewportArguments::initialScale):
+        (BlackBerry::WebKit::WebViewportArguments::setInitialScale):
+        (BlackBerry::WebKit::WebViewportArguments::minimumScale):
+        (BlackBerry::WebKit::WebViewportArguments::setMinimumScale):
+        (BlackBerry::WebKit::WebViewportArguments::maximumScale):
+        (BlackBerry::WebKit::WebViewportArguments::setMaximumScale):
+        (BlackBerry::WebKit::WebViewportArguments::width):
+        (BlackBerry::WebKit::WebViewportArguments::setWidth):
+        (BlackBerry::WebKit::WebViewportArguments::height):
+        (BlackBerry::WebKit::WebViewportArguments::setHeight):
+        (BlackBerry::WebKit::WebViewportArguments::targetDensityDpi):
+        (BlackBerry::WebKit::WebViewportArguments::setTargetDensityDpi):
+        (BlackBerry::WebKit::WebViewportArguments::userScalable):
+        (BlackBerry::WebKit::WebViewportArguments::setUserScalable):
+        (BlackBerry::WebKit::WebViewportArguments::operator==):
+        (BlackBerry::WebKit::WebViewportArguments::operator!=):
+        * Api/WebViewportArguments.h: Added.
+        (WebCore):
+        (WebKit):
+
 2012-04-19  Arvid Nilsson  <anils...@rim.com>
 
         [BlackBerry] Always use the AnimationFrameRateController for accelerated animations
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to