Diff
Modified: trunk/LayoutTests/ChangeLog (288103 => 288104)
--- trunk/LayoutTests/ChangeLog 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/LayoutTests/ChangeLog 2022-01-18 00:50:09 UTC (rev 288104)
@@ -1,3 +1,16 @@
+2022-01-17 ChangSeok Oh <[email protected]>
+
+ [GTK] Implement form validation with gtk3 widgets in the UI process
+ https://bugs.webkit.org/show_bug.cgi?id=234629
+
+ Reviewed by Carlos Garcia Campos.
+
+ We skip fast/forms/validation-message-clone.html for now. Although this patch
+ implements a validation bubble with a native widget, related tests cannot be enabled
+ due to missing JS APIs for the UI script controller (e.g., contentsOfUserInterfaceItem).
+
+ * platform/gtk/TestExpectations: Skip fast/forms/validation-message-clone.html
+
2022-01-17 Alan Bujtas <[email protected]>
Fractional td width is not rendering correctly
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (288103 => 288104)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2022-01-18 00:50:09 UTC (rev 288104)
@@ -660,6 +660,7 @@
webkit.org/b/167579 fast/forms/validation-message-on-listbox.html [ Skip ]
webkit.org/b/167579 fast/forms/validation-message-on-menulist.html [ Skip ]
webkit.org/b/167579 fast/forms/validation-message-on-radio.html [ Skip ]
+webkit.org/b/167579 fast/forms/validation-message-clone.html [ Skip ]
webkit.org/b/137096 svg/W3C-SVG-1.1/text-altglyph-01-b.svg [ Failure ]
webkit.org/b/137096 svg/custom/altglyph.svg [ Failure ]
Modified: trunk/Source/WebCore/ChangeLog (288103 => 288104)
--- trunk/Source/WebCore/ChangeLog 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebCore/ChangeLog 2022-01-18 00:50:09 UTC (rev 288104)
@@ -1,3 +1,29 @@
+2022-01-17 ChangSeok Oh <[email protected]>
+
+ [GTK] Implement form validation with gtk3 widgets in the UI process
+ https://bugs.webkit.org/show_bug.cgi?id=234629
+
+ Reviewed by Carlos Garcia Campos.
+
+ This change re-implements form validation with gtk3 widgets in the UI process.
+ The current form validation is implemented by using shadow DOM in the web process.
+ The overall design is similar to that of mac port but the gtk port adds
+ a callback of webkitWebViewBaseSetShouldNotifyFocusEvents to WebCore::ValidationBubble
+ to suppress a focus event triggered by the popover widget. Otherwise, the native
+ bubble does not display properly.
+ This change does not support gtk4 yet. A follow-up patch will add the gtk4 support.
+
+ No new tests because existing tests cover this change.
+
+ * SourcesGTK.txt:
+ * platform/ValidationBubble.h:
+ (WebCore::ValidationBubble::create):
+ * platform/gtk/ValidationBubbleGtk.cpp: Added.
+ (WebCore::ValidationBubble::ValidationBubble):
+ (WebCore::ValidationBubble::~ValidationBubble):
+ (WebCore::ValidationBubble::invalidate):
+ (WebCore::ValidationBubble::showRelativeTo):
+
2022-01-17 Alan Bujtas <[email protected]>
Fractional td width is not rendering correctly
Modified: trunk/Source/WebCore/SourcesGTK.txt (288103 => 288104)
--- trunk/Source/WebCore/SourcesGTK.txt 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebCore/SourcesGTK.txt 2022-01-18 00:50:09 UTC (rev 288104)
@@ -134,6 +134,7 @@
platform/gtk/ScrollbarThemeGtk.cpp
platform/gtk/SelectionData.cpp
platform/gtk/ThemeGtk.cpp
+platform/gtk/ValidationBubbleGtk.cpp
platform/gtk/WidgetGtk.cpp
platform/text/Hyphenation.cpp
Modified: trunk/Source/WebCore/platform/ValidationBubble.h (288103 => 288104)
--- trunk/Source/WebCore/platform/ValidationBubble.h 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebCore/platform/ValidationBubble.h 2022-01-18 00:50:09 UTC (rev 288104)
@@ -49,6 +49,8 @@
#elif PLATFORM(IOS_FAMILY)
OBJC_CLASS UIView;
using PlatformView = UIView;
+#elif PLATFORM(GTK)
+using PlatformView = GtkWidget;
#else
using PlatformView = void;
#endif
@@ -61,10 +63,18 @@
double minimumFontSize { 0 };
};
+#if PLATFORM(GTK)
+ using ShouldNotifyFocusEventsCallback = Function<void(PlatformView*, bool shouldNotifyFocusEvents)>;
+ static Ref<ValidationBubble> create(PlatformView* view, const String& message, const Settings& settings, ShouldNotifyFocusEventsCallback&& callback)
+ {
+ return adoptRef(*new ValidationBubble(view, message, settings, WTFMove(callback)));
+ }
+#else
static Ref<ValidationBubble> create(PlatformView* view, const String& message, const Settings& settings)
{
return adoptRef(*new ValidationBubble(view, message, settings));
}
+#endif
WEBCORE_EXPORT ~ValidationBubble();
@@ -79,7 +89,12 @@
#endif
private:
+#if PLATFORM(GTK)
+ WEBCORE_EXPORT ValidationBubble(PlatformView*, const String& message, const Settings&, ShouldNotifyFocusEventsCallback&&);
+ void invalidate();
+#else
WEBCORE_EXPORT ValidationBubble(PlatformView*, const String& message, const Settings&);
+#endif
PlatformView* m_view;
String m_message;
@@ -91,6 +106,9 @@
RetainPtr<WebValidationBubbleTapRecognizer> m_tapRecognizer;
RetainPtr<WebValidationBubbleDelegate> m_popoverDelegate;
WeakObjCPtr<UIViewController> m_presentingViewController;
+#elif PLATFORM(GTK)
+ GtkWidget* m_popover { nullptr };
+ ShouldNotifyFocusEventsCallback m_shouldNotifyFocusEventsCallback { nullptr };
#endif
};
Added: trunk/Source/WebCore/platform/gtk/ValidationBubbleGtk.cpp (0 => 288104)
--- trunk/Source/WebCore/platform/gtk/ValidationBubbleGtk.cpp (rev 0)
+++ trunk/Source/WebCore/platform/gtk/ValidationBubbleGtk.cpp 2022-01-18 00:50:09 UTC (rev 288104)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include "config.h"
+#include "ValidationBubble.h"
+
+#if PLATFORM(GTK)
+
+#include <glib.h>
+#include <wtf/glib/GUniquePtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+static const float horizontalMargin = 5;
+static const float verticalMargin = 5;
+static const float maxLabelWidthChars = 40;
+static const double minFontSize = 11;
+
+ValidationBubble::ValidationBubble(GtkWidget* webView, const String& message, const Settings& settings, ShouldNotifyFocusEventsCallback&& callback)
+ : m_view(webView)
+ , m_message(message)
+ , m_fontSize(std::max(settings.minimumFontSize, minFontSize))
+ , m_shouldNotifyFocusEventsCallback(WTFMove(callback))
+{
+#if !USE(GTK4)
+ GtkWidget* label = gtk_label_new(nullptr);
+
+ // https://docs.gtk.org/Pango/pango_markup.html
+ GUniquePtr<gchar> markup(g_markup_printf_escaped("<span font='%f'>%s</span>", m_fontSize, message.utf8().data()));
+ gtk_label_set_markup(GTK_LABEL(label), markup.get());
+
+ gtk_widget_set_halign(label, GTK_ALIGN_START);
+ gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
+
+ gtk_widget_set_margin_top(label, verticalMargin);
+ gtk_widget_set_margin_bottom(label, verticalMargin);
+ gtk_widget_set_margin_start(label, horizontalMargin);
+ gtk_widget_set_margin_end(label, horizontalMargin);
+
+ gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+ gtk_label_set_lines(GTK_LABEL(label), 4);
+ gtk_label_set_max_width_chars(GTK_LABEL(label), maxLabelWidthChars);
+
+ m_popover = gtk_popover_new(webView);
+ gtk_popover_set_modal(GTK_POPOVER(m_popover), FALSE);
+ gtk_popover_set_position(GTK_POPOVER(m_popover), GTK_POS_TOP);
+ gtk_popover_set_constrain_to(GTK_POPOVER(m_popover), GTK_POPOVER_CONSTRAINT_NONE);
+
+ gtk_container_add(GTK_CONTAINER(m_popover), label);
+ gtk_widget_show(label);
+
+ g_signal_connect_swapped(m_popover, "closed", G_CALLBACK(+[](ValidationBubble* validationBubble) {
+ validationBubble->invalidate();
+ }), this);
+#endif
+}
+
+ValidationBubble::~ValidationBubble()
+{
+ invalidate();
+}
+
+void ValidationBubble::invalidate()
+{
+#if !USE(GTK4)
+ if (!m_popover)
+ return;
+
+ g_signal_handlers_disconnect_by_data(m_popover, this);
+
+ gtk_widget_destroy(m_popover);
+ m_popover = nullptr;
+
+ m_shouldNotifyFocusEventsCallback(m_view, true);
+#endif
+}
+
+void ValidationBubble::showRelativeTo(const IntRect& anchorRect)
+{
+#if !USE(GTK4)
+ m_shouldNotifyFocusEventsCallback(m_view, false);
+
+ GdkRectangle rect(anchorRect);
+ gtk_popover_set_pointing_to(GTK_POPOVER(m_popover), &rect);
+
+ gtk_popover_popup(GTK_POPOVER(m_popover));
+#endif
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(GTK)
Modified: trunk/Source/WebKit/ChangeLog (288103 => 288104)
--- trunk/Source/WebKit/ChangeLog 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/ChangeLog 2022-01-18 00:50:09 UTC (rev 288104)
@@ -1,3 +1,35 @@
+2022-01-17 ChangSeok Oh <[email protected]>
+
+ [GTK] Implement form validation with gtk3 widgets in the UI process
+ https://bugs.webkit.org/show_bug.cgi?id=234629
+
+ Reviewed by Carlos Garcia Campos.
+
+ This change re-implements form validation with gtk3 widgets in the UI process.
+ The current form validation is implemented by using shadow DOM in the web process.
+ The overall design is similar to that of mac port but the gtk port adds
+ a callback of webkitWebViewBaseSetShouldNotifyFocusEvents to WebCore::ValidationBubble
+ to suppress a focus event triggered by the popover widget. Otherwise, the native
+ bubble does not display properly.
+ This change does not support gtk4 yet. A follow-up patch will add the gtk4 support.
+ To avoid complaints from the gtk4 EWS, we guard implementation of ValidationBubbleGtk
+ temporarily and install pageConfiguration.validationMessageClient for gtk3 only.
+ The gtk4 keeps using the shadow DOM bubble until having native bubble support.
+
+ * SourcesGTK.txt:
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::createValidationBubble):
+ * UIProcess/API/gtk/PageClientImpl.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::hideValidationMessage):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/gtk/WebPageProxyGtk.cpp:
+ (WebKit::WebPageProxy::showValidationMessage):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::m_appHighlightsVisible):
+
2022-01-17 Youenn Fablet <[email protected]>
Make ServiceWorkerClient.id a UUID instead of a string derived from a ScriptExecutionContextIdentifier
Modified: trunk/Source/WebKit/SourcesGTK.txt (288103 => 288104)
--- trunk/Source/WebKit/SourcesGTK.txt 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/SourcesGTK.txt 2022-01-18 00:50:09 UTC (rev 288104)
@@ -413,6 +413,8 @@
WebProcess/MediaCache/WebMediaKeyStorageManager.cpp
+WebProcess/WebCoreSupport/WebValidationMessageClient.cpp
+
WebProcess/WebCoreSupport/glib/WebEditorClientGLib.cpp
WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp (288103 => 288104)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2022-01-18 00:50:09 UTC (rev 288104)
@@ -51,6 +51,7 @@
#include <WebCore/GtkUtilities.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/RefPtrCairo.h>
+#include <WebCore/ValidationBubble.h>
#include <wtf/Compiler.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
@@ -293,6 +294,13 @@
}
#endif
+Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message, const ValidationBubble::Settings& settings)
+{
+ return ValidationBubble::create(m_viewWidget, message, settings, [](GtkWidget* webView, bool shouldNotifyFocusEvents) {
+ webkitWebViewBaseSetShouldNotifyFocusEvents(WEBKIT_WEB_VIEW_BASE(webView), shouldNotifyFocusEvents);
+ });
+}
+
void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
{
webkitWebViewBaseEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext);
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h (288103 => 288104)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2022-01-18 00:50:09 UTC (rev 288104)
@@ -101,6 +101,7 @@
#if ENABLE(DATALIST_ELEMENT)
RefPtr<WebDataListSuggestionsDropdown> createDataListSuggestionsDropdown(WebPageProxy&) override;
#endif
+ Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final;
void selectionDidChange() override;
RefPtr<ViewSnapshot> takeViewSnapshot(std::optional<WebCore::IntRect>&&) override;
#if ENABLE(DRAG_SUPPORT)
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (288103 => 288104)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2022-01-18 00:50:09 UTC (rev 288104)
@@ -387,7 +387,7 @@
virtual RefPtr<WebDateTimePicker> createDateTimePicker(WebPageProxy&) = 0;
#endif
-#if PLATFORM(COCOA)
+#if PLATFORM(COCOA) || PLATFORM(GTK)
virtual Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) = 0;
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (288103 => 288104)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-01-18 00:50:09 UTC (rev 288104)
@@ -9913,7 +9913,7 @@
void WebPageProxy::hideValidationMessage()
{
-#if PLATFORM(COCOA)
+#if PLATFORM(COCOA) || PLATFORM(GTK)
m_validationBubble = nullptr;
#endif
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (288103 => 288104)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2022-01-18 00:50:09 UTC (rev 288104)
@@ -1610,7 +1610,7 @@
// Form validation messages.
void showValidationMessage(const WebCore::IntRect& anchorClientRect, const String& message);
void hideValidationMessage();
-#if PLATFORM(COCOA)
+#if PLATFORM(COCOA) || PLATFORM(GTK)
WebCore::ValidationBubble* validationBubble() const { return m_validationBubble.get(); } // For testing.
#endif
@@ -2865,7 +2865,7 @@
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
RefPtr<WebDateTimePicker> m_dateTimePicker;
#endif
-#if PLATFORM(COCOA)
+#if PLATFORM(COCOA) || PLATFORM(GTK)
RefPtr<WebCore::ValidationBubble> m_validationBubble;
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (288103 => 288104)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2022-01-18 00:50:09 UTC (rev 288104)
@@ -57,7 +57,7 @@
AccessibilityScreenToRootView(WebCore::IntPoint screenPoint) -> (WebCore::IntPoint windowPoint) Synchronous
RootViewToAccessibilityScreen(WebCore::IntRect rect) -> (WebCore::IntRect screenFrame) Synchronous
-#if PLATFORM(COCOA)
+#if PLATFORM(COCOA) || PLATFORM(GTK)
ShowValidationMessage(WebCore::IntRect anchorRect, String message)
HideValidationMessage()
#endif
Modified: trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp (288103 => 288104)
--- trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp 2022-01-18 00:50:09 UTC (rev 288104)
@@ -85,6 +85,12 @@
webkitWebViewBaseShowEmojiChooser(WEBKIT_WEB_VIEW_BASE(viewWidget()), caretRect, WTFMove(completionHandler));
}
+void WebPageProxy::showValidationMessage(const WebCore::IntRect& anchorClientRect, const String& message)
+{
+ m_validationBubble = pageClient().createValidationBubble(message, { m_preferences->minimumFontSize() });
+ m_validationBubble->showRelativeTo(anchorClientRect);
+}
+
void WebPageProxy::sendMessageToWebViewWithReply(UserMessage&& message, CompletionHandler<void(UserMessage&&)>&& completionHandler)
{
if (!WEBKIT_IS_WEB_VIEW(viewWidget())) {
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (288103 => 288104)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-01-17 21:32:38 UTC (rev 288103)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-01-18 00:50:09 UTC (rev 288104)
@@ -609,7 +609,7 @@
pageConfiguration.speechSynthesisClient = makeUnique<WebSpeechSynthesisClient>(*this);
#endif
-#if PLATFORM(COCOA)
+#if PLATFORM(COCOA) || (PLATFORM(GTK) && !USE(GTK4))
pageConfiguration.validationMessageClient = makeUnique<WebValidationMessageClient>(*this);
#endif