Unreviewed. Fix GTK4 build with GTK 3.98.4
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 May 2020 13:04:55 +0000 (13:04 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 May 2020 13:04:55 +0000 (13:04 +0000)
.:

* Source/cmake/OptionsGTK.cmake:

Source/WebCore:

* platform/gtk/GtkUtilities.cpp:
(WebCore::convertWidgetPointToScreenPoint):
* platform/gtk/GtkVersioning.h:
(gtk_widget_destroy):
* platform/gtk/PlatformScreenGtk.cpp:
(WebCore::screenDPI):

Source/WebKit:

* PlatformGTK.cmake:
* UIProcess/API/gtk/WebKitPrintOperation.cpp:
(webkitPrintOperationRunDialog):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseAddDialog):
(webkitWebViewBaseRemoveChild):
(webkitWebViewBaseContainerForall):
(webkitWebViewBaseAddWebInspector):
(webkitWebViewBaseRemoveWebInspector):
(webkitWebViewBaseDispose):
(webkitWebViewBaseSizeAllocate):
(webkitWebViewBaseConstructed):
(webkit_web_view_base_class_init):
* UIProcess/API/gtk/WebKitWebViewBase.h: Removed.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp:
(WebKit::RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow):
(WebKit::RemoteWebInspectorProxy::platformSave):
* UIProcess/Inspector/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformCreateFrontendWindow):
(WebKit::WebInspectorProxy::platformAttach):
(WebKit::WebInspectorProxy::platformDetach):
(WebKit::WebInspectorProxy::platformSave):
* UIProcess/gtk/WebContextMenuProxyGtk.cpp:
(WebKit::WebContextMenuProxyGtk::~WebContextMenuProxyGtk):

Tools:

* MiniBrowser/gtk/BrowserTab.c:
(loadChanged):
(browserTabConstructed):
* MiniBrowser/gtk/BrowserWindow.c:
(webViewClose):
(browserWindowSetupToolbarItem):
(browser_window_init):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261912 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/platform/gtk/GtkUtilities.cpp
Source/WebCore/platform/gtk/GtkVersioning.h
Source/WebCore/platform/gtk/PlatformScreenGtk.cpp
Source/WebKit/ChangeLog
Source/WebKit/PlatformGTK.cmake
Source/WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
Source/WebKit/UIProcess/API/gtk3/WebKitWebViewBase.h [moved from Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.h with 100% similarity]
Source/WebKit/UIProcess/API/gtk4/WebKitWebViewBase.h [new file with mode: 0644]
Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp
Source/WebKit/UIProcess/Inspector/gtk/WebInspectorProxyGtk.cpp
Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.cpp
Source/cmake/OptionsGTK.cmake
Tools/ChangeLog
Tools/MiniBrowser/gtk/BrowserTab.c
Tools/MiniBrowser/gtk/BrowserWindow.c

index 2629e25..e0cf764 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Unreviewed. Fix GTK4 build with GTK 3.98.4
+
+        * Source/cmake/OptionsGTK.cmake:
+
 2020-05-18  Michael Catanzaro  <mcatanzaro@gnome.org>
 
         [GTK] Allow gtk-doc and introspection in cross builds
index 8d68fc8..e69f7df 100644 (file)
@@ -1,3 +1,14 @@
+2020-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Unreviewed. Fix GTK4 build with GTK 3.98.4
+
+        * platform/gtk/GtkUtilities.cpp:
+        (WebCore::convertWidgetPointToScreenPoint):
+        * platform/gtk/GtkVersioning.h:
+        (gtk_widget_destroy):
+        * platform/gtk/PlatformScreenGtk.cpp:
+        (WebCore::screenDPI):
+
 2020-05-12  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK4] Add support for drag and drop operations
index aac7702..b4351ed 100644 (file)
@@ -50,7 +50,11 @@ IntPoint convertWidgetPointToScreenPoint(GtkWidget* widget, const IntPoint& poin
     if (!toplevelWidget || !gtk_widget_is_toplevel(toplevelWidget) || !GTK_IS_WINDOW(toplevelWidget))
         return point;
 
+#if USE(GTK4)
+    double xInWindow, yInWindow;
+#else
     int xInWindow, yInWindow;
+#endif
     gtk_widget_translate_coordinates(widget, toplevelWidget, point.x(), point.y(), &xInWindow, &yInWindow);
 
     const auto origin = gtkWindowGetOrigin(toplevelWidget);
index be596e1..1c42896 100644 (file)
@@ -45,6 +45,13 @@ gtk_widget_get_toplevel(GtkWidget* widget)
 }
 
 static inline void
