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

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 18:17:05 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7a9a18553d37d7f9d354b32169601d7ddc560181
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 9 14:56:33 2010 +0000

    2010-12-09  Joone Hur  <joone at kldp.org>
    
            Reviewed by Martin Robinson.
    
            [GTK] Support for viewport meta tag
            https://bugs.webkit.org/show_bug.cgi?id=45443
    
            Included viewport test cases for WebKitGtk
    
            * platform/gtk/Skipped: Unskip fast/viewport except viewport-45.html.
    2010-12-09  Joone Hur  <joone at kldp.org>
    
            Reviewed by Martin Robinson.
    
            [GTK] Support for viewport meta tag
            https://bugs.webkit.org/show_bug.cgi?id=45443
    
            This patch adds a new gobject to offer the viewport properties to user agents.
            It is WebKitViewportAttributes that contains the viewport size, initial scale with limits,
            and information about whether a user is able to scale the contents in the viewport.
    
            This feature was introduced by Safari on the iPhone. For more information on
            the viewport properties, refer to the Safari reference library at
            http://developer.apple.com/safari/library/documentation/appleapplications/reference/safarihtmlref/articles/metatags.html
    
            * GNUmakefile.am: Added webkitviewportattributes.h webkitviewportattributes.cpp.
            * WebCoreSupport/ChromeClientGtk.cpp:
            (WebKit::ChromeClient::dispatchViewportDataDidChange): Added this callback to know whether the viewport arguments is available.
            * WebCoreSupport/ChromeClientGtk.h:
            * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
            (DumpRenderTreeSupportGtk::dumpConfigurationForViewport): Added this function to compute the viewport attributes with the given availableWidth and availableHeight.
            * WebCoreSupport/DumpRenderTreeSupportGtk.h:
            * WebCoreSupport/FrameLoaderClientGtk.cpp:
            (WebKit::postCommitFrameViewSetup): Invalidate the viewport attributes.
            * webkit/webkit.h:
            * webkit/webkitdefines.h:
            * webkit/webkitprivate.h: Added webkitViewportAttributesRecompute as a private function.
            * webkit/webkitviewportattributes.cpp: Added.
            (webkit_viewport_attributes_class_init):
            (webkit_viewport_attributes_init):
            (webkit_viewport_attributes_get_property):
            (webkit_viewport_attributes_set_property):
            (webkitViewportAttributesRecompute): Recompute the optimal viewport attributes and emit the viewport-attributes-changed signal.
            (webkit_viewport_attributes_recompute): a public API for calling webkitViewportAttributesRecompute.
            * webkit/webkitviewportattributes.h: Added.
            * webkit/webkitwebview.cpp:
            (webkit_web_view_get_property): Added PROP_VIEWPORT_ATTRIBUTES.
            (webkit_web_view_dispose): Deallocate the WebKitViewportAttributes instance.
            (webkit_web_view_class_init): Added the viewport-attributes-recompute-requested and viewport-attributes-changed signals.
            (webkit_web_view_init): Set the WebKitViewportAttributes instance.
            (webkit_web_view_get_viewport_attributes): Added a getter to obtain the WebKitViewportAttributes instance held by the given WebKitWebView.
            * webkit/webkitwebview.h:
            * webkit/webkitwebviewprivate.h: Added WebKitViewportAttributes as a private variable.
    2010-12-09  Joone Hur  <joone at kldp.org>
    
             Reviewed by Martin Robinson.
    
             [GTK] Support for viewport meta tag
             https://bugs.webkit.org/show_bug.cgi?id=45443
    
             Add support for testing the viewport properties for WebKitGtk.
    
             * DumpRenderTree/LayoutTestController.cpp:
             (dumpConfigurationForViewportCallback): Added this JS callback to set the size of the visible viewport.
             (LayoutTestController::staticFunctions):
             * DumpRenderTree/LayoutTestController.h:
             * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
             (LayoutTestController::dumpConfigurationForViewport): Added this function to test the viewport properties.
             * DumpRenderTree/mac/LayoutTestControllerMac.mm:
             (LayoutTestController::dumpConfigurationForViewport): Ditto.
             * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
             (LayoutTestController::dumpConfigurationForViewport): Ditto.
             * DumpRenderTree/win/LayoutTestControllerWin.cpp:
             (LayoutTestController::dumpConfigurationForViewport): Ditto.
             * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
             (LayoutTestController::dumpConfigurationForViewport): Ditto.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73608 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e5c1c62..628ab8b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-12-09  Joone Hur  <joone at kldp.org>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Support for viewport meta tag
+        https://bugs.webkit.org/show_bug.cgi?id=45443
+
+        Included viewport test cases for WebKitGtk
+
+        * platform/gtk/Skipped: Unskip fast/viewport except viewport-45.html.
+
 2010-12-09  Yury Semikhatsky  <yurys at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index 999e3f8..6c782b4 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -5491,7 +5491,8 @@ fullscreen/
 canvas/philip/tests/2d.path.isPointInPath.edge.html
 
 # viewport meta tag support
