Changeset 176513 in webkit


Ignore:
Timestamp:
Nov 24, 2014 3:18:55 AM (9 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] WebKitWebView is created with the wrong web context when using webkit_web_view_new_with_related_view()
https://bugs.webkit.org/show_bug.cgi?id=139023

Reviewed by Sergio Villar Senin.

Source/WebKit2:

The WebKitWebContext is a construct only property, so it's always
set to the default value when not provided, during the
construction. When a related-view is used to create a new web view
we should ensure that the same web context is used for the new web
view, instead of the default. We should also ignore any web
context given as construct parameter if a related view is alos provided.

  • UIProcess/API/gtk/WebKitWebView.cpp:

(webkitWebViewConstructed): Do not set the context to the default
one when not given during construction.
(webkitWebViewSetProperty): Only use the default web context when
not provided as construct parameter and there isn't a related view.

Tools:

Rename WebKitWebView/default-context as WebKitWebView/web-context
and check we are always using the right context for new web views.

  • TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:

(testWebViewWebContext):
(beforeAll):
(testWebViewDefaultContext): Deleted.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r176512 r176513  
     12014-11-24  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] WebKitWebView is created with the wrong web context when using webkit_web_view_new_with_related_view()
     4        https://bugs.webkit.org/show_bug.cgi?id=139023
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        The WebKitWebContext is a construct only property, so it's always
     9        set to the default value when not provided, during the
     10        construction. When a related-view is used to create a new web view
     11        we should ensure that the same web context is used for the new web
     12        view, instead of the default. We should also ignore any web
     13        context given as construct parameter if a related view is alos provided.
     14
     15        * UIProcess/API/gtk/WebKitWebView.cpp:
     16        (webkitWebViewConstructed): Do not set the context to the default
     17        one when not given during construction.
     18        (webkitWebViewSetProperty): Only use the default web context when
     19        not provided as construct parameter and there isn't a related view.
     20
    1212014-11-23  Carlos Garcia Campos  <cgarcia@igalia.com>
    222
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp

    r175694 r176513  
    565565static void webkitWebViewConstructed(GObject* object)
    566566{
    567     if (G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed)
    568         G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object);
     567    G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object);
    569568
    570569    WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
    571570    WebKitWebViewPrivate* priv = webView->priv;
     571    if (priv->relatedView)
     572        priv->context = webkit_web_view_get_context(priv->relatedView);
     573    else if (!priv->context)
     574        priv->context = webkit_web_context_get_default();
    572575    if (!priv->settings)
    573576        priv->settings = adoptGRef(webkit_settings_new());
     577
    574578    webkitWebContextCreatePageForWebView(priv->context, webView, priv->userContentManager.get(), priv->relatedView);
    575579
     
    604608    case PROP_WEB_CONTEXT: {
    605609        gpointer webContext = g_value_get_object(value);
    606         webView->priv->context = webContext ? WEBKIT_WEB_CONTEXT(webContext) : webkit_web_context_get_default();
     610        webView->priv->context = webContext ? WEBKIT_WEB_CONTEXT(webContext) : nullptr;
    607611        break;
    608612    }
  • trunk/Tools/ChangeLog

    r176512 r176513  
     12014-11-24  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] WebKitWebView is created with the wrong web context when using webkit_web_view_new_with_related_view()
     4        https://bugs.webkit.org/show_bug.cgi?id=139023
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        Rename WebKitWebView/default-context as WebKitWebView/web-context
     9        and check we are always using the right context for new web views.
     10
     11        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
     12        (testWebViewWebContext):
     13        (beforeAll):
     14        (testWebViewDefaultContext): Deleted.
     15
    1162014-11-23  Carlos Garcia Campos  <cgarcia@igalia.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp

    r176260 r176513  
    2525#include <wtf/gobject/GRefPtr.h>
    2626
    27 static void testWebViewDefaultContext(WebViewTest* test, gconstpointer)
     27static void testWebViewWebContext(WebViewTest* test, gconstpointer)
    2828{
    2929    g_assert(webkit_web_view_get_context(test->m_webView) == test->m_webContext.get());
     30    g_assert(webkit_web_context_get_default() != test->m_webContext.get());
    3031
    3132    // Check that a web view created with g_object_new has the default context.
    32     GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, NULL));
     33    GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, nullptr));
    3334    g_assert(webkit_web_view_get_context(webView.get()) == webkit_web_context_get_default());
     35
     36    // Check that a web view created with a related view has the related view context.
     37    webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_related_view(test->m_webView));
     38    g_assert(webkit_web_view_get_context(webView.get()) == test->m_webContext.get());
     39
     40    // Check that a web context given as construct parameter is ignored if a related view is also provided.
     41    webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
     42        "web-context", webkit_web_context_get_default(), "related-view", test->m_webView, nullptr));
     43    g_assert(webkit_web_view_get_context(webView.get()) == test->m_webContext.get());
    3444}
    3545
     
    574584void beforeAll()
    575585{
    576     WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
     586    WebViewTest::add("WebKitWebView", "web-context", testWebViewWebContext);
    577587    WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset);
    578588    WebViewTest::add("WebKitWebView", "settings", testWebViewSettings);
Note: See TracChangeset for help on using the changeset viewer.