mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWeb: Leave tooltip or unhover link only if page entered/hovered one
Before, on a mouse-move event, if the hovered html element did not have a tooltip or it was not a link, `page_did_leave_tooltip_area()` and `page_did_unhover_link()` virtual functions would get called. Now, the page remembers if it is in a tooltip area or hovering a link and only informs of leaving or unhovering only if it was.
This commit is contained in:
parent
318fc62b53
commit
d48831e893
Notes:
github-actions[bot]
2024-12-10 13:30:47 +00:00
Author: https://github.com/ronak69 Commit: https://github.com/LadybirdBrowser/ladybird/commit/d48831e893e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1411
2 changed files with 19 additions and 3 deletions
|
@ -626,15 +626,22 @@ EventResult EventHandler::handle_mousemove(CSSPixelPoint viewport_position, CSSP
|
|||
|
||||
if (hovered_node_changed) {
|
||||
GC::Ptr<HTML::HTMLElement const> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr;
|
||||
|
||||
if (hovered_html_element && hovered_html_element->title().has_value()) {
|
||||
page.set_is_in_tooltip_area(true);
|
||||
page.client().page_did_enter_tooltip_area(hovered_html_element->title()->to_byte_string());
|
||||
} else {
|
||||
} else if (page.is_in_tooltip_area()) {
|
||||
page.set_is_in_tooltip_area(false);
|
||||
page.client().page_did_leave_tooltip_area();
|
||||
}
|
||||
if (is_hovering_link)
|
||||
|
||||
if (is_hovering_link) {
|
||||
page.set_is_hovering_link(true);
|
||||
page.client().page_did_hover_link(document.parse_url(hovered_link_element->href()));
|
||||
else
|
||||
} else if (page.is_hovering_link()) {
|
||||
page.set_is_hovering_link(false);
|
||||
page.client().page_did_unhover_link();
|
||||
}
|
||||
}
|
||||
|
||||
return EventResult::Handled;
|
||||
|
|
|
@ -121,6 +121,12 @@ public:
|
|||
bool is_webdriver_active() const { return m_is_webdriver_active; }
|
||||
void set_is_webdriver_active(bool b) { m_is_webdriver_active = b; }
|
||||
|
||||
bool is_hovering_link() const { return m_is_hovering_link; }
|
||||
void set_is_hovering_link(bool b) { m_is_hovering_link = b; }
|
||||
|
||||
bool is_in_tooltip_area() const { return m_is_in_tooltip_area; }
|
||||
void set_is_in_tooltip_area(bool b) { m_is_in_tooltip_area = b; }
|
||||
|
||||
Gfx::StandardCursor current_cursor() const { return m_current_cursor; }
|
||||
void set_current_cursor(Gfx::StandardCursor cursor) { m_current_cursor = cursor; }
|
||||
|
||||
|
@ -249,6 +255,9 @@ private:
|
|||
// The webdriver-active flag is set to true when the user agent is under remote control. It is initially false.
|
||||
bool m_is_webdriver_active { false };
|
||||
|
||||
bool m_is_hovering_link { false };
|
||||
bool m_is_in_tooltip_area { false };
|
||||
|
||||
Gfx::StandardCursor m_current_cursor { Gfx::StandardCursor::Arrow };
|
||||
|
||||
DevicePixelPoint m_window_position {};
|
||||
|
|
Loading…
Reference in a new issue