dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / css / style_sheet.lucb
#==============================================================================================
#
# style_sheet - CSS::StyleSheet: the base of every style sheet (owner node, media, title)
#
# DESCRIPTION:
# Port of LibWeb/CSS/StyleSheet.cpp (lines 1-57) and the inline members of StyleSheet.h
# (lines 18-79): the StyleSheet interface's state (owner node, parent style sheet,
# location, title, type, media list, the disabled, alternate and origin-clean flags).
#
# Copyright (c) 2018-2021, Andreas Kling <andreas@ladybird.org>
# Copyright (c) 2021, the SerenityOS developers.
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
# mark: StyleSheet.h ============================================================================
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:24 Web::CSS::StyleSheet::type (pure virtual).
pub func css_style_sheet_type_impl(this: CssStyleSheet*) -> ak.String:
_ = this
trap("pure virtual: Web::CSS::StyleSheet::type")
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:27 Web::CSS::StyleSheet::owner_node.
pub func css_style_sheet_owner_node(this: CssStyleSheet*) -> DomElement*?:
return this.m_owner_node
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:32 Web::CSS::StyleSheet::location.
pub func css_style_sheet_location(this: CssStyleSheet*) -> web_url.Url?:
return this.m_location
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:32 Web::CSS::StyleSheet::set_location.
pub func css_style_sheet_set_location(this: CssStyleSheet*, location: web_url.Url?):
this.m_location = location
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:35 Web::CSS::StyleSheet::title.
pub func css_style_sheet_title(this: CssStyleSheet*) -> ak.String:
return this.m_title
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:36 Web::CSS::StyleSheet::set_title.
pub func css_style_sheet_set_title(this: CssStyleSheet*, title: ak.String):
this.m_title = title
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:38 Web::CSS::StyleSheet::set_type.
pub func css_style_sheet_set_type(this: CssStyleSheet*, type_: ak.String):
this.m_type_string = type_
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:41 Web::CSS::StyleSheet::media.
pub func css_style_sheet_media(this: CssStyleSheet*) -> CssMediaList*:
return this.m_media
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:46 Web::CSS::StyleSheet::set_media.
pub func css_style_sheet_set_media(this: CssStyleSheet*, media: ak.String):
css_media_list_set_media_text(this.m_media, ak.string_bytes_as_string_view(&media))
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:50 Web::CSS::StyleSheet::is_alternate.
pub func css_style_sheet_is_alternate(this: CssStyleSheet*) -> bool:
return this.m_alternate
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:51 Web::CSS::StyleSheet::set_alternate.
pub func css_style_sheet_set_alternate(this: CssStyleSheet*, alternate: bool):
this.m_alternate = alternate
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:53 Web::CSS::StyleSheet::is_origin_clean.
pub func css_style_sheet_is_origin_clean(this: CssStyleSheet*) -> bool:
return this.m_origin_clean
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:54 Web::CSS::StyleSheet::set_origin_clean.
pub func css_style_sheet_set_origin_clean(this: CssStyleSheet*, origin_clean: bool):
this.m_origin_clean = origin_clean
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:57 Web::CSS::StyleSheet::disabled.
pub func css_style_sheet_disabled(this: CssStyleSheet*) -> bool:
return this.m_disabled
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:57 Web::CSS::StyleSheet::set_disabled (virtual).
pub func css_style_sheet_set_disabled_impl(this: CssStyleSheet*, disabled: bool):
this.m_disabled = disabled
## Ported from Libraries/LibWeb/CSS/StyleSheet.h:59 Web::CSS::StyleSheet::parent_style_sheet.
pub func css_style_sheet_parent_style_sheet(this: CssStyleSheet*) -> CssCssStyleSheet*?:
return this.m_parent_style_sheet
# mark: StyleSheet.cpp ==========================================================================
## Ported from Libraries/LibWeb/CSS/StyleSheet.cpp:15 Web::CSS::StyleSheet::StyleSheet.
pub func css_style_sheet_construct(this: CssStyleSheet*, realm: Realm*, media: CssMediaList*):
bind_platform_object_construct_realm(this.bind_platform_object(), realm)
css_style_sheet_init_fields(this)
this.m_media = media
css_media_list_set_associated_style_sheet(this.m_media, this)
## Ported from Libraries/LibWeb/CSS/StyleSheet.cpp:22 Web::CSS::StyleSheet::visit_edges (override).
pub func css_style_sheet_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
let this = (CssStyleSheet*)base
bind_platform_object_visit_edges_impl(base, visitor)
gc.cell_visitor_visit_t(visitor, this.m_owner_node)
gc.cell_visitor_visit_t(visitor, this.m_parent_style_sheet)
gc.cell_visitor_visit_t_2(visitor, this.m_media)
## Ported from Libraries/LibWeb/CSS/StyleSheet.cpp:30 Web::CSS::StyleSheet::href.
pub func css_style_sheet_href(this: CssStyleSheet*) -> ak.String?:
if let location = this.m_location:
return web_url.url_to_string(&location)
return none
## Ported from Libraries/LibWeb/CSS/StyleSheet.cpp:37 Web::CSS::StyleSheet::set_owner_node.
pub func css_style_sheet_set_owner_node(this: CssStyleSheet*, element: DomElement*?):
this.m_owner_node = element
## Ported from Libraries/LibWeb/CSS/StyleSheet.cpp:42 Web::CSS::StyleSheet::set_parent_css_style_sheet.
pub func css_style_sheet_set_parent_css_style_sheet(this: CssStyleSheet*, parent: CssCssStyleSheet*?):
this.m_parent_style_sheet = parent
## Ported from Libraries/LibWeb/CSS/StyleSheet.cpp:48 Web::CSS::StyleSheet::title_for_bindings.
# https://drafts.csswg.org/cssom/#dom-stylesheet-title
pub func css_style_sheet_title_for_bindings(this: CssStyleSheet*) -> ak.String?:
# The title attribute must return the title or null if title is the empty string.
if ak.string_is_empty(&this.m_title):
return none
return this.m_title