mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
LibWeb: Give Document a "target element"
The target element is the one matching the URL fragment. We don't yet set it to anything.
This commit is contained in:
parent
28aa4ca767
commit
13b4bf48a8
4 changed files with 28 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
||||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||||
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
||||||
* Copyright (c) 2021-2023, Luke Wilde <lukew@serenityos.org>
|
* Copyright (c) 2021-2023, Luke Wilde <lukew@serenityos.org>
|
||||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -1713,6 +1713,23 @@ void Document::set_active_element(Element* element)
|
||||||
m_layout_root->set_needs_display();
|
m_layout_root->set_needs_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::set_target_element(Element* element)
|
||||||
|
{
|
||||||
|
if (m_target_element.ptr() == element)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_target_element)
|
||||||
|
m_target_element->set_needs_style_update(true);
|
||||||
|
|
||||||
|
m_target_element = element;
|
||||||
|
|
||||||
|
if (m_target_element)
|
||||||
|
m_target_element->set_needs_style_update(true);
|
||||||
|
|
||||||
|
if (m_layout_root)
|
||||||
|
m_layout_root->set_needs_display();
|
||||||
|
}
|
||||||
|
|
||||||
DeprecatedString Document::ready_state() const
|
DeprecatedString Document::ready_state() const
|
||||||
{
|
{
|
||||||
switch (m_readiness) {
|
switch (m_readiness) {
|
||||||
|
|
|
@ -295,6 +295,9 @@ public:
|
||||||
|
|
||||||
void set_active_element(Element*);
|
void set_active_element(Element*);
|
||||||
|
|
||||||
|
Element const* target_element() const { return m_target_element.ptr(); }
|
||||||
|
void set_target_element(Element*);
|
||||||
|
|
||||||
bool created_for_appropriate_template_contents() const { return m_created_for_appropriate_template_contents; }
|
bool created_for_appropriate_template_contents() const { return m_created_for_appropriate_template_contents; }
|
||||||
|
|
||||||
JS::NonnullGCPtr<Document> appropriate_template_contents_owner_document();
|
JS::NonnullGCPtr<Document> appropriate_template_contents_owner_document();
|
||||||
|
@ -565,6 +568,7 @@ private:
|
||||||
|
|
||||||
JS::GCPtr<Element> m_focused_element;
|
JS::GCPtr<Element> m_focused_element;
|
||||||
JS::GCPtr<Element> m_active_element;
|
JS::GCPtr<Element> m_active_element;
|
||||||
|
JS::GCPtr<Element> m_target_element;
|
||||||
|
|
||||||
bool m_created_for_appropriate_template_contents { false };
|
bool m_created_for_appropriate_template_contents { false };
|
||||||
JS::GCPtr<Document> m_associated_inert_template_document;
|
JS::GCPtr<Document> m_associated_inert_template_document;
|
||||||
|
|
|
@ -634,6 +634,11 @@ bool Element::is_active() const
|
||||||
return document().active_element() == this;
|
return document().active_element() == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Element::is_target() const
|
||||||
|
{
|
||||||
|
return document().target_element() == this;
|
||||||
|
}
|
||||||
|
|
||||||
JS::NonnullGCPtr<HTMLCollection> Element::get_elements_by_class_name(DeprecatedFlyString const& class_names)
|
JS::NonnullGCPtr<HTMLCollection> Element::get_elements_by_class_name(DeprecatedFlyString const& class_names)
|
||||||
{
|
{
|
||||||
Vector<FlyString> list_of_class_names;
|
Vector<FlyString> list_of_class_names;
|
||||||
|
|
|
@ -168,6 +168,7 @@ public:
|
||||||
|
|
||||||
bool is_focused() const;
|
bool is_focused() const;
|
||||||
bool is_active() const;
|
bool is_active() const;
|
||||||
|
bool is_target() const;
|
||||||
|
|
||||||
JS::NonnullGCPtr<HTMLCollection> get_elements_by_class_name(DeprecatedFlyString const&);
|
JS::NonnullGCPtr<HTMLCollection> get_elements_by_class_name(DeprecatedFlyString const&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue