mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
LibWeb: Distinguish between length and percentage values
Though most CSS properties accept either, some do not, so distinguishing between them lets us catch some invalid values at parse time.
This commit is contained in:
parent
3f311ec0ac
commit
450b782c18
1 changed files with 8 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -334,10 +335,14 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
|
|||
if (style_value.is_image())
|
||||
return true;
|
||||
)~~~");
|
||||
} else if (type_name == "length" || type_name == "percentage") {
|
||||
// FIXME: Handle lengths and percentages separately
|
||||
} else if (type_name == "length") {
|
||||
property_generator.append(R"~~~(
|
||||
if (style_value.has_length() || style_value.is_calculated())
|
||||
if ((style_value.has_length() && !style_value.to_length().is_percentage()) || style_value.is_calculated())
|
||||
return true;
|
||||
)~~~");
|
||||
} else if (type_name == "percentage") {
|
||||
property_generator.append(R"~~~(
|
||||
if ((style_value.has_length() && style_value.to_length().is_percentage()) || style_value.is_calculated())
|
||||
return true;
|
||||
)~~~");
|
||||
} else if (type_name == "number" || type_name == "integer") {
|
||||
|
|
Loading…
Reference in a new issue