mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
script: Use an implemented pseudo-element to fortype=color
::color-swatch
(#37427)
Implement internal pseudo element, which would be resolved as a "Implemented Pseudo Element" within style computation. This is an concrete element that would has a primary style after the style computation, but could match and style resolved like an pseudo element. Therefore, it would have a different behavior compared to how does `pseudo`s that `ServoLayoutNode` had. Where they would not have a concrete element behind it. Note that, due to the nature of these pseudo elements residing inside a UA widget, these pseudo elements would therefore not be accessible in JavaScript by default. This kind of element is required in order to implement the [form control pseudo element](https://drafts.csswg.org/css-forms-1/#pseudo-elements) like `::placeholder`, `::color-swatch`, `::field-text`, etc. See [this docs](https://hackmd.io/@ChaKweTiau/BJ3zRdLQlg) for more details of the implementation. Then, the implemented pseudo element is utilized to implement style matching for input `type=text`. Servo's side of: https://github.com/servo/stylo/pull/212 Testing: No WPT regression. --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
This commit is contained in:
parent
d2ccf419c3
commit
378c4648e4
12 changed files with 201 additions and 163 deletions
|
@ -687,6 +687,43 @@ impl Element {
|
|||
Ok(shadow_root)
|
||||
}
|
||||
|
||||
/// Attach a UA widget shadow root with its default parameters.
|
||||
/// Additionally mark ShadowRoot to use styling configuration for a UA widget.
|
||||
///
|
||||
/// The general trait of these elements is that it would hide the implementation.
|
||||
/// Thus, we would make it inaccessible (i.e., closed mode, not cloneable, and
|
||||
/// not serializable).
|
||||
///
|
||||
/// With UA shadow root element being assumed as one element, any focus should
|
||||
/// be delegated to its host.
|
||||
///
|
||||
// TODO: Ideally, all of the UA shadow root should use UA widget styling, but
|
||||
// some of the UA widget implemented prior to the implementation of Gecko's
|
||||
// UA widget matching might need some tweaking.
|
||||
// FIXME: We are yet to implement more complex focusing with that is necessary
|
||||
// for delegate focus, and we are using workarounds for that right now.
|
||||
pub(crate) fn attach_ua_shadow_root(
|
||||
&self,
|
||||
use_ua_widget_styling: bool,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<ShadowRoot> {
|
||||
let root = self
|
||||
.attach_shadow(
|
||||
IsUserAgentWidget::Yes,
|
||||
ShadowRootMode::Closed,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
SlotAssignmentMode::Manual,
|
||||
can_gc,
|
||||
)
|
||||
.expect("Attaching UA shadow root failed");
|
||||
|
||||
root.upcast::<Node>()
|
||||
.set_in_ua_widget(use_ua_widget_styling);
|
||||
root
|
||||
}
|
||||
|
||||
pub(crate) fn detach_shadow(&self, can_gc: CanGc) {
|
||||
let Some(ref shadow_root) = self.shadow_root() else {
|
||||
unreachable!("Trying to detach a non-attached shadow root");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue