mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
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:
parent
ac6fe2e211
commit
318fc62b53
Notes:
github-actions[bot]
2024-12-10 13:30:54 +00:00
Author: https://github.com/ronak69
Commit: 318fc62b53
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1411
2 changed files with 9 additions and 1 deletions
|
@ -619,7 +619,10 @@ EventResult EventHandler::handle_mousemove(CSSPixelPoint viewport_position, CSSP
|
||||||
|
|
||||||
auto& page = m_navigable->page();
|
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) {
|
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;
|
GC::Ptr<HTML::HTMLElement const> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr;
|
||||||
|
|
|
@ -121,6 +121,9 @@ public:
|
||||||
bool is_webdriver_active() const { return m_is_webdriver_active; }
|
bool is_webdriver_active() const { return m_is_webdriver_active; }
|
||||||
void set_is_webdriver_active(bool b) { m_is_webdriver_active = b; }
|
void set_is_webdriver_active(bool b) { m_is_webdriver_active = b; }
|
||||||
|
|
||||||
|
Gfx::StandardCursor current_cursor() const { return m_current_cursor; }
|
||||||
|
void set_current_cursor(Gfx::StandardCursor cursor) { m_current_cursor = cursor; }
|
||||||
|
|
||||||
DevicePixelPoint window_position() const { return m_window_position; }
|
DevicePixelPoint window_position() const { return m_window_position; }
|
||||||
void set_window_position(DevicePixelPoint position) { m_window_position = position; }
|
void set_window_position(DevicePixelPoint position) { m_window_position = position; }
|
||||||
|
|
||||||
|
@ -246,6 +249,8 @@ private:
|
||||||
// The webdriver-active flag is set to true when the user agent is under remote control. It is initially false.
|
// 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_webdriver_active { false };
|
||||||
|
|
||||||
|
Gfx::StandardCursor m_current_cursor { Gfx::StandardCursor::Arrow };
|
||||||
|
|
||||||
DevicePixelPoint m_window_position {};
|
DevicePixelPoint m_window_position {};
|
||||||
DevicePixelSize m_window_size {};
|
DevicePixelSize m_window_size {};
|
||||||
GC::Ptr<GC::Function<void(DevicePixelRect)>> m_window_rect_observer;
|
GC::Ptr<GC::Function<void(DevicePixelRect)>> m_window_rect_observer;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue