Title: [206067] trunk/Source/WebKit2
Revision
206067
Author
carlo...@webkit.org
Date
2016-09-17 01:34:20 -0700 (Sat, 17 Sep 2016)

Log Message

[GTK] Move the rendering of auth dialog shadow to the auth dialog widget
https://bugs.webkit.org/show_bug.cgi?id=162061

Reviewed by Michael Catanzaro.

Instead of rendering the shadow in the web view, we can let the auth dialog do it. This fixes the rendering of
the shadow in Wayland when using gdk_cairo_draw_from_gl().

* UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:
(webkitAuthenticationDialogDraw): Draw the shadow before rendering the child.
(webkitAuthenticationDialogSizeAllocate): Center the child on the allocated space.
(webkit_authentication_dialog_class_init): Add size_allocate implementation.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseDraw): Do not draw the shadow when auth dialog is present.
(webkitWebViewBaseSizeAllocate): Give the whole web view allocation to the auth dialog.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (206066 => 206067)


--- trunk/Source/WebKit2/ChangeLog	2016-09-17 08:32:15 UTC (rev 206066)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-17 08:34:20 UTC (rev 206067)
@@ -1,5 +1,23 @@
 2016-09-17  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        [GTK] Move the rendering of auth dialog shadow to the auth dialog widget
+        https://bugs.webkit.org/show_bug.cgi?id=162061
+
+        Reviewed by Michael Catanzaro.
+
+        Instead of rendering the shadow in the web view, we can let the auth dialog do it. This fixes the rendering of
+        the shadow in Wayland when using gdk_cairo_draw_from_gl().
+
+        * UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:
+        (webkitAuthenticationDialogDraw): Draw the shadow before rendering the child.
+        (webkitAuthenticationDialogSizeAllocate): Center the child on the allocated space.
+        (webkit_authentication_dialog_class_init): Add size_allocate implementation.
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseDraw): Do not draw the shadow when auth dialog is present.
+        (webkitWebViewBaseSizeAllocate): Give the whole web view allocation to the auth dialog.
+
+2016-09-17  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [ThreadedCompositor] Scrolling artifacts on accelerated subframes
         https://bugs.webkit.org/show_bug.cgi?id=149060
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp (206066 => 206067)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp	2016-09-17 08:32:15 UTC (rev 206066)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp	2016-09-17 08:34:20 UTC (rev 206067)
@@ -204,11 +204,20 @@
 {
     WebKitAuthenticationDialogPrivate* priv = WEBKIT_AUTHENTICATION_DIALOG(widget)->priv;
 
-    gtk_style_context_save(priv->styleContext.get());
-    gtk_style_context_add_class(priv->styleContext.get(), GTK_STYLE_CLASS_BACKGROUND);
-    gtk_render_background(priv->styleContext.get(), cr, 0, 0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
-    gtk_style_context_restore(priv->styleContext.get());
+    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
+    cairo_set_source_rgba(cr, 0, 0, 0, 0.5);
+    cairo_paint(cr);
 
+    if (GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget))) {
+        GtkAllocation allocation;
+        gtk_widget_get_allocation(child, &allocation);
+
+        gtk_style_context_save(priv->styleContext.get());
+        gtk_style_context_add_class(priv->styleContext.get(), GTK_STYLE_CLASS_BACKGROUND);
+        gtk_render_background(priv->styleContext.get(), cr, allocation.x, allocation.y, allocation.width, allocation.height);
+        gtk_style_context_restore(priv->styleContext.get());
+    }
+
     GTK_WIDGET_CLASS(webkit_authentication_dialog_parent_class)->draw(widget, cr);
 
     return FALSE;
@@ -222,6 +231,27 @@
     GTK_WIDGET_CLASS(webkit_authentication_dialog_parent_class)->map(widget);
 }
 
+static void webkitAuthenticationDialogSizeAllocate(GtkWidget* widget, GtkAllocation* allocation)
+{
+    GTK_WIDGET_CLASS(webkit_authentication_dialog_parent_class)->size_allocate(widget, allocation);
+
+    GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget));
+    if (!child)
+        return;
+
+    GtkRequisition naturalSize;
+    gtk_widget_get_preferred_size(child, 0, &naturalSize);
+
+    GtkAllocation childAllocation;
+    gtk_widget_get_allocation(child, &childAllocation);
+
+    childAllocation.x += (allocation->width - naturalSize.width) / 2;
+    childAllocation.y += (allocation->height - naturalSize.height) / 2;
+    childAllocation.width = naturalSize.width;
+    childAllocation.height = naturalSize.height;
+    gtk_widget_size_allocate(child, &childAllocation);
+}
+
 static void webkitAuthenticationDialogConstructed(GObject* object)
 {
     G_OBJECT_CLASS(webkit_authentication_dialog_parent_class)->constructed(object);
@@ -254,6 +284,7 @@
     GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(klass);
     widgetClass->draw = webkitAuthenticationDialogDraw;
     widgetClass->map = webkitAuthenticationDialogMap;
+    widgetClass->size_allocate = webkitAuthenticationDialogSizeAllocate;
 }
 
 GtkWidget* webkitAuthenticationDialogNew(WebKitAuthenticationRequest* request, CredentialStorageMode mode)

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (206066 => 206067)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2016-09-17 08:32:15 UTC (rev 206066)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2016-09-17 08:34:20 UTC (rev 206067)
@@ -542,12 +542,6 @@
         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;
@@ -602,15 +596,10 @@
     // 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);
+        GtkRequisition minimumSize;
+        gtk_widget_get_preferred_size(priv->authenticationDialog, &minimumSize, nullptr);
 
-        GtkAllocation childAllocation = {
-            (viewRect.width() - naturalSize.width) / 2,
-            (viewRect.height() - naturalSize.height) / 2,
-            naturalSize.width,
-            naturalSize.height
-        };
+        GtkAllocation childAllocation = { 0, 0, std::max(minimumSize.width, viewRect.width()), std::max(minimumSize.height, viewRect.height()) };
         gtk_widget_size_allocate(priv->authenticationDialog, &childAllocation);
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to