summaryrefslogtreecommitdiff
path: root/Source/WebKit/gtk/webkit/webkitwebview.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-09 14:16:12 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-09 14:16:12 +0100
commit03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (patch)
tree52599cd0ab782b1768e23ad176f7618f98333cb6 /Source/WebKit/gtk/webkit/webkitwebview.cpp
parentcd44dc59cdfc39534aef4d417e9f3c412e3be139 (diff)
downloadqtwebkit-03e12282df9aa1e1fb05a8b90f1cfc2e08764cec.tar.gz
Imported WebKit commit e09a82039aa4273ab318b71122e92d8e5f233525 (http://svn.webkit.org/repository/webkit/trunk@107223)
Diffstat (limited to 'Source/WebKit/gtk/webkit/webkitwebview.cpp')
-rw-r--r--Source/WebKit/gtk/webkit/webkitwebview.cpp64
1 files changed, 54 insertions, 10 deletions
diff --git a/Source/WebKit/gtk/webkit/webkitwebview.cpp b/Source/WebKit/gtk/webkit/webkitwebview.cpp
index ac6158b44..c22461c74 100644
--- a/Source/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/Source/WebKit/gtk/webkit/webkitwebview.cpp
@@ -648,6 +648,12 @@ static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr)
if (!gdk_cairo_get_clip_rectangle(cr, &clipRect))
return FALSE;
+ WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
+#if USE(TEXTURE_MAPPER_GL)
+ if (priv->acceleratedCompositingContext->renderLayersToWindow(clipRect))
+ return FALSE;
+#endif
+
cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr);
if (rectList->status || !rectList->num_rectangles) {
cairo_rectangle_list_destroy(rectList);
@@ -656,8 +662,8 @@ static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr)
Vector<IntRect> rects;
for (int i = 0; i < rectList->num_rectangles; i++) {
- copyRectFromCairoSurfaceToContext(WEBKIT_WEB_VIEW(widget)->priv->backingStore->cairoSurface(),
- cr, IntSize(), enclosingIntRect(FloatRect(rectList->rectangles[i])));
+ copyRectFromCairoSurfaceToContext(priv->backingStore->cairoSurface(), cr, IntSize(),
+ enclosingIntRect(FloatRect(rectList->rectangles[i])));
}
cairo_rectangle_list_destroy(rectList);
@@ -859,28 +865,52 @@ static void updateChildAllocationFromPendingAllocation(GtkWidget* child, void*)
*allocation = IntRect();
}
-static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
+static void resizeWebViewFromAllocation(WebKitWebView* webView, GtkAllocation* allocation)
{
- GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation);
-
- Page* page = core(WEBKIT_WEB_VIEW(widget));
+ Page* page = core(webView);
IntSize oldSize;
if (FrameView* frameView = page->mainFrame()->view()) {
oldSize = frameView->size();
frameView->resize(allocation->width, allocation->height);
}
- gtk_container_forall(GTK_CONTAINER(widget), updateChildAllocationFromPendingAllocation, 0);
+ gtk_container_forall(GTK_CONTAINER(webView), updateChildAllocationFromPendingAllocation, 0);
WebKit::ChromeClient* chromeClient = static_cast<WebKit::ChromeClient*>(page->chrome()->client());
chromeClient->widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height));
chromeClient->adjustmentWatcher()->updateAdjustmentsFromScrollbars();
#if USE(ACCELERATED_COMPOSITING)
- WEBKIT_WEB_VIEW(widget)->priv->acceleratedCompositingContext->resizeRootLayer(IntSize(allocation->width, allocation->height));
+ webView->priv->acceleratedCompositingContext->resizeRootLayer(IntSize(allocation->width, allocation->height));
#endif
}
+static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
+{
+ GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation);
+
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ if (!gtk_widget_get_mapped(widget)) {
+ webView->priv->needsResizeOnMap = true;
+ return;
+ }
+ resizeWebViewFromAllocation(webView, allocation);
+}
+
+static void webkitWebViewMap(GtkWidget* widget)
+{
+ GTK_WIDGET_CLASS(webkit_web_view_parent_class)->map(widget);
+
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ if (!webView->priv->needsResizeOnMap)
+ return;
+
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+ resizeWebViewFromAllocation(webView, &allocation);
+ webView->priv->needsResizeOnMap = false;
+}
+
static void webkit_web_view_grab_focus(GtkWidget* widget)
{
@@ -941,6 +971,8 @@ static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus
static void webkit_web_view_realize(GtkWidget* widget)
{
+ WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
+
gtk_widget_set_realized(widget, TRUE);
GtkAllocation allocation;
@@ -979,6 +1011,10 @@ static void webkit_web_view_realize(GtkWidget* widget)
attributes_mask |= GDK_WA_COLORMAP;
#endif
GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
+ priv->hasNativeWindow = gdk_window_ensure_native(window);
+#endif
gtk_widget_set_window(widget, window);
gdk_window_set_user_data(window, widget);
@@ -993,8 +1029,6 @@ static void webkit_web_view_realize(GtkWidget* widget)
gtk_style_context_set_background(gtk_widget_get_style_context(widget), window);
#endif
- WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
- WebKitWebViewPrivate* priv = webView->priv;
gtk_im_context_set_client_window(priv->imContext.get(), window);
}
@@ -2767,6 +2801,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
widgetClass->query_tooltip = webkit_web_view_query_tooltip;
widgetClass->show_help = webkit_web_view_show_help;
#endif
+ widgetClass->map = webkitWebViewMap;
GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
containerClass->add = webkit_web_view_container_add;
@@ -3211,6 +3246,10 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
coreSettings->setWebGLEnabled(settingsPrivate->enableWebgl);
#endif
+#if USE(ACCELERATED_COMPOSITING)
+ coreSettings->setAcceleratedCompositingEnabled(settingsPrivate->enableAcceleratedCompositing);
+#endif
+
#if ENABLE(WEB_AUDIO)
coreSettings->setWebAudioEnabled(settingsPrivate->enableWebAudio);
#endif
@@ -3343,6 +3382,11 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
settings->setWebGLEnabled(g_value_get_boolean(&value));
#endif
+#if USE(ACCELERATED_COMPOSITING)
+ else if (name == g_intern_string("enable-accelerated-compositing"))
+ settings->setAcceleratedCompositingEnabled(g_value_get_boolean(&value));
+#endif
+
#if ENABLE(WEB_AUDIO)
else if (name == g_intern_string("enable-webaudio"))
settings->setWebAudioEnabled(g_value_get_boolean(&value));