LibWeb: Make request_select_dropdown more similar to context menu api

This commit is contained in:
Bastiaan van der Plaat 2023-12-12 22:35:37 +01:00 committed by Andreas Kling
parent aee8b39c65
commit cbb660c756
Notes: sideshowbarker 2024-07-17 03:03:44 +09:00
7 changed files with 10 additions and 9 deletions

View file

@ -239,7 +239,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
select_dropdown_add_item(m_select_dropdown, item);
}
m_select_dropdown->exec(mapToGlobal(QPoint(content_position.x(), content_position.y())));
m_select_dropdown->exec(view().mapToGlobal(QPoint(content_position.x(), content_position.y()) / view().device_pixel_ratio()));
};
QObject::connect(focus_location_editor_action, &QAction::triggered, this, &Tab::focus_location_editor);

View file

@ -298,7 +298,8 @@ void HTMLSelectElement::activation_behavior(DOM::Event const&)
// Request select dropdown
auto weak_element = make_weak_ptr<HTMLSelectElement>();
auto rect = get_bounding_client_rect();
document().browsing_context()->top_level_browsing_context()->page().did_request_select_dropdown(weak_element, Gfx::IntPoint { rect->x(), rect->y() }, rect->width(), items);
auto position = document().browsing_context()->to_top_level_position(Web::CSSPixelPoint { rect->x(), rect->y() });
document().browsing_context()->top_level_browsing_context()->page().did_request_select_dropdown(weak_element, position, CSSPixels(rect->width()), items);
set_is_open(true);
}

View file

@ -331,7 +331,7 @@ void Page::color_picker_closed(Optional<Color> picked_color)
}
}
void Page::did_request_select_dropdown(WeakPtr<HTML::HTMLSelectElement> target, Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items)
void Page::did_request_select_dropdown(WeakPtr<HTML::HTMLSelectElement> target, Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items)
{
if (m_pending_non_blocking_dialog == PendingNonBlockingDialog::None) {
m_pending_non_blocking_dialog = PendingNonBlockingDialog::Select;

View file

@ -129,7 +129,7 @@ public:
void did_request_color_picker(WeakPtr<HTML::HTMLInputElement> target, Color current_color);
void color_picker_closed(Optional<Color> picked_color);
void did_request_select_dropdown(WeakPtr<HTML::HTMLSelectElement> target, Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items);
void did_request_select_dropdown(WeakPtr<HTML::HTMLSelectElement> target, Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items);
void select_dropdown_closed(Optional<String> value);
enum class PendingNonBlockingDialog {
@ -277,7 +277,7 @@ public:
// https://html.spec.whatwg.org/multipage/input.html#show-the-picker,-if-applicable
virtual void page_did_request_file_picker(WeakPtr<DOM::EventTarget>, [[maybe_unused]] bool multiple) {};
virtual void page_did_request_color_picker([[maybe_unused]] Color current_color) {};
virtual void page_did_request_select_dropdown([[maybe_unused]] Gfx::IntPoint content_position, [[maybe_unused]] i32 minimum_width, [[maybe_unused]] Vector<Web::HTML::SelectItem> items) {};
virtual void page_did_request_select_dropdown([[maybe_unused]] Web::CSSPixelPoint content_position, [[maybe_unused]] Web::CSSPixels minimum_width, [[maybe_unused]] Vector<Web::HTML::SelectItem> items) {};
virtual void page_did_finish_text_test() {};

View file

@ -387,7 +387,7 @@ void WebContentClient::did_request_color_picker(Color const& current_color)
void WebContentClient::did_request_select_dropdown(Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> const& items)
{
if (m_view.on_request_select_dropdown)
m_view.on_request_select_dropdown(content_position, minimum_width, items);
m_view.on_request_select_dropdown(m_view.to_widget_position(content_position), m_view.to_widget_position(Gfx::IntPoint { minimum_width, 0 }).x(), items);
}
void WebContentClient::did_finish_handling_input_event(bool event_was_accepted)

View file

@ -509,9 +509,9 @@ void PageClient::page_did_request_color_picker(Color current_color)
client().async_did_request_color_picker(current_color);
}
void PageClient::page_did_request_select_dropdown(Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items)
void PageClient::page_did_request_select_dropdown(Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items)
{
client().async_did_request_select_dropdown(content_position, minimum_width, items);
client().async_did_request_select_dropdown(page().css_to_device_point(content_position).to_type<int>(), minimum_width * device_pixels_per_css_pixel(), items);
}
void PageClient::page_did_change_theme_color(Gfx::Color color)

View file

@ -119,7 +119,7 @@ private:
virtual void page_did_close_browsing_context(Web::HTML::BrowsingContext const&) override;
virtual void request_file(Web::FileRequest) override;
virtual void page_did_request_color_picker(Color current_color) override;
virtual void page_did_request_select_dropdown(Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items) override;
virtual void page_did_request_select_dropdown(Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items) override;
virtual void page_did_finish_text_test() override;
virtual void page_did_change_theme_color(Gfx::Color color) override;
virtual void page_did_insert_clipboard_entry(String data, String presentation_style, String mime_type) override;