+gtk_widget_destroy(GtkWidget* widget)
+{
+    ASSERT(GTK_IS_WINDOW(widget));
+    gtk_window_destroy(GTK_WINDOW(widget));
+}
+
+static inline void
 gtk_window_get_position(GtkWindow*, int* x, int* y)
 {
     *x = *y = 0;
index 4e977aa..052cc4c 100644 (file)
@@ -117,7 +117,11 @@ double screenDPI()
     GdkDisplay* display = gdk_display_get_default();
     if (!display)
         return defaultDpi;
+#if USE(GTK4)
+    GdkMonitor* monitor = GDK_MONITOR(g_list_model_get_item(gdk_display_get_monitors(display), 0));
+#else
     GdkMonitor* monitor = gdk_display_get_monitor(display, 0);
+#endif
     if (!monitor)
         return defaultDpi;
 
index 3b778fa..f53b869 100644 (file)
@@ -1,3 +1,33 @@
+2020-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Unreviewed. Fix GTK4 build with GTK 3.98.4
+
+        * PlatformGTK.cmake:
+        * UIProcess/API/gtk/WebKitPrintOperation.cpp:
+        (webkitPrintOperationRunDialog):
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseAddDialog):
+        (webkitWebViewBaseRemoveChild):
+        (webkitWebViewBaseContainerForall):
+        (webkitWebViewBaseAddWebInspector):
+        (webkitWebViewBaseRemoveWebInspector):
+        (webkitWebViewBaseDispose):
+        (webkitWebViewBaseSizeAllocate):
+        (webkitWebViewBaseConstructed):
+        (webkit_web_view_base_class_init):
+        * UIProcess/API/gtk/WebKitWebViewBase.h: Removed.
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+        * UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp:
+        (WebKit::RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow):
+        (WebKit::RemoteWebInspectorProxy::platformSave):
+        * UIProcess/Inspector/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::platformCreateFrontendWindow):
+        (WebKit::WebInspectorProxy::platformAttach):
+        (WebKit::WebInspectorProxy::platformDetach):
+        (WebKit::WebInspectorProxy::platformSave):
+        * UIProcess/gtk/WebContextMenuProxyGtk.cpp:
+        (WebKit::WebContextMenuProxyGtk::~WebContextMenuProxyGtk):
+
 2020-05-12  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK4] Add support for drag and drop operations
index f829dc3..b94522c 100644 (file)
@@ -76,6 +76,7 @@ set(WebKit2GTK_INSTALLED_HEADERS
     ${DERIVED_SOURCES_WEBKIT2GTK_API_DIR}/WebKitVersion.h
     ${WEBKIT_DIR}/UIProcess/API/gtk${GTK_API_VERSION}/WebKitContextMenuItem.h
     ${WEBKIT_DIR}/UIProcess/API/gtk${GTK_API_VERSION}/WebKitInputMethodContext.h
+    ${WEBKIT_DIR}/UIProcess/API/gtk${GTK_API_VERSION}/WebKitWebViewBase.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitApplicationInfo.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitAuthenticationRequest.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitAutocleanups.h
@@ -135,7 +136,6 @@ set(WebKit2GTK_INSTALLED_HEADERS
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitWebInspector.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitWebResource.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitWebView.h
-    ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitWebViewBase.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitWebViewSessionState.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitWebsiteData.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitWebsiteDataManager.h
index 67eccad..8cae2a2 100644 (file)
@@ -252,6 +252,9 @@ static void notifySelectedPrinterCallback(GtkPrintUnixDialog* dialog, GParamSpec
 
 static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOperation* printOperation, GtkWindow* parent)
 {
+#if USE(GTK4)
+    return WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL;
+#else
     GtkPrintUnixDialog* printDialog = GTK_PRINT_UNIX_DIALOG(gtk_print_unix_dialog_new(0, parent));
     gtk_print_unix_dialog_set_manual_capabilities(printDialog, static_cast<GtkPrintCapabilities>(GTK_PRINT_CAPABILITY_NUMBER_UP
                                                                                                  | GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT
@@ -296,6 +299,7 @@ static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOpe
     gtk_widget_destroy(GTK_WIDGET(printDialog));
 
     return returnValue;
+#endif
 }
 #else
 // TODO: We need to add an implementation for Windows.
index 15f66fd..fd7ee96 100644 (file)
@@ -144,7 +144,9 @@ private:
 };
 #endif
 
+#if !USE(GTK4)
 typedef HashMap<GtkWidget*, IntRect> WebKitWebViewChildrenMap;
+#endif
 typedef HashMap<uint32_t, GUniquePtr<GdkEvent>> TouchEventsMap;
 
 struct _WebKitWebViewBasePrivate {
@@ -177,7 +179,9 @@ struct _WebKitWebViewBasePrivate {
     }
 #endif
 
+#if !USE(GTK4)
     WebKitWebViewChildrenMap children;
+#endif
     std::unique_ptr<PageClientImpl> pageClient;
     RefPtr<WebPageProxy> pageProxy;
     bool shouldForwardNextKeyEvent { false };
@@ -240,7 +244,11 @@ struct _WebKitWebViewBasePrivate {
     std::unique_ptr<PointerLockManager> pointerLockManager;
 };
 
+#if USE(GTK4)
+WEBKIT_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_WIDGET)
+#else
 WEBKIT_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
+#endif
 
 static void webkitWebViewBaseScheduleUpdateActivityState(WebKitWebViewBase* webViewBase, OptionSet<ActivityState::Flag> flagsToUpdate)
 {
@@ -465,6 +473,7 @@ static void webkitWebViewBaseUnrealize(GtkWidget* widget)
     GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->unrealize(widget);
 }
 
+#if !USE(GTK4)
 static bool webkitWebViewChildIsInternalWidget(WebKitWebViewBase* webViewBase, GtkWidget* widget)
 {
     WebKitWebViewBasePrivate* priv = webViewBase->priv;
@@ -486,34 +495,45 @@ static void webkitWebViewBaseContainerAdd(GtkContainer* container, GtkWidget* wi
 
     gtk_widget_set_parent(widget, GTK_WIDGET(container));
 }
+#endif
 
 void webkitWebViewBaseAddDialog(WebKitWebViewBase* webViewBase, GtkWidget* dialog)
 {
     WebKitWebViewBasePrivate* priv = webViewBase->priv;
     priv->dialog = dialog;
-    gtk_container_add(GTK_CONTAINER(webViewBase), dialog);
+    gtk_widget_set_parent(dialog, GTK_WIDGET(webViewBase));
     gtk_widget_show(dialog);
 
     // We need to draw the shadow over the widget.
     gtk_widget_queue_draw(GTK_WIDGET(webViewBase));
 }
 
-void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector, AttachmentSide attachmentSide)
+#if USE(GTK4)
+static void webkitWebViewBaseRemoveChild(WebKitWebViewBase* webViewBase, GtkWidget* widget)
 {
-    if (webViewBase->priv->inspectorView == inspector && webViewBase->priv->inspectorAttachmentSide == attachmentSide)
+    if (!widget)
         return;
 
-    webViewBase->priv->inspectorAttachmentSide = attachmentSide;
+    WebKitWebViewBasePrivate* priv = webViewBase->priv;
+    if (priv->inspectorView == widget) {
+        priv->inspectorView = nullptr;
+        priv->inspectorViewSize = 0;
+    } else if (priv->dialog == widget) {
+        priv->dialog = nullptr;
+        if (gtk_widget_get_visible(GTK_WIDGET(webViewBase)))
+            gtk_widget_grab_focus(GTK_WIDGET(webViewBase));
+    } else if (priv->keyBindingTranslator.widget() == widget)
+        priv->keyBindingTranslator.invalidate();
+    else
+        RELEASE_ASSERT_NOT_REACHED();
 
-    if (webViewBase->priv->inspectorView == inspector) {
-        gtk_widget_queue_resize(GTK_WIDGET(webViewBase));
-        return;
-    }
+    gboolean wasVisible = gtk_widget_get_visible(widget);
+    gtk_widget_unparent(widget);
 
-    webViewBase->priv->inspectorView = inspector;
-    gtk_container_add(GTK_CONTAINER(webViewBase), inspector);
+    if (wasVisible && gtk_widget_get_visible(GTK_WIDGET(webViewBase)))
+        gtk_widget_queue_resize(GTK_WIDGET(webViewBase));
 }
-
+#else
 static void webkitWebViewBaseContainerRemove(GtkContainer* container, GtkWidget* widget)
 {
     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container);
@@ -540,15 +560,8 @@ static void webkitWebViewBaseContainerRemove(GtkContainer* container, GtkWidget*
         gtk_widget_queue_resize(widgetContainer);
 }
 
-#if USE(GTK4)
-static void webkitWebViewBaseContainerForall(GtkContainer* container, GtkCallback callback, gpointer callbackData)
-#else
 static void webkitWebViewBaseContainerForall(GtkContainer* container, gboolean includeInternals, GtkCallback callback, gpointer callbackData)
-#endif
 {
-#if USE(GTK4)
-    bool includeInternals = true;
-#endif
     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container);
     WebKitWebViewBasePrivate* priv = webView->priv;
 
@@ -576,6 +589,35 @@ void webkitWebViewBaseChildMoveResize(WebKitWebViewBase* webView, GtkWidget* chi
     webView->priv->children.set(child, childRect);
     gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webView));
 }
+#endif
+
+void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector, AttachmentSide attachmentSide)
+{
+    if (webViewBase->priv->inspectorView == inspector && webViewBase->priv->inspectorAttachmentSide == attachmentSide)
+        return;
+
+    webViewBase->priv->inspectorAttachmentSide = attachmentSide;
+
+    if (webViewBase->priv->inspectorView == inspector) {
+        gtk_widget_queue_resize(GTK_WIDGET(webViewBase));
+        return;
+    }
+
+    webViewBase->priv->inspectorView = inspector;
+    gtk_widget_set_parent(inspector, GTK_WIDGET(webViewBase));
+}
+
+void webkitWebViewBaseRemoveWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector)
+{
+    if (webViewBase->priv->inspectorView != inspector)
+        return;
+
+#if USE(GTK4)
+    webkitWebViewBaseRemoveChild(webViewBase, inspector);
+#else
+    gtk_container_remove(GTK_CONTAINER(webViewBase), inspector);
+#endif
+}
 
 #if GTK_CHECK_VERSION(3, 24, 0) && !USE(GTK4)
 static void webkitWebViewBaseCompleteEmojiChooserRequest(WebKitWebViewBase* webView, const String& text)
