mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
LibWeb: Split BorderRadiusStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
25114c159d
commit
66bc816284
10 changed files with 95 additions and 54 deletions
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.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
|
||||
*/
|
||||
|
||||
#include "BorderRadiusStyleValue.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
ErrorOr<String> BorderRadiusStyleValue::to_string() const
|
||||
{
|
||||
if (m_properties.horizontal_radius == m_properties.vertical_radius)
|
||||
return m_properties.horizontal_radius.to_string();
|
||||
return String::formatted("{} / {}", TRY(m_properties.horizontal_radius.to_string()), TRY(m_properties.vertical_radius.to_string()));
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue const> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size, CSSPixels line_height, CSSPixels root_line_height) const
|
||||
{
|
||||
if (m_properties.horizontal_radius.is_percentage() && m_properties.vertical_radius.is_percentage())
|
||||
return *this;
|
||||
auto absolutized_horizontal_radius = m_properties.horizontal_radius;
|
||||
auto absolutized_vertical_radius = m_properties.vertical_radius;
|
||||
if (!m_properties.horizontal_radius.is_percentage())
|
||||
absolutized_horizontal_radius = absolutized_length(m_properties.horizontal_radius.length(), viewport_rect, font_metrics, font_size, root_font_size, line_height, root_line_height).value_or(m_properties.horizontal_radius.length());
|
||||
if (!m_properties.vertical_radius.is_percentage())
|
||||
absolutized_vertical_radius = absolutized_length(m_properties.vertical_radius.length(), viewport_rect, font_metrics, font_size, root_font_size, line_height, root_line_height).value_or(m_properties.vertical_radius.length());
|
||||
return BorderRadiusStyleValue::create(absolutized_horizontal_radius, absolutized_vertical_radius);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue