mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:57:34 +00:00
LibWeb: Allow passing StringView to CSSRuleList::insert_a_css_rule()
The spec is a little bizarre here. One caller of this (`CSSStyleSheet::insert_rule()`) wants to give it a parsed CSSRule, but the spec itself wants it to take a string. (As will be used by `CSSGroupingRule::insert_rule()`) Using a Variant isn't pretty but it's the best solution I've come to - having two overloads was worse, whether one called the other or they just duplicated the logic. This seems the least bad.
This commit is contained in:
parent
dfba0cb2d9
commit
6e6607a92f
2 changed files with 19 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -12,6 +12,7 @@
|
|||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
@ -49,7 +50,7 @@ public:
|
|||
bool is_supported_property_index(u32 index) const;
|
||||
|
||||
DOM::ExceptionOr<void> remove_a_css_rule(u32 index);
|
||||
DOM::ExceptionOr<unsigned> insert_a_css_rule(NonnullRefPtr<CSSRule>, u32 index);
|
||||
DOM::ExceptionOr<unsigned> insert_a_css_rule(Variant<StringView, NonnullRefPtr<CSSRule>>, u32 index);
|
||||
|
||||
void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;
|
||||
// Returns whether the match state of any media queries changed after evaluation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue