mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Remove Length::Type::Percentage :^)
All `<percentage>`s in the CSS grammar are now represented by the `Percentage` class, and `<length-percentage>` by `LengthPercentage`.
This commit is contained in:
parent
5e9a6302e5
commit
cff44831a8
Notes:
sideshowbarker
2024-07-17 20:36:12 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/cff44831a84 Pull-request: https://github.com/SerenityOS/serenity/pull/12007
5 changed files with 3 additions and 19 deletions
|
@ -307,13 +307,12 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
|
|||
)~~~");
|
||||
} else if (type_name == "length") {
|
||||
property_generator.append(R"~~~(
|
||||
if ((style_value.has_length() && !style_value.to_length().is_percentage()) || style_value.is_calculated())
|
||||
if (style_value.has_length() || style_value.is_calculated())
|
||||
return true;
|
||||
)~~~");
|
||||
} else if (type_name == "percentage") {
|
||||
// FIXME: Detecting lengths here is temporary until Length/Percentage are fully separated.
|
||||
property_generator.append(R"~~~(
|
||||
if (style_value.is_percentage() || style_value.is_calculated() || (style_value.has_length() && !style_value.to_length().is_percentage()))
|
||||
if (style_value.is_percentage() || style_value.is_calculated())
|
||||
return true;
|
||||
)~~~");
|
||||
} else if (type_name == "number" || type_name == "integer") {
|
||||
|
|
|
@ -55,8 +55,6 @@ Length Length::resolved(const Length& fallback_for_undefined, const Layout::Node
|
|||
return fallback_for_undefined;
|
||||
if (is_calculated())
|
||||
return Length(resolve_calculated_value(layout_node, reference_for_percent), Type::Px);
|
||||
if (is_percentage())
|
||||
return make_px(raw_value() / 100.0f * reference_for_percent);
|
||||
if (is_relative())
|
||||
return make_px(to_px(layout_node));
|
||||
return *this;
|
||||
|
@ -257,8 +255,6 @@ const char* Length::unit_name() const
|
|||
return "rem";
|
||||
case Type::Auto:
|
||||
return "auto";
|
||||
case Type::Percentage:
|
||||
return "%";
|
||||
case Type::Undefined:
|
||||
return "undefined";
|
||||
case Type::Vh:
|
||||
|
|
|
@ -16,7 +16,6 @@ class Length {
|
|||
public:
|
||||
enum class Type {
|
||||
Undefined,
|
||||
Percentage,
|
||||
Calculated,
|
||||
Auto,
|
||||
Cm,
|
||||
|
@ -52,7 +51,6 @@ public:
|
|||
|
||||
bool is_undefined_or_auto() const { return m_type == Type::Undefined || m_type == Type::Auto; }
|
||||
bool is_undefined() const { return m_type == Type::Undefined; }
|
||||
bool is_percentage() const { return m_type == Type::Percentage || m_type == Type::Calculated; }
|
||||
bool is_auto() const { return m_type == Type::Auto; }
|
||||
bool is_calculated() const { return m_type == Type::Calculated; }
|
||||
|
||||
|
|
|
@ -2184,12 +2184,7 @@ Optional<Length> Parser::parse_length(StyleComponentValueRule const& component_v
|
|||
if (dimension->is_length())
|
||||
return dimension->length();
|
||||
|
||||
// FIXME: This is a temporary hack until Length is split up fully.
|
||||
if (dimension->is_percentage()) {
|
||||
auto percentage = dimension->percentage();
|
||||
return Length { (float)percentage.value(), Length::Type::Percentage };
|
||||
}
|
||||
|
||||
// FIXME: auto isn't a length!
|
||||
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_case("auto"))
|
||||
return Length::make_auto();
|
||||
|
||||
|
|
|
@ -1194,10 +1194,6 @@ public:
|
|||
Percentage const& percentage() const { return m_percentage; }
|
||||
Percentage& percentage() { return m_percentage; }
|
||||
|
||||
// FIXME: This is a temporary hack until we fully separate Length and Percentage.
|
||||
bool has_length() const override { return true; }
|
||||
Length to_length() const override { return { m_percentage.value(), Length::Type::Percentage }; }
|
||||
|
||||
virtual String to_string() const override
|
||||
{
|
||||
return m_percentage.to_string();
|
||||
|
|
Loading…
Add table
Reference in a new issue