Changeset 96136 in webkit
- Timestamp:
- Sep 27, 2011 11:32:55 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r96133 r96136 1 2011-09-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Use WebKitWebContext in WebKitWebView 4 https://bugs.webkit.org/show_bug.cgi?id=67990 5 6 Reviewed by Martin Robinson. 7 8 Use webkit_web_context_get_default() instead of 9 WKContextGetSharedProcessContext() and add API to create a view 10 with a given web context and to return the current context 11 associated to the view. 12 13 * GNUmakefile.am: Add new files to compilation. 14 * UIProcess/API/gtk/WebKitPrivate.h: Added. 15 * UIProcess/API/gtk/WebKitWebContext.cpp: 16 (webkitWebContextGetWKContext): Private API to get the WKContext 17 wrapped by the WebKitWebContext. 18 * UIProcess/API/gtk/WebKitWebContextPrivate.h: Added. 19 * UIProcess/API/gtk/WebKitWebView.cpp: 20 (webkitWebViewConstructed): Create the webpage using the web 21 context of the view. 22 (webkitWebViewSetProperty): 23 (webkitWebViewGetProperty): 24 (webkit_web_view_init): 25 (webkit_web_view_class_init): 26 (webkit_web_view_new): Create a new view with the default context. 27 (webkit_web_view_new_with_context): Create a new view with the 28 given context. 29 (webkit_web_view_get_context): Return the context. 30 * UIProcess/API/gtk/WebKitWebView.h: 31 * UIProcess/API/gtk/tests/testwebview.c: Added. 32 (testWebViewDefaultContext): 33 (main): 34 1 35 2011-09-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 36 -
trunk/Source/WebKit2/GNUmakefile.am
r96133 r96136 454 454 Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h \ 455 455 Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp \ 456 Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h \ 456 457 Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h \ 457 458 Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp \ 459 Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h \ 458 460 Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h \ 459 461 Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp \ … … 988 990 # Unit tests 989 991 TEST_PROGS += \ 990 Programs/unittests/webkit2/testwebcontext 992 Programs/unittests/webkit2/testwebcontext \ 993 Programs/unittests/webkit2/testwebview 991 994 992 995 noinst_PROGRAMS += $(TEST_PROGS) … … 1018 1021 Programs_unittests_webkit2_testwebcontext_LDADD = $(webkit2_tests_ldadd) 1019 1022 Programs_unittests_webkit2_testwebcontext_LDFLAGS = $(webkit2_tests_ldflags) 1023 1024 Programs_unittests_webkit2_testwebview_SOURCES = Source/WebKit2/UIProcess/API/gtk/tests/testwebview.c 1025 Programs_unittests_webkit2_testwebview_CFLAGS = $(webkit2_tests_cflags) 1026 Programs_unittests_webkit2_testwebview_LDADD = $(webkit2_tests_ldadd) 1027 Programs_unittests_webkit2_testwebview_LDFLAGS = $(webkit2_tests_ldflags) 1020 1028 1021 1029 # WebKitWebProcess -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
r96133 r96136 21 21 #include "WebKitWebContext.h" 22 22 23 #include "WebKitWebContextPrivate.h" 23 24 #include <WebKit2/WKContext.h> 24 25 #include <WebKit2/WKType.h> … … 75 76 } 76 77 78 WKContextRef webkitWebContextGetWKContext(WebKitWebContext* context) 79 { 80 g_assert(WEBKIT_IS_WEB_CONTEXT(context)); 77 81 82 return context->priv->context; 83 } 84 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r95901 r96136 22 22 23 23 #include "NotImplemented.h" 24 #include "WebKitWebContextPrivate.h" 24 25 #include "WebKitWebViewBasePrivate.h" 26 #include "WebKitPrivate.h" 25 27 #include "WebPageProxy.h" 26 28 #include <WebKit2/WKBase.h> … … 30 32 using namespace WebCore; 31 33 34 enum { 35 PROP_0, 36 37 PROP_WEB_CONTEXT 38 }; 39 40 struct _WebKitWebViewPrivate { 41 WebKitWebContext* context; 42 }; 43 32 44 G_DEFINE_TYPE(WebKitWebView, webkit_web_view, WEBKIT_TYPE_WEB_VIEW_BASE) 45 46 static void webkitWebViewConstructed(GObject* object) 47 { 48 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); 49 50 webkitWebViewBaseCreateWebPage(WEBKIT_WEB_VIEW_BASE(webView), 51 webkitWebContextGetWKContext(webView->priv->context), 0); 52 } 53 54 static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) 55 { 56 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); 57 58 switch (propId) { 59 case PROP_WEB_CONTEXT: 60 webView->priv->context = WEBKIT_WEB_CONTEXT(g_value_get_object(value)); 61 break; 62 default: 63 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); 64 } 65 } 66 67 static void webkitWebViewGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) 68 { 69 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); 70 71 switch (propId) { 72 case PROP_WEB_CONTEXT: 73 g_value_take_object(value, webView->priv->context); 74 break; 75 default: 76 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); 77 } 78 } 33 79 34 80 static void webkit_web_view_init(WebKitWebView* webView) 35 81 { 36 web kitWebViewBaseCreateWebPage(WEBKIT_WEB_VIEW_BASE(webView), WKContextGetSharedProcessContext(), 0);82 webView->priv = G_TYPE_INSTANCE_GET_PRIVATE(webView, WEBKIT_TYPE_WEB_VIEW, WebKitWebViewPrivate); 37 83 } 38 84 39 85 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) 40 86 { 87 GObjectClass* gObjectClass = G_OBJECT_CLASS(webViewClass); 88 89 gObjectClass->constructed = webkitWebViewConstructed; 90 gObjectClass->set_property = webkitWebViewSetProperty; 91 gObjectClass->get_property = webkitWebViewGetProperty; 92 93 g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); 94 95 /** 96 * WebKitWebView:web-context: 97 * 98 * The #WebKitWebContext of the view. 99 */ 100 g_object_class_install_property(gObjectClass, 101 PROP_WEB_CONTEXT, 102 g_param_spec_object("web-context", 103 "Web Context", 104 "The web context for the view", 105 WEBKIT_TYPE_WEB_CONTEXT, 106 static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); 41 107 } 42 108 43 109 // Public API. 110 111 /** 112 * webkit_web_view_new: 113 * 114 * Creates a new #WebKitWebView with the default #WebKitWebContext. 115 * See also webkit_web_view_new_with_context(). 116 * 117 * Returns: The newly created #WebKitWebView widget 118 */ 44 119 GtkWidget* webkit_web_view_new() 45 120 { 46 return GTK_WIDGET(WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, NULL))); 121 return webkit_web_view_new_with_context(webkit_web_context_get_default()); 122 } 123 124 /** 125 * webkit_web_view_new_with_context: 126 * @context: the #WebKitWebContext to be used by the #WebKitWebView 127 * 128 * Creates a new #WebKitWebView with the given #WebKitWebContext. 129 * 130 * Returns: The newly created #WebKitWebView widget 131 */ 132 GtkWidget* webkit_web_view_new_with_context(WebKitWebContext* context) 133 { 134 g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); 135 136 return GTK_WIDGET(g_object_new(WEBKIT_TYPE_WEB_VIEW, "web-context", context, NULL)); 137 } 138 139 /** 140 * webkit_web_view_get_context: 141 * @web_view: a #WebKitWebView 142 * 143 * Gets the web context of @web_view. 144 * 145 * Returns: (transfer-none): the #WebKitWebContext of the view 146 */ 147 WebKitWebContext* webkit_web_view_get_context(WebKitWebView *webView) 148 { 149 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 150 151 return webView->priv->context; 47 152 } 48 153 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
r96121 r96136 24 24 #define WebKitWebView_h 25 25 26 #include <webkit2/WebKitWebContext.h> 26 27 #include <webkit2/WebKitWebViewBase.h> 27 28 … … 61 62 62 63 WK_EXPORT GType 63 webkit_web_view_get_type (void);64 webkit_web_view_get_type (void); 64 65 65 66 WK_EXPORT GtkWidget * 66 webkit_web_view_new (void); 67 webkit_web_view_new (void); 68 69 WK_EXPORT GtkWidget * 70 webkit_web_view_new_with_context (WebKitWebContext *context); 71 72 WK_EXPORT WebKitWebContext * 73 webkit_web_view_get_context (WebKitWebView *web_view); 67 74 68 75 WK_EXPORT void 69 webkit_web_view_load_uri (WebKitWebView*webView,70 const gchar*uri);76 webkit_web_view_load_uri (WebKitWebView *webView, 77 const gchar *uri); 71 78 72 79 WK_EXPORT void 73 webkit_web_view_go_back (WebKitWebView*webView);80 webkit_web_view_go_back (WebKitWebView *webView); 74 81 75 82 WK_EXPORT void 76 webkit_web_view_go_forward (WebKitWebView*webView);83 webkit_web_view_go_forward (WebKitWebView *webView); 77 84 78 85 G_END_DECLS
Note: See TracChangeset
for help on using the changeset viewer.