-fast/viewport
+# https://bugs.webkit.org/show_bug.cgi?id=47481
+fast/viewport/viewport-45.html
 
 # Pre-HMTL5 parser quirks only apply to the mac port for now.
 fast/parser/pre-html5-parser-quirks.html
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 9fcfd4a..bd413fe 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,47 @@
+2010-12-09  Joone Hur  <joone at kldp.org>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Support for viewport meta tag
+        https://bugs.webkit.org/show_bug.cgi?id=45443
+
+        This patch adds a new gobject to offer the viewport properties to user agents.
+        It is WebKitViewportAttributes that contains the viewport size, initial scale with limits, 
+        and information about whether a user is able to scale the contents in the viewport.
+        
+        This feature was introduced by Safari on the iPhone. For more information on 
+        the viewport properties, refer to the Safari reference library at 
+        http://developer.apple.com/safari/library/documentation/appleapplications/reference/safarihtmlref/articles/metatags.html
+
+        * GNUmakefile.am: Added webkitviewportattributes.h webkitviewportattributes.cpp. 
+        * WebCoreSupport/ChromeClientGtk.cpp:
+        (WebKit::ChromeClient::dispatchViewportDataDidChange): Added this callback to know whether the viewport arguments is available.
+        * WebCoreSupport/ChromeClientGtk.h:
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::dumpConfigurationForViewport): Added this function to compute the viewport attributes with the given availableWidth and availableHeight.
+        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
+        * WebCoreSupport/FrameLoaderClientGtk.cpp: 
+        (WebKit::postCommitFrameViewSetup): Invalidate the viewport attributes.
+        * webkit/webkit.h:
+        * webkit/webkitdefines.h:
+        * webkit/webkitprivate.h: Added webkitViewportAttributesRecompute as a private function.
+        * webkit/webkitviewportattributes.cpp: Added.
+        (webkit_viewport_attributes_class_init):
+        (webkit_viewport_attributes_init):
+        (webkit_viewport_attributes_get_property):
+        (webkit_viewport_attributes_set_property):
+        (webkitViewportAttributesRecompute): Recompute the optimal viewport attributes and emit the viewport-attributes-changed signal.
+        (webkit_viewport_attributes_recompute): a public API for calling webkitViewportAttributesRecompute.
+        * webkit/webkitviewportattributes.h: Added.
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_get_property): Added PROP_VIEWPORT_ATTRIBUTES.
+        (webkit_web_view_dispose): Deallocate the WebKitViewportAttributes instance.
+        (webkit_web_view_class_init): Added the viewport-attributes-recompute-requested and viewport-attributes-changed signals.
+        (webkit_web_view_init): Set the WebKitViewportAttributes instance.
+        (webkit_web_view_get_viewport_attributes): Added a getter to obtain the WebKitViewportAttributes instance held by the given WebKitWebView.
+        * webkit/webkitwebview.h:
+        * webkit/webkitwebviewprivate.h: Added WebKitViewportAttributes as a private variable.
+
 2010-12-09  Xan Lopez  <xlopez at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebKit/gtk/GNUmakefile.am b/WebKit/gtk/GNUmakefile.am
index bccbd5a..7fdf253 100644
--- a/WebKit/gtk/GNUmakefile.am
+++ b/WebKit/gtk/GNUmakefile.am
@@ -119,6 +119,7 @@ webkitgtk_static_h_api += \
 	$(srcdir)/WebKit/gtk/webkit/webkitnetworkresponse.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitsecurityorigin.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitsoupauthdialog.h \
+	$(srcdir)/WebKit/gtk/webkit/webkitviewportattributes.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebbackforwardlist.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebdatabase.h \
 	$(srcdir)/WebKit/gtk/webkit/webkitwebdatasource.h \
@@ -182,6 +183,7 @@ webkitgtk_sources += \
 	WebKit/gtk/webkit/webkitprivate.h \
 	WebKit/gtk/webkit/webkitsoupauthdialog.c \
 	WebKit/gtk/webkit/webkitversion.cpp \
+	WebKit/gtk/webkit/webkitviewportattributes.cpp \
 	WebKit/gtk/webkit/webkitwebbackforwardlist.cpp \
 	WebKit/gtk/webkit/webkitwebdatasource.cpp \
 	WebKit/gtk/webkit/webkitwebframe.cpp \
diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
index 60c7880..ad29af0 100644
--- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
@@ -24,6 +24,7 @@
 #include "config.h"
 #include "ChromeClientGtk.h"
 
+#include "Chrome.h"
 #include "Console.h"
 #include "DumpRenderTreeSupportGtk.h"
 #include "Element.h"
@@ -617,6 +618,12 @@ void ChromeClient::chooseIconForFiles(const Vector<WTF::String>& filenames, WebC
     chooser->iconLoaded(Icon::createIconForFiles(filenames));
 }
 
+void ChromeClient::dispatchViewportDataDidChange(const ViewportArguments& arguments) const
+{
+    // Recompute the viewport attributes making it valid.
+    webkitViewportAttributesRecompute(webkit_web_view_get_viewport_attributes(m_webView));
+}
+
 void ChromeClient::setCursor(const Cursor&)
 {
     notImplemented();
diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
index 8252f06..b4a1a37 100644
--- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
@@ -110,6 +110,8 @@ namespace WebKit {
 
         virtual void setToolTip(const WTF::String&, WebCore::TextDirection);
 
+        virtual void dispatchViewportDataDidChange(const WebCore::ViewportArguments& arguments) const;
+
         virtual void print(WebCore::Frame*);
 #if ENABLE(DATABASE)
         virtual void exceededDatabaseQuota(WebCore::Frame*, const WTF::String&);
diff --git a/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp b/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
index b455c1a..91e5a11 100644
--- a/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *  Copyright (C) 2010 Joone Hur <joone at kldp.org>
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -408,3 +409,15 @@ void DumpRenderTreeSupportGtk::layoutFrame(WebKitWebFrame* frame)
 
     view->layout();
 }
+
+// For testing fast/viewport.
+void DumpRenderTreeSupportGtk::dumpConfigurationForViewport(WebKitWebView* webView, gint availableWidth, gint availableHeight)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+    ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments();
+    // desktopWidth = 980, deviceWidth = 320, deviceHeight = 480, deviceDPI = 160
+    ViewportAttributes attrs = computeViewportAttributes(arguments, 980, 320, 480, 160, IntSize(availableWidth, availableHeight));
+
+    fprintf(stdout, "viewport size %dx%d scale %f with limits [%f, %f]\n", attrs.layoutSize.width(), attrs.layoutSize.height(), attrs.initialScale, attrs.minimumScale, attrs.maximumScale);
+}
diff --git a/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h b/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h
index 6db6268..dd1d49d 100644
--- a/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h
+++ b/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h
@@ -21,6 +21,7 @@
 
 
 #include "JSStringRef.h"
+#include <webkit/webkitdefines.h>
 
 #include <atk/atk.h>
 #include <glib.h>
@@ -40,6 +41,7 @@ public:
     static void setLinksIncludedInFocusChain(bool);
     static bool linksIncludedInFocusChain();
     static JSValueRef nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping);
