dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / css / style_values / shadow_style_value.lucb
#==============================================================================================
#
# shadow_style_value - ShadowStyleValue: a box or text shadow
#
# DESCRIPTION:
# Port of LibWeb/CSS/StyleValues/ShadowStyleValue.cpp (lines 1-73) and the inline members
# of ShadowStyleValue.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/ShadowStyleValue.h:32 Web::CSS::ShadowStyleValue::create.
pub func css_shadow_style_value_create(shadow_type: CssShadowStyleValueShadowType, color: CssStyleValue*?, offset_x: CssStyleValue*, offset_y: CssStyleValue*, blur_radius: CssStyleValue*?, spread_distance: CssStyleValue*?, placement: CssShadowPlacement) -> CssShadowStyleValue*:
let this = &(new CssShadowStyleValue[1] --- else trap("out of memory"))[0]
css_shadow_style_value_construct(this, shadow_type, color, offset_x, offset_y, blur_radius, spread_distance, placement)
return this
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h:45 Web::CSS::ShadowStyleValue::shadow_type.
pub func css_shadow_style_value_shadow_type(this: CssShadowStyleValue*) -> CssShadowStyleValueShadowType:
return this.m_properties.shadow_type
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp:17 Web::CSS::ShadowStyleValue::serialize (override).
pub func css_shadow_style_value_serialize_impl(base: CssStyleValue*, builder: ak.StringBuilder*, mode: css_syntax.SerializationMode):
let this = (CssShadowStyleValue*)base
if let color = this.m_properties.color:
css_style_value_serialize(color, builder, mode)
ak.string_builder_append_u8(builder, ' ')
css_style_value_serialize(this.m_properties.offset_x, builder, mode)
ak.string_builder_append_u8(builder, ' ')
css_style_value_serialize(this.m_properties.offset_y, builder, mode)
if let blur_radius = this.m_properties.blur_radius:
ak.string_builder_append_u8(builder, ' ')
css_style_value_serialize(blur_radius, builder, mode)
if let spread_distance = this.m_properties.spread_distance:
if this.m_properties.shadow_type == CssShadowStyleValueShadowType.normal:
ak.string_builder_append_u8(builder, ' ')
css_style_value_serialize(spread_distance, builder, mode)
if this.m_properties.placement == CssShadowPlacement.inner:
ak.string_builder_append(builder, " inset")
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp:42 Web::CSS::ShadowStyleValue::color.
pub func css_shadow_style_value_color(this: CssShadowStyleValue*) -> CssStyleValue*:
let color = this.m_properties.color else return css_keyword_style_value_create(css_data.Keyword.currentcolor).css_style_value()
return color
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp:49 Web::CSS::ShadowStyleValue::blur_radius.
pub func css_shadow_style_value_blur_radius(this: CssShadowStyleValue*) -> CssStyleValue*:
let blur_radius = this.m_properties.blur_radius else return css_length_style_value_create(css_length_make_px_css_pixels(gfx.CssPixels.from_int(0))).css_style_value()
return blur_radius
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp:56 Web::CSS::ShadowStyleValue::spread_distance.
pub func css_shadow_style_value_spread_distance(this: CssShadowStyleValue*) -> CssStyleValue*:
let spread_distance = this.m_properties.spread_distance else return css_length_style_value_create(css_length_make_px_css_pixels(gfx.CssPixels.from_int(0))).css_style_value()
return spread_distance
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp:63 Web::CSS::ShadowStyleValue::absolutized (override).
pub func css_shadow_style_value_absolutized_impl(base: CssStyleValue*, computation_context: CssComputationContext) -> CssStyleValue*:
let this = (CssShadowStyleValue*)base
let absolutized_color = css_style_value_absolutized(css_shadow_style_value_color(this), computation_context)
let absolutized_offset_x = css_style_value_absolutized(css_shadow_style_value_offset_x(this), computation_context)
let absolutized_offset_y = css_style_value_absolutized(css_shadow_style_value_offset_y(this), computation_context)
let absolutized_blur_radius = css_style_value_absolutized(css_shadow_style_value_blur_radius(this), computation_context)
let absolutized_spread_distance = css_style_value_absolutized(css_shadow_style_value_spread_distance(this), computation_context)
return css_shadow_style_value_create(this.m_properties.shadow_type, absolutized_color, absolutized_offset_x, absolutized_offset_y, absolutized_blur_radius, absolutized_spread_distance, css_shadow_style_value_placement(this)).css_style_value()
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h:47 Web::CSS::ShadowStyleValue::offset_x.
pub func css_shadow_style_value_offset_x(this: CssShadowStyleValue*) -> CssStyleValue*:
return this.m_properties.offset_x
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h:48 Web::CSS::ShadowStyleValue::offset_y.
pub func css_shadow_style_value_offset_y(this: CssShadowStyleValue*) -> CssStyleValue*:
return this.m_properties.offset_y
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h:51 Web::CSS::ShadowStyleValue::placement.
pub func css_shadow_style_value_placement(this: CssShadowStyleValue*) -> CssShadowPlacement:
return this.m_properties.placement
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h:55 Web::CSS::ShadowStyleValue::properties_equal.
pub func css_shadow_style_value_properties_equal(this: CssShadowStyleValue*, other: CssShadowStyleValue*) -> bool:
let a = &this.m_properties
let b = &other.m_properties
return a.shadow_type == b.shadow_type and css_optional_style_values_equal(a.color, b.color) and css_style_values_equal(a.offset_x, b.offset_x) and css_style_values_equal(a.offset_y, b.offset_y) and css_optional_style_values_equal(a.blur_radius, b.blur_radius) and css_optional_style_values_equal(a.spread_distance, b.spread_distance) and a.placement == b.placement
## Ported from Libraries/LibWeb/CSS/StyleValues/StyleValue.h:202 Web::CSS::StyleValueWithDefaultOperators::equals for Web::CSS::ShadowStyleValue (CRTP helper) (override).
pub func css_shadow_style_value_equals_impl(base: CssStyleValue*, other: CssStyleValue*) -> bool:
if css_style_value_type(base) != css_style_value_type(other):
return false
return css_shadow_style_value_properties_equal((CssShadowStyleValue*)base, (CssShadowStyleValue*)other)
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h:57 Web::CSS::ShadowStyleValue::is_computationally_independent (override).
pub func css_shadow_style_value_is_computationally_independent_impl(base: CssStyleValue*) -> bool:
let this = (CssShadowStyleValue*)base
return css_is_null_or_computationally_independent(this.m_properties.color) and css_style_value_is_computationally_independent(this.m_properties.offset_x) and css_style_value_is_computationally_independent(this.m_properties.offset_y) and css_is_null_or_computationally_independent(this.m_properties.blur_radius) and css_is_null_or_computationally_independent(this.m_properties.spread_distance)
## Ported from Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h:67 Web::CSS::ShadowStyleValue::ShadowStyleValue.
pub func css_shadow_style_value_construct(this: CssShadowStyleValue*, shadow_type: CssShadowStyleValueShadowType, color: CssStyleValue*?, offset_x: CssStyleValue*, offset_y: CssStyleValue*, blur_radius: CssStyleValue*?, spread_distance: CssStyleValue*?, placement: CssShadowPlacement):
css_style_value_construct(this.css_style_value(), CssStyleValueType.shadow)
css_style_value_set_class(this.css_style_value(), (const CssStyleValueVTable*)&css_shadow_style_value_vtable, &css_shadow_style_value_class)
this.m_properties = CssShadowStyleValueProperties(shadow_type = shadow_type, color = color, offset_x = offset_x, offset_y = offset_y, blur_radius = blur_radius, spread_distance = spread_distance, placement = placement)