Changeset 206072 in webkit


Ignore:
Timestamp:
Sep 17, 2016 3:52:16 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r206067 - [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.

Location:
releases/WebKitGTK/webkit-2.14/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog

    r206071 r206072  
     12016-09-17  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Move the rendering of auth dialog shadow to the auth dialog widget
     4        https://bugs.webkit.org/show_bug.cgi?id=162061
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Instead of rendering the shadow in the web view, we can let the auth dialog do it. This fixes the rendering of
     9        the shadow in Wayland when using gdk_cairo_draw_from_gl().
     10
     11        * UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:
     12        (webkitAuthenticationDialogDraw): Draw the shadow before rendering the child.
     13        (webkitAuthenticationDialogSizeAllocate): Center the child on the allocated space.
     14        (webkit_authentication_dialog_class_init): Add size_allocate implementation.
     15        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     16        (webkitWebViewBaseDraw): Do not draw the shadow when auth dialog is present.
     17        (webkitWebViewBaseSizeAllocate): Give the whole web view allocation to the auth dialog.
     18
    1192016-09-17  Carlos Garcia Campos  <cgarcia@igalia.com>
    220
  • releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp

    r190413 r206072  
    205205    WebKitAuthenticationDialogPrivate* priv = WEBKIT_AUTHENTICATION_DIALOG(widget)->priv;
    206206
    207     gtk_style_context_save(priv->styleContext.get());
    208     gtk_style_context_add_class(priv->styleContext.get(), GTK_STYLE_CLASS_BACKGROUND);
    209     gtk_render_background(priv->styleContext.get(), cr, 0, 0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
    210     gtk_style_context_restore(priv->styleContext.get());
     207    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
     208    cairo_set_source_rgba(cr, 0, 0, 0, 0.5);
     209    cairo_paint(cr);
     210
     211    if (GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget))) {
     212        GtkAllocation allocation;
     213        gtk_widget_get_allocation(child, &allocation);
     214
     215        gtk_style_context_save(priv->styleContext.get());
     216        gtk_style_context_add_class(priv->styleContext.get(), GTK_STYLE_CLASS_BACKGROUND);
     217        gtk_render_background(priv->styleContext.get(), cr, allocation.x, allocation.y, allocation.width, allocation.height);
     218        gtk_style_context_restore(priv->styleContext.get());
     219    }
    211220
    212221    GTK_WIDGET_CLASS(webkit_authentication_dialog_parent_class)->draw(widget, cr);
     
    221230
    222231    GTK_WIDGET_CLASS(webkit_authentication_dialog_parent_class)->map(widget);
     232}
     233
     234static void webkitAuthenticationDialogSizeAllocate(GtkWidget* widget, GtkAllocation* allocation)
     235{
     236    GTK_WIDGET_CLASS(webkit_authentication_dialog_parent_class)->size_allocate(widget, allocation);
     237
     238    GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget));
     239    if (!child)
     240        return;
     241
     242    GtkRequisition naturalSize;
     243    gtk_widget_get_preferred_size(child, 0, &naturalSize);
     244
     245    GtkAllocation childAllocation;
     246    gtk_widget_get_allocation(child, &childAllocation);
     247
     248    childAllocation.x += (allocation->width - naturalSize.width) / 2;
     249    childAllocation.y += (allocation->height - naturalSize.height) / 2;
     250    childAllocation.width = naturalSize.width;
     251    childAllocation.height = naturalSize.height;
     252    gtk_widget_size_allocate(child, &childAllocation);
    223253}
    224254
     
    255285    widgetClass->draw = webkitAuthenticationDialogDraw;
    256286    widgetClass->map = webkitAuthenticationDialogMap;
     287    widgetClass->size_allocate = webkitAuthenticationDialogSizeAllocate;
    257288}
    258289
  • releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r205587 r206072  
    543543    }
    544544
    545     if (webViewBase->priv->authenticationDialog) {
    546         cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    547         cairo_set_source_rgba(cr, 0, 0, 0, 0.5);
    548         cairo_paint(cr);
    549     }
    550 
    551545    GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->draw(widget, cr);
    552546
     
    603597    // after calculating the inspector allocation.
    604598    if (priv->authenticationDialog) {
    605         GtkRequisition naturalSize;
    606         gtk_widget_get_preferred_size(priv->authenticationDialog, 0, &naturalSize);
    607 
    608         GtkAllocation childAllocation = {
    609             (viewRect.width() - naturalSize.width) / 2,
    610             (viewRect.height() - naturalSize.height) / 2,
    611             naturalSize.width,
    612             naturalSize.height
    613         };
     599        GtkRequisition minimumSize;
     600        gtk_widget_get_preferred_size(priv->authenticationDialog, &minimumSize, nullptr);
     601
     602        GtkAllocation childAllocation = { 0, 0, std::max(minimumSize.width, viewRect.width()), std::max(minimumSize.height, viewRect.height()) };
    614603        gtk_widget_size_allocate(priv->authenticationDialog, &childAllocation);
    615604    }
Note: See TracChangeset for help on using the changeset viewer.