From 2cc108a15e0ed67841f1c4cc691f7705a301ce91 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sat, 28 Jan 2023 20:22:52 +0100 Subject: [PATCH] LibWeb: Rename DOM::shadow_root() to shadow_root_internal() The shadowRoot property getter that will be added in subsequent commits has an additional check that checks whether the shadow root is opened. I didn't update the function logic to match with the IDL interface, because it's very likely we don't want that check in the existing code, so that for example closed shadow root elements can still be updated. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Element.h | 4 ++-- Userland/Libraries/LibWeb/DOM/Node.cpp | 2 +- Userland/Libraries/LibWeb/DOM/ShadowRoot.h | 2 +- Userland/Libraries/LibWeb/HTML/Focus.cpp | 2 +- Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp | 2 +- Userland/Services/WebContent/WebDriverConnection.cpp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index b5ed5db7709..e2730c4d47b 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -894,7 +894,7 @@ void Document::update_layout() if (needs_full_style_update || node.child_needs_style_update()) { if (node.is_element()) { - if (auto* shadow_root = static_cast(node).shadow_root()) { + if (auto* shadow_root = static_cast(node).shadow_root_internal()) { if (needs_full_style_update || shadow_root->needs_style_update() || shadow_root->child_needs_style_update()) needs_relayout |= update_style_recursively(*shadow_root); } diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 48356195f38..1fe9b022587 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -131,8 +131,8 @@ public: JS::NonnullGCPtr get_elements_by_class_name(DeprecatedFlyString const&); - ShadowRoot* shadow_root() { return m_shadow_root.ptr(); } - ShadowRoot const* shadow_root() const { return m_shadow_root.ptr(); } + ShadowRoot* shadow_root_internal() { return m_shadow_root.ptr(); } + ShadowRoot const* shadow_root_internal() const { return m_shadow_root.ptr(); } void set_shadow_root(JS::GCPtr); void set_custom_properties(HashMap custom_properties) { m_custom_properties = move(custom_properties); } diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 8de25502e8a..08165a3d9d6 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -247,7 +247,7 @@ void Node::invalidate_style() node.m_needs_style_update = true; if (node.has_children()) node.m_child_needs_style_update = true; - if (auto* shadow_root = node.is_element() ? static_cast(node).shadow_root() : nullptr) { + if (auto* shadow_root = node.is_element() ? static_cast(node).shadow_root_internal() : nullptr) { node.m_child_needs_style_update = true; shadow_root->m_needs_style_update = true; if (shadow_root->has_children()) diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h index b4d33a8df46..37e1add258b 100644 --- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h +++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h @@ -53,7 +53,7 @@ inline IterationDecision Node::for_each_shadow_including_descendant(Callback cal return IterationDecision::Break; for (auto* child = first_child(); child; child = child->next_sibling()) { if (child->is_element()) { - if (JS::GCPtr shadow_root = static_cast(child)->shadow_root()) { + if (JS::GCPtr shadow_root = static_cast(child)->shadow_root_internal()) { if (shadow_root->for_each_shadow_including_descendant(callback) == IterationDecision::Break) return IterationDecision::Break; } diff --git a/Userland/Libraries/LibWeb/HTML/Focus.cpp b/Userland/Libraries/LibWeb/HTML/Focus.cpp index 5eeef7f8c0d..e74322da62b 100644 --- a/Userland/Libraries/LibWeb/HTML/Focus.cpp +++ b/Userland/Libraries/LibWeb/HTML/Focus.cpp @@ -218,7 +218,7 @@ void run_unfocusing_steps(DOM::Node* old_focus_target) // context's DOM anchor, then set old focus target to that currently focused area of a top-level browsing // context. if (is_shadow_host(old_focus_target)) { - auto* shadow_root = static_cast(old_focus_target)->shadow_root(); + auto* shadow_root = static_cast(old_focus_target)->shadow_root_internal(); if (shadow_root->delegates_focus()) { auto& top_level_browsing_context = old_focus_target->document().browsing_context()->top_level_browsing_context(); if (auto currently_focused_area = top_level_browsing_context.currently_focused_area()) { diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index 659bff04870..d3f89c4c5e1 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -239,7 +239,7 @@ ErrorOr TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder:: insert_node_into_inline_or_block_ancestor(*layout_node, display, AppendOrPrepend::Append); } - auto* shadow_root = is(dom_node) ? verify_cast(dom_node).shadow_root() : nullptr; + auto* shadow_root = is(dom_node) ? verify_cast(dom_node).shadow_root_internal() : nullptr; if ((dom_node.has_children() || shadow_root) && layout_node->can_have_children()) { push_parent(verify_cast(*layout_node)); diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index ec4116072d2..2f5310ac436 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -996,7 +996,7 @@ Messages::WebDriverClient::GetElementShadowRootResponse WebDriverConnection::get auto* element = TRY(get_known_connected_element(element_id)); // 4. Let shadow root be element's shadow root. - auto* shadow_root = element->shadow_root(); + auto* shadow_root = element->shadow_root_internal(); // 5. If shadow root is null, return error with error code no such shadow root. if (!shadow_root)