script/layout: Implement Element.currentCSSZoom attribute (#40304)

Implements the `currentCSSZoom` readonly attribute on the Element
interface as
[spec](https://drafts.csswg.org/cssom-view/#dom-element-currentcsszoom).
- Adds a new layout query (`CurrentCSSZoomQuery`) that traverses from
the target element up through its ancestors
- Accumulates the product of all `zoom` CSS property values to compute
the effective zoom
- Returns 1.0 for elements that are not being rendered (display: none or
no layout data)

Testing: Updated WPT (removed 4 FAIL expectations from
`idlharness.html.ini`). Behavior tests in Element-currentCSSZoom.html
remain as expected FAIL because the underlying CSS `zoom` property
implementation in Servo does not yet apply zoom values to layout (the
zoom property is parsed but computed values remain 1.0).
Fixes: #40256

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
This commit is contained in:
WaterWhisperer
2025-11-05 22:25:53 +08:00
committed by GitHub
parent c23491f1a6
commit a90dff6919
9 changed files with 47 additions and 27 deletions

View File

@@ -2690,6 +2690,13 @@ impl Window {
.query_client_rect(node.to_trusted_node_address())
}
pub(crate) fn current_css_zoom_query(&self, node: &Node) -> f32 {
self.layout_reflow(QueryMsg::CurrentCSSZoomQuery);
self.layout
.borrow()
.query_current_css_zoom(node.to_trusted_node_address())
}
/// Find the scroll area of the given node, if it is not None. If the node
/// is None, find the scroll area of the viewport.
pub(crate) fn scrolling_area_query(&self, node: Option<&Node>) -> UntypedRect<i32> {