Skip to content

Commit a03a914

Browse files
domeniczcorpan
authored andcommitted
Use logical positioning for centering a dialog
Fixes whatwg#2185. Tests: web-platform-tests/wpt#4605
1 parent 7915184 commit a03a914

File tree

1 file changed

+38
-21
lines changed

1 file changed

+38
-21
lines changed

source

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,6 +3320,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
33203320
<dfn data-x-href="https://drafts.csswg.org/css2/box.html#propdef-padding-bottom">'padding-bottom'</dfn>,
33213321
<dfn data-x-href="https://drafts.csswg.org/css2/box.html#propdef-padding-left">'padding-left'</dfn>, and
33223322
<dfn data-x-href="https://drafts.csswg.org/css2/box.html#propdef-padding-right">'padding-right'</dfn> properties</li>
3323+
<li>The <dfn data-x-href="https://drafts.csswg.org/css2/visuren.html#propdef-top">'top'</dfn>,
3324+
<dfn data-x-href="https://drafts.csswg.org/css2/visuren.html#propdef-bottom">'bottom'</dfn>,
3325+
<dfn data-x-href="https://drafts.csswg.org/css2/visuren.html#propdef-left">'left'</dfn>, and
3326+
<dfn data-x-href="https://drafts.csswg.org/css2/visuren.html#propdef-right">'right'</dfn> properties</li>
33233327
<li>The <dfn data-x-href="https://drafts.csswg.org/css2/visuren.html#float-position">'float'</dfn> property</li>
33243328
<li>The <dfn data-x-href="https://drafts.csswg.org/css2/visuren.html#flow-control">'clear'</dfn> property</li>
33253329
<li>The <dfn data-x-href="https://drafts.csswg.org/css2/visudet.html#the-width-property">'width'</dfn> property</li>
@@ -3434,14 +3438,16 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
34343438

34353439
<p>The <dfn
34363440
data-x-href="https://drafts.csswg.org/css-overflow/#propdef-overflow">'overflow'</dfn> property
3437-
is defined in the <cite>CSS Overflow</cite> specification. <ref spec=CSSOVERFLOW></p>
3441+
and its <dfn
3442+
data-x-href="https://drafts.csswg.org/css-overflow/#valdef-overflow-hidden">'hidden'</dfn> value
3443+
are defined in the <cite>CSS Overflow</cite> specification. <ref spec=CSSOVERFLOW></p>
34383444

34393445
<p>The following features are defined in the <cite>CSS Positioned Layout</cite> specification:
34403446
<ref spec=CSSPOSITION></p>
34413447

34423448
<ul class="brief">
3443-
<li>The <dfn data-x-href="https://drafts.csswg.org/css-position/#position-property">'position'</dfn> property</li>
3444-
<li>The <dfn data-x-href="https://drafts.csswg.org/css-position/#propdef-top">'top'</dfn> property</li>
3449+
<li>The <dfn data-x-href="https://drafts.csswg.org/css-position/#position-property">'position'</dfn> property and its
3450+
<dfn data-x-href="https://drafts.csswg.org/css-position/#valdef-position-static">'static'</dfn> value</li>
34453451
</ul>
34463452

34473453
<p>The <dfn
@@ -3477,7 +3483,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
34773483
<ul class="brief">
34783484
<li>The <dfn data-x-href="https://drafts.csswg.org/css-writing-modes/#direction">'direction'</dfn> property</li>
34793485
<li>The <dfn data-x-href="https://drafts.csswg.org/css-writing-modes/#unicode-bidi">'unicode-bidi'</dfn> property</li>
3480-
<li>The <dfn data-x-href="https://drafts.csswg.org/css-writing-modes/#block-size">block size</dfn>,
3486+
<li>The <dfn data-x-href="https://drafts.csswg.org/css-writing-modes/#block-flow-direction">block flow direction</dfn>,
3487+
<dfn data-x-href="https://drafts.csswg.org/css-writing-modes/#block-size">block size</dfn>,
34813488
<dfn data-x-href="https://drafts.csswg.org/css-writing-modes/#inline-size">inline size</dfn>,
34823489
<dfn data-x-href="https://drafts.csswg.org/css-writing-modes/#block-start">block-start</dfn>,
34833490
<dfn data-x-href="https://drafts.csswg.org/css-writing-modes/#block-end">block-end</dfn>,
@@ -57414,32 +57421,42 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
5741457421
element. The <span>centered alignment</span> mode is only used for <code>dialog</code> elements
5741557422
that are in the <span>top layer</span>. <ref spec=FULLSCREEN> <ref spec=CSS></p>
5741657423

