mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 01:57:44 +00:00
LibWeb: Change cursor to IBeam when hovering text
This is what most browsers do, hopefully it isn't too silly :^)
This commit is contained in:
parent
1ec0f54de1
commit
ac4897d613
1 changed files with 11 additions and 1 deletions
|
@ -176,6 +176,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
||||||
|
|
||||||
bool hovered_node_changed = false;
|
bool hovered_node_changed = false;
|
||||||
bool is_hovering_link = false;
|
bool is_hovering_link = false;
|
||||||
|
bool is_hovering_text = false;
|
||||||
auto result = layout_root()->hit_test(position, HitTestType::Exact);
|
auto result = layout_root()->hit_test(position, HitTestType::Exact);
|
||||||
const HTML::HTMLAnchorElement* hovered_link_element = nullptr;
|
const HTML::HTMLAnchorElement* hovered_link_element = nullptr;
|
||||||
if (result.layout_node) {
|
if (result.layout_node) {
|
||||||
|
@ -190,6 +191,8 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
||||||
hovered_node_changed = node != document.hovered_node();
|
hovered_node_changed = node != document.hovered_node();
|
||||||
document.set_hovered_node(node);
|
document.set_hovered_node(node);
|
||||||
if (node) {
|
if (node) {
|
||||||
|
if (node->is_text())
|
||||||
|
is_hovering_text = true;
|
||||||
hovered_link_element = node->enclosing_link_element();
|
hovered_link_element = node->enclosing_link_element();
|
||||||
if (hovered_link_element) {
|
if (hovered_link_element) {
|
||||||
#ifdef HTML_DEBUG
|
#ifdef HTML_DEBUG
|
||||||
|
@ -211,7 +214,14 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
||||||
page_client.page_did_change_selection();
|
page_client.page_did_change_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
page_client.page_did_request_cursor_change(is_hovering_link ? GUI::StandardCursor::Hand : GUI::StandardCursor::None);
|
|
||||||
|
if (is_hovering_link)
|
||||||
|
page_client.page_did_request_cursor_change(GUI::StandardCursor::Hand);
|
||||||
|
else if (is_hovering_text)
|
||||||
|
page_client.page_did_request_cursor_change(GUI::StandardCursor::IBeam);
|
||||||
|
else
|
||||||
|
page_client.page_did_request_cursor_change(GUI::StandardCursor::None);
|
||||||
|
|
||||||
if (hovered_node_changed) {
|
if (hovered_node_changed) {
|
||||||
RefPtr<HTML::HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element() : nullptr;
|
RefPtr<HTML::HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element() : nullptr;
|
||||||
if (hovered_html_element && !hovered_html_element->title().is_null()) {
|
if (hovered_html_element && !hovered_html_element->title().is_null()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue