dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / css / css_style_declaration.lucb
#==============================================================================================
#
# css_style_declaration - CSS::CSSStyleDeclaration: the base of declaration blocks
#
# DESCRIPTION:
# Port of LibWeb/CSS/CSSStyleDeclaration.cpp (lines 1-85) and the inline members of
# CSSStyleDeclaration.h (lines 20-98): the computed, readonly and updating flags, the
# parent rule and owner node, cssText, and "update style attribute for".
#
# Copyright (c) 2018-2024, Andreas Kling <andreas@ladybird.org>
# Copyright (c) 2023-2025, Sam Atkins <sam@ladybird.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
# mark: CSSStyleDeclaration.h ===================================================================
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:30 Web::CSS::CSSStyleDeclaration::length (pure virtual).
pub func css_style_declaration_length_impl(this: CssStyleDeclaration*) -> usize:
_ = this
trap("pure virtual: Web::CSS::CSSStyleDeclaration::length")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:31 Web::CSS::CSSStyleDeclaration::item (pure virtual).
pub func css_style_declaration_item_impl(this: CssStyleDeclaration*, index: usize) -> ak.String:
_ = this
_ = index
trap("pure virtual: Web::CSS::CSSStyleDeclaration::item")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:33 Web::CSS::CSSStyleDeclaration::set_property (pure virtual).
pub func css_style_declaration_set_property_impl(this: CssStyleDeclaration*, property_name: ak.FlyString, css_text: ak.StringView, priority: ak.StringView) -> !:
_ = this
_ = property_name
_ = css_text
_ = priority
trap("pure virtual: Web::CSS::CSSStyleDeclaration::set_property")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:34 Web::CSS::CSSStyleDeclaration::remove_property (pure virtual).
pub func css_style_declaration_remove_property_impl(this: CssStyleDeclaration*, property_name: ak.FlyString) -> ak.String!:
_ = this
_ = property_name
trap("pure virtual: Web::CSS::CSSStyleDeclaration::remove_property")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:36 Web::CSS::CSSStyleDeclaration::get_property_value (pure virtual).
pub func css_style_declaration_get_property_value_impl(this: CssStyleDeclaration*, property_name: ak.FlyString) -> ak.String:
_ = this
_ = property_name
trap("pure virtual: Web::CSS::CSSStyleDeclaration::get_property_value")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:37 Web::CSS::CSSStyleDeclaration::get_property_priority (pure virtual).
pub func css_style_declaration_get_property_priority_impl(this: CssStyleDeclaration*, property_name: ak.FlyString) -> ak.StringView:
_ = this
_ = property_name
trap("pure virtual: Web::CSS::CSSStyleDeclaration::get_property_priority")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:40 Web::CSS::CSSStyleDeclaration::set_css_text (pure virtual).
pub func css_style_declaration_set_css_text_impl(this: CssStyleDeclaration*, arg0: ak.StringView) -> !:
_ = this
_ = arg0
trap("pure virtual: Web::CSS::CSSStyleDeclaration::set_css_text")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:42 Web::CSS::CSSStyleDeclaration::serialized (pure virtual).
pub func css_style_declaration_serialized_impl(this: CssStyleDeclaration*) -> ak.String:
_ = this
trap("pure virtual: Web::CSS::CSSStyleDeclaration::serialized")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:45 Web::CSS::CSSStyleDeclaration::is_computed.
# https://drafts.csswg.org/cssom/#cssstyledeclaration-computed-flag
pub func css_style_declaration_is_computed(this: CssStyleDeclaration*) -> bool:
return this.m_computed
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:48 Web::CSS::CSSStyleDeclaration::is_readonly.
# https://drafts.csswg.org/cssom/#cssstyledeclaration-readonly-flag
pub func css_style_declaration_is_readonly(this: CssStyleDeclaration*) -> bool:
return this.m_readonly
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:51 Web::CSS::CSSStyleDeclaration::parent_rule.
# https://drafts.csswg.org/cssom/#cssstyledeclaration-parent-css-rule
pub func css_style_declaration_parent_rule(this: CssStyleDeclaration*) -> CssRule*?:
return this.m_parent_rule
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:52 Web::CSS::CSSStyleDeclaration::set_parent_rule.
pub func css_style_declaration_set_parent_rule(this: CssStyleDeclaration*, parent: CssRule*?):
this.m_parent_rule = parent
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:55 Web::CSS::CSSStyleDeclaration::owner_node.
# https://drafts.csswg.org/cssom/#cssstyledeclaration-owner-node
pub func css_style_declaration_owner_node(this: CssStyleDeclaration*) -> DomAbstractElement?:
return this.m_owner_node
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:56 Web::CSS::CSSStyleDeclaration::set_owner_node.
pub func css_style_declaration_set_owner_node(this: CssStyleDeclaration*, owner_node: DomAbstractElement?):
this.m_owner_node = owner_node
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:59 Web::CSS::CSSStyleDeclaration::is_updating.
# https://drafts.csswg.org/cssom/#cssstyledeclaration-updating-flag
pub func css_style_declaration_is_updating(this: CssStyleDeclaration*) -> bool:
return this.m_updating
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:60 Web::CSS::CSSStyleDeclaration::set_is_updating.
pub func css_style_declaration_set_is_updating(this: CssStyleDeclaration*, value: bool):
this.m_updating = value
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:62 Web::CSS::CSSStyleDeclaration::has_property (virtual).
pub func css_style_declaration_has_property_impl(this: CssStyleDeclaration*, arg0: CssPropertyNameAndId) -> bool:
_ = this
_ = arg0
trap("VERIFY_NOT_REACHED")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:63 Web::CSS::CSSStyleDeclaration::get_property_style_value (virtual).
pub func css_style_declaration_get_property_style_value_impl(this: CssStyleDeclaration*, arg0: CssPropertyNameAndId) -> CssStyleValue*?:
_ = this
_ = arg0
trap("VERIFY_NOT_REACHED")
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.h:64 Web::CSS::CSSStyleDeclaration::set_property_style_value (virtual).
pub func css_style_declaration_set_property_style_value_impl(this: CssStyleDeclaration*, arg0: CssPropertyNameAndId, arg1: CssStyleValue*) -> !:
_ = this
_ = arg0
_ = arg1
trap("VERIFY_NOT_REACHED")
# mark: CSSStyleDeclaration.cpp =================================================================
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp:18 Web::CSS::CSSStyleDeclaration::CSSStyleDeclaration.
pub func css_style_declaration_construct(this: CssStyleDeclaration*, realm: Realm*, computed: CssStyleDeclarationComputed, readonly: CssStyleDeclarationReadonly):
bind_platform_object_construct_realm(this.bind_platform_object(), realm)
this.m_computed = computed == CssStyleDeclarationComputed.yes
this.m_readonly = readonly == CssStyleDeclarationReadonly.yes
this.platform_object.m_legacy_platform_object_flags = BindPlatformObjectLegacyPlatformObjectFlags(supports_indexed_properties = 1)
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp:29 Web::CSS::CSSStyleDeclaration::initialize (override).
pub func css_style_declaration_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.css_style_declaration)
js_cell_initialize_impl(base, realm)
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp:36 Web::CSS::CSSStyleDeclaration::update_style_attribute.
# https://drafts.csswg.org/cssom/#update-style-attribute-for
pub func css_style_declaration_update_style_attribute(this: CssStyleDeclaration*):
# 1. Assert: declaration block’s computed flag is unset.
assert(not css_style_declaration_is_computed(this))
# 2. Let owner node be declaration block’s owner node.
# 3. If owner node is null, then return.
var owner_node = css_style_declaration_owner_node(this) else return
# 4. Set declaration block’s updating flag.
css_style_declaration_set_is_updating(this, true)
# 5. Set an attribute value for owner node using "style" and the result of serializing declaration block.
dom_element_set_attribute_value(dom_abstract_element_element(&owner_node), html_attribute_names_style, css_style_declaration_serialized(this))
# 6. Unset declaration block’s updating flag.
css_style_declaration_set_is_updating(this, false)
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp:58 Web::CSS::CSSStyleDeclaration::css_text.
# https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-csstext
pub func css_style_declaration_css_text(this: CssStyleDeclaration*) -> ak.String:
# 1. If the computed flag is set, then return the empty string.
if css_style_declaration_is_computed(this):
return ak.string_from_str("")
# 2. Return the result of serializing the declarations.
return css_style_declaration_serialized(this)
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp:68 Web::CSS::CSSStyleDeclaration::item_value (override).
pub func css_style_declaration_item_value_impl(base: BindPlatformObject*, index: usize) -> JsValue?:
let this = (CssStyleDeclaration*)base
let value = css_style_declaration_item(this, index)
if ak.string_is_empty(&value):
return none
return js_primitive_string_create_string(js_cell_vm(this.js_cell()), value)
## Ported from Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp:77 Web::CSS::CSSStyleDeclaration::visit_edges (override).
pub func css_style_declaration_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
let this = (CssStyleDeclaration*)base
bind_platform_object_visit_edges_impl(base, visitor)
gc.cell_visitor_visit_t(visitor, this.m_parent_rule)
if let owner_node = this.m_owner_node:
dom_abstract_element_visit(&owner_node, visitor)