@@ -588,7 +630,13 @@ static void webkitWebViewBaseCompleteEmojiChooserRequest(WebKitWebViewBase* webV
 static void webkitWebViewBaseDispose(GObject* gobject)
 {
     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(gobject);
+#if USE(GTK4)
+    webkitWebViewBaseRemoveChild(webView, webView->priv->dialog);
+    webkitWebViewBaseRemoveChild(webView, webView->priv->inspectorView);
+    webkitWebViewBaseRemoveChild(webView, webView->priv->keyBindingTranslator.widget());
+#else
     g_clear_pointer(&webView->priv->dialog, gtk_widget_destroy);
+#endif
     webkitWebViewBaseSetToplevelOnScreenWindow(webView, nullptr);
     if (webView->priv->accessible)
         webkitWebViewAccessibleSetWebView(WEBKIT_WEB_VIEW_ACCESSIBLE(webView->priv->accessible.get()), nullptr);
@@ -660,6 +708,7 @@ static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
 }
 #endif
 
+#if !USE(GTK4)
 static void webkitWebViewBaseChildAllocate(GtkWidget* child, gpointer userData)
 {
     if (!gtk_widget_get_visible(child))
@@ -675,6 +724,7 @@ static void webkitWebViewBaseChildAllocate(GtkWidget* child, gpointer userData)
     gtk_widget_size_allocate(child, &childAllocation);
     priv->children.set(child, IntRect());
 }
+#endif
 
 #if USE(GTK4)
 static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, int width, int height, int baseline)
@@ -691,7 +741,9 @@ static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allo
 #endif
 
     WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+#if !USE(GTK4)
     gtk_container_foreach(GTK_CONTAINER(webViewBase), webkitWebViewBaseChildAllocate, webViewBase);
+#endif
 
     IntRect viewRect(allocation->x, allocation->y, allocation->width, allocation->height);
     WebKitWebViewBasePrivate* priv = webViewBase->priv;
@@ -1630,7 +1682,7 @@ static void webkitWebViewBaseConstructed(GObject* object)
 
     WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(object)->priv;
     priv->pageClient = makeUnique<PageClientImpl>(viewWidget);
-    gtk_container_add(GTK_CONTAINER(viewWidget), priv->keyBindingTranslator.widget());
+    gtk_widget_set_parent(priv->keyBindingTranslator.widget(), viewWidget);
 
 #if ENABLE(DRAG_SUPPORT)
     priv->dropTarget = makeUnique<DropTarget>(viewWidget);
@@ -1716,10 +1768,12 @@ static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebVie
     gobjectClass->constructed = webkitWebViewBaseConstructed;
     gobjectClass->dispose = webkitWebViewBaseDispose;
 
+#if !USE(GTK4)
     GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webkitWebViewBaseClass);
     containerClass->add = webkitWebViewBaseContainerAdd;
     containerClass->remove = webkitWebViewBaseContainerRemove;
     containerClass->forall = webkitWebViewBaseContainerForall;
+#endif
 
     // Before creating a WebKitWebViewBasePriv we need to be sure that WebKit is started.
     // Usually starting a context triggers InitializeWebKit2, but in case
index 703e36d..ed62279 100644 (file)
@@ -71,6 +71,7 @@ bool webkitWebViewBaseIsInWindow(WebKitWebViewBase*);
 
 void webkitWebViewBaseAddDialog(WebKitWebViewBase*, GtkWidget*);
 void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector, WebKit::AttachmentSide);
+void webkitWebViewBaseRemoveWebInspector(WebKitWebViewBase*, GtkWidget*);
 void webkitWebViewBaseResetClickCounter(WebKitWebViewBase*);
 void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase*, const WebKit::LayerTreeContext&);
 void webkitWebViewBaseUpdateAcceleratedCompositingMode(WebKitWebViewBase*, const WebKit::LayerTreeContext&);
diff --git a/Source/WebKit/UIProcess/API/gtk4/WebKitWebViewBase.h b/Source/WebKit/UIProcess/API/gtk4/WebKitWebViewBase.h
new file mode 100644 (file)
index 0000000..ff69295
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitWebViewBase_h
+#define WebKitWebViewBase_h
+
+#include <gtk/gtk.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_VIEW_BASE              (webkit_web_view_base_get_type())
+#define WEBKIT_WEB_VIEW_BASE(object)           (G_TYPE_CHECK_INSTANCE_CAST((object), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBase))
+#define WEBKIT_WEB_VIEW_BASE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBaseClass))
+#define WEBKIT_IS_WEB_VIEW_BASE(object)        (G_TYPE_CHECK_INSTANCE_TYPE((object), WEBKIT_TYPE_WEB_VIEW_BASE))
+#define WEBKIT_IS_WEB_VIEW_BASE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW_BASE))
+#define WEBKIT_WEB_VIEW_BASE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBaseClass))
+
+typedef struct _WebKitWebViewBase WebKitWebViewBase;
+typedef struct _WebKitWebViewBaseClass WebKitWebViewBaseClass;
+typedef struct _WebKitWebViewBasePrivate WebKitWebViewBasePrivate;
+
+struct _WebKitWebViewBase {
+    GtkWidget parentInstance;
+    /*< private >*/
+    WebKitWebViewBasePrivate* priv;
+};
+
+struct _WebKitWebViewBaseClass {
+    GtkWidgetClass parentClass;
+
+    void (*_webkit_reserved0) (void);
+    void (*_webkit_reserved1) (void);
+    void (*_webkit_reserved2) (void);
+    void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_web_view_base_get_type (void);
+
+G_END_DECLS
+
+#endif /* WebKitWebViewBase_h */
index c56f7f2..3f3f480 100644 (file)
@@ -34,6 +34,7 @@
 #include "WebKitWebViewBasePrivate.h"
 #include "WebPageGroup.h"
 #include <WebCore/CertificateInfo.h>
+#include <WebCore/GtkVersioning.h>
 #include <wtf/text/Base64.h>
 
 namespace WebKit {
@@ -72,8 +73,12 @@ WebPageProxy* RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow()
     g_object_add_weak_pointer(G_OBJECT(m_webView), reinterpret_cast<void**>(&m_webView));
 
     m_window = webkitInspectorWindowNew();
+#if USE(GTK4)
+    gtk_window_set_child(GTK_WINDOW(m_window), m_webView);
+#else
     gtk_container_add(GTK_CONTAINER(m_window), m_webView);
     gtk_widget_show(m_webView);
+#endif
 
     g_object_add_weak_pointer(G_OBJECT(m_window), reinterpret_cast<void**>(&m_window));
     gtk_window_present(GTK_WINDOW(m_window));
@@ -115,14 +120,13 @@ static void remoteFileReplaceContentsCallback(GObject* sourceObject, GAsyncResul
 void RemoteWebInspectorProxy::platformSave(const String& suggestedURL, const String& content, bool base64Encoded, bool forceSaveDialog)
 {
     UNUSED_PARAM(forceSaveDialog);
+#if !USE(GTK4)
 
     GRefPtr<GtkFileChooserNative> dialog = adoptGRef(gtk_file_chooser_native_new("Save File",
         GTK_WINDOW(m_window), GTK_FILE_CHOOSER_ACTION_SAVE, "Save", "Cancel"));
 
     GtkFileChooser* chooser = GTK_FILE_CHOOSER(dialog.get());
-#if !USE(GTK4)
     gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
-#endif
 
     // Some inspector views (Audits for instance) use a custom URI scheme, such
     // as web-inspector. So we can't rely on the URL being a valid file:/// URL
@@ -149,6 +153,7 @@ void RemoteWebInspectorProxy::platformSave(const String& suggestedURL, const Str
     GUniquePtr<char> path(g_file_get_path(file.get()));
     g_file_replace_contents_async(file.get(), data, dataLength, nullptr, false,
         G_FILE_CREATE_REPLACE_DESTINATION, nullptr, remoteFileReplaceContentsCallback, m_inspectorPage);
+#endif
 }
 
 void RemoteWebInspectorProxy::platformAppend(const String&, const String&)
index 95ffd55..479e02c 100644 (file)
@@ -264,8 +264,12 @@ void WebInspectorProxy::platformCreateFrontendWindow()
 
     ASSERT(!m_inspectorWindow);
     m_inspectorWindow = webkitInspectorWindowNew();
+#if USE(GTK4)
+    gtk_window_set_child(GTK_WINDOW(m_inspectorWindow), m_inspectorView);
+#else
     gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
     gtk_widget_show(m_inspectorView);
+#endif
 
     if (!m_inspectedURLString.isEmpty())
         updateInspectorWindowTitle();
@@ -390,9 +394,13 @@ void WebInspectorProxy::platformAttach()
 {
     GRefPtr<GtkWidget> inspectorView = m_inspectorView;
     if (m_inspectorWindow) {
+#if USE(GTK4)
+        gtk_window_set_child(GTK_WINDOW(m_inspectorWindow), nullptr);
+#else
         gtk_container_remove(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
+#endif
         gtk_widget_destroy(m_inspectorWindow);
-        m_inspectorWindow = 0;
+        m_inspectorWindow = nullptr;
     }
 
     // Set a default sizes based on InspectorFrontendClientLocal.
@@ -426,7 +434,7 @@ void WebInspectorProxy::platformDetach()
         // the inspector is opened if the inspector is shown/closed quickly. So,
         // we might not have a parent yet.
         if (GtkWidget* parent = gtk_widget_get_parent(m_inspectorView))
-            gtk_container_remove(GTK_CONTAINER(parent), m_inspectorView);
+            webkitWebViewBaseRemoveWebInspector(WEBKIT_WEB_VIEW_BASE(parent), m_inspectorView);
     }
 
     // Return early if we are not visible. This means the inspector was closed while attached
@@ -486,7 +494,7 @@ static void fileReplaceContentsCallback(GObject* sourceObject, GAsyncResult* res
 void WebInspectorProxy::platformSave(const String& suggestedURL, const String& content, bool base64Encoded, bool forceSaveDialog)
 {
     UNUSED_PARAM(forceSaveDialog);
-
+#if !USE(GTK4)
     GtkWidget* parent = gtk_widget_get_toplevel(m_inspectorView);
     if (!WebCore::widgetIsOnscreenToplevelWindow(parent))
         return;
@@ -495,9 +503,7 @@ void WebInspectorProxy::platformSave(const String& suggestedURL, const String& c
         GTK_WINDOW(parent), GTK_FILE_CHOOSER_ACTION_SAVE, "Save", "Cancel"));
 
     GtkFileChooser* chooser = GTK_FILE_CHOOSER(dialog.get());
-#if !USE(GTK4)
     gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
-#endif
 
     // Some inspector views (Audits for instance) use a custom URI scheme, such
     // as web-inspector. So we can't rely on the URL being a valid file:/// URL
@@ -524,6 +530,7 @@ void WebInspectorProxy::platformSave(const String& suggestedURL, const String& c
     GUniquePtr<char> path(g_file_get_path(file.get()));
     g_file_replace_contents_async(file.get(), data, dataLength, nullptr, false,
         G_FILE_CREATE_REPLACE_DESTINATION, nullptr, fileReplaceContentsCallback, m_inspectorPage);
+#endif
 }
 
 void WebInspectorProxy::platformAppend(const String&, const String&)
index e48063b..49fa685 100644 (file)
@@ -280,7 +280,9 @@ WebContextMenuProxyGtk::~WebContextMenuProxyGtk()
     m_signalHandlers.clear();
 
     gtk_widget_insert_action_group(GTK_WIDGET(m_menu), gContextMenuItemGroup, nullptr);
+#if !USE(GTK4)
     gtk_widget_destroy(m_menu);
+#endif
 }
 
 } // namespace WebKit
index 1b0bb53..17a4aad 100644 (file)
@@ -8,7 +8,7 @@ SET_PROJECT_VERSION(2 29 1)
 
 if (USE_GTK4)
     set(WEBKITGTK_API_VERSION 5.0)
-    set(GTK_MINIMUM_VERSION 3.98.2)
+    set(GTK_MINIMUM_VERSION 3.98.4)
     CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT 0 0 0)
 else ()
     set(WEBKITGTK_API_VERSION 4.0)
index 49505ca..c8a19ae 100644 (file)
@@ -1,3 +1,15 @@
+2020-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Unreviewed. Fix GTK4 build with GTK 3.98.4
+
+        * MiniBrowser/gtk/BrowserTab.c:
+        (loadChanged):
+        (browserTabConstructed):
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (webViewClose):
+        (browserWindowSetupToolbarItem):
+        (browser_window_init):
+
 2020-05-20  Sam Weinig  <weinig@apple.com>
 
         Remove unused Color::getHSV function
index b221685..07d41a9 100644 (file)
@@ -135,18 +135,22 @@ static gboolean decidePolicy(WebKitWebView *webView, WebKitPolicyDecision *decis
     return TRUE;
 }
 
+#if !GTK_CHECK_VERSION(3, 98, 4)
 static void removeChildIfInfoBar(GtkWidget *child, GtkContainer *tab)
 {
     if (GTK_IS_INFO_BAR(child))
         gtk_container_remove(tab, child);
 }
+#endif
 
 static void loadChanged(WebKitWebView *webView, WebKitLoadEvent loadEvent, BrowserTab *tab)
 {
     if (loadEvent != WEBKIT_LOAD_STARTED)
         return;
 
+#if !GTK_CHECK_VERSION(3, 98, 4)
     gtk_container_foreach(GTK_CONTAINER(tab), (GtkCallback)removeChildIfInfoBar, tab);
+#endif
 }
 
 static GtkWidget *createInfoBarQuestionMessage(const char *title, const char *text)
@@ -403,8 +407,12 @@ static void browserTabConstructed(GObject *gObject)
 #endif
 
     GtkWidget *overlay = gtk_overlay_new();
+#if GTK_CHECK_VERSION(3, 98, 4)
+    gtk_box_append(GTK_BOX(tab), overlay);
+#else
     gtk_container_add(GTK_CONTAINER(tab), overlay);
     gtk_widget_show(overlay);
+#endif
 
     tab->statusLabel = gtk_label_new(NULL);
     gtk_widget_set_halign(tab->statusLabel, GTK_ALIGN_START);
index 22b8251..1de214c 100644 (file)
@@ -312,7 +312,11 @@ static void webViewClose(WebKitWebView *webView, BrowserWindow *window)
 {
     int tabsCount = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->notebook));
     if (tabsCount == 1) {
+#if GTK_CHECK_VERSION(3, 98, 4)
+        gtk_window_destroy(GTK_WINDOW(window));
+#else
         gtk_widget_destroy(GTK_WIDGET(window));
+#endif
         return;
     }
 
@@ -320,7 +324,11 @@ static void webViewClose(WebKitWebView *webView, BrowserWindow *window)
     for (i = 0; i < tabsCount; ++i) {
         BrowserTab *tab = (BrowserTab *)gtk_notebook_get_nth_page(GTK_NOTEBOOK(window->notebook), i);
         if (browser_tab_get_web_view(tab) == webView) {
+#if GTK_CHECK_VERSION(3, 98, 4)
+            gtk_notebook_remove_page(GTK_NOTEBOOK(window->notebook), i);
+#else
             gtk_widget_destroy(GTK_WIDGET(tab));
+#endif
             return;
         }
     }
@@ -944,11 +952,11 @@ static void browserWindowTabAddedOrRemoved(GtkNotebook *notebook, BrowserTab *ta
 }
 
 #if GTK_CHECK_VERSION(3, 98, 0)
-static GtkWidget* browserWindowSetupToolbarItem(BrowserWindow* window, GtkContainer* container, const char* namedIcon, GCallback callback)
+static GtkWidget* browserWindowSetupToolbarItem(BrowserWindow* window, GtkBox* box, const char* namedIcon, GCallback callback)
 {
     GtkWidget *button = gtk_button_new_from_icon_name(namedIcon);
     gtk_button_set_has_frame(GTK_BUTTON(button), FALSE);
-    gtk_container_add(container, button);
+    gtk_box_append(box, button);
     g_signal_connect_swapped(button, "clicked", callback, (gpointer)window);
 
     return button;
@@ -1059,9 +1067,9 @@ static void browser_window_init(BrowserWindow *window)
     gtk_center_box_set_center_widget(GTK_CENTER_BOX(toolbar), window->uriEntry);
 
     GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-    window->backItem = browserWindowSetupToolbarItem(window, GTK_CONTAINER(box), "go-previous", G_CALLBACK(goBackCallback));
-    window->forwardItem = browserWindowSetupToolbarItem(window, GTK_CONTAINER(box), "go-next", G_CALLBACK(goForwardCallback));
-    window->reloadOrStopButton = browserWindowSetupToolbarItem(window, GTK_CONTAINER(box), "view-refresh", G_CALLBACK(reloadOrStopCallback));
+    window->backItem = browserWindowSetupToolbarItem(window, GTK_BOX(box), "go-previous", G_CALLBACK(goBackCallback));
+    window->forwardItem = browserWindowSetupToolbarItem(window, GTK_BOX(box), "go-next", G_CALLBACK(goForwardCallback));
+    window->reloadOrStopButton = browserWindowSetupToolbarItem(window, GTK_BOX(box), "view-refresh", G_CALLBACK(reloadOrStopCallback));
     gtk_center_box_set_start_widget(GTK_CENTER_BOX(toolbar), box);
 #else
     GtkWidget *toolbar = gtk_toolbar_new();
@@ -1101,8 +1109,8 @@ static void browser_window_init(BrowserWindow *window)
 #endif
     GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
     window->mainBox = vbox;
-#if GTK_CHECK_VERSION(3, 98, 0)
-    gtk_container_add(GTK_CONTAINER(vbox), toolbar);
+#if GTK_CHECK_VERSION(3, 98, 4)
+    gtk_box_append(GTK_BOX(vbox), toolbar);
 #else
     gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
     gtk_widget_show(toolbar);
@@ -1114,13 +1122,13 @@ static void browser_window_init(BrowserWindow *window)
     g_signal_connect(window->notebook, "page-removed", G_CALLBACK(browserWindowTabAddedOrRemoved), window);
     gtk_notebook_set_show_tabs(GTK_NOTEBOOK(window->notebook), FALSE);
     gtk_notebook_set_show_border(GTK_NOTEBOOK(window->notebook), FALSE);
-#if !GTK_CHECK_VERSION(3, 98, 0)
+#if !GTK_CHECK_VERSION(3, 98, 4)
     gtk_box_pack_start(GTK_BOX(window->mainBox), window->notebook, TRUE, TRUE, 0);
     gtk_widget_show(window->notebook);
     gtk_container_add(GTK_CONTAINER(window), vbox);
     gtk_widget_show(vbox);
 #else
-    gtk_container_add(GTK_CONTAINER(window->mainBox), window->notebook);
+    gtk_box_append(GTK_BOX(window->mainBox), window->notebook);
     gtk_window_set_child(GTK_WINDOW(window), vbox);
 #endif
 }