From b306db359a2deccb58ae0af0c7c5a494be7f7c3f Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 22 Jun 2023 13:30:35 -0400 Subject: [PATCH] LibWeb: Begin scrubbing the media timeline and volume on mouse-down This feels a bit more natural than waiting until the first mouse-move event to begin scrubbing. --- .../LibWeb/Painting/MediaPaintable.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/MediaPaintable.cpp b/Userland/Libraries/LibWeb/Painting/MediaPaintable.cpp index 437ae54c07..a055d81cf2 100644 --- a/Userland/Libraries/LibWeb/Painting/MediaPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/MediaPaintable.cpp @@ -288,10 +288,13 @@ MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mousedown(Badge(layout_box().dom_node()); auto const& cached_layout_boxes = media_element.cached_layout_boxes({}); - if (cached_layout_boxes.timeline_rect.has_value() && cached_layout_boxes.timeline_rect->contains(position)) + if (cached_layout_boxes.timeline_rect.has_value() && cached_layout_boxes.timeline_rect->contains(position)) { media_element.set_layout_mouse_tracking_component({}, HTML::HTMLMediaElement::MouseTrackingComponent::Timeline); - else if (cached_layout_boxes.volume_rect.has_value() && cached_layout_boxes.volume_rect->contains(position)) + set_current_time(media_element, *cached_layout_boxes.timeline_rect, position, Temporary::Yes); + } else if (cached_layout_boxes.volume_rect.has_value() && cached_layout_boxes.volume_rect->contains(position)) { media_element.set_layout_mouse_tracking_component({}, HTML::HTMLMediaElement::MouseTrackingComponent::Volume); + set_volume(media_element, *cached_layout_boxes.volume_rect, position); + } if (media_element.layout_mouse_tracking_component({}).has_value()) const_cast(browsing_context()).event_handler().set_mouse_event_tracking_layout_node(&layout_node()); @@ -342,21 +345,11 @@ MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mouseup(Badgecontains(position)) { - set_current_time(media_element, *cached_layout_boxes.timeline_rect, position, Temporary::No); - return DispatchEventOfSameName::Yes; - } - if (cached_layout_boxes.speaker_button_rect.has_value() && cached_layout_boxes.speaker_button_rect->contains(position)) { media_element.set_muted(!media_element.muted()); return DispatchEventOfSameName::Yes; } - if (cached_layout_boxes.volume_rect.has_value() && cached_layout_boxes.volume_rect->contains(position)) { - set_volume(media_element, *cached_layout_boxes.volume_rect, position); - return DispatchEventOfSameName::Yes; - } - return DispatchEventOfSameName::No; }