LibWeb: Remember page's cursor and request change only when it changes

Before, on *every* mouse-move event, `page_did_request_cursor_change()`
virtual function would get called, requesting to change cursor to the
event's mouse position's cursor.

Now, the page keeps track of the last cursor change that was requested
("page's current cursor") and only requests cursor change again if and
only if the current cursor is not already the one that is required.
This commit is contained in:
ronak69 2024-04-20 10:13:39 +00:00 committed by Tim Flynn
commit 318fc62b53
Notes: github-actions[bot] 2024-12-10 13:30:54 +00:00
2 changed files with 9 additions and 1 deletions

View file

@ -619,7 +619,10 @@ EventResult EventHandler::handle_mousemove(CSSPixelPoint viewport_position, CSSP
auto& page = m_navigable->page();
page.client().page_did_request_cursor_change(hovered_node_cursor);
if (page.current_cursor() != hovered_node_cursor) {
page.set_current_cursor(hovered_node_cursor);
page.client().page_did_request_cursor_change(hovered_node_cursor);
}
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;