forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Add pseudoElement parameter to GetAnimationsOptions
This corresponds to: w3c/csswg-drafts#11050 For now, we don't do anything useful with this parameter, because we don't yet support animating pseudo-elements.
- Loading branch information
Showing
14 changed files
with
141 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
#import <Animations/Animation.idl> | ||
#import <Animations/KeyframeEffect.idl> | ||
|
||
// https://www.w3.org/TR/web-animations-1/#the-animatable-interface-mixin | ||
// https://drafts.csswg.org/web-animations-1/#the-animatable-interface-mixin | ||
interface mixin Animatable { | ||
Animation animate(object? keyframes, optional (unrestricted double or KeyframeAnimationOptions) options = {}); | ||
sequence<Animation> getAnimations(optional GetAnimationsOptions options = {}); | ||
}; | ||
|
||
// https://www.w3.org/TR/web-animations-1/#dictdef-keyframeanimationoptions | ||
// https://drafts.csswg.org/web-animations-1/#dictdef-keyframeanimationoptions | ||
dictionary KeyframeAnimationOptions : KeyframeEffectOptions { | ||
DOMString id = ""; | ||
AnimationTimeline? timeline; | ||
}; | ||
|
||
// https://www.w3.org/TR/web-animations-1/#dictdef-getanimationsoptions | ||
// https://drafts.csswg.org/web-animations-1/#dictdef-getanimationsoptions | ||
dictionary GetAnimationsOptions { | ||
boolean subtree = false; | ||
CSSOMString? pseudoElement = null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Userland/Libraries/LibWeb/Animations/PseudoElementParsing.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2024, Sam Atkins <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include "PseudoElementParsing.h" | ||
#include <LibWeb/CSS/Parser/Parser.h> | ||
|
||
namespace Web::Animations { | ||
|
||
// https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-pseudo-element-parsing | ||
WebIDL::ExceptionOr<Optional<CSS::Selector::PseudoElement>> pseudo_element_parsing(JS::Realm& realm, Optional<String> const& value) | ||
{ | ||
// 1. Given the value value, perform the following steps: | ||
|
||
// 2. If value is not null and is an invalid <pseudo-element-selector>, | ||
Optional<CSS::Selector::PseudoElement> pseudo_element; | ||
if (value.has_value()) { | ||
pseudo_element = parse_pseudo_element_selector(CSS::Parser::ParsingContext { realm }, *value); | ||
if (!pseudo_element.has_value()) { | ||
// 1. Throw a DOMException with error name "SyntaxError". | ||
// 2. Abort. | ||
return WebIDL::SyntaxError::create(realm, MUST(String::formatted("Invalid pseudo-element selector: \"{}\"", value.value()))); | ||
} | ||
} | ||
|
||
// 3. If value is one of the legacy Selectors Level 2 single-colon selectors (':before', ':after', ':first-letter', or ':first-line'), | ||
// then return the equivalent two-colon selector (e.g. '::before'). | ||
if (value.has_value() && value->is_one_of(":before", ":after", ":first-letter", ":first-line")) { | ||
return CSS::Selector::PseudoElement::from_string(MUST(value->substring_from_byte_offset(1))); | ||
} | ||
|
||
// 4. Otherwise, return value. | ||
return pseudo_element; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
Userland/Libraries/LibWeb/Animations/PseudoElementParsing.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2024, Sam Atkins <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/Optional.h> | ||
#include <AK/String.h> | ||
#include <LibWeb/CSS/Selector.h> | ||
#include <LibWeb/WebIDL/ExceptionOr.h> | ||
|
||
namespace Web::Animations { | ||
|
||
// https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-pseudo-element-parsing | ||
WebIDL::ExceptionOr<Optional<CSS::Selector::PseudoElement>> pseudo_element_parsing(JS::Realm&, Optional<String> const&); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters