Truly independent web browser
LibWeb: Remove MouseAction::SwallowEvent
Aliaksandr Kalenik0c756a780c76
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cppindex f3fb29f2853..2996cdd91b2 100644--- a/Libraries/LibWeb/Page/EventHandler.cpp+++ b/Libraries/LibWeb/Page/EventHandler.cpp@@ -458,7 +458,7 @@ EventResult EventHandler::handle_mousedown(CSSPixelPoint visual_viewport_positio// NB: The contextmenu event is dispatched even if the page cancelled the pointerdown or mousedown event,// matching other engines. The page can still suppress the native context menu by cancelling the// contextmenu event itself.- if (is_context_menu_trigger && dispatch_result != PointerEventDispatchResult::SwallowedByChromeWidget)+ if (is_context_menu_trigger)maybe_show_context_menu(*node, coordinates, screen_position, viewport_position, buttons, modifiers);if (dispatch_result != PointerEventDispatchResult::RunDefaultActions)@@ -5420,8 +5420,7 @@ EventHandler::DispatchedPointerEvent EventHandler::dispatch_a_pointer_event_for_// The events above may have changed layout, and chrome widgets are very likely to touch committed boxes.if (chrome_widget || m_captured_chrome_widget)document.update_layout(DOM::UpdateLayoutReason::EventHandlerDispatchChromeWidgetEvent);- if (!dispatch_chrome_widget_pointer_event(chrome_widget, pointer_event_name, button, coordinates.visual_viewport_position))- return { PointerEventDispatchResult::SwallowedByChromeWidget, pointer_capture_target };+ dispatch_chrome_widget_pointer_event(chrome_widget, pointer_event_name, button, coordinates.visual_viewport_position);// FIXME: This will be moved to the click event and need to track the targets of the pointerdown and pointerup events.// https://github.com/w3c/pointerevents/pull/460@@ -5612,28 +5611,16 @@ void EventHandler::record_last_known_mouse_position(CSSPixelPoint visual_viewporm_last_known_mouse_screen_position = screen_position;}-bool EventHandler::dispatch_chrome_widget_pointer_event(RefPtr<Painting::ChromeWidget> target, Utf16FlyString const& type, unsigned button, CSSPixelPoint visual_viewport_position)+void EventHandler::dispatch_chrome_widget_pointer_event(RefPtr<Painting::ChromeWidget> target, Utf16FlyString const& type, unsigned button, CSSPixelPoint visual_viewport_position){- bool allow_default_behavior = true;-if (m_captured_chrome_widget) {- auto action = m_captured_chrome_widget->handle_pointer_event(type, button, visual_viewport_position);- if (has_flag(action, Painting::MouseAction::SwallowEvent))- allow_default_behavior = false;- if (has_flag(action, Painting::MouseAction::CaptureInput))- return allow_default_behavior;+ if (m_captured_chrome_widget->handle_pointer_event(type, button, visual_viewport_position) == Painting::MouseAction::CaptureInput)+ return;m_captured_chrome_widget = nullptr;}- if (target) {- auto action = target->handle_pointer_event(type, button, visual_viewport_position);- if (has_flag(action, Painting::MouseAction::SwallowEvent))- allow_default_behavior = false;- if (has_flag(action, Painting::MouseAction::CaptureInput))- m_captured_chrome_widget = target;- }-- return allow_default_behavior;+ if (target && target->handle_pointer_event(type, button, visual_viewport_position) == Painting::MouseAction::CaptureInput)+ m_captured_chrome_widget = target;}static Gfx::Cursor resolve_cursor(Layout::NodeWithStyle const& layout_node, Layout::NodeWithStyle const* cursor_values_owner, ReadonlySpan<CSS::ComputedValuesFFI::ComputedCursor> cursor_data, Gfx::StandardCursor auto_cursor)diff --git a/Libraries/LibWeb/Page/EventHandler.h b/Libraries/LibWeb/Page/EventHandler.hindex ccf566848b7..e8fa58a0039 100644--- a/Libraries/LibWeb/Page/EventHandler.h+++ b/Libraries/LibWeb/Page/EventHandler.h@@ -284,7 +284,6 @@ private:RunDefaultActions,CancelledByPage,MouseEventPrevented,- SwallowedByChromeWidget,};struct DispatchedPointerEvent {PointerEventDispatchResult result;@@ -305,7 +304,7 @@ private:void track_the_effective_position_of_the_legacy_mouse_pointer(GC::Ptr<DOM::Node>, Optional<DOM::HoverEventData> = {});void report_hovered_node_to_client(GC::Ptr<DOM::Node>);- bool dispatch_chrome_widget_pointer_event(RefPtr<Painting::ChromeWidget>, Utf16FlyString const& type, unsigned button, CSSPixelPoint visual_viewport_position);+ void dispatch_chrome_widget_pointer_event(RefPtr<Painting::ChromeWidget>, Utf16FlyString const& type, unsigned button, CSSPixelPoint visual_viewport_position);void update_nested_navigable_under_pointer(GC::Ptr<HTML::LocalNavigable>);void update_cursor(Layout::BegunRead const& read, Layout::Node const*, GC::Ptr<DOM::Node> host_element, RefPtr<Painting::ChromeWidget>, bool hit_text_fragment = false);diff --git a/Libraries/LibWeb/Painting/ChromeWidget.h b/Libraries/LibWeb/Painting/ChromeWidget.hindex 43f6bf41760..4b13c97bab4 100644--- a/Libraries/LibWeb/Painting/ChromeWidget.h+++ b/Libraries/LibWeb/Painting/ChromeWidget.h@@ -7,7 +7,6 @@#pragma once#include <AK/Badge.h>-#include <AK/EnumBits.h>#include <AK/HashMap.h>#include <AK/RefCounted.h>#include <AK/RefPtr.h>@@ -23,13 +22,10 @@namespace Web::Painting {enum class MouseAction : u8 {- None = 0,- CaptureInput = 1 << 0,- SwallowEvent = 1 << 1,+ None,+ CaptureInput,};-AK_ENUM_BITWISE_OPERATORS(MouseAction);-enum class ChromeWidgetKind : u8 {None,ResizeHandle,