mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
layout: Simplify and generalize the usage of pseudo-elements (#36202)
- Remove the last remaining Servo-specific PseudoElement enum from layout. This was made to select `::before` and `::after` (both eager pseudo-elements), but now `traverse_pseudo_element` is called `traverse_eager_pseudo_element` and should work on any eager pseudo element. - Expose a single way of getting psuedo-element variants of ThreadSafeLayoutElement in the Layout DOM, which returns `None` when the pseudo-element doesn't apply (not defined for eager pseudo-elements or when trying to get `<details>` related pseudo-elements on elements that they don't apply to). - Ensure that NodeAndStyleInfo always refers to a node. This is done by making sure that anonymous boxes are all associated with their originating node. These changes are prepatory work for implementation of the `::marker` pseudo-element as well as ensuring that all anonymous boxes can be cached into the box tree eventually. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
c30ad5a30e
commit
b5c8164e99
15 changed files with 278 additions and 354 deletions
|
@ -116,19 +116,19 @@ pub fn process_resolved_style_request<'dom>(
|
|||
// We call process_resolved_style_request after performing a whole-document
|
||||
// traversal, so in the common case, the element is styled.
|
||||
let layout_element = node.to_threadsafe().as_element().unwrap();
|
||||
let layout_element = pseudo.map_or_else(
|
||||
|| Some(layout_element),
|
||||
|pseudo_element| layout_element.get_pseudo(pseudo_element),
|
||||
);
|
||||
|
||||
let layout_element = match layout_element {
|
||||
None => {
|
||||
// The pseudo doesn't exist, return nothing. Chrome seems to query
|
||||
// the element itself in this case, Firefox uses the resolved value.
|
||||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=29006
|
||||
return String::new();
|
||||
let layout_element = match pseudo {
|
||||
Some(pseudo_element_type) => {
|
||||
match layout_element.with_pseudo(*pseudo_element_type) {
|
||||
Some(layout_element) => layout_element,
|
||||
None => {
|
||||
// The pseudo doesn't exist, return nothing. Chrome seems to query
|
||||
// the element itself in this case, Firefox uses the resolved value.
|
||||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=29006
|
||||
return String::new();
|
||||
},
|
||||
}
|
||||
},
|
||||
Some(layout_element) => layout_element,
|
||||
None => layout_element,
|
||||
};
|
||||
|
||||
let style = &*layout_element.resolved_style();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue