You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[css-viewport] [cssom-view-1] Add a definition of the zoom CSS property (#9699)
* Add definition of the zoom css property
* Spell out the complete spec
* none
* Avoid zero
* Further clarifications
* Add zoom in more places
* Fixes to formatting
* Fixes to formatting
* Replace 'or zoom' with 'unscaled'
* Fix formatting and add alt text
* Shorten notes
* Shorten heading
* Add background images
* Omit fenced frames; clarify note about iframes
* Fix spec reference type
* Fix spaces and tabs
* Fix some lint issues
* Remove stray character
* Remove more 'and zoom'
* fix unscaled
* Fix newlines
* Special-case 0 and 0%
* HTMLImageElement.{x,y} should be scaled
* Address code review feedback
* Address code review comments
* Fix flat tree
* Add notes about web compat
* Fix references that should say 'scaled'
* Clarify effective zoom
* Fix typo
Co-authored-by: Simon Pieters <[email protected]>
* Switch to used value instead of computed style
* define used value instead of claiming it as a consequence
* Clarify flat tree ancestors
---------
Co-authored-by: Simon Pieters <[email protected]>
showing the zooming effect before and after zoom has applied. The second is 1.5 larger.">
465
+
</div>
466
+
467
+
<div class="example">
468
+
Example of nested zoom.
469
+
In this example, "Inner text" is 4x as large as "Outer text",
470
+
and "Middle text" is 2x as large as "Outer text".
471
+
472
+
<pre>
473
+
<div style="zoom: 2">
474
+
Middle text
475
+
<div style="zoom: 2">
476
+
Inner text
477
+
<div>
478
+
<div>
479
+
Outer text
480
+
</pre>
481
+
</div>
482
+
483
+
<div class="example">
484
+
Example of replaced elements. In this example,
485
+
the image and iframe will be twice as large as their default sizing.
486
+
487
+
<pre>
488
+
<div style="zoom: 2">
489
+
<img src="...">
490
+
<iframe src="..."></iframe>
491
+
<div>
492
+
</pre>
493
+
</div>
494
+
495
+
The <dfn>effective zoom</dfn> of an element is the product of its computed
496
+
value of 'zoom' and all flat tree ancestors' computed values of 'zoom'.
497
+
498
+
The <dfn export>scaled</dfn> value of a CSS length is the [=used value=] of that length;
499
+
in particular it includes zoom.
500
+
501
+
The <dfn export>unscaled</dfn> value of a CSS length relative to an element is the [=scaled=] value divided by the element's [=effective zoom=].
502
+
503
+
<div class="note">
504
+
The [=effective zoom=] of an element in a nested frame may be a value other than 1 even if 'zoom' is never set on an element in that frame. This can be observed by authors via APIs such as {{Window/devicePixelRatio}} and {{Element/getBoundingClientRect}}.
505
+
</div>
506
+
507
+
<h3 id='zoom-om'>
508
+
DOM and CSSOM interaction
509
+
</h3>
510
+
511
+
Computed style APIs (i.e., all values returned by {{getComputedStyle()}}) that are non-auto and non-percentage lengths must be [=unscaled=].
512
+
513
+
The {{Element/getBoundingClientRect}},
514
+
{{Element/getClientRects}},
515
+
and {{IntersectionObserver}} APIs must return rects with [=scaled=]
516
+
lengths.
517
+
518
+
All other APIs related to element geometries must return [=unscaled=] lengths.
519
+
This is explained in detail in [[cssom-view#extensions-to-the-htmlelement-interface]].
520
+
521
+
The {{Window/devicePixelRatio}} of a frame is multiplied by the [=effective zoom=] inherited by its parent frame.
522
+
</h3>
523
+
361
524
<h2 class="no-num" id="changes">Appendix A. Changes</h2>
Copy file name to clipboardExpand all lines: cssom-view-1/Overview.bs
+16-15
Original file line number
Diff line number
Diff line change
@@ -1141,7 +1141,7 @@ aborting on the first step that returns a value:
1141
1141
1. Return the {{DOMRect}} object in <var>list</var> at index 0.
1142
1142
1. If <a>caret node</a> is a text entry widget that is a replaced element,
1143
1143
and that is in the document,
1144
-
return a {{DOMRect}} object for the caret in the widget
1144
+
return a [=scaled=]{{DOMRect}} object for the caret in the widget
1145
1145
as represented by the <a>caret offset</a> value.
1146
1146
The <a>transforms</a> that apply to the element and its ancestors are applied.
1147
1147
1. Return null.
@@ -1197,7 +1197,7 @@ namely {{CheckVisibilityOptions/opacityProperty}} and {{CheckVisibilityOptions/v
1197
1197
The <dfn method for=Element>getClientRects()</dfn> method, when invoked, must return the result of the following algorithm:
1198
1198
1199
1199
1. If the element on which it was invoked does not have an associated [=CSS/box=] return an empty {{DOMRectList}} object and stop this algorithm.
1200
-
1. If the element has an associated <a>SVG layout box</a> return a {{DOMRectList}} object containing a single {{DOMRect}} object that describes the bounding box of the element as defined by the SVG specification, applying the <a>transforms</a> that apply to the element and its ancestors.
1200
+
1. If the element has an associated <a>SVG layout box</a> return a [=scaled=]{{DOMRectList}} object containing a single {{DOMRect}} object that describes the bounding box of the element as defined by the SVG specification, applying the <a>transforms</a> that apply to the element and its ancestors.
1201
1201
1. Return a {{DOMRectList}} object containing {{DOMRect}} objects in content order, one for each <a spec=css-break>box fragment</a>, describing its border area (including those with a height or width of zero) with the following constraints:
1202
1202
1203
1203
* Apply the <a>transforms</a> that apply to the element and its ancestors.
@@ -1418,24 +1418,24 @@ The <dfn attribute for=Element>scrollHeight</dfn> attribute must return the resu
1418
1418
The <dfn attribute for=Element>clientTop</dfn> attribute must run these steps:
1419
1419
1420
1420
1. If the element has no associated [=CSS/box=] or if the [=CSS/box=] is inline, return zero.
1421
-
1. Return the computed value of the 'border-top-width' property plus the height of any scrollbar rendered between the top <a>padding edge</a> and the top <a>border edge</a>, ignoring any <a>transforms</a> that apply to the element and its ancestors.
1421
+
1. Return the [=unscaled=]computed value of the 'border-top-width' property plus the height of any scrollbar rendered between the top <a>padding edge</a> and the top <a>border edge</a>, ignoring any <a>transforms</a> that apply to the element and its ancestors.
1422
1422
1423
1423
The <dfn attribute for=Element>clientLeft</dfn> attribute must run these steps:
1424
1424
1425
1425
1. If the element has no associated [=CSS/box=] or if the [=CSS/box=] is inline, return zero.
1426
-
1. Return the computed value of the 'border-left-width' property plus the width of any scrollbar rendered between the left <a>padding edge</a> and the left <a>border edge</a>, ignoring any <a>transforms</a> that apply to the element and its ancestors.
1426
+
1. Return the [=unscaled=]computed value of the 'border-left-width' property plus the width of any scrollbar rendered between the left <a>padding edge</a> and the left <a>border edge</a>, ignoring any <a>transforms</a> that apply to the element and its ancestors.
1427
1427
1428
1428
The <dfn attribute for=Element>clientWidth</dfn> attribute must run these steps:
1429
1429
1430
1430
1. If the element has no associated [=CSS/box=] or if the [=CSS/box=] is inline, return zero.
1431
1431
1. If the element is the [=root element=] and the element's <a>node document</a> is not in <a>quirks mode</a>, or if the element is <a>the <code>body</code> element</a> and the element's <a>node document</a><em>is</em> in <a>quirks mode</a>, return the <a>viewport</a> width excluding the size of a rendered scroll bar (if any).
1432
-
1. Return the width of the <a>padding edge</a> excluding the width of any rendered scrollbar between the <a>padding edge</a> and the <a>border edge</a>, ignoring any <a>transforms</a> that apply to the element and its ancestors.
1432
+
1. Return the [=unscaled=]width of the <a>padding edge</a> excluding the width of any rendered scrollbar between the <a>padding edge</a> and the <a>border edge</a>, ignoring any <a>transforms</a> or that apply to the element and its ancestors.
1433
1433
1434
1434
The <dfn attribute for=Element>clientHeight</dfn> attribute must run these steps:
1435
1435
1436
1436
1. If the element has no associated [=CSS/box=] or if the [=CSS/box=] is inline, return zero.
1437
1437
1. If the element is the [=root element=] and the element's <a>node document</a> is not in <a>quirks mode</a>, or if the element is <a>the <code>body</code> element</a> and the element's <a>node document</a><em>is</em> in <a>quirks mode</a>, return the <a>viewport</a> height excluding the size of a rendered scroll bar (if any).
1438
-
1. Return the height of the <a>padding edge</a> excluding the height of any rendered scrollbar between the <a>padding edge</a> and the <a>border edge</a>, ignoring any <a>transforms</a> that apply to the element and its ancestors.
1438
+
1. Return the [=unscaled=]height of the <a>padding edge</a> excluding the height of any rendered scrollbar between the <a>padding edge</a> and the <a>border edge</a>, ignoring any <a>transforms</a> that apply to the element and its ancestors.
@@ -1553,6 +1553,7 @@ The <dfn attribute for=HTMLElement>offsetParent</dfn> attribute must return the
1553
1553
1. If <var>ancestor</var> is <a>closed-shadow-hidden</a> from the element and its computed value of the 'position' property is ''position/fixed'', terminate this algorithm and return null.
1554
1554
1. If <var>ancestor</var> is not <a>closed-shadow-hidden</a> from the element and satisfies at least one of the following, terminate this algorithm and return <var>ancestor</var>.
1555
1555
* The element is a containing block of absolutely-positioned descendants (regardless of whether there are any absolutely-positioned descendants).
1556
+
* The element has a non-default used value of 'zoom'.
1556
1557
* It is <a>the <code>body</code> element</a>.
1557
1558
* The computed value of the 'position' property of the element is ''static'' and the ancestor is one of the following <a>HTML elements</a>: <code>td</code>, <code>th</code>, or <code>table</code>.
1558
1559
1. If there is no more parent of <var>ancestor</var> in the <a>flat tree</a>, terminate this algorithm and return null.
@@ -1561,8 +1562,8 @@ The <dfn attribute for=HTMLElement>offsetParent</dfn> attribute must return the
1561
1562
The <dfn attribute for=HTMLElement>offsetTop</dfn> attribute must return the result of running these steps:
1562
1563
1563
1564
1. If the element is <a>the <code>body</code> element</a> or does not have any associated [=CSS/box=] return zero and terminate this algorithm.
1564
-
1. If the {{HTMLElement/offsetParent}} of the element is null return the y-coordinate of the top <a>border edge</a> of the first [=CSS/box=] associated with the element, relative to the <a>initial containing block</a> origin, ignoring any <a>transforms</a>that apply to the element and its ancestors, and terminate this algorithm.
1565
-
1. Return the result of subtracting the y-coordinate of the top <a>padding edge</a>
1565
+
1. If the {{HTMLElement/offsetParent}} of the element is null return the [=unscaled=]y-coordinate of the top <a>border edge</a> of the first [=CSS/box=] associated with the element, relative to the <a>initial containing block</a> origin, ignoring any <a>transforms</a>that apply to the element and its ancestors and terminate this algorithm.
1566
+
1. Return the [=unscaled=]result of subtracting the y-coordinate of the top <a>padding edge</a>
1566
1567
of the first [=CSS/box=] associated with the {{HTMLElement/offsetParent}} of the element
1567
1568
from the y-coordinate of the top <a>border edge</a>
1568
1569
of the first [=CSS/box=] associated with the element,
@@ -1574,13 +1575,13 @@ The <dfn attribute for=HTMLElement>offsetTop</dfn> attribute must return the res
1574
1575
The <dfn attribute for=HTMLElement>offsetLeft</dfn> attribute must return the result of running these steps:
1575
1576
1576
1577
1. If the element is <a>the <code>body</code> element</a> or does not have any associated [=CSS/box=] return zero and terminate this algorithm.
1577
-
1. If the {{HTMLElement/offsetParent}} of the element is null return the x-coordinate of the left <a>border edge</a> of the first [=CSS/box=] associated with the element, relative to the <a>initial containing block</a> origin, ignoring any <a>transforms</a> that apply to the element and its ancestors, and terminate this algorithm.
1578
-
1. Return the result of subtracting the x-coordinate of the left <a>padding edge</a> of the first [=CSS/box=] associated with the {{HTMLElement/offsetParent}} of the element from the x-coordinate of the left <a>border edge</a> of the first [=CSS/box=] associated with the element, relative to the <a>initial containing block</a> origin, ignoring any <a>transforms</a> that apply to the element and its ancestors.
1578
+
1. If the {{HTMLElement/offsetParent}} of the element is null return the [=unscaled=]x-coordinate of the left <a>border edge</a> of the first [=CSS/box=] associated with the element, relative to the <a>initial containing block</a> origin, ignoring any <a>transforms</a> that apply to the element and its ancestors, and terminate this algorithm.
1579
+
1. Return the [=unscaled=]result of subtracting the x-coordinate of the left <a>padding edge</a> of the first [=CSS/box=] associated with the {{HTMLElement/offsetParent}} of the element from the x-coordinate of the left <a>border edge</a> of the first [=CSS/box=] associated with the element, relative to the <a>initial containing block</a> origin, ignoring any <a>transforms</a> that apply to the element and its ancestors.
1579
1580
1580
1581
The <dfn attribute for=HTMLElement>offsetWidth</dfn> attribute must return the result of running these steps:
1581
1582
1582
1583
1. If the element does not have any associated [=CSS/box=] return zero and terminate this algorithm.
1583
-
1. Return the width of the axis-aligned bounding box
1584
+
1. Return the [=unscaled=]width of the axis-aligned bounding box
1584
1585
of the [=border boxes=]
1585
1586
of all fragments generated by the element's [=principal box=],
1586
1587
ignoring any <a>transforms</a> that apply to the element and its ancestors.
@@ -1593,7 +1594,7 @@ The <dfn attribute for=HTMLElement>offsetWidth</dfn> attribute must return the r
1593
1594
The <dfn attribute for=HTMLElement>offsetHeight</dfn> attribute must return the result of running these steps:
1594
1595
1595
1596
1. If the element does not have any associated [=CSS/box=] return zero and terminate this algorithm.
1596
-
1. Return the height of the axis-aligned bounding box
1597
+
1. Return the [=unscaled=]height of the axis-aligned bounding box
1597
1598
of the [=border boxes=]
1598
1599
of all fragments generated by the element's [=principal box=],
1599
1600
ignoring any <a>transforms</a> that apply to the element and its ancestors.
The <dfn attribute for=HTMLImageElement>x</dfn> attribute, on getting, must return the x-coordinate of the left <a>border edge</a> of the
1617
+
The <dfn attribute for=HTMLImageElement>x</dfn> attribute, on getting, must return the [=scaled=]x-coordinate of the left <a>border edge</a> of the
1617
1618
first [=CSS/box=] associated with the element, relative to the <a>initial containing block</a> origin, ignoring any
1618
1619
<a>transforms</a> that apply to the element and its ancestors, or zero if there is no [=CSS/box=].
1619
1620
1620
-
The <dfn attribute for=HTMLImageElement>y</dfn> attribute, on getting, must return the y-coordinate of the top <a>border edge</a> of the
1621
+
The <dfn attribute for=HTMLImageElement>y</dfn> attribute, on getting, must return the [=scaled=]y-coordinate of the top <a>border edge</a> of the
1621
1622
first [=CSS/box=] associated with the element, relative to the <a>initial containing block</a> origin, ignoring any
1622
1623
<a>transforms</a> that apply to the element and its ancestors, or zero if there is no [=CSS/box=].
1623
1624
@@ -1637,7 +1638,7 @@ containing a list of {{DOMRect}} objects in content order that matches the follo
1637
1638
1638
1639
* For each element selected by the range, whose parent is not selected by the range, include the border areas returned by invoking {{Element/getClientRects()}} on the element.
1639
1640
* For each {{Text}} node selected or partially selected by the range (including when the
1640
-
boundary-points are identical), include a{{DOMRect}} object (for the part that is selected, not
1641
+
boundary-points are identical), include [=scaled=]{{DOMRect}} object (for the part that is selected, not
1641
1642
the whole line box). The bounds of these {{DOMRect}} objects are computed using font metrics;
1642
1643
thus, for horizontal writing, the vertical dimension of each box is determined by the font
1643
1644
ascent and descent, and the horizontal dimension by the text advance width. If the range covers
0 commit comments