mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibWeb: Introduce CalculatedOr type
This is intended as a replacement for Length and friends each holding a `RefPtr<CalculatedStyleValue>`. Instead, let's make the types explicit about whether they are calculated or not. This then means a Length is always a Length, and won't require including `StyleValue.h`. As noted, it's probably nicer for LengthOrCalculated to live in `Length.h`, but we can't do that until Length stops including `StyleValue.h`.
This commit is contained in:
parent
b727f8113f
commit
fa90a3bb4f
Notes:
sideshowbarker
2024-07-17 23:00:03 +09:00
Author: https://github.com/AtkinsSJ
Commit: fa90a3bb4f
Pull-request: https://github.com/SerenityOS/serenity/pull/18104
5 changed files with 206 additions and 4 deletions
36
Userland/Libraries/LibWeb/CSS/CalculatedOr.cpp
Normal file
36
Userland/Libraries/LibWeb/CSS/CalculatedOr.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "CalculatedOr.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
|
||||
{
|
||||
return calculated->resolve_angle().value();
|
||||
}
|
||||
|
||||
Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
|
||||
{
|
||||
return calculated->resolve_frequency().value();
|
||||
}
|
||||
|
||||
Length LengthOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node) const
|
||||
{
|
||||
return calculated->resolve_length(layout_node).value();
|
||||
}
|
||||
|
||||
Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
|
||||
{
|
||||
return calculated->resolve_percentage().value();
|
||||
}
|
||||
|
||||
Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
|
||||
{
|
||||
return calculated->resolve_time().value();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue