1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:18:11 +00:00

LibWeb: Implement most of CSSStyleRule.insertRule()

This commit is contained in:
Andreas Kling 2021-09-29 21:12:39 +02:00
parent f53d0ddba2
commit 994e33b0f7
5 changed files with 42 additions and 8 deletions

View file

@ -5,6 +5,7 @@
*/
#include <LibWeb/CSS/CSSStyleSheet.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/DOM/ExceptionOr.h>
namespace Web::CSS {
@ -25,17 +26,17 @@ DOM::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned
// FIXME: 2. If the disallow modification flag is set, throw a NotAllowedError DOMException.
// Let parsed rule be the return value of invoking parse a rule with rule.
// 3. Let parsed rule be the return value of invoking parse a rule with rule.
auto parsed_rule = parse_css_rule(CSS::ParsingContext {}, rule);
// If parsed rule is a syntax error, return parsed rule.
// 4. If parsed rule is a syntax error, return parsed rule.
if (!parsed_rule)
return DOM::SyntaxError::create("Unable to parse CSS rule.");
// If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException.
// FIXME: 5. If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException.
// Return the result of invoking insert a CSS rule rule in the CSS rules at index.
(void)index;
(void)rule;
TODO();
// 6. Return the result of invoking insert a CSS rule rule in the CSS rules at index.
return m_rules->insert_a_css_rule(parsed_rule.release_nonnull(), index);
}
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-deleterule