mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-17 05:29:56 +00:00
LibWeb/CSS: Update CSS::supports() to match current spec
Also introduce usage of PropertyNameAndID.
This commit is contained in:
parent
ce7a8418ed
commit
2906176500
Notes:
github-actions[bot]
2025-10-02 12:47:38 +00:00
Author: https://github.com/AtkinsSJ
Commit: 2906176500
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6310
1 changed files with 7 additions and 12 deletions
|
@ -12,7 +12,7 @@
|
|||
#include <LibWeb/CSS/Parser/Syntax.h>
|
||||
#include <LibWeb/CSS/Parser/SyntaxParsing.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/PropertyName.h>
|
||||
#include <LibWeb/CSS/PropertyNameAndID.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
|
@ -26,21 +26,16 @@ WebIDL::ExceptionOr<String> escape(JS::VM&, StringView identifier)
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/css-conditional-3/#dom-css-supports
|
||||
bool supports(JS::VM&, FlyString const& property, StringView value)
|
||||
bool supports(JS::VM&, FlyString const& property_name, StringView value)
|
||||
{
|
||||
// 1. If property is an ASCII case-insensitive match for any defined CSS property that the UA supports,
|
||||
// and value successfully parses according to that property’s grammar, return true.
|
||||
if (auto property_id = property_id_from_string(property); property_id.has_value()) {
|
||||
if (parse_css_value(Parser::ParsingParams {}, value, property_id.value()))
|
||||
// 1. If property is an ASCII case-insensitive match for any defined CSS property that the UA supports, or is a
|
||||
// custom property name string, and value successfully parses according to that property’s grammar, return true.
|
||||
if (auto property = PropertyNameAndID::from_name(property_name); property.has_value()) {
|
||||
if (parse_css_value(Parser::ParsingParams {}, value, property->id()))
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. Otherwise, if property is a custom property name string, return true.
|
||||
else if (is_a_custom_property_name_string(property)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 3. Otherwise, return false.
|
||||
// 2. Otherwise, return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue