mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibWeb: Let CSS::Size contain a CalculatedStyleValue
Technically this was already true, but now we explicitly allow it instead of that calc value being hidden inside a Length or Percentage.
This commit is contained in:
parent
ac4350748e
commit
62a8cf2bb8
4 changed files with 19 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -15,6 +16,7 @@ class Size {
|
|||
public:
|
||||
enum class Type {
|
||||
Auto,
|
||||
Calculated,
|
||||
Length,
|
||||
Percentage,
|
||||
MinContent,
|
||||
|
@ -27,12 +29,14 @@ public:
|
|||
static Size make_px(CSSPixels);
|
||||
static Size make_length(Length);
|
||||
static Size make_percentage(Percentage);
|
||||
static Size make_calculated(NonnullRefPtr<CalculatedStyleValue>);
|
||||
static Size make_min_content();
|
||||
static Size make_max_content();
|
||||
static Size make_fit_content(Length available_space);
|
||||
static Size make_none();
|
||||
|
||||
bool is_auto() const { return m_type == Type::Auto; }
|
||||
bool is_calculated() const { return m_type == Type::Calculated; }
|
||||
bool is_length() const { return m_type == Type::Length; }
|
||||
bool is_percentage() const { return m_type == Type::Percentage; }
|
||||
bool is_min_content() const { return m_type == Type::MinContent; }
|
||||
|
@ -45,6 +49,12 @@ public:
|
|||
|
||||
bool contains_percentage() const;
|
||||
|
||||
CalculatedStyleValue const& calculated() const
|
||||
{
|
||||
VERIFY(is_calculated());
|
||||
return m_length_percentage.calculated();
|
||||
}
|
||||
|
||||
CSS::Length const& length() const
|
||||
{
|
||||
VERIFY(is_length());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue