mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00: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
Notes:
sideshowbarker
2024-07-18 02:09:48 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/450b782c18b Pull-request: https://github.com/SerenityOS/serenity/pull/10540
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