static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr) { WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webViewBase->priv->pageProxy->drawingArea()); if (!drawingArea) return FALSE; GdkRectangle clipRect; if (!gdk_cairo_get_clip_rectangle(cr, &clipRect)) return FALSE; #if USE(TEXTURE_MAPPER_GL) if (webkitWebViewRenderAcceleratedCompositingResults(webViewBase, drawingArea, cr, &clipRect)) return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->draw(widget, cr); #endif WebCore::Region unpaintedRegion; // This is simply unused. drawingArea->paint(cr, clipRect, unpaintedRegion); if (webViewBase->priv->authenticationDialog) { cairo_set_operator(cr, CAIRO_OPERATOR_OVER); cairo_set_source_rgba(cr, 0, 0, 0, 0.5); cairo_paint(cr); } GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->draw(widget, cr); return FALSE; }
static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation, bool sizeChanged) { gtk_container_foreach(GTK_CONTAINER(webViewBase), webkitWebViewBaseChildAllocate, webViewBase); IntRect viewRect(allocation->x, allocation->y, allocation->width, allocation->height); WebKitWebViewBasePrivate* priv = webViewBase->priv; if (priv->inspectorView) { GtkAllocation childAllocation = viewRect; if (priv->inspectorAttachmentSide == AttachmentSide::Bottom) { int inspectorViewHeight = std::min(static_cast<int>(priv->inspectorViewSize), allocation->height); childAllocation.x = 0; childAllocation.y = allocation->height - inspectorViewHeight; childAllocation.height = inspectorViewHeight; viewRect.setHeight(std::max(allocation->height - inspectorViewHeight, 1)); } else { int inspectorViewWidth = std::min(static_cast<int>(priv->inspectorViewSize), allocation->width); childAllocation.y = 0; childAllocation.x = allocation->width - inspectorViewWidth; childAllocation.width = inspectorViewWidth; viewRect.setWidth(std::max(allocation->width - inspectorViewWidth, 1)); } gtk_widget_size_allocate(priv->inspectorView, &childAllocation); } // The authentication dialog is centered in the view rect, which means that it // never overlaps the web inspector. Thus, we need to calculate the allocation here // after calculating the inspector allocation. if (priv->authenticationDialog) { GtkRequisition naturalSize; gtk_widget_get_preferred_size(priv->authenticationDialog, 0, &naturalSize); GtkAllocation childAllocation = { (viewRect.width() - naturalSize.width) / 2, (viewRect.height() - naturalSize.height) / 2, naturalSize.width, naturalSize.height }; gtk_widget_size_allocate(priv->authenticationDialog, &childAllocation); } DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea()); #if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11) if (sizeChanged && priv->redirectedWindow && drawingArea && drawingArea->isInAcceleratedCompositingMode()) priv->redirectedWindow->resize(viewRect.size()); #endif if (drawingArea) drawingArea->setSize(viewRect.size(), IntSize(), IntSize()); #if !GTK_CHECK_VERSION(3, 13, 4) webkitWebViewBaseNotifyResizerSize(webViewBase); #endif }
void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase) { #if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11) WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv; if (!priv->redirectedWindow) return; DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea()); if (!drawingArea) return; priv->redirectedWindow->resize(drawingArea->size()); #else UNUSED_PARAM(webkitWebViewBase); #endif }
static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr) { WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webViewBase->priv->pageProxy->drawingArea()); if (!drawingArea) return FALSE; GdkRectangle clipRect; if (!gdk_cairo_get_clip_rectangle(cr, &clipRect)) return FALSE; #if USE(TEXTURE_MAPPER_GL) if (webkitWebViewRenderAcceleratedCompositingResults(webViewBase, drawingArea, cr, &clipRect)) return FALSE; #endif WebCore::Region unpaintedRegion; // This is simply unused. drawingArea->paint(cr, clipRect, unpaintedRegion); return FALSE; }
static void webkitWebViewBaseRealize(GtkWidget* widget) { WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget); WebKitWebViewBasePrivate* priv = webView->priv; #if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11) GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); if (GDK_IS_X11_DISPLAY(display)) { priv->redirectedWindow = RedirectedXCompositeWindow::create( gtk_widget_get_parent_window(widget), [webView] { DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webView->priv->pageProxy->drawingArea()); if (drawingArea && drawingArea->isInAcceleratedCompositingMode()) gtk_widget_queue_draw(GTK_WIDGET(webView)); }); if (priv->redirectedWindow) { DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea()); drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID()); } } #endif gtk_widget_set_realized(widget, TRUE); GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); GdkWindowAttr attributes; attributes.window_type = GDK_WINDOW_CHILD; attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON3_MOTION_MASK | GDK_TOUCH_MASK; gint attributesMask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributesMask); gtk_widget_set_window(widget, window); gdk_window_set_user_data(window, widget); gtk_style_context_set_background(gtk_widget_get_style_context(widget), window); gtk_im_context_set_client_window(priv->inputMethodFilter.context(), window); GtkWidget* toplevel = gtk_widget_get_toplevel(widget); if (widgetIsOnscreenToplevelWindow(toplevel)) webkitWebViewBaseSetToplevelOnScreenWindow(webView, GTK_WINDOW(toplevel)); }