mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-15 20:49:41 +00:00
LibWeb/CSS: Support converting CSSImageValue to a StyleValue
Some checks are pending
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
No known WPT improvements. CSSImageValue is a black box which we implement the same as CSSStyleValue, so this may not be observably different.
This commit is contained in:
parent
d855b3d90f
commit
feafaf09fc
Notes:
github-actions[bot]
2025-10-04 20:57:57 +00:00
Author: https://github.com/AtkinsSJ
Commit: feafaf09fc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6370
2 changed files with 28 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "CSSImageValue.h"
|
||||
#include <LibWeb/Bindings/CSSImageValuePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/PropertyNameAndID.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
|
@ -38,4 +39,30 @@ WebIDL::ExceptionOr<String> CSSImageValue::to_string() const
|
|||
return Base::to_string();
|
||||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#create-an-internal-representation
|
||||
WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSImageValue::create_an_internal_representation(PropertyNameAndID const& property) const
|
||||
{
|
||||
// If value is a CSSStyleValue subclass,
|
||||
// If value does not match the grammar of a list-valued property iteration of property, throw a TypeError.
|
||||
// NB: https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue-match-a-grammar doesn't list CSSImageValue, but
|
||||
// we should match <image>.
|
||||
bool const matches_grammar = [&] {
|
||||
if (property.is_custom_property()) {
|
||||
// FIXME: If this is a registered custom property, check if that allows <image>.
|
||||
return true;
|
||||
}
|
||||
return property_accepts_type(property.id(), ValueType::Image);
|
||||
}();
|
||||
if (!matches_grammar) {
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Property '{}' does not accept <image>", property.name())) };
|
||||
}
|
||||
|
||||
// FIXME: If any component of property’s CSS grammar has a limited numeric range, and the corresponding part of value
|
||||
// is a CSSUnitValue that is outside of that range, replace that value with the result of wrapping it in a
|
||||
// fresh CSSMathSum whose values internal slot contains only that part of value.
|
||||
|
||||
// Return the value.
|
||||
return NonnullRefPtr { *source_value() };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
virtual ~CSSImageValue() override = default;
|
||||
|
||||
virtual WebIDL::ExceptionOr<String> to_string() const override;
|
||||
virtual WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> create_an_internal_representation(PropertyNameAndID const&) const override;
|
||||
|
||||
private:
|
||||
explicit CSSImageValue(JS::Realm&, NonnullRefPtr<StyleValue const> source_value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue