layout: Use the PseudoElement from ServoThreadSafeLayoutNode in NodeAndStyleInfo (#38630)

Instead of storing the non-pseudo version of the node in
`NodeAndStyleInfo`, store the pseudo version and use that to query the
`PseudoElement` that a `NodeAndStyleInfo` refers to.

This is a step on the way toward fixing nested pseudo-elements in Servo.

Testing: This should not change behavior and is thus covered by existing
WPT tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-08-13 19:31:57 +02:00 committed by GitHub
parent ee7c1d9109
commit 5ff084a688
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 34 additions and 38 deletions

View file

@ -14,8 +14,8 @@ use layout_api::wrapper_traits::{
LayoutDataTrait, LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
};
use layout_api::{
GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutNodeType, SVGElementData, StyleData,
TrustedNodeAddress,
GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType,
SVGElementData, StyleData, TrustedNodeAddress,
};
use net_traits::image_cache::Image;
use pixels::ImageMetadata;
@ -258,8 +258,16 @@ impl<'dom> ServoThreadSafeLayoutNode<'dom> {
.map(Self::new)
}
pub fn is_text_container_of_single_line_input(&self) -> bool {
self.pseudo.is_none() && self.node.node.is_text_container_of_single_line_input()
/// Whether this is a container for the text within a single-line text input. This
/// is used to solve the special case of line height for a text entry widget.
/// <https://html.spec.whatwg.org/multipage/#the-input-element-as-a-text-entry-widget>
// TODO(stevennovaryo): Remove the addition of HTMLInputElement here once all of the
// input element is implemented with UA shadow DOM. This is temporary
// workaround for past version of input element where we are
// rendering it as a bare html element.
pub fn is_single_line_text_input(&self) -> bool {
self.type_id() == Some(LayoutNodeType::Element(LayoutElementType::HTMLInputElement)) ||
(self.pseudo.is_none() && self.node.node.is_text_container_of_single_line_input())
}
pub fn is_text_input(&self) -> bool {