mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
Libweb: Invalidate layout for the value
-attribute of li
-elements
This commit is contained in:
parent
370098514a
commit
029bcf13fd
Notes:
github-actions[bot]
2025-05-10 23:15:26 +00:00
Author: https://github.com/InvalidUsernameException
Commit: 029bcf13fd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4686
6 changed files with 38 additions and 4 deletions
|
@ -3298,10 +3298,10 @@ size_t Element::number_of_owned_list_items() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/grouping-content.html#list-owner
|
// https://html.spec.whatwg.org/multipage/grouping-content.html#list-owner
|
||||||
Element const* Element::list_owner() const
|
Element* Element::list_owner() const
|
||||||
{
|
{
|
||||||
// Any element whose computed value of 'display' is 'list-item' has a list owner, which is determined as follows:
|
// Any element whose computed value of 'display' is 'list-item' has a list owner, which is determined as follows:
|
||||||
if (!computed_properties()->display().is_list_item())
|
if (!computed_properties() || !computed_properties()->display().is_list_item())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// 1. If the element is not being rendered, return null; the element has no list owner.
|
// 1. If the element is not being rendered, return null; the element has no list owner.
|
||||||
|
@ -3332,7 +3332,7 @@ Element const* Element::list_owner() const
|
||||||
}
|
}
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
return ancestor;
|
return const_cast<Element*>(ancestor.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/grouping-content.html#ordinal-value
|
// https://html.spec.whatwg.org/multipage/grouping-content.html#ordinal-value
|
||||||
|
|
|
@ -468,7 +468,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t number_of_owned_list_items() const;
|
size_t number_of_owned_list_items() const;
|
||||||
Element const* list_owner() const;
|
Element* list_owner() const;
|
||||||
size_t ordinal_value() const;
|
size_t ordinal_value() const;
|
||||||
|
|
||||||
void set_pointer_capture(WebIDL::Long pointer_id);
|
void set_pointer_capture(WebIDL::Long pointer_id);
|
||||||
|
|
|
@ -27,6 +27,17 @@ void HTMLLIElement::initialize(JS::Realm& realm)
|
||||||
Base::initialize(realm);
|
Base::initialize(realm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HTMLLIElement::attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
||||||
|
{
|
||||||
|
Base::attribute_changed(local_name, old_value, value, namespace_);
|
||||||
|
|
||||||
|
if (local_name == HTML::AttributeNames::value) {
|
||||||
|
if (auto* owner = list_owner()) {
|
||||||
|
owner->set_needs_layout_tree_update(true, DOM::SetNeedsLayoutTreeUpdateReason::HTMLOListElementOrdinalValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/grouping-content.html#dom-li-value
|
// https://html.spec.whatwg.org/multipage/grouping-content.html#dom-li-value
|
||||||
WebIDL::Long HTMLLIElement::value()
|
WebIDL::Long HTMLLIElement::value()
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,6 +45,7 @@ private:
|
||||||
HTMLLIElement(DOM::Document&, DOM::QualifiedName);
|
HTMLLIElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
virtual void attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
||||||
|
|
||||||
virtual bool is_presentational_hint(FlyString const&) const override;
|
virtual bool is_presentational_hint(FlyString const&) const override;
|
||||||
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
|
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<ol>
|
||||||
|
<li value="42">Item a</li>
|
||||||
|
<li>Item b</li>
|
||||||
|
</ol>
|
17
Tests/LibWeb/Ref/input/li-change-value-attribute.html
Normal file
17
Tests/LibWeb/Ref/input/li-change-value-attribute.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<link rel="match" href="../expected/li-change-value-attribute-ref.html" />
|
||||||
|
<ol>
|
||||||
|
<li id="first">Item a</li>
|
||||||
|
<li>Item b</li>
|
||||||
|
</ol>
|
||||||
|
<script>
|
||||||
|
// Two nested requestAnimationFrame() calls to force code execution _after_ initial paint
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
document.getElementById("first").value = 42;
|
||||||
|
document.documentElement.className = '';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue