summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp7
-rw-r--r--Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp8
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp3
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaList.cpp6
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp79
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.h1
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp28
-rw-r--r--Userland/Libraries/LibWeb/CSS/Supports.cpp5
-rw-r--r--Userland/Libraries/LibWeb/CSS/Supports.h2
12 files changed, 73 insertions, 72 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
index ce97679e98..9674c37424 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
@@ -49,6 +49,7 @@ ErrorOr<void> generate_header_file(JsonObject& properties, Core::File& file)
#include <AK/NonnullRefPtr.h>
#include <AK/StringView.h>
#include <AK/Traits.h>
+#include <LibJS/Forward.h>
#include <LibWeb/Forward.h>
namespace Web::CSS {
@@ -106,7 +107,7 @@ PropertyID property_id_from_camel_case_string(StringView);
PropertyID property_id_from_string(StringView);
StringView string_from_property_id(PropertyID);
bool is_inherited_property(PropertyID);
-NonnullRefPtr<StyleValue> property_initial_value(PropertyID);
+NonnullRefPtr<StyleValue> property_initial_value(JS::Realm&, PropertyID);
bool property_accepts_value(PropertyID, StyleValue&);
size_t property_maximum_value_count(PropertyID);
@@ -308,13 +309,13 @@ bool property_affects_stacking_context(PropertyID property_id)
}
}
-NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id)
+NonnullRefPtr<StyleValue> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
{
static Array<RefPtr<StyleValue>, to_underlying(last_property_id) + 1> initial_values;
static bool initialized = false;
if (!initialized) {
initialized = true;
- Parser::ParsingContext parsing_context;
+ Parser::ParsingContext parsing_context(context_realm);
)~~~");
// NOTE: Parsing a shorthand property requires that its longhands are already available here.
diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp
index 39db209b33..8db43b2672 100644
--- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp
@@ -41,6 +41,8 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::escape)
// https://www.w3.org/TR/css-conditional-3/#dom-css-supports
JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
{
+ auto& realm = *vm.current_realm();
+
if (!vm.argument_count())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountAtLeastOne, "CSS.supports");
@@ -53,7 +55,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
auto property = CSS::property_id_from_string(property_name);
if (property != CSS::PropertyID::Invalid) {
auto value_string = TRY(vm.argument(1).to_deprecated_string(vm));
- if (parse_css_value({}, value_string, property))
+ if (parse_css_value(CSS::Parser::ParsingContext { realm }, value_string, property))
return JS::Value(true);
}
// Otherwise, if property is a custom property name string, return true.
@@ -69,11 +71,11 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
auto supports_text = TRY(vm.argument(0).to_deprecated_string(vm));
// If conditionText, parsed and evaluated as a <supports-condition>, would return true, return true.
- if (auto supports = parse_css_supports({}, supports_text); supports && supports->matches())
+ if (auto supports = parse_css_supports(CSS::Parser::ParsingContext { realm }, supports_text); supports && supports->matches())
return JS::Value(true);
// Otherwise, If conditionText, wrapped in parentheses and then parsed and evaluated as a <supports-condition>, would return true, return true.
- if (auto supports = parse_css_supports({}, DeprecatedString::formatted("({})", supports_text)); supports && supports->matches())
+ if (auto supports = parse_css_supports(CSS::Parser::ParsingContext { realm }, DeprecatedString::formatted("({})", supports_text)); supports && supports->matches())
return JS::Value(true);
// Otherwise, return false.
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
index 53c581ef63..a44712e99a 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
@@ -93,7 +93,7 @@ WebIDL::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(Proper
return {};
// 5. Let component value list be the result of parsing value for property property.
- auto component_value_list = parse_css_value(CSS::Parser::ParsingContext {}, value, property_id);
+ auto component_value_list = parse_css_value(CSS::Parser::ParsingContext { realm() }, value, property_id);
// 6. If component value list is null, then return.
if (!component_value_list)
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp
index c886048f6c..75357e0f64 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp
@@ -99,7 +99,7 @@ DeprecatedString CSSStyleRule::selector_text() const
void CSSStyleRule::set_selector_text(StringView selector_text)
{
// 1. Run the parse a group of selectors algorithm on the given value.
- auto parsed_selectors = parse_selector({}, selector_text);
+ auto parsed_selectors = parse_selector(Parser::ParsingContext { realm() }, selector_text);
// 2. If the algorithm returns a non-null value replace the associated group of selectors with the returned value.
if (parsed_selectors.has_value())
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp
index 8d572e722c..24e77226a9 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp
@@ -54,7 +54,8 @@ WebIDL::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsign
// FIXME: 2. If the disallow modification flag is set, throw a NotAllowedError DOMException.
// 3. Let parsed rule be the return value of invoking parse a rule with rule.
- auto parsed_rule = parse_css_rule(CSS::Parser::ParsingContext {}, rule);
+ auto context = m_style_sheet_list ? CSS::Parser::ParsingContext { m_style_sheet_list->document() } : CSS::Parser::ParsingContext { realm() };
+ auto parsed_rule = parse_css_rule(context, rule);
// 4. If parsed rule is a syntax error, return parsed rule.
if (!parsed_rule)
diff --git a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp
index b27c0978b2..ff1b50a759 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp
@@ -37,7 +37,7 @@ DeprecatedString CSSSupportsRule::condition_text() const
void CSSSupportsRule::set_condition_text(DeprecatedString text)
{
- if (auto new_supports = parse_css_supports({}, text))
+ if (auto new_supports = parse_css_supports(Parser::ParsingContext { realm() }, text))
m_supports = new_supports.release_nonnull();
}
diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.cpp b/Userland/Libraries/LibWeb/CSS/MediaList.cpp
index c3abe4c2f0..038e8f4df3 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaList.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaList.cpp
@@ -44,7 +44,7 @@ void MediaList::set_media_text(DeprecatedString const& text)
m_media.clear();
if (text.is_empty())
return;
- m_media = parse_media_query_list({}, text);
+ m_media = parse_media_query_list(Parser::ParsingContext { realm() }, text);
}
bool MediaList::is_supported_property_index(u32 index) const
@@ -65,7 +65,7 @@ DeprecatedString MediaList::item(u32 index) const
void MediaList::append_medium(DeprecatedString medium)
{
// 1. Let m be the result of parsing the given value.
- auto m = parse_media_query({}, medium);
+ auto m = parse_media_query(Parser::ParsingContext { realm() }, medium);
// 2. If m is null, then return.
if (!m)
@@ -85,7 +85,7 @@ void MediaList::append_medium(DeprecatedString medium)
// https://www.w3.org/TR/cssom-1/#dom-medialist-deletemedium
void MediaList::delete_medium(DeprecatedString medium)
{
- auto m = parse_media_query({}, medium);
+ auto m = parse_media_query(Parser::ParsingContext { realm() }, medium);
if (!m)
return;
m_media.remove_all_matching([&](auto& existing) -> bool {
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 92d0cada9d..0dafea1438 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -40,11 +40,6 @@ static void log_parse_error(SourceLocation const& location = SourceLocation::cur
namespace Web::CSS::Parser {
-ParsingContext::ParsingContext()
- : m_realm(*Bindings::main_thread_vm().current_realm())
-{
-}
-
ParsingContext::ParsingContext(JS::Realm& realm)
: m_realm(realm)
{
@@ -1414,7 +1409,7 @@ Optional<Supports::Feature> Parser::parse_supports_feature(TokenStream<Component
if (auto declaration = consume_a_declaration(block_tokens); declaration.has_value()) {
transaction.commit();
return Supports::Feature {
- Supports::Declaration { declaration->to_string().release_value_but_fixme_should_propagate_errors() }
+ Supports::Declaration { declaration->to_string().release_value_but_fixme_should_propagate_errors(), JS::make_handle(m_context.realm()) }
};
}
}
@@ -1427,7 +1422,7 @@ Optional<Supports::Feature> Parser::parse_supports_feature(TokenStream<Component
builder.append(item.to_string().release_value_but_fixme_should_propagate_errors());
transaction.commit();
return Supports::Feature {
- Supports::Selector { builder.to_string().release_value_but_fixme_should_propagate_errors() }
+ Supports::Selector { builder.to_string().release_value_but_fixme_should_propagate_errors(), JS::make_handle(m_context.realm()) }
};
}
@@ -4075,15 +4070,15 @@ RefPtr<StyleValue> Parser::parse_background_value(Vector<ComponentValue> const&
};
auto complete_background_layer = [&]() {
- background_images.append(background_image ? background_image.release_nonnull() : property_initial_value(PropertyID::BackgroundImage));
- background_positions.append(background_position ? background_position.release_nonnull() : property_initial_value(PropertyID::BackgroundPosition));
- background_sizes.append(background_size ? background_size.release_nonnull() : property_initial_value(PropertyID::BackgroundSize));
- background_repeats.append(background_repeat ? background_repeat.release_nonnull() : property_initial_value(PropertyID::BackgroundRepeat));
- background_attachments.append(background_attachment ? background_attachment.release_nonnull() : property_initial_value(PropertyID::BackgroundAttachment));
+ background_images.append(background_image ? background_image.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundImage));
+ background_positions.append(background_position ? background_position.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundPosition));
+ background_sizes.append(background_size ? background_size.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundSize));
+ background_repeats.append(background_repeat ? background_repeat.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat));
+ background_attachments.append(background_attachment ? background_attachment.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment));
if (!background_origin && !background_clip) {
- background_origin = property_initial_value(PropertyID::BackgroundOrigin);
- background_clip = property_initial_value(PropertyID::BackgroundClip);
+ background_origin = property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin);
+ background_clip = property_initial_value(m_context.realm(), PropertyID::BackgroundClip);
} else if (!background_clip) {
background_clip = background_origin;
}
@@ -4195,7 +4190,7 @@ RefPtr<StyleValue> Parser::parse_background_value(Vector<ComponentValue> const&
complete_background_layer();
if (!background_color)
- background_color = property_initial_value(PropertyID::BackgroundColor);
+ background_color = property_initial_value(m_context.realm(), PropertyID::BackgroundColor);
return BackgroundStyleValue::create(
background_color.release_nonnull(),
StyleValueList::create(move(background_images), StyleValueList::Separator::Comma),
@@ -4208,21 +4203,21 @@ RefPtr<StyleValue> Parser::parse_background_value(Vector<ComponentValue> const&
}
if (!background_color)
- background_color = property_initial_value(PropertyID::BackgroundColor);
+ background_color = property_initial_value(m_context.realm(), PropertyID::BackgroundColor);
if (!background_image)
- background_image = property_initial_value(PropertyID::BackgroundImage);
+ background_image = property_initial_value(m_context.realm(), PropertyID::BackgroundImage);
if (!background_position)
- background_position = property_initial_value(PropertyID::BackgroundPosition);
+ background_position = property_initial_value(m_context.realm(), PropertyID::BackgroundPosition);
if (!background_size)
- background_size = property_initial_value(PropertyID::BackgroundSize);
+ background_size = property_initial_value(m_context.realm(), PropertyID::BackgroundSize);
if (!background_repeat)
- background_repeat = property_initial_value(PropertyID::BackgroundRepeat);
+ background_repeat = property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat);
if (!background_attachment)
- background_attachment = property_initial_value(PropertyID::BackgroundAttachment);
+ background_attachment = property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment);
if (!background_origin && !background_clip) {
- background_origin = property_initial_value(PropertyID::BackgroundOrigin);
- background_clip = property_initial_value(PropertyID::BackgroundClip);
+ background_origin = property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin);
+ background_clip = property_initial_value(m_context.realm(), PropertyID::BackgroundClip);
} else if (!background_clip) {
background_clip = background_origin;
}
@@ -4552,11 +4547,11 @@ RefPtr<StyleValue> Parser::parse_border_value(Vector<ComponentValue> const& comp
}
if (!border_width)
- border_width = property_initial_value(PropertyID::BorderWidth);
+ border_width = property_initial_value(m_context.realm(), PropertyID::BorderWidth);
if (!border_style)
- border_style = property_initial_value(PropertyID::BorderStyle);
+ border_style = property_initial_value(m_context.realm(), PropertyID::BorderStyle);
if (!border_color)
- border_color = property_initial_value(PropertyID::BorderColor);
+ border_color = property_initial_value(m_context.realm(), PropertyID::BorderColor);
return BorderStyleValue::create(border_width.release_nonnull(), border_style.release_nonnull(), border_color.release_nonnull());
}
@@ -5080,11 +5075,11 @@ RefPtr<StyleValue> Parser::parse_flex_value(Vector<ComponentValue> const& compon
}
if (!flex_grow)
- flex_grow = property_initial_value(PropertyID::FlexGrow);
+ flex_grow = property_initial_value(m_context.realm(), PropertyID::FlexGrow);
if (!flex_shrink)
- flex_shrink = property_initial_value(PropertyID::FlexShrink);
+ flex_shrink = property_initial_value(m_context.realm(), PropertyID::FlexShrink);
if (!flex_basis)
- flex_basis = property_initial_value(PropertyID::FlexBasis);
+ flex_basis = property_initial_value(m_context.realm(), PropertyID::FlexBasis);
return FlexStyleValue::create(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull());
}
@@ -5116,9 +5111,9 @@ RefPtr<StyleValue> Parser::parse_flex_flow_value(Vector<ComponentValue> const& c
}
if (!flex_direction)
- flex_direction = property_initial_value(PropertyID::FlexDirection);
+ flex_direction = property_initial_value(m_context.realm(), PropertyID::FlexDirection);
if (!flex_wrap)
- flex_wrap = property_initial_value(PropertyID::FlexWrap);
+ flex_wrap = property_initial_value(m_context.realm(), PropertyID::FlexWrap);
return FlexFlowStyleValue::create(flex_direction.release_nonnull(), flex_wrap.release_nonnull());
}
@@ -5229,13 +5224,13 @@ RefPtr<StyleValue> Parser::parse_font_value(Vector<ComponentValue> const& compon
return nullptr;
if (!font_stretch)
- font_stretch = property_initial_value(PropertyID::FontStretch);
+ font_stretch = property_initial_value(m_context.realm(), PropertyID::FontStretch);
if (!font_style)
- font_style = property_initial_value(PropertyID::FontStyle);
+ font_style = property_initial_value(m_context.realm(), PropertyID::FontStyle);
if (!font_weight)
- font_weight = property_initial_value(PropertyID::FontWeight);
+ font_weight = property_initial_value(m_context.realm(), PropertyID::FontWeight);
if (!line_height)
- line_height = property_initial_value(PropertyID::LineHeight);
+ line_height = property_initial_value(m_context.realm(), PropertyID::LineHeight);
return FontStyleValue::create(font_stretch.release_nonnull(), font_style.release_nonnull(), font_weight.release_nonnull(), font_size.release_nonnull(), line_height.release_nonnull(), font_families.release_nonnull());
}
@@ -5559,11 +5554,11 @@ RefPtr<StyleValue> Parser::parse_list_style_value(Vector<ComponentValue> const&
}
if (!list_position)
- list_position = property_initial_value(PropertyID::ListStylePosition);
+ list_position = property_initial_value(m_context.realm(), PropertyID::ListStylePosition);
if (!list_image)
- list_image = property_initial_value(PropertyID::ListStyleImage);
+ list_image = property_initial_value(m_context.realm(), PropertyID::ListStyleImage);
if (!list_type)
- list_type = property_initial_value(PropertyID::ListStyleType);
+ list_type = property_initial_value(m_context.realm(), PropertyID::ListStyleType);
return ListStyleStyleValue::create(list_position.release_nonnull(), list_image.release_nonnull(), list_type.release_nonnull());
}
@@ -5645,13 +5640,13 @@ RefPtr<StyleValue> Parser::parse_text_decoration_value(Vector<ComponentValue> co
}
if (!decoration_line)
- decoration_line = property_initial_value(PropertyID::TextDecorationLine);
+ decoration_line = property_initial_value(m_context.realm(), PropertyID::TextDecorationLine);
if (!decoration_thickness)
- decoration_thickness = property_initial_value(PropertyID::TextDecorationThickness);
+ decoration_thickness = property_initial_value(m_context.realm(), PropertyID::TextDecorationThickness);
if (!decoration_style)
- decoration_style = property_initial_value(PropertyID::TextDecorationStyle);
+ decoration_style = property_initial_value(m_context.realm(), PropertyID::TextDecorationStyle);
if (!decoration_color)
- decoration_color = property_initial_value(PropertyID::TextDecorationColor);
+ decoration_color = property_initial_value(m_context.realm(), PropertyID::TextDecorationColor);
return TextDecorationStyleValue::create(decoration_line.release_nonnull(), decoration_thickness.release_nonnull(), decoration_style.release_nonnull(), decoration_color.release_nonnull());
}
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
index 59e32c553b..fc95ad8b66 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
@@ -33,7 +33,6 @@ namespace Web::CSS::Parser {
class ParsingContext {
public:
- ParsingContext();
explicit ParsingContext(JS::Realm&);
explicit ParsingContext(DOM::Document const&);
explicit ParsingContext(DOM::Document const&, AK::URL);
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index 087ed52206..4594c409b8 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -111,22 +111,22 @@ private:
HashMap<float, NonnullRefPtr<Gfx::ScaledFont>> mutable m_cached_fonts;
};
-static CSSStyleSheet& default_stylesheet()
+static CSSStyleSheet& default_stylesheet(DOM::Document const& document)
{
static JS::Handle<CSSStyleSheet> sheet;
if (!sheet.cell()) {
extern StringView default_stylesheet_source;
- sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(), default_stylesheet_source));
+ sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(document), default_stylesheet_source));
}
return *sheet;
}
-static CSSStyleSheet& quirks_mode_stylesheet()
+static CSSStyleSheet& quirks_mode_stylesheet(DOM::Document const& document)
{
static JS::Handle<CSSStyleSheet> sheet;
if (!sheet.cell()) {
extern StringView quirks_mode_stylesheet_source;
- sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(), quirks_mode_stylesheet_source));
+ sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(document), quirks_mode_stylesheet_source));
}
return *sheet;
}
@@ -135,9 +135,9 @@ template<typename Callback>
void StyleComputer::for_each_stylesheet(CascadeOrigin cascade_origin, Callback callback) const
{
if (cascade_origin == CascadeOrigin::UserAgent) {
- callback(default_stylesheet());
+ callback(default_stylesheet(document()));
if (document().in_quirks_mode())
- callback(quirks_mode_stylesheet());
+ callback(quirks_mode_stylesheet(document()));
}
if (cascade_origin == CascadeOrigin::Author) {
for (auto const& sheet : document().style_sheets().sheets()) {
@@ -907,12 +907,12 @@ static DOM::Element const* element_to_inherit_style_from(DOM::Element const* ele
return parent_element;
}
-static NonnullRefPtr<StyleValue const> get_inherit_value(CSS::PropertyID property_id, DOM::Element const* element, Optional<CSS::Selector::PseudoElement> pseudo_element)
+static NonnullRefPtr<StyleValue const> get_inherit_value(JS::Realm& initial_value_context_realm, CSS::PropertyID property_id, DOM::Element const* element, Optional<CSS::Selector::PseudoElement> pseudo_element)
{
auto* parent_element = element_to_inherit_style_from(element, pseudo_element);
if (!parent_element || !parent_element->computed_css_values())
- return property_initial_value(property_id);
+ return property_initial_value(initial_value_context_realm, property_id);
return parent_element->computed_css_values()->property(property_id);
};
@@ -923,19 +923,19 @@ void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM
auto& value_slot = style.m_property_values[to_underlying(property_id)];
if (!value_slot) {
if (is_inherited_property(property_id))
- style.m_property_values[to_underlying(property_id)] = get_inherit_value(property_id, element, pseudo_element);
+ style.m_property_values[to_underlying(property_id)] = get_inherit_value(document().realm(), property_id, element, pseudo_element);
else
- style.m_property_values[to_underlying(property_id)] = property_initial_value(property_id);
+ style.m_property_values[to_underlying(property_id)] = property_initial_value(document().realm(), property_id);
return;
}
if (value_slot->is_initial()) {
- value_slot = property_initial_value(property_id);
+ value_slot = property_initial_value(document().realm(), property_id);
return;
}
if (value_slot->is_inherit()) {
- value_slot = get_inherit_value(property_id, element, pseudo_element);
+ value_slot = get_inherit_value(document().realm(), property_id, element, pseudo_element);
return;
}
@@ -944,10 +944,10 @@ void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM
if (value_slot->is_unset()) {
if (is_inherited_property(property_id)) {
// then if it is an inherited property, this is treated as inherit,
- value_slot = get_inherit_value(property_id, element, pseudo_element);
+ value_slot = get_inherit_value(document().realm(), property_id, element, pseudo_element);
} else {
// and if it is not, this is treated as initial.
- value_slot = property_initial_value(property_id);
+ value_slot = property_initial_value(document().realm(), property_id);
}
}
}
diff --git a/Userland/Libraries/LibWeb/CSS/Supports.cpp b/Userland/Libraries/LibWeb/CSS/Supports.cpp
index 65ba825edb..15e129b981 100644
--- a/Userland/Libraries/LibWeb/CSS/Supports.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Supports.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibJS/Runtime/Realm.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/Supports.h>
@@ -52,13 +53,13 @@ bool Supports::InParens::evaluate() const
bool Supports::Declaration::evaluate() const
{
- auto style_property = parse_css_supports_condition({}, declaration);
+ auto style_property = parse_css_supports_condition(Parser::ParsingContext { *realm }, declaration);
return style_property.has_value();
}
bool Supports::Selector::evaluate() const
{
- auto style_property = parse_selector({}, selector);
+ auto style_property = parse_selector(Parser::ParsingContext { *realm }, selector);
return style_property.has_value();
}
diff --git a/Userland/Libraries/LibWeb/CSS/Supports.h b/Userland/Libraries/LibWeb/CSS/Supports.h
index 99f8f01afc..826b80a208 100644
--- a/Userland/Libraries/LibWeb/CSS/Supports.h
+++ b/Userland/Libraries/LibWeb/CSS/Supports.h
@@ -23,12 +23,14 @@ class Supports final : public RefCounted<Supports> {
public:
struct Declaration {
String declaration;
+ JS::Handle<JS::Realm> realm;
bool evaluate() const;
ErrorOr<String> to_string() const;
};
struct Selector {
String selector;
+ JS::Handle<JS::Realm> realm;
bool evaluate() const;
ErrorOr<String> to_string() const;
};