Changeset 246669 in webkit


Ignore:
Timestamp:
Jun 20, 2019 10:15:06 PM (5 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Stop pretending WebCore::Widget can have a platform widget
https://bugs.webkit.org/show_bug.cgi?id=199066

Reviewed by Michael Catanzaro.

Source/WebCore:

That was only possible in legacy WebKit that we no longer support. The code can be simplified a bit.

  • platform/Widget.cpp:

(WebCore::Widget::init):

  • platform/Widget.h:

(WebCore::Widget::setPlatformWidget):
(WebCore::Widget::releasePlatformWidget): Deleted.
(WebCore::Widget::retainPlatformWidget): Deleted.

  • platform/gtk/PlatformScreenGtk.cpp:

(WebCore::systemVisual):
(WebCore::screenDepth):
(WebCore::screenDepthPerComponent):
(WebCore::screenRect):
(WebCore::screenAvailableRect):
(WebCore::getToplevel): Deleted.
(WebCore::getVisual): Deleted.
(WebCore::getScreen): Deleted.

  • platform/gtk/WidgetGtk.cpp:

(WebCore::Widget::~Widget):
(WebCore::Widget::show):
(WebCore::Widget::hide):
(WebCore::Widget::setIsSelected):
(WebCore::Widget::setFrameRect):
(WebCore::Widget::releasePlatformWidget): Deleted.
(WebCore::Widget::retainPlatformWidget): Deleted.

  • platform/ios/WidgetIOS.mm:

(WebCore::Widget::~Widget):

Source/WebKit:

Rename PlatformWidget as PlatformViewWidget to avoid conflict with PlatformWidget defined in WebCore.

  • UIProcess/WebPageProxy.h:
  • UIProcess/win/WebPageProxyWin.cpp:

(WebKit::WebPageProxy::viewWidget):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r246668 r246669  
     12019-06-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Stop pretending WebCore::Widget can have a platform widget
     4        https://bugs.webkit.org/show_bug.cgi?id=199066
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        That was only possible in legacy WebKit that we no longer support. The code can be simplified a bit.
     9
     10        * platform/Widget.cpp:
     11        (WebCore::Widget::init):
     12        * platform/Widget.h:
     13        (WebCore::Widget::setPlatformWidget):
     14        (WebCore::Widget::releasePlatformWidget): Deleted.
     15        (WebCore::Widget::retainPlatformWidget): Deleted.
     16        * platform/gtk/PlatformScreenGtk.cpp:
     17        (WebCore::systemVisual):
     18        (WebCore::screenDepth):
     19        (WebCore::screenDepthPerComponent):
     20        (WebCore::screenRect):
     21        (WebCore::screenAvailableRect):
     22        (WebCore::getToplevel): Deleted.
     23        (WebCore::getVisual): Deleted.
     24        (WebCore::getScreen): Deleted.
     25        * platform/gtk/WidgetGtk.cpp:
     26        (WebCore::Widget::~Widget):
     27        (WebCore::Widget::show):
     28        (WebCore::Widget::hide):
     29        (WebCore::Widget::setIsSelected):
     30        (WebCore::Widget::setFrameRect):
     31        (WebCore::Widget::releasePlatformWidget): Deleted.
     32        (WebCore::Widget::retainPlatformWidget): Deleted.
     33        * platform/ios/WidgetIOS.mm:
     34        (WebCore::Widget::~Widget):
     35
    1362019-06-20  Simon Fraser  <simon.fraser@apple.com>
    237
  • trunk/Source/WebCore/platform/Widget.cpp

    r245868 r246669  
    3939    m_parentVisible = false;
    4040    m_widget = widget;
    41     if (m_widget)
    42         retainPlatformWidget();
    4341}
    4442
  • trunk/Source/WebCore/platform/Widget.h

    r245868 r246669  
    5151typedef struct HWND__* HWND;
    5252typedef HWND PlatformWidget;
    53 #elif PLATFORM(GTK)
    54 typedef struct _GtkWidget GtkWidget;
    55 typedef struct _GtkContainer GtkContainer;
    56 typedef GtkWidget* PlatformWidget;
    5753#else
    5854typedef void* PlatformWidget;
     
    201197    void init(PlatformWidget); // Must be called by all Widget constructors to initialize cross-platform data.
    202198
    203     void releasePlatformWidget();
    204     void retainPlatformWidget();
    205 
    206199    // These methods are used to convert from the root widget to the containing window,
    207200    // which has behavior that may differ between platforms (e.g. Mac uses flipped window coordinates).
     
    235228inline void Widget::setPlatformWidget(PlatformWidget widget)
    236229{
    237     if (widget != m_widget) {
    238         releasePlatformWidget();
    239         m_widget = widget;
    240         retainPlatformWidget();
    241     }
    242 }
    243 
    244 #endif
    245 
    246 #if !PLATFORM(GTK)
    247 
    248 inline void Widget::releasePlatformWidget()
    249 {
    250 }
    251 
    252 inline void Widget::retainPlatformWidget()
    253 {
     230    m_widget = widget;
    254231}
    255232
  • trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp

    r246632 r246669  
    4747namespace WebCore {
    4848
    49 static GtkWidget* getToplevel(GtkWidget* widget)
    50 {
    51     GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
    52     return gtk_widget_is_toplevel(toplevel) ? toplevel : 0;
    53 }
    54 
    55 static GdkVisual* getVisual(Widget* widget)
    56 {
    57     GtkWidget* container = widget ? GTK_WIDGET(widget->root()->hostWindow()->platformPageClient()) : 0;
    58     if (!container) {
    59         GdkScreen* screen = gdk_screen_get_default();
    60         return screen ? gdk_screen_get_system_visual(screen) : 0;
    61     }
    62 
    63     if (!gtk_widget_get_realized(container))
    64         container = getToplevel(container);
    65     return container ? gdk_window_get_visual(gtk_widget_get_window(container)) : 0;
    66 }
    67 
    68 int screenDepth(Widget* widget)
    69 {
    70     GdkVisual* visual = getVisual(widget);
    71     if (!visual)
    72         return 24;
    73     return gdk_visual_get_depth(visual);
    74 }
    75 
    76 int screenDepthPerComponent(Widget* widget)
    77 {
    78     GdkVisual* visual = getVisual(widget);
    79     if (!visual)
    80         return 8;
    81 
    82     return gdk_visual_get_bits_per_rgb(visual);
     49static GdkVisual* systemVisual()
     50{
     51    if (auto* screen = gdk_screen_get_default())
     52        return gdk_screen_get_system_visual(screen);
     53
     54    return nullptr;
     55}
     56
     57int screenDepth(Widget*)
     58{
     59    if (auto* visual = systemVisual())
     60        return gdk_visual_get_depth(visual);
     61
     62    return 24;
     63}
     64
     65int screenDepthPerComponent(Widget*)
     66{
     67    if (auto* visual = systemVisual())
     68        return gdk_visual_get_bits_per_rgb(visual);
     69
     70    return 8;
    8371}
    8472
     
    150138}
    151139
    152 #if !GTK_CHECK_VERSION(3, 22, 0)
    153 static GdkScreen* getScreen(GtkWidget* widget)
    154 {
    155     return gtk_widget_has_screen(widget) ? gtk_widget_get_screen(widget) : gdk_screen_get_default();
    156 }
    157 #endif
    158 
    159 FloatRect screenRect(Widget* widget)
    160 {
    161     GtkWidget* container = widget ? GTK_WIDGET(widget->root()->hostWindow()->platformPageClient()) : 0;
    162     if (container)
    163         container = getToplevel(container);
    164 
     140FloatRect screenRect(Widget*)
     141{
    165142    GdkRectangle geometry;
    166143#if GTK_CHECK_VERSION(3, 22, 0)
    167     GdkDisplay* display = container ? gtk_widget_get_display(container) : gdk_display_get_default();
    168     if (!display)
    169         return FloatRect();
    170 
    171     GdkMonitor* monitor = container ? gdk_display_get_monitor_at_window(display, gtk_widget_get_window(container)) : gdk_display_get_monitor(display, 0);
     144    GdkDisplay* display = gdk_display_get_default();
     145    if (!display)
     146        return { };
     147
     148    auto* monitor = gdk_display_get_monitor(display, 0);
     149    if (!monitor)
     150        return { };
    172151
    173152    gdk_monitor_get_geometry(monitor, &geometry);
    174153#else
    175     GdkScreen* screen = container ? getScreen(container) : gdk_screen_get_default();
     154    GdkScreen* screen = gdk_screen_get_default();
     155    if (!screen)
     156        return { };
     157
     158    gdk_screen_get_monitor_geometry(screen, 0, &geometry);
     159#endif // !GTK_CHECK_VERSION(3, 22, 0)
     160
     161    return FloatRect(geometry.x, geometry.y, geometry.width, geometry.height);
     162}
     163
     164FloatRect screenAvailableRect(Widget*)
     165{
     166    GdkRectangle workArea;
     167#if GTK_CHECK_VERSION(3, 22, 0)
     168    GdkDisplay* display = gdk_display_get_default();
     169    if (!display)
     170        return { };
     171
     172    auto* monitor = gdk_display_get_monitor(display, 0);
     173    if (!monitor)
     174        return { };
     175
     176    gdk_monitor_get_workarea(monitor, &workArea);
     177#else
     178    GdkScreen* screen = gdk_screen_get_default();
    176179    if (!screen)
    177180        return FloatRect();
    178181
    179     gint monitor = container ? gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(container)) : 0;
    180 
    181     gdk_screen_get_monitor_geometry(screen, monitor, &geometry);
     182    gdk_screen_get_monitor_workarea(screen, 0, &workArea);
    182183#endif // !GTK_CHECK_VERSION(3, 22, 0)
    183184
    184     return FloatRect(geometry.x, geometry.y, geometry.width, geometry.height);
    185 }
    186 
    187 FloatRect screenAvailableRect(Widget* widget)
    188 {
    189     GtkWidget* container = widget ? GTK_WIDGET(widget->root()->hostWindow()->platformPageClient()) : 0;
    190     if (container && !gtk_widget_get_realized(container))
    191         return screenRect(widget);
    192 
    193     GdkRectangle workArea;
    194 #if GTK_CHECK_VERSION(3, 22, 0)
    195     GdkDisplay* display = container ? gtk_widget_get_display(container) : gdk_display_get_default();
    196     if (!display)
    197         return FloatRect();
    198 
    199     GdkMonitor* monitor = container ? gdk_display_get_monitor_at_window(display, gtk_widget_get_window(container)) : gdk_display_get_monitor(display, 0);
    200 
    201     gdk_monitor_get_workarea(monitor, &workArea);
    202 #else
    203     GdkScreen* screen = container ? getScreen(container) : gdk_screen_get_default();
    204     if (!screen)
    205         return FloatRect();
    206 
    207     gint monitor = container ? gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(container)) : 0;
    208 
    209     gdk_screen_get_monitor_workarea(screen, monitor, &workArea);
    210 #endif // !GTK_CHECK_VERSION(3, 22, 0)
    211 
    212185    return FloatRect(workArea.x, workArea.y, workArea.width, workArea.height);
    213 
    214186}
    215187
  • trunk/Source/WebCore/platform/gtk/WidgetGtk.cpp

    r246632 r246669  
    3131#include "Cursor.h"
    3232#include "FrameView.h"
    33 #include "GraphicsContext.h"
    3433#include "HostWindow.h"
    3534#include "IntRect.h"
    36 
    37 #include <gdk/gdk.h>
    38 #include <gtk/gtk.h>
    3935
    4036namespace WebCore {
     
    4339{
    4440    ASSERT(!parent());
    45 
    46     releasePlatformWidget();
    4741}
    4842
     
    6256{
    6357    setSelfVisible(true);
    64 
    65     if (isParentVisible() && platformWidget())
    66         gtk_widget_show(platformWidget());
    6758}
    6859
     
    7061{
    7162    setSelfVisible(false);
    72 
    73     if (isParentVisible() && platformWidget())
    74         gtk_widget_hide(platformWidget());
    7563}
    7664
     
    7967}
    8068
    81 void Widget::setIsSelected(bool isSelected)
     69void Widget::setIsSelected(bool)
    8270{
    83     if (!platformWidget())
    84         return;
    85 
    86     // See if the platformWidget has a webkit-widget-is-selected property
    87     // and set it afterwards.
    88     GParamSpec* spec = g_object_class_find_property(G_OBJECT_GET_CLASS(platformWidget()),
    89                                                     "webkit-widget-is-selected");
    90     if (!spec)
    91         return;
    92 
    93     g_object_set(platformWidget(), "webkit-widget-is-selected", isSelected, NULL);
    9471}
    9572
     
    9774{
    9875    m_frame = rect;
    99     frameRectsChanged();
    100 }
    101 
    102 void Widget::releasePlatformWidget()
    103 {
    104     if (!platformWidget())
    105          return;
    106     g_object_unref(platformWidget());
    107 }
    108 
    109 void Widget::retainPlatformWidget()
    110 {
    111     if (!platformWidget())
    112          return;
    113     g_object_ref_sink(platformWidget());
    11476}
    11577
  • trunk/Source/WebCore/platform/ios/WidgetIOS.mm

    r237266 r246669  
    6363}
    6464
    65 Widget::~Widget()
    66 {
    67     releasePlatformWidget();
     65Widget::~Widget()
     66{
    6867}
    6968
  • trunk/Source/WebKit/ChangeLog

    r246665 r246669  
     12019-06-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Stop pretending WebCore::Widget can have a platform widget
     4        https://bugs.webkit.org/show_bug.cgi?id=199066
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Rename PlatformWidget as PlatformViewWidget to avoid conflict with PlatformWidget defined in WebCore.
     9
     10        * UIProcess/WebPageProxy.h:
     11        * UIProcess/win/WebPageProxyWin.cpp:
     12        (WebKit::WebPageProxy::viewWidget):
     13
    1142019-06-20  Megan Gardner  <megan_gardner@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r246596 r246669  
    218218
    219219#if PLATFORM(GTK)
    220 typedef GtkWidget* PlatformWidget;
     220typedef GtkWidget* PlatformViewWidget;
    221221#endif
    222222
     
    230230
    231231#if PLATFORM(WIN)
    232 typedef HWND PlatformWidget;
     232typedef HWND PlatformViewWidget;
    233233#endif
    234234
     
    805805
    806806#if PLATFORM(GTK)
    807     PlatformWidget viewWidget();
     807    PlatformViewWidget viewWidget();
    808808    bool makeGLContextCurrent();
    809809#endif
     
    813813
    814814#if PLATFORM(WIN)
    815     PlatformWidget viewWidget();
     815    PlatformViewWidget viewWidget();
    816816#endif
    817817#if PLATFORM(WPE)
  • trunk/Source/WebKit/UIProcess/win/WebPageProxyWin.cpp

    r244897 r246669  
    6666}
    6767
    68 PlatformWidget WebPageProxy::viewWidget()
     68PlatformViewWidget WebPageProxy::viewWidget()
    6969{
    7070    return static_cast<PageClientImpl&>(pageClient()).viewWidget();
Note: See TracChangeset for help on using the changeset viewer.