+    static void dumpConfigurationForViewport(WebKitWebView* webView, gint availableWidth, gint availableHeight);
 
     // FIXME: Move these to webkitwebframe.h once their API has been discussed.
     static GSList* getFrameChildren(WebKitWebFrame* frame);
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
index 6834949..5c12c69 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
@@ -1292,6 +1292,12 @@ static void postCommitFrameViewSetup(WebKitWebFrame *frame, FrameView *view, boo
     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(containingWindow);
     view->setGtkAdjustments(priv->horizontalAdjustment.get(), priv->verticalAdjustment.get(), resetValues);
 
+    // Invalidate the viewport attributes - they will only be valid
+    // again if the page we're beginning to load now has an
+    // appropriate viewport meta tag.
+    containingWindow->priv->viewportAttributes->priv->isValid = FALSE;
+    g_object_notify(G_OBJECT(containingWindow->priv->viewportAttributes.get()), "valid");
+
     if (priv->currentMenu) {
         PlatformRefPtr<GtkMenu> menu(priv->currentMenu);
         priv->currentMenu.clear();
diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h
index fc71c2c..2428f62 100644
--- a/WebKit/gtk/webkit/webkit.h
+++ b/WebKit/gtk/webkit/webkit.h
@@ -30,6 +30,7 @@
 #include <webkit/webkitnetworkrequest.h>
 #include <webkit/webkitnetworkresponse.h>
 #include <webkit/webkitsoupauthdialog.h>
+#include <webkit/webkitviewportattributes.h>
 #include <webkit/webkitwebdatasource.h>
 #include <webkit/webkitwebframe.h>
 #include <webkit/webkitwebsettings.h>
diff --git a/WebKit/gtk/webkit/webkitdefines.h b/WebKit/gtk/webkit/webkitdefines.h
index b06a3bf..399cb4c 100644
--- a/WebKit/gtk/webkit/webkitdefines.h
+++ b/WebKit/gtk/webkit/webkitdefines.h
@@ -92,6 +92,9 @@ typedef struct _WebKitHitTestResultClass WebKitHitTestResultClass;
 typedef struct _WebKitGeolocationPolicyDecision WebKitGeolocationPolicyDecision;
 typedef struct _WebKitGeolocationPolicyDecisionClass WebKitGeolocationPolicyDecisionClass;
 
+typedef struct _WebKitViewportAttributes WebKitViewportAttributes;
+typedef struct _WebKitViewportAttributesClass WebKitViewportAttributesClass;
+
 G_END_DECLS
 
 #endif
diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h
index 4889a15..083640d 100644
--- a/WebKit/gtk/webkit/webkitprivate.h
+++ b/WebKit/gtk/webkit/webkitprivate.h
@@ -33,6 +33,7 @@
 #include <webkit/webkitdownload.h>
 #include <webkit/webkithittestresult.h>
 #include <webkit/webkitnetworkrequest.h>
+#include <webkit/webkitviewportattributes.h>
 #include <webkit/webkitwebview.h>
 #include <webkit/webkitwebdatasource.h>
 #include <webkit/webkitwebframe.h>
@@ -141,6 +142,25 @@ extern "C" {
         gboolean disposed;
     };
 
+    struct _WebKitViewportAttributesPrivate {
+        WebKitWebView* webView;
+        int deviceWidth;
+        int deviceHeight;
+        int availableWidth;
+        int availableHeight;
+        int desktopWidth;
+        int deviceDPI;
+
+        int width;
+        int height;
+        float initialScaleFactor;
+        float minimumScaleFactor;
+        float maximumScaleFactor;
+        float devicePixelRatio;
+        gboolean userScalable;
+        gboolean isValid;
+    };
+
     WTF::String
     webkitUserAgent();
 
@@ -249,6 +269,9 @@ extern "C" {
 
     WEBKIT_API WebKitWebDatabase *
     webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const char* databaseName);
+
+    // WebKitViewportAttributes private
+    void webkitViewportAttributesRecompute(WebKitViewportAttributes*);
 }
 
 #endif
diff --git a/WebKit/gtk/webkit/webkitviewportattributes.cpp b/WebKit/gtk/webkit/webkitviewportattributes.cpp
new file mode 100644
index 0000000..1508843
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitviewportattributes.cpp
@@ -0,0 +1,571 @@
+/*
+ * Copyright (C) 2010 Joone Hur <joone at kldp.org>
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitviewportattributes.h"
+
+#include "Chrome.h"
+#include "webkitprivate.h"
+#include "webkitwebviewprivate.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitviewportattributes
+ * @short_description: Represents the viewport properties of a web page
+ * @see_also: #WebKitWebView::viewport-attributes-recompute-requested
+ * @see_also: #WebKitWebView::viewport-attributes-changed
+ *
+ * #WebKitViewportAttributes offers the viewport properties to user agents to
+ * control the viewport layout. It contains the viewport size, initial scale with limits,
+ * and information about whether a user is able to scale the contents in the viewport.
+ * This makes a web page fit the device screen.
+ *
+ * The #WebKitWebView::viewport-attributes-changed signal will be emitted with #WebKitViewportAttributes
+ * when the viewport attributes are updated in the case of loading web pages contain
+ * the viewport properties and calling webkit_viewport_attributes_recompute.
+ *
+ * If the device size, available size, desktop width, or device DPI needs to be changed due to 
+ * a consequence of an explicit browser request (caused by screen rotation, resizing, or similar reasons),
+ * You should call #webkit_viewport_attributes_recompute to recompute the viewport properties and 
+ * override those values in the handler of #WebKitWebView::viewport-attributes-recompute-requested signal.
+ *
+ * For more information on the viewport properties, refer to the Safari reference library at
+ * http://developer.apple.com/safari/library/documentation/appleapplications/reference/safarihtmlref/articles/metatags.html
+ *
+ * <informalexample><programlisting>
+ * /<!-- -->* Connect to the viewport-attributes-changes signal *<!-- -->/
+ * WebKitViewportAttributes* attributes = webkit_web_view_get_viewport_attributes (web_view);
+ * g_signal_connect (web_view, "viewport-attributes-recompute-requested", G_CALLBACK (viewport_recompute_cb), window);
+ * g_signal_connect (web_view, "viewport-attributes-changed", G_CALLBACK (viewport_changed_cb), window);
+ * g_signal_connect (attributes, "notify::valid", G_CALLBACK (viewport_valid_changed_cb), web_view);
+ *
+ * /<!-- -->* Handle the viewport-attributes-recompute-requested signal to override the device width *<!-- -->/
+ * static void
+ * viewport_recompute_cb (WebKitWebView* web_view, WebKitViewportAttributes* attributes, GtkWidget* window)
+ * {
+ *     int override_available_width = 480;
+ *     g_object_set (G_OBJECT(attributes), "available-width", override_available_width, NULL);
+ * }
+ *
+ * /<!-- -->* Handle the viewport-attributes-changed signal to recompute the initial scale factor *<!-- -->/
+ * static void 
+ * viewport_changed_cb (WebKitWebView* web_view, WebKitViewportAttributes* attributes, gpointer data)
+ * {
+ *     gfloat initialScale;
+ *     g_object_get (G_OBJECT (atributes), "initial-scale-factor", &initialScale, NULL);
+ *     webkit_web_view_set_zoom_level (web_view, initialScale);
+ * }
+ * 
+ * /<!-- -->* Handle the notify::valid signal to initialize the zoom level *<!-- -->/
+ * static void
+ * viewport_valid_changed_cb (WebKitViewportAttributes* attributes, GParamSpec* pspec, WebKitWebView* web_view)
+ * {
+ *     gboolean is_valid;
+ *     g_object_get (attributes, "valid", &is_valid, NULL);
+ *     if (!is_valid) 
+ *         webkit_web_view_set_zoom_level (web_view, 1.0);
+ * }
+ * </programlisting></informalexample>
+ */
+
+using namespace WebKit;
+using namespace WebCore;
+
+enum {
+    PROP_0,
+
+    PROP_DEVICE_WIDTH,
+    PROP_DEVICE_HEIGHT,
+    PROP_AVAILABLE_WIDTH,
+    PROP_AVAILABLE_HEIGHT,
+    PROP_DESKTOP_WIDTH,
+    PROP_DEVICE_DPI,
+    PROP_WIDTH,
+    PROP_HEIGHT,
+    PROP_INITIAL_SCALE_FACTOR,
+    PROP_MINIMUM_SCALE_FACTOR,
+    PROP_MAXIMUM_SCALE_FACTOR,
+    PROP_DEVICE_PIXEL_RATIO,
+    PROP_USER_SCALABLE,
+    PROP_VALID
+};
+
+G_DEFINE_TYPE(WebKitViewportAttributes, webkit_viewport_attributes, G_TYPE_OBJECT);
+
+#define WEBKIT_VIEWPORT_ATTRIBUTES_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, WebKitViewportAttributesPrivate))
+
+static void webkit_viewport_attributes_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* paramSpec);
+static void webkit_viewport_attributes_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* paramSpec);
+
+static void webkit_viewport_attributes_class_init(WebKitViewportAttributesClass* kclass)
+{
+    GObjectClass* gobjectClass = G_OBJECT_CLASS(kclass);
+    gobjectClass->get_property = webkit_viewport_attributes_get_property;
+    gobjectClass->set_property = webkit_viewport_attributes_set_property;
+
+    /**
+     * WebKitViewportAttributs:device-width:
+     *
+     * The width of the screen. This value is always automatically
+     * pre-computed during a viewport attributes recomputation, and
+     * can be overridden by the handler of
+     * WebKitWebView::viewport-attributes-recompute-requested. You
+     * should not do that unless you have a very good reason.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_DEVICE_WIDTH,
+                                    g_param_spec_int(
+                                    "device-width",
+                                    _("Device Width"),
+                                    _("The width of the screen."),
+                                    0,
+                                    G_MAXINT,
+                                    0,
+                                    WEBKIT_PARAM_READWRITE));
+
+    /**
+     * WebKitViewportAttributs:device-height:
+     *
+     * The height of the screen. This value is always automatically
+     * pre-computed during a viewport attributes recomputation, and
+     * can be overriden by the handler of
+     * WebKitWebView::viewport-attributes-recompute-requested. You
+     * should not do that unless you have a very good reason.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_DEVICE_HEIGHT,
+                                    g_param_spec_int(
+                                    "device-height",
+                                    _("Device Height"),
+                                    _("The height of the screen."),
+                                    0,
+                                    G_MAXINT,
+                                    0,
+                                    WEBKIT_PARAM_READWRITE));
+
+    /**
+     * WebKitViewportAttributs:available-width:
+     *
+     * The width of the current visible area. This will usually be the
+     * same as the space allocated to the widget, but in some cases
+     * you may have decided to make the widget bigger than the visible
+     * area. This value is by default initialized to the size
+     * allocated by the widget, but you can override it in the handler
+     * of WebKitWebView::viewport-attributes-recompute-requested to
+     * let the engine know what the visible area is.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_AVAILABLE_WIDTH,
+                                    g_param_spec_int(
+                                    "available-width",
+                                    _("Available Width"),
+                                    _("The width of the visible area."),
+                                    0,
+                                    G_MAXINT,
+                                    0,
+                                    WEBKIT_PARAM_READWRITE));
+
+    /**
+     * WebKitViewportAttributs:available-height:
+     *
+     * The height of the current visible area. This will usually be the
+     * same as the space allocated to the widget, but in some cases
+     * you may have decided to make the widget bigger than the visible
+     * area. This value is by default initialized to the size
+     * allocated by the widget, but you can override it in the handler
+     * of WebKitWebView::viewport-attributes-recompute-requested to
+     * let the engine know what the visible area is.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_AVAILABLE_HEIGHT,
+                                    g_param_spec_int(
+                                    "available-height",
+                                    _("Available Height"),
+                                    _("The height of the visible area."),
+                                    0,
+                                    G_MAXINT,
+                                    0,
+                                    WEBKIT_PARAM_READWRITE));
+
+    /**
+     * WebKitViewportAttributs:desktop-width:
+     *
+     * The width of viewport that works well for most web pages designed for 
+     * desktop. This value is initialized to 980 pixels by default and used 
+     * during a viewport attributes recomputation. Also, it can be overriden by 
+     * the handler of WebKitWebView::viewport-attributes-recompute-requested. 
+     * You should not do that unless you have a very good reason.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_DESKTOP_WIDTH,
+                                    g_param_spec_int(
+                                    "desktop-width",
+                                    _("Desktop Width"),
+                                    _("The width of viewport that works well for most web pages designed for desktop."),
+                                    0,
+                                    G_MAXINT,
+                                    980,
+                                    WEBKIT_PARAM_READWRITE));
+
+    /**
+     * WebKitViewportAttributs:device-dpi:
+     *
+     * The number of dots per inch of the screen. This value is 
+     * initialized to 160 dpi by default and used during a viewport 
+     * attributes recomputation, because it is the dpi of the original 
+     * iPhone and Android devices. Also, it can be overriden by the 
+     * handler of WebKitWebView::viewport-attributes-recompute-requested. 
+     * You should not do that unless you have a very good reason.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_DEVICE_DPI,
+                                    g_param_spec_int(
+                                    "device-dpi",
+                                    _("Device DPI"),
+                                    _("The number of dots per inch of the screen."),
+                                    0,
+                                    G_MAXINT,
+                                    160,
+                                    WEBKIT_PARAM_READWRITE));
+
+    /**
+     * WebKitViewportAttributs:width:
+     *
+     * The width of the viewport. Before getting this property, 
+     * you need to make sure that #WebKitViewportAttributes is valid.
+     * 
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_WIDTH,
+                                    g_param_spec_int(
+                                    "width",
+                                    _("Width"),
+                                    _("The width of the viewport."),
+                                    0,
+                                    G_MAXINT,
+                                    0,
+                                    WEBKIT_PARAM_READABLE));
+
+    /**
+     * WebKitViewportAttributs:height:
+     *
+     * The height of the viewport. Before getting this property,
+     * you need to make sure that #WebKitViewportAttributes is valid.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_HEIGHT,
+                                    g_param_spec_int(
+                                    "height",
+                                    _("Height"),
+                                    _("The height of the viewport."),
+                                    0,
+                                    G_MAXINT,
+                                    0,
+                                    WEBKIT_PARAM_READABLE));
+
+    /**
+     * WebKitViewportAttributs:initial-scale-factor:
+     *
+     * The initial scale of the viewport. Before getting this property,
+     * you need to make sure that #WebKitViewportAttributes is valid.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_INITIAL_SCALE_FACTOR,
+                                    g_param_spec_float(
+                                    "initial-scale-factor",
+                                    _("Initial Scale Factor"),
+                                    _("The initial scale of the viewport."),
+                                    -1,
+                                    G_MAXFLOAT,
+                                    -1,
+                                    WEBKIT_PARAM_READABLE));
+
+    /**
+     * WebKitViewportAttributs:minimum-scale-factor:
+     *
+     * The minimum scale of the viewport. Before getting this property, 
+     * you need to make sure that #WebKitViewportAttributes is valid.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_MINIMUM_SCALE_FACTOR,
+                                    g_param_spec_float(
+                                    "minimum-scale-factor",
+                                    _("Minimum Scale Factor"),
+                                    _("The minimum scale of the viewport."),
+                                    -1,
+                                    G_MAXFLOAT,
+                                    -1,
+                                    WEBKIT_PARAM_READABLE));
+
+    /**
+     * WebKitViewportAttributs:maximum-scale-factor:
+     *
+     * The maximum scale of the viewport. Before getting this property, 
+     * you need to make sure that #WebKitViewportAttributes is valid.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_MAXIMUM_SCALE_FACTOR,
+                                    g_param_spec_float(
+                                    "maximum-scale-factor",
+                                    _("Maximum Scale Factor"),
+                                    _("The maximum scale of the viewport."),
+                                    -1,
+                                    G_MAXFLOAT,
+                                    -1,
+                                    WEBKIT_PARAM_READABLE));
+
+    /**
+     * WebKitViewportAttributs:device-pixel-ratio:
+     *
+     * The device pixel ratio of the viewport. Before getting this property,
+     * you need to make sure that #WebKitViewportAttributes is valid.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_DEVICE_PIXEL_RATIO,
+                                    g_param_spec_float(
+                                    "device-pixel-ratio",
+                                    _("Device Pixel Ratio"),
+                                    _("The device pixel ratio of the viewport."),
+                                    -1,
+                                    G_MAXFLOAT,
+                                    -1,
+                                    WEBKIT_PARAM_READABLE));
+
+    /**
+     * WebKitViewportAttributs:user-scalable:
+     *
+     * Determines whether or not the user can zoom in and out.
+     * Before getting this property, you need to make sure that 
+     * #WebKitViewportAttributes is valid.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_USER_SCALABLE,
+                                    g_param_spec_boolean(
+                                    _("user-scalable"),
+                                    _("User Scalable"),
+                                    _("Determines whether or not the user can zoom in and out."),
+                                    TRUE,
+                                    WEBKIT_PARAM_READABLE));
+
+    /**
+     * WebKitViewportAttributs:valid:
+     *
+     * Determines whether or not the attributes are valid. 
+     * #WebKitViewportAttributes are only valid on pages 
+     * which have a viewport meta tag, and have already 
+     * had the attributes calculated.
+     *
+     * Since: 1.3.8
+     */
+    g_object_class_install_property(gobjectClass,
+                                    PROP_VALID,
+                                    g_param_spec_boolean(
+                                    _("valid"),
+                                    _("Valid"),
+                                    _("Determines whether or not the attributes are valid, and can be used."),
+                                    FALSE,
+                                    WEBKIT_PARAM_READABLE));
+
+    g_type_class_add_private(kclass, sizeof(WebKitViewportAttributesPrivate));
+}
+
+static void webkit_viewport_attributes_init(WebKitViewportAttributes* viewport)
+{
+    viewport->priv = WEBKIT_VIEWPORT_ATTRIBUTES_GET_PRIVATE(viewport);
+
+    viewport->priv->deviceWidth = 0;
+    viewport->priv->deviceHeight = 0;
+    viewport->priv->availableWidth = 0;
+    viewport->priv->availableHeight = 0;
+    viewport->priv->desktopWidth = 980; // This value works well for most web pages designed for desktop browsers.
+    viewport->priv->deviceDPI = 160; // It is the dpi of the original iPhone and Android devices.
+    viewport->priv->width = 0;
+    viewport->priv->height = 0;
+    viewport->priv->initialScaleFactor = -1;
+    viewport->priv->minimumScaleFactor = -1;
+    viewport->priv->maximumScaleFactor = -1;
+    viewport->priv->devicePixelRatio = -1;
+    viewport->priv->userScalable = TRUE;
+    viewport->priv->isValid = FALSE;
+}
+
+static void webkit_viewport_attributes_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* paramSpec)
+{
+    WebKitViewportAttributes* viewportAttributes = WEBKIT_VIEWPORT_ATTRIBUTES(object);
+    WebKitViewportAttributesPrivate* priv = viewportAttributes->priv;
+
+    switch (propertyID) {
+    case PROP_DEVICE_WIDTH:
+        g_value_set_int(value, priv->deviceWidth);
+        break;
+    case PROP_DEVICE_HEIGHT:
+        g_value_set_int(value, priv->deviceHeight);
+        break;
+    case PROP_AVAILABLE_WIDTH:
+        g_value_set_int(value, priv->availableWidth);
+        break;
+    case PROP_AVAILABLE_HEIGHT:
+        g_value_set_int(value, priv->availableHeight);
+        break;
+    case PROP_DESKTOP_WIDTH:
+        g_value_set_int(value, priv->desktopWidth);
+        break;
+    case PROP_DEVICE_DPI:
+        g_value_set_int(value, priv->deviceDPI);
+        break;
+    case PROP_WIDTH:
+        g_value_set_int(value, priv->width);
+        break;
+    case PROP_HEIGHT:
+        g_value_set_int(value, priv->height);
+        break;
+    case PROP_INITIAL_SCALE_FACTOR:
+        g_value_set_float(value, priv->initialScaleFactor);
+        break;
+    case PROP_MINIMUM_SCALE_FACTOR:
+        g_value_set_float(value, priv->minimumScaleFactor);
+        break;
+    case PROP_MAXIMUM_SCALE_FACTOR:
+        g_value_set_float(value, priv->maximumScaleFactor);
+        break;
+    case PROP_DEVICE_PIXEL_RATIO:
+        g_value_set_float(value, priv->devicePixelRatio);
+        break;
+    case PROP_USER_SCALABLE:
+        g_value_set_boolean(value, priv->userScalable);
+        break;
+    case PROP_VALID:
+        g_value_set_boolean(value, priv->isValid);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, paramSpec);
+        break;
+    }
+}
+
+static void webkit_viewport_attributes_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* paramSpec)
+{
+    WebKitViewportAttributes* viewportAttributes = WEBKIT_VIEWPORT_ATTRIBUTES(object);
+    WebKitViewportAttributesPrivate* priv = viewportAttributes->priv;
+
+    switch (propertyID) {
+    case PROP_DEVICE_WIDTH:
+        priv->deviceWidth = g_value_get_int(value);
+        break;
+    case PROP_DEVICE_HEIGHT:
+        priv->deviceHeight = g_value_get_int(value);
+        break;
+    case PROP_AVAILABLE_WIDTH:
+        priv->availableWidth = g_value_get_int(value);
+        break;
+    case PROP_AVAILABLE_HEIGHT:
+        priv->availableHeight = g_value_get_int(value);
+        break;
+    case PROP_DESKTOP_WIDTH:
+        priv->desktopWidth = g_value_get_int(value);
+        break;
+    case PROP_DEVICE_DPI:
+        priv->deviceDPI = g_value_get_int(value);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, paramSpec);
+        break;
+    }
+}
+
+void webkitViewportAttributesRecompute(WebKitViewportAttributes* viewportAttributes)
+{
+    WebKitViewportAttributesPrivate* priv = viewportAttributes->priv;
+    WebKitWebView* webView = priv->webView;
+
+    IntRect windowRect(webView->priv->corePage->chrome()->windowRect());
+    priv->deviceWidth = windowRect.width();
+    priv->deviceHeight = windowRect.height();
+
+    IntRect rect(webView->priv->corePage->chrome()->pageRect());
+    priv->availableWidth = rect.width();
+    priv->availableHeight = rect.height();
+
+    // First of all, we give the application an opportunity to override some of the values.
+    g_signal_emit_by_name(webView, "viewport-attributes-recompute-requested", viewportAttributes);
+
+    ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments();
+
+    ViewportAttributes attributes = computeViewportAttributes(arguments, priv->desktopWidth, priv->deviceWidth, priv->deviceHeight, priv->deviceDPI, IntSize(priv->availableWidth, priv->availableHeight));
+
+    priv->width = attributes.layoutSize.width();
+    priv->height = attributes.layoutSize.height();
+    priv->initialScaleFactor = attributes.initialScale;
+    priv->minimumScaleFactor = attributes.minimumScale;
+    priv->maximumScaleFactor = attributes.maximumScale;
+    priv->devicePixelRatio = attributes.devicePixelRatio;
+    priv->userScalable = arguments.userScalable;
+
+    if (!priv->isValid) {
+        priv->isValid = TRUE;
+        g_object_notify(G_OBJECT(viewportAttributes), "valid");
+    }
+
+    // Now let the application know it is safe to use the new values.
+    g_signal_emit_by_name(webView, "viewport-attributes-changed", viewportAttributes);
+}
+
+/**
+ * webkit_viewport_attributes_recompute:
+ * @viewportAttributes: a #WebKitViewportAttributes
+ *
+ * Recompute the optimal viewport attributes and emit the viewport-attribute-changed signal. 
+ * The viewport-attributes-recompute-requested signal also will be handled to override 
+ * the device size, available size, desktop width, or device DPI.
+ *
+ * Since: 1.3.8
+ */
+void webkit_viewport_attributes_recompute(WebKitViewportAttributes* viewportAttributes)
+{
+    if (!viewportAttributes->priv->isValid)
+        return;
+    webkitViewportAttributesRecompute(viewportAttributes);
+}
diff --git a/WebKit/gtk/webkit/webkitviewportattributes.h b/WebKit/gtk/webkit/webkitviewportattributes.h
new file mode 100644
index 0000000..7d90c1b
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitviewportattributes.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Joone Hur <joone at kldp.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitviewportattributes_h
+#define webkitviewportattributes_h
+
+#include <glib-object.h>
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_VIEWPORT_ATTRIBUTES            (webkit_viewport_attributes_get_type())
+#define WEBKIT_VIEWPORT_ATTRIBUTES(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, WebKitViewportAttributes))
+#define WEBKIT_VIEWPORT_ATTRIBUTES_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, WebKitViewportAttributesClass))
+#define WEBKIT_IS_VIEWPORT_ATTRIBUTES(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_VIEWPORT_ATTRIBUTES))
+#define WEBKIT_IS_VIEWPORT_ATTRIBUTES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_VIEWPORT_ATTRIBUTES))
+#define WEBKIT_VIEWPORT_ATTRIBUTES_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, WebKitViewportAttributesClass))
+
+typedef struct _WebKitViewportAttributesPrivate WebKitViewportAttributesPrivate;
+
+struct _WebKitViewportAttributes {
+    GObject parent_instance;
+
+    /*< private >*/
+    WebKitViewportAttributesPrivate *priv;
+};
+
+struct _WebKitViewportAttributesClass {
+    GObjectClass parent_class;
+
+    /* Padding for future expansion */
+    void (*_webkit_reserved0) (void);
+    void (*_webkit_reserved1) (void);
+    void (*_webkit_reserved2) (void);
+    void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_viewport_attributes_get_type                 (void);
+
+WEBKIT_API void
+webkit_viewport_attributes_recompute(WebKitViewportAttributes* viewportAttributes);
+
+G_END_DECLS
+
+#endif
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 3b87c23..4652c46 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -10,6 +10,7 @@
  *  Copyright (C) 2009, 2010 Igalia S.L.
  *  Copyright (C) 2009 Movial Creative Technologies Inc.
  *  Copyright (C) 2009 Bobby Powers
+ *  Copyright (C) 2010 Joone Hur <joone at kldp.org>
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -174,7 +175,6 @@ enum {
     GEOLOCATION_POLICY_DECISION_CANCELLED,
     ONLOAD_EVENT,
     FRAME_CREATED,
-
     SHOULD_BEGIN_EDITING,
     SHOULD_END_EDITING,
     SHOULD_INSERT_NODE,
@@ -186,6 +186,8 @@ enum {
     EDITING_BEGAN,
     USER_CHANGED_CONTENTS,
     EDITING_ENDED,
+    VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED,
+    VIEWPORT_ATTRIBUTES_CHANGED,
 
     LAST_SIGNAL
 };
@@ -200,6 +202,7 @@ enum {
     PROP_EDITABLE,
     PROP_SETTINGS,
     PROP_WEB_INSPECTOR,
+    PROP_VIEWPORT_ATTRIBUTES,
     PROP_WINDOW_FEATURES,
     PROP_TRANSPARENT,
     PROP_ZOOM_LEVEL,
@@ -525,6 +528,9 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue*
     case PROP_WEB_INSPECTOR:
         g_value_set_object(value, webkit_web_view_get_inspector(webView));
         break;
+    case PROP_VIEWPORT_ATTRIBUTES:
+        g_value_set_object(value, webkit_web_view_get_viewport_attributes(webView));
+        break;
     case PROP_WINDOW_FEATURES:
         g_value_set_object(value, webkit_web_view_get_window_features(webView));
         break;
@@ -1372,6 +1378,7 @@ static void webkit_web_view_dispose(GObject* object)
     }
 
     priv->webInspector.clear();
+    priv->viewportAttributes.clear();
     priv->webWindowFeatures.clear();
     priv->mainResource.clear();
     priv->subResources.clear();
@@ -2735,6 +2742,55 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
         g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
     /*
+     * WebKitWebView::viewport-attributes-recompute-requested
+     * @web_view: the object which received the signal
+     * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes.
+     *
+     * The #WebKitWebView::viewport-attributes-recompute-requested 
+     * signal will be emitted when a page with a viewport meta tag
+     * loads and when webkit_viewport_attributes_recompute is called.
+     *
+     * The #WebKitViewportAttributes will have device size, available size,
+     * desktop width, and device DPI pre-filled by values that make sense 
+     * for the current screen and widget, but you can override those values 
+     * if you have special requirements (for instance, if you made your
+     * widget bigger than the available visible area, you should override 
+     * the available-width and available-height properties to the actual 
+     * visible area).
+     *
+     * Since: 1.3.8
+     */
+    webkit_web_view_signals[VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED] = g_signal_new("viewport-attributes-recompute-requested",
+            G_TYPE_FROM_CLASS(webViewClass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+            0,
+            0, 0,
+            g_cclosure_marshal_VOID__OBJECT,
+            G_TYPE_NONE, 1,
+            WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
+
+    /*
+     * WebKitWebView::viewport-attributes-changed
+     * @web_view: the object which received the signal
+     * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes.
+     *
+     * The #WebKitWebView::viewport-attributes-changed signal will be emitted 
+     * after the emission of #WebKitWebView::viewport-attributes-recompute-requested 
+     * and the subsequent viewport attribute recomputation. At this point, 
+     * if the #WebKitViewportAttributes are valid, the viewport attributes are available.
+     * 
+     * Since: 1.3.8
+     */
+    webkit_web_view_signals[VIEWPORT_ATTRIBUTES_CHANGED] = g_signal_new("viewport-attributes-changed",
+            G_TYPE_FROM_CLASS(webViewClass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+            0,
+            0, 0,
+            g_cclosure_marshal_VOID__OBJECT,
+            G_TYPE_NONE, 1,
+            WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
+
+    /*
      * implementations of virtual methods
      */
     webViewClass->create_web_view = webkit_web_view_real_create_web_view;
@@ -2978,6 +3034,20 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
                                                         WEBKIT_PARAM_READABLE));
 
     /**
+    * WebKitWebView:viewport-attributes:
+    *
+    * The associated #WebKitViewportAttributes instance.
+    *
+    * Since: 1.3.8
+    */
+    g_object_class_install_property(objectClass, PROP_VIEWPORT_ATTRIBUTES,
+                                    g_param_spec_object("viewport-attributes",
+                                                        _("Viewport Attributes"),
+                                                        _("The associated WebKitViewportAttributes instance"),
+                                                        WEBKIT_TYPE_VIEWPORT_ATTRIBUTES,
+                                                        WEBKIT_PARAM_READABLE));
+
+    /**
     * WebKitWebView:window-features:
     *
     * An associated WebKitWebWindowFeatures instance.
@@ -3404,6 +3474,10 @@ static void webkit_web_view_init(WebKitWebView* webView)
     priv->webInspector = adoptPlatformRef(WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL)));
     webkit_web_inspector_set_inspector_client(priv->webInspector.get(), priv->corePage);
 
+    // And our ViewportAttributes friend.
+    priv->viewportAttributes = adoptPlatformRef(WEBKIT_VIEWPORT_ATTRIBUTES(g_object_new(WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, NULL)));
+    priv->viewportAttributes->priv->webView = webView;
+
     // The smart pointer will call g_object_ref_sink on these adjustments.
     priv->horizontalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
     priv->verticalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
@@ -3543,6 +3617,29 @@ WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView)
     return webView->priv->webInspector.get();
 }
 
+/**
+ * webkit_web_view_get_viewport_attributes:
+ * @webView: a #WebKitWebView
+ *
+ * Obtains the #WebKitViewportAttributes associated with the
+ * #WebKitWebView. Every #WebKitWebView object has a
+ * #WebKitWebViewporAttributes object attached to it as soon as it is
+ * created, so this function will only return NULL if the argument is
+ * not a valid #WebKitWebView. Do note however that the viewport
+ * attributes object only contains valid information when the current
+ * page has a viewport meta tag. You can check whether the data should
+ * be used by checking the #WebKitViewport:valid property.
+ *
+ * Return value: (transfer none): the #WebKitViewportAttributes instance.
+ *
+ * Since: 1.3.8
+ */
+WebKitViewportAttributes* webkit_web_view_get_viewport_attributes(WebKitWebView* webView)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+    return webView->priv->viewportAttributes.get();
+}
+
 // internal
 static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures)
 {
diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h
index 514d83c..34c4d5e 100644
--- a/WebKit/gtk/webkit/webkitwebview.h
+++ b/WebKit/gtk/webkit/webkitwebview.h
@@ -427,6 +427,9 @@ webkit_get_cache_model                          (void);
 WEBKIT_API WebKitDOMDocument *
 webkit_web_view_get_dom_document                (WebKitWebView        *webView);
 
+WEBKIT_API WebKitViewportAttributes*
+webkit_web_view_get_viewport_attributes         (WebKitWebView        *webView);
+
 G_END_DECLS
 
 #endif
diff --git a/WebKit/gtk/webkit/webkitwebviewprivate.h b/WebKit/gtk/webkit/webkitwebviewprivate.h
index 66665b2..dec6dad 100644
--- a/WebKit/gtk/webkit/webkitwebviewprivate.h
+++ b/WebKit/gtk/webkit/webkitwebviewprivate.h
@@ -54,6 +54,7 @@ struct _WebKitWebViewPrivate {
     WebCore::Page* corePage;
     PlatformRefPtr<WebKitWebSettings> webSettings;
     PlatformRefPtr<WebKitWebInspector> webInspector;
+    PlatformRefPtr<WebKitViewportAttributes> viewportAttributes;
     PlatformRefPtr<WebKitWebWindowFeatures> webWindowFeatures;
 
     WebKitWebFrame* mainFrame;
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 77fcaf3..afab861 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,27 @@
+2010-12-09  Joone Hur  <joone at kldp.org>
+
+         Reviewed by Martin Robinson.
+
+         [GTK] Support for viewport meta tag
+         https://bugs.webkit.org/show_bug.cgi?id=45443
+
+         Add support for testing the viewport properties for WebKitGtk.
+
+         * DumpRenderTree/LayoutTestController.cpp:
+         (dumpConfigurationForViewportCallback): Added this JS callback to set the size of the visible viewport.
+         (LayoutTestController::staticFunctions):
+         * DumpRenderTree/LayoutTestController.h:
+         * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+         (LayoutTestController::dumpConfigurationForViewport): Added this function to test the viewport properties.
+         * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+         (LayoutTestController::dumpConfigurationForViewport): Ditto.
+         * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
+         (LayoutTestController::dumpConfigurationForViewport): Ditto.
+         * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+         (LayoutTestController::dumpConfigurationForViewport): Ditto.
+         * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
+         (LayoutTestController::dumpConfigurationForViewport): Ditto.
+
 2010-12-08  William Siegrist <wsiegrist at apple.com>
 
         Reviewed by Eric Seidel.
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
index a22579a..5bbd3f6 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Joone Hur <joone at kldp.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -140,6 +141,22 @@ static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JS
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef dumpConfigurationForViewportCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 2)
+        return JSValueMakeUndefined(context);
+
+    double availableWidth = JSValueToNumber(context, arguments[0], exception);
+    ASSERT(!*exception);
+    double availableHeight = JSValueToNumber(context, arguments[1], exception);
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpConfigurationForViewport(static_cast<int>(availableWidth), static_cast<int>(availableHeight));
+   
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef dumpDatabaseCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
@@ -1914,6 +1931,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpConfigurationForViewport", dumpConfigurationForViewportCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h
index 2e9c856..e39c939 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.h
@@ -285,6 +285,8 @@ public:
 
     bool hasSpellingMarker(int from, int length);
 
+    void dumpConfigurationForViewport(int availableWidth, int availableHeight);
+
     // The following API test functions should probably be moved to platform-specific 
     // unit tests outside of DRT once they exist.
     void apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL);
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index 83874f4..835f7d8 100644
--- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -4,6 +4,7 @@
  * Copyright (C) 2008 Nuanti Ltd.
  * Copyright (C) 2009 Jan Michael Alonzo <jmalonzo at gmail.com>
  * Copyright (C) 2009 Collabora Ltd.
+ * Copyright (C) 2010 Joone Hur <joone at kldp.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -819,3 +820,10 @@ bool LayoutTestController::hasSpellingMarker(int, int)
     // FIXME: Implement this.
     return false;
 }
+
+void LayoutTestController::dumpConfigurationForViewport(int availableWidth, int availableHeight)
+{
+    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
+    ASSERT(webView);
+    DumpRenderTreeSupportGtk::dumpConfigurationForViewport(webView, availableWidth, availableHeight);
+}
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index be3eb09..5df941d 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -989,3 +989,7 @@ bool LayoutTestController::hasSpellingMarker(int from, int length)
 {
     return [mainFrame hasSpellingMarker:from length:length];
 }
+void LayoutTestController::dumpConfigurationForViewport(int /*availableWidth*/, int /*availableHeight*/)
+{
+
+}
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index b1a4ef4..edb0517 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -1415,3 +1415,8 @@ bool LayoutTestController::hasSpellingMarker(int from, int length)
         return false;
     return ret;
 }
+
+void LayoutTestController::dumpConfigurationForViewport(int /*availableWidth*/, int /*availableHeight*/)
+{
+    // FIXME: Implement this.
+}
diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
index 120a1b6..714a4c4 100644
--- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
+++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
@@ -511,6 +511,11 @@ bool LayoutTestController::hasSpellingMarker(int, int)
     return false;
 }
 
+void LayoutTestController::dumpConfigurationForViewport(int /*availableWidth*/, int /*availableHeight*/)
+{
+    // FIXME: Implement
+}
+
 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
 {
     // FIXME: Implement

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list