diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 77c13a040b1..b6d195196b8 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -74,6 +74,7 @@ set(SOURCES CSS/StyleValues/BorderRadiusShorthandStyleValue.cpp CSS/StyleValues/BorderRadiusStyleValue.cpp CSS/StyleValues/BorderStyleValue.cpp + CSS/StyleValues/CalculatedStyleValue.cpp CSS/StyleValues/ColorStyleValue.cpp CSS/StyleValues/ConicGradientStyleValue.cpp CSS/StyleValues/ContentStyleValue.cpp diff --git a/Userland/Libraries/LibWeb/CSS/CalculatedOr.h b/Userland/Libraries/LibWeb/CSS/CalculatedOr.h index f64e879476a..28d6aeb834c 100644 --- a/Userland/Libraries/LibWeb/CSS/CalculatedOr.h +++ b/Userland/Libraries/LibWeb/CSS/CalculatedOr.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include namespace Web::CSS { diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index f5f83af1d82..c9e27c2efe4 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/PercentageOr.h b/Userland/Libraries/LibWeb/CSS/PercentageOr.h index 4e7166a1885..a790cb7b102 100644 --- a/Userland/Libraries/LibWeb/CSS/PercentageOr.h +++ b/Userland/Libraries/LibWeb/CSS/PercentageOr.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include namespace Web::CSS { diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 4b5b1495826..87f76868caa 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index ec330244c22..cd7d9406c08 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -323,754 +324,4 @@ StyleValueList const& StyleValue::as_value_list() const return static_cast(*this); } -void CalculatedStyleValue::CalculationResult::add(CalculationResult const& other, Layout::Node const* layout_node, PercentageBasis const& percentage_basis) -{ - add_or_subtract_internal(SumOperation::Add, other, layout_node, percentage_basis); -} - -void CalculatedStyleValue::CalculationResult::subtract(CalculationResult const& other, Layout::Node const* layout_node, PercentageBasis const& percentage_basis) -{ - add_or_subtract_internal(SumOperation::Subtract, other, layout_node, percentage_basis); -} - -void CalculatedStyleValue::CalculationResult::add_or_subtract_internal(SumOperation op, CalculationResult const& other, Layout::Node const* layout_node, PercentageBasis const& percentage_basis) -{ - // We know from validation when resolving the type, that "both sides have the same type, or that one side is a and the other is an ". - // Though, having the same type may mean that one side is a and the other a . - // Note: This is almost identical to ::add() - - m_value.visit( - [&](Number const& number) { - auto other_number = other.m_value.get(); - if (op == SumOperation::Add) { - m_value = number + other_number; - } else { - m_value = number - other_number; - } - }, - [&](Angle const& angle) { - auto this_degrees = angle.to_degrees(); - if (other.m_value.has()) { - auto other_degrees = other.m_value.get().to_degrees(); - if (op == SumOperation::Add) - m_value = Angle::make_degrees(this_degrees + other_degrees); - else - m_value = Angle::make_degrees(this_degrees - other_degrees); - } else { - VERIFY(percentage_basis.has()); - - auto other_degrees = percentage_basis.get().percentage_of(other.m_value.get()).to_degrees(); - if (op == SumOperation::Add) - m_value = Angle::make_degrees(this_degrees + other_degrees); - else - m_value = Angle::make_degrees(this_degrees - other_degrees); - } - }, - [&](Frequency const& frequency) { - auto this_hertz = frequency.to_hertz(); - if (other.m_value.has()) { - auto other_hertz = other.m_value.get().to_hertz(); - if (op == SumOperation::Add) - m_value = Frequency::make_hertz(this_hertz + other_hertz); - else - m_value = Frequency::make_hertz(this_hertz - other_hertz); - } else { - VERIFY(percentage_basis.has()); - - auto other_hertz = percentage_basis.get().percentage_of(other.m_value.get()).to_hertz(); - if (op == SumOperation::Add) - m_value = Frequency::make_hertz(this_hertz + other_hertz); - else - m_value = Frequency::make_hertz(this_hertz - other_hertz); - } - }, - [&](Length const& length) { - auto this_px = length.to_px(*layout_node); - if (other.m_value.has()) { - auto other_px = other.m_value.get().to_px(*layout_node); - if (op == SumOperation::Add) - m_value = Length::make_px(this_px + other_px); - else - m_value = Length::make_px(this_px - other_px); - } else { - VERIFY(percentage_basis.has()); - - auto other_px = percentage_basis.get().percentage_of(other.m_value.get()).to_px(*layout_node); - if (op == SumOperation::Add) - m_value = Length::make_px(this_px + other_px); - else - m_value = Length::make_px(this_px - other_px); - } - }, - [&](Time const& time) { - auto this_seconds = time.to_seconds(); - if (other.m_value.has