mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-11 21:52:53 +00:00
LibWeb: Implement length
and item()
for ResolvedCSSStyleDeclaration
This commit is contained in:
parent
08cf35cf9a
commit
a3a5af3fd1
Notes:
sideshowbarker
2024-07-17 03:05:16 +09:00
Author: https://github.com/AtkinsSJ
Commit: a3a5af3fd1
Pull-request: https://github.com/SerenityOS/serenity/pull/21269
1 changed files with 11 additions and 3 deletions
|
@ -61,15 +61,23 @@ void ResolvedCSSStyleDeclaration::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_element.ptr());
|
visitor.visit(m_element.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-length
|
||||||
size_t ResolvedCSSStyleDeclaration::length() const
|
size_t ResolvedCSSStyleDeclaration::length() const
|
||||||
{
|
{
|
||||||
return 0;
|
// The length attribute must return the number of CSS declarations in the declarations.
|
||||||
|
// FIXME: Include the number of custom properties.
|
||||||
|
return to_underlying(last_longhand_property_id) - to_underlying(first_longhand_property_id) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-item
|
||||||
String ResolvedCSSStyleDeclaration::item(size_t index) const
|
String ResolvedCSSStyleDeclaration::item(size_t index) const
|
||||||
{
|
{
|
||||||
(void)index;
|
// The item(index) method must return the property name of the CSS declaration at position index.
|
||||||
return {};
|
// FIXME: Return custom properties if index > last_longhand_property_id.
|
||||||
|
if (index > length())
|
||||||
|
return {};
|
||||||
|
auto property_id = static_cast<PropertyID>(index + to_underlying(first_longhand_property_id));
|
||||||
|
return MUST(String::from_utf8(string_from_property_id(property_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<StyleValue const> style_value_for_background_property(Layout::NodeWithStyle const& layout_node, Function<NonnullRefPtr<StyleValue const>(BackgroundLayerData const&)> callback, Function<NonnullRefPtr<StyleValue const>()> default_value)
|
static NonnullRefPtr<StyleValue const> style_value_for_background_property(Layout::NodeWithStyle const& layout_node, Function<NonnullRefPtr<StyleValue const>(BackgroundLayerData const&)> callback, Function<NonnullRefPtr<StyleValue const>()> default_value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue