[Webkit-unassigned] [Bug 45443] [GTK] Support for viewport meta tag

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 9 07:58:55 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=45443





--- Comment #55 from Joone Hur <joone at kldp.org>  2010-11-09 07:58:55 PST ---
(In reply to comment #54)
> (From update of attachment 73192 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=73192&action=review
> 
> > WebKit/gtk/webkit/webkitviewportattributes.cpp:301
> > + */
> > +void webkit_viewport_attributes_recompute(WebKitWebView* webView)
> > +{
> > +    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
> > +
> > +    GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(webView));
> > +    FloatRect rect = webView->priv->corePage->chrome()->pageRect();
> > +    ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments();
> > +    // The DesktopWidth has 980, because this value works well for most web pages designed for desktop user agents.
> > +    ViewportAttributes attrs = computeViewportAttributes(arguments, 980, gdk_screen_get_width(screen), gdk_screen_get_height(screen), webkit_web_view_get_dpi(webView), IntSize(static_cast<gint>(rect.width()), static_cast<gint>(rect.height())));
> > +    PlatformRefPtr<WebKitViewportAttributes> viewportAttributes(adoptPlatformRef(webkit_viewport_attributes_new(attrs, arguments.userScalable)));
> > +
> > +    g_signal_emit_by_name(webView, "viewport-attributes-changed", viewportAttributes.get()); 
> 
> I still don't understand your choice of only firing the signal after you have computed the values. Can you describe to me how you would use this API in a browser?

The example is included in the source file.

* <informalexample><programlisting>
 * /<!-- -->* Connect to the viewport-attributes-changes signal *<!-- -->/
 * g_signal_connect (webView, "viewport-attributes-changed", G_CALLBACK (viewport_change_cb), webView);
 g_signal_connect (web_view, "size-allocate", G_CALLBACK(window_size_change_cb), web_view);
 *
 * /<!-- -->* Handle the signal to get the initial scale value *<!-- -->/
 * static void
 * viewport_change_cb(WebKitWebView* webView, WebKitViewportAttributes* viewportAttributes)
 * {
 *     gfloat initialScale; 
 *     g_object_get(G_OBJECT(viewportAttributes), "initial-scale-factor", &initialScale, NULL);
 *     webkit_web_view_set_full_content_zoom(webView, TRUE);
 *     webkit_web_view_set_zoom_level(webView, initialScale);
 * }
 * </programlisting></informalexample>
 */

When the size of the viewport changes, we need to recompute the viewport attribute as follows,

static int window_width = 0;
static void
window_size_change_cb(WebKitWebView* web_view, GtkAllocation* allocation, gpointer user_data)
{
    if (window_width != allocation->width)
      webkit_viewport_attributes_recompute(web_view);   
    window_width = allocation->width;
}

This example code makes the browser work like Safari on the iPhone.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list