57417-
<p>When an element <var>subject</var> is placed in <span>centered alignment</span> mode,
57418-
and when it is in that mode and has new rendering boxes created, the user agent must set up the
57419-
element such that its top static position, for the purposes of calculating the
57420-
<span>used value</span> of the <span>'top'</span> property, is the value that would place the
57421-
element's top <span>margin edge</span> as far from the top of the <span>viewport</span> as the
57422-
element's bottom <span>margin edge</span> from the bottom of the <span>viewport</span>, if the
57423-
element's height is less than the height of the <span>viewport</span>, and otherwise is the value
57424-
that would place the element's top <span>margin edge</span> at the top of the
57424+
<p>When an element <var>subject</var> is placed in <span>centered alignment</span> mode, and when
57425+
it is in that mode and has new rendering boxes created, the user agent must set up the element
57426+
such that its static position of the edge that corresponds to <var>subject</var>'s parent's
57427+
<span>block-start</span> edge, for the purposes of calculating the <span>used value</span> of the
57428+
appropriate box offset property (<span>'top'</span>, <span>'right'</span>, <span>'bottom'</span>,
57429+
or <span>'left'</span>), is the value that would place the element's <span>margin edge</span> on
57430+
the side that corresponds to <var>subject</var>'s parent's <span>block-start</span> side as far
57431+
from the same-side edge of the <span>viewport</span> as the element's opposing side <span>margin
57432+
edge</span> from that same-side edge of the <span>viewport</span>, if the element's dimension
57433+
(<span>'width'</span> or <span>'height'</span>) in <var>subject</var>'s parent's <span>block flow
57434+
direction</span> is less than the same-axis dimension of the <span>viewport</span>, and otherwise
57435+
is the value that would place the element's <span>margin edge</span> on the side that corresponds
57436+
to <var>subject</var>'s parent's <span>block-start</span> side at the same-side edge of the
5742557437
<span>viewport</span>.</p>
5742657438

5742757439
<p>If there is a <code>dialog</code> element with <span>centered alignment</span> and that is
5742857440
<span>being rendered</span> when its <span>browsing context</span> changes <span>viewport</span>
57429-
width (as measured in <span data-x="'px'">CSS pixels</span>), then the user agent must recreate
57430-
the element's boxes, recalculating its top static position as in the previous paragraph.</p>
57441+
dimensions (as measured in <span data-x="'px'">CSS pixels</span>), or when this
57442+
<code>dialog</code> element's parent changes <span>block flow direction</span>, then the user
57443+
agent must recreate the element's boxes, recalculating its edge that corresponds to this
57444+
<code>dialog</code> element's parent's <span>block-start</span> edge as in the previous
57445+
paragraph.</p>
5743157446

57432-
<p>This top static position of a <code>dialog</code> element with <span>centered alignment</span>
57433-
must remain the element's top static position until its boxes are recreated. (The element's static
57434-
position is only used in calculating the <span>used value</span> of the <span>'top'</span>
57435-
property in certain situations; it's not used, for instance, to position the element if its
57436-
<span>'position'</span> property is set to 'static'.)</p>
57447+
<p>This static position of a <code>dialog</code> element's edge with <span>centered
57448+
alignment</span> must remain the element's static position of that edge until its boxes are
57449+
recreated. (The element's static position is only used in calculating the <span>used value</span>
57450+
of the appropriate box offset property (<span>'top'</span>, <span>'right'</span>,
57451+
<span>'bottom'</span>, or <span>'left'</span>) in certain situations; it's not used, for instance,
57452+
to position the element if its <span>'position'</span> property is set to
57453+
<span>'static'</span>.)</p>
5743757454

5743857455
<p>User agents in visual interactive media should allow the user to pan the <span>viewport</span>
5743957456
to access all parts of a <code>dialog</code> element's <span>border box</span>, even if the
5744057457
element is larger than the <span>viewport</span> and the <span>viewport</span> would otherwise not
5744157458
have a scroll mechanism (e.g. because the <span>viewport</span>'s <span>'overflow'</span> property
57442-
is set to 'hidden').</p>
57459+
is set to <span>'hidden'</span>).</p>
5744357460

5744457461
<hr>
5744557462

@@ -109942,7 +109959,7 @@ listing, plaintext, pre, xmp {
109942109959
dialog:not([open]) { display: none; }
109943109960
dialog {
109944109961
position: absolute;
109945-
left: 0; right: 0;
109962+
offset-inline-start: 0; offset-inline-end: 0;
109946109963
width: fit-content;
109947109964
height: fit-content;
109948109965
margin: auto;

0 commit comments

Comments
 (0)