dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / css / style_values / rect_style_value.lucb
#==============================================================================================
#
# rect_style_value - RectStyleValue: rect()
#
# DESCRIPTION:
# Port of LibWeb/CSS/StyleValues/RectStyleValue.cpp (lines 1-45) and the inline members of
# RectStyleValue.h.
#
# Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
# Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
# Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
# Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.cpp:14 Web::CSS::RectStyleValue::create.
pub func css_rect_style_value_create(top: CssStyleValue*, right: CssStyleValue*, bottom: CssStyleValue*, left: CssStyleValue*) -> CssRectStyleValue*:
let this = &(new CssRectStyleValue[1] --- else trap("out of memory"))[0]
css_rect_style_value_construct(this, top, right, bottom, left)
return this
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h:22 Web::CSS::RectStyleValue::top.
pub func css_rect_style_value_top(this: CssRectStyleValue*) -> CssStyleValue*:
return this.m_top
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h:23 Web::CSS::RectStyleValue::right.
pub func css_rect_style_value_right(this: CssRectStyleValue*) -> CssStyleValue*:
return this.m_right
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h:24 Web::CSS::RectStyleValue::bottom.
pub func css_rect_style_value_bottom(this: CssRectStyleValue*) -> CssStyleValue*:
return this.m_bottom
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h:25 Web::CSS::RectStyleValue::left.
pub func css_rect_style_value_left(this: CssRectStyleValue*) -> CssStyleValue*:
return this.m_left
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h:27 Web::CSS::RectStyleValue::rect.
pub func css_rect_style_value_rect(this: CssRectStyleValue*) -> CssEdgeRect:
return CssEdgeRect(top_edge = css_length_or_auto_from_style_value(this.m_top, none), right_edge = css_length_or_auto_from_style_value(this.m_right, none), bottom_edge = css_length_or_auto_from_style_value(this.m_bottom, none), left_edge = css_length_or_auto_from_style_value(this.m_left, none))
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.cpp:19 Web::CSS::RectStyleValue::absolutized (override).
pub func css_rect_style_value_absolutized_impl(base: CssStyleValue*, context: CssComputationContext) -> CssStyleValue*:
let this = (CssRectStyleValue*)base
let top_absolutized = css_style_value_absolutized(this.m_top, context)
let right_absolutized = css_style_value_absolutized(this.m_right, context)
let bottom_absolutized = css_style_value_absolutized(this.m_bottom, context)
let left_absolutized = css_style_value_absolutized(this.m_left, context)
if css_style_values_equal(top_absolutized, this.m_top) and css_style_values_equal(right_absolutized, this.m_right) and css_style_values_equal(bottom_absolutized, this.m_bottom) and css_style_values_equal(left_absolutized, this.m_left):
return base
return css_rect_style_value_create(top_absolutized, right_absolutized, bottom_absolutized, left_absolutized).css_style_value()
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.cpp:32 Web::CSS::RectStyleValue::serialize (override).
pub func css_rect_style_value_serialize_impl(base: CssStyleValue*, builder: ak.StringBuilder*, mode: css_syntax.SerializationMode):
let this = (CssRectStyleValue*)base
ak.string_builder_append(builder, "rect(")
css_style_value_serialize(this.m_top, builder, mode)
ak.string_builder_append(builder, ", ")
css_style_value_serialize(this.m_right, builder, mode)
ak.string_builder_append(builder, ", ")
css_style_value_serialize(this.m_bottom, builder, mode)
ak.string_builder_append(builder, ", ")
css_style_value_serialize(this.m_left, builder, mode)
ak.string_builder_append(builder, ")")
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h:32 Web::CSS::RectStyleValue::properties_equal.
pub func css_rect_style_value_properties_equal(this: CssRectStyleValue*, other: CssRectStyleValue*) -> bool:
return css_style_values_equal(this.m_top, other.m_top) and css_style_values_equal(this.m_right, other.m_right) and css_style_values_equal(this.m_bottom, other.m_bottom) and css_style_values_equal(this.m_left, other.m_left)
## Ported from Libraries/LibWeb/CSS/StyleValues/StyleValue.h:202 Web::CSS::StyleValueWithDefaultOperators::equals for Web::CSS::RectStyleValue (CRTP helper) (override).
pub func css_rect_style_value_equals_impl(base: CssStyleValue*, other: CssStyleValue*) -> bool:
if css_style_value_type(base) != css_style_value_type(other):
return false
return css_rect_style_value_properties_equal((CssRectStyleValue*)base, (CssRectStyleValue*)other)
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h:40 Web::CSS::RectStyleValue::is_computationally_independent (override).
pub func css_rect_style_value_is_computationally_independent_impl(base: CssStyleValue*) -> bool:
let this = (CssRectStyleValue*)base
return css_style_value_is_computationally_independent(this.m_top) and css_style_value_is_computationally_independent(this.m_right) and css_style_value_is_computationally_independent(this.m_bottom) and css_style_value_is_computationally_independent(this.m_left)
## Ported from Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h:49 Web::CSS::RectStyleValue::RectStyleValue.
pub func css_rect_style_value_construct(this: CssRectStyleValue*, top: CssStyleValue*, right: CssStyleValue*, bottom: CssStyleValue*, left: CssStyleValue*):
css_style_value_construct(this.css_style_value(), CssStyleValueType.rect)
css_style_value_set_class(this.css_style_value(), (const CssStyleValueVTable*)&css_rect_style_value_vtable, &css_rect_style_value_class)
this.m_top = top
this.m_right = right
this.m_bottom = bottom
this.m_left = left