mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 01:00:05 +00:00
LibWeb: Serialize resolved CSS values in dedicated serialization mode
This doesn't actually do anything differently yet, but it will in the very next commit.
This commit is contained in:
parent
e85c3c97fb
commit
b3c4b4fd97
Notes:
github-actions[bot]
2024-12-07 08:31:59 +00:00
Author: https://github.com/awesomekling
Commit: b3c4b4fd97
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2820
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 12 additions and 3 deletions
|
@ -271,7 +271,9 @@ String CSSStyleDeclaration::get_property_value(StringView property_name) const
|
||||||
if (property_id.value() == PropertyID::Custom) {
|
if (property_id.value() == PropertyID::Custom) {
|
||||||
auto maybe_custom_property = custom_property(FlyString::from_utf8_without_validation(property_name.bytes()));
|
auto maybe_custom_property = custom_property(FlyString::from_utf8_without_validation(property_name.bytes()));
|
||||||
if (maybe_custom_property.has_value()) {
|
if (maybe_custom_property.has_value()) {
|
||||||
return maybe_custom_property.value().value->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
return maybe_custom_property.value().value->to_string(
|
||||||
|
computed_flag() ? Web::CSS::CSSStyleValue::SerializationMode::ResolvedValue
|
||||||
|
: Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -302,7 +304,7 @@ String CSSStyleDeclaration::get_property_value(StringView property_name) const
|
||||||
|
|
||||||
// 3. If important flags of all declarations in list are same, then return the serialization of list.
|
// 3. If important flags of all declarations in list are same, then return the serialization of list.
|
||||||
// NOTE: Currently we implement property-specific shorthand serialization in ShorthandStyleValue::to_string().
|
// NOTE: Currently we implement property-specific shorthand serialization in ShorthandStyleValue::to_string().
|
||||||
return ShorthandStyleValue::create(property_id.value(), longhand_ids, list)->to_string(CSSStyleValue::SerializationMode::Normal);
|
return ShorthandStyleValue::create(property_id.value(), longhand_ids, list)->to_string(computed_flag() ? CSSStyleValue::SerializationMode::ResolvedValue : CSSStyleValue::SerializationMode::Normal);
|
||||||
|
|
||||||
// 4. Return the empty string.
|
// 4. Return the empty string.
|
||||||
// NOTE: This is handled by the loop.
|
// NOTE: This is handled by the loop.
|
||||||
|
@ -311,7 +313,9 @@ String CSSStyleDeclaration::get_property_value(StringView property_name) const
|
||||||
auto maybe_property = property(property_id.value());
|
auto maybe_property = property(property_id.value());
|
||||||
if (!maybe_property.has_value())
|
if (!maybe_property.has_value())
|
||||||
return {};
|
return {};
|
||||||
return maybe_property->value->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
return maybe_property->value->to_string(
|
||||||
|
computed_flag() ? Web::CSS::CSSStyleValue::SerializationMode::ResolvedValue
|
||||||
|
: Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertypriority
|
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertypriority
|
||||||
|
|
|
@ -50,6 +50,9 @@ public:
|
||||||
|
|
||||||
virtual GC::Ptr<CSSRule> parent_rule() const;
|
virtual GC::Ptr<CSSRule> parent_rule() const;
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/cssom/#cssstyledeclaration-computed-flag
|
||||||
|
[[nodiscard]] virtual bool computed_flag() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CSSStyleDeclaration(JS::Realm&);
|
explicit CSSStyleDeclaration(JS::Realm&);
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ private:
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
virtual bool computed_flag() const override { return true; }
|
||||||
|
|
||||||
RefPtr<CSSStyleValue const> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
|
RefPtr<CSSStyleValue const> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
|
||||||
|
|
||||||
GC::Ref<DOM::Element> m_element;
|
GC::Ref<DOM::Element> m_element;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue