mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
64
Libraries/LibWeb/CSS/CSS.cpp
Normal file
64
Libraries/LibWeb/CSS/CSS.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/CSS/CSS.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/PropertyName.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
// https://www.w3.org/TR/cssom-1/#dom-css-escape
|
||||
WebIDL::ExceptionOr<String> escape(JS::VM&, StringView identifier)
|
||||
{
|
||||
// The escape(ident) operation must return the result of invoking serialize an identifier of ident.
|
||||
return serialize_an_identifier(identifier);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-conditional-3/#dom-css-supports
|
||||
bool supports(JS::VM& vm, StringView property, StringView value)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 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::ParsingContext { realm }, value, property_id.value()))
|
||||
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.
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-conditional-3/#dom-css-supports
|
||||
WebIDL::ExceptionOr<bool> supports(JS::VM& vm, StringView condition_text)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. If conditionText, parsed and evaluated as a <supports-condition>, would return true, return true.
|
||||
if (auto supports = parse_css_supports(Parser::ParsingContext { realm }, condition_text); supports && supports->matches())
|
||||
return true;
|
||||
|
||||
// 2. Otherwise, If conditionText, wrapped in parentheses and then parsed and evaluated as a <supports-condition>, would return true, return true.
|
||||
auto wrapped_condition_text = TRY_OR_THROW_OOM(vm, String::formatted("({})", condition_text));
|
||||
|
||||
if (auto supports = parse_css_supports(Parser::ParsingContext { realm }, wrapped_condition_text); supports && supports->matches())
|
||||
return true;
|
||||
|
||||
// 3. Otherwise, return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue