LibWeb: Invalidate layout for ol-attributes that affect it

This commit is contained in:
InvalidUsernameException 2025-05-10 19:08:24 +02:00 committed by Andreas Kling
commit 370098514a
Notes: github-actions[bot] 2025-05-10 23:15:32 +00:00
9 changed files with 78 additions and 0 deletions

View file

@ -114,6 +114,7 @@ enum class SetNeedsLayoutReason {
X(ElementSetInnerHTML) \
X(DetailsElementOpenedOrClosed) \
X(HTMLInputElementSrcAttribute) \
X(HTMLOListElementOrdinalValues) \
X(HTMLObjectElementUpdateLayoutAndChildObjects) \
X(KeyframeEffect) \
X(NodeInsertBefore) \

View file

@ -8,6 +8,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/AttributeNames.h>
#include <LibWeb/HTML/HTMLOListElement.h>
#include <LibWeb/HTML/Numbers.h>
@ -28,6 +29,15 @@ void HTMLOListElement::initialize(JS::Realm& realm)
Base::initialize(realm);
}
void HTMLOListElement::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.is_one_of(HTML::AttributeNames::reversed, HTML::AttributeNames::start, HTML::AttributeNames::type)) {
set_needs_layout_tree_update(true, DOM::SetNeedsLayoutTreeUpdateReason::HTMLOListElementOrdinalValues);
}
}
// https://html.spec.whatwg.org/multipage/grouping-content.html#dom-ol-start
WebIDL::Long HTMLOListElement::start()
{

View file

@ -34,6 +34,7 @@ private:
HTMLOListElement(DOM::Document&, DOM::QualifiedName);
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 void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;

View file

@ -0,0 +1,5 @@
<!DOCTYPE html>
<ol reversed>
<li>Item a</li>
<li>Item b</li>
</ol>

View file

@ -0,0 +1,5 @@
<!DOCTYPE html>
<ol start="42">
<li>Item a</li>
<li>Item b</li>
</ol>

View file

@ -0,0 +1,5 @@
<!DOCTYPE html>
<ol type="I">
<li>Item a</li>
<li>Item b</li>
</ol>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="match" href="../expected/ol-change-reversed-attribute-ref.html" />
<ol id="list">
<li>Item a</li>
<li>Item b</li>
</ol>
<script>
// Two nested requestAnimationFrame() calls to force code execution _after_ initial paint
requestAnimationFrame(() => {
requestAnimationFrame(() => {
document.getElementById("list").reversed = true;
document.documentElement.className = '';
});
});
</script>
</html>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="match" href="../expected/ol-change-start-attribute-ref.html" />
<ol id="list">
<li>Item a</li>
<li>Item b</li>
</ol>
<script>
// Two nested requestAnimationFrame() calls to force code execution _after_ initial paint
requestAnimationFrame(() => {
requestAnimationFrame(() => {
document.getElementById("list").start = 42;
document.documentElement.className = '';
});
});
</script>
</html>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="match" href="../expected/ol-change-type-attribute-ref.html" />
<ol id="list">
<li>Item a</li>
<li>Item b</li>
</ol>
<script>
// Two nested requestAnimationFrame() calls to force code execution _after_ initial paint
requestAnimationFrame(() => {
requestAnimationFrame(() => {
document.getElementById("list").type = 'I';
document.documentElement.className = '';
});
});
</script>
</html>