mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Make Node::parent_element return GC::Ptr
This is useful for people like myself who run with debug mode to more reliably get stacktraces without spinning up a debugger.
This commit is contained in:
parent
a14481ee05
commit
3e17b1c9ae
Notes:
github-actions[bot]
2025-04-18 09:08:36 +00:00
Author: https://github.com/shannonbooth
Commit: 3e17b1c9ae
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4393
18 changed files with 48 additions and 54 deletions
|
@ -467,15 +467,15 @@ GC::Ptr<DOM::Element> HTMLElement::offset_parent() const
|
|||
// - The computed value of the position property of the element is static
|
||||
// and the ancestor is one of the following HTML elements: td, th, or table.
|
||||
|
||||
for (auto* ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
for (auto ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
if (!ancestor->layout_node())
|
||||
continue;
|
||||
if (ancestor->layout_node()->is_positioned())
|
||||
return const_cast<Element*>(ancestor);
|
||||
return const_cast<Element*>(ancestor.ptr());
|
||||
if (is<HTML::HTMLBodyElement>(*ancestor))
|
||||
return const_cast<Element*>(ancestor);
|
||||
return const_cast<Element*>(ancestor.ptr());
|
||||
if (!ancestor->layout_node()->is_positioned() && ancestor->local_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th, HTML::TagNames::table))
|
||||
return const_cast<Element*>(ancestor);
|
||||
return const_cast<Element*>(ancestor.ptr());
|
||||
}
|
||||
|
||||
// 3. Return null.
|
||||
|
@ -843,7 +843,7 @@ Optional<ARIA::Role> HTMLElement::default_role() const
|
|||
// https://www.w3.org/TR/html-aria/#el-aside
|
||||
if (local_name() == TagNames::aside) {
|
||||
// https://w3c.github.io/html-aam/#el-aside
|
||||
for (auto const* ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
for (auto ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
if (ancestor->local_name().is_one_of(TagNames::article, TagNames::aside, TagNames::nav, TagNames::section)
|
||||
&& accessible_name(document()).value().is_empty())
|
||||
return ARIA::Role::generic;
|
||||
|
@ -887,7 +887,7 @@ Optional<ARIA::Role> HTMLElement::default_role() const
|
|||
// If not a descendant of an article, aside, main, nav or section element, or an element with role=article,
|
||||
// complementary, main, navigation or region then (footer) role=contentinfo (header) role=banner. Otherwise,
|
||||
// role=generic.
|
||||
for (auto const* ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
for (auto ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
if (ancestor->local_name().is_one_of(TagNames::article, TagNames::aside, TagNames::main, TagNames::nav, TagNames::section)) {
|
||||
if (local_name() == TagNames::footer)
|
||||
return ARIA::Role::sectionfooter;
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
// https://www.w3.org/TR/html-aria/#el-li
|
||||
virtual Optional<ARIA::Role> default_role() const override
|
||||
{
|
||||
for (auto const* ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
for (auto ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
if (ancestor->role_or_default() == ARIA::Role::list)
|
||||
return ARIA::Role::listitem;
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ HTMLFormElement* HTMLLegendElement::form()
|
|||
{
|
||||
// The form IDL attribute's behavior depends on whether the legend element is in a fieldset element or not.
|
||||
// If the legend has a fieldset element as its parent, then the form IDL attribute must return the same value as the form IDL attribute on that fieldset element.
|
||||
if (is<HTML::HTMLFieldSetElement>(parent_element())) {
|
||||
return as<HTML::HTMLFieldSetElement>(parent_element())->form();
|
||||
if (auto* field_set = as_if<HTML::HTMLFieldSetElement>(parent_element().ptr())) {
|
||||
return field_set->form();
|
||||
}
|
||||
|
||||
// Otherwise, it must return null.
|
||||
|
|
|
@ -250,7 +250,7 @@ void HTMLOptionElement::removed_from(Node* old_parent, Node& old_root)
|
|||
if (old_parent) {
|
||||
if (is<HTMLSelectElement>(*old_parent))
|
||||
static_cast<HTMLSelectElement&>(*old_parent).update_selectedness();
|
||||
else if (is<HTMLOptGroupElement>(*old_parent) && old_parent->parent_element() && is<HTMLSelectElement>(old_parent->parent_element()))
|
||||
else if (is<HTMLOptGroupElement>(*old_parent) && old_parent->parent_element() && is<HTMLSelectElement>(*old_parent->parent_element()))
|
||||
static_cast<HTMLSelectElement&>(*old_parent->parent_element()).update_selectedness();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ void HTMLSummaryElement::activation_behavior(DOM::Event const&)
|
|||
return;
|
||||
|
||||
// 2. Let parent be this summary element's parent.
|
||||
auto* parent = this->parent_element();
|
||||
auto parent = this->parent_element();
|
||||
|
||||
// 3. If the open attribute is present on parent, then remove it. Otherwise, set parent's open attribute to the empty string.
|
||||
if (parent->has_attribute(HTML::AttributeNames::open))
|
||||
|
@ -50,7 +50,7 @@ bool HTMLSummaryElement::is_summary_for_its_parent_details()
|
|||
return false;
|
||||
|
||||
// 2. Let parent be this summary element's parent.
|
||||
auto* parent = this->parent_element();
|
||||
auto parent = this->parent_element();
|
||||
|
||||
// 3. If parent is not a details element, then return false.
|
||||
if (!is<HTMLDetailsElement>(*parent))
|
||||
|
|
|
@ -215,7 +215,7 @@ WebIDL::Long HTMLTableCellElement::cell_index() const
|
|||
Optional<ARIA::Role> HTMLTableCellElement::default_role() const
|
||||
{
|
||||
if (local_name() == TagNames::th) {
|
||||
for (auto const* ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
for (auto ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
||||
// AD-HOC: The ancestor checks here aren’t explicitly defined in the spec, but implicitly follow from what
|
||||
// the spec does state, and from the physical placement/layout of elements. Also, the el-th and el-th-in-row
|
||||
// tests at https://wpt.fyi/results/html-aam/table-roles.html require doing these ancestor checks — and
|
||||
|
|
|
@ -151,7 +151,7 @@ void HTMLTrackElement::start_the_track_processing_model()
|
|||
return;
|
||||
|
||||
// 3. If the text track's track element does not have a media element as a parent, return.
|
||||
if (!is<HTMLMediaElement>(parent_element()))
|
||||
if (!is<HTMLMediaElement>(parent_element().ptr()))
|
||||
return;
|
||||
|
||||
// 4. Run the remainder of these steps in parallel, allowing whatever caused these steps to run to continue.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue