Skip to content

Commit

Permalink
[giow] (1) Simplify <dialog> positioning logic. Basically, the CB is …
Browse files Browse the repository at this point in the history
…always the ICB, and the static position gets reset more often than before.

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=20418
Affected topics: HTML

git-svn-id: http://svn.whatwg.org/webapps@7981 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jun 14, 2013
1 parent 3212225 commit 513630e
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 101 deletions.
91 changes: 58 additions & 33 deletions complete.html
Expand Up @@ -57697,9 +57697,18 @@ <h4 id=the-dialog-element><span class=secno>4.11.7 </span>The <dfn><code>dialog<
<p class=note>An example of such a UI mechanism would be the user
pressing the "Escape" key.</p>

<hr><p>When a user agent is to <dfn id=set-up-the-default-static-position>set up the default static
<hr><p>The containing block of all <code><a href=#the-dialog-element>dialog</a></code> elements that are <i>absolutely positioned</i>
must be the initial containing block.</p>

<p>All <code><a href=#the-dialog-element>dialog</a></code> elements are always in one of two modes: <dfn id=mundanely-aligned>mundanely aligned</dfn>,
or <dfn id=magically-aligned>magically aligned</dfn>. When a <code><a href=#the-dialog-element>dialog</a></code> element is created, it must be placed
in the <a href=#mundanely-aligned>mundanely aligned</a> mode, the user agent must <a href=#set-up-the-default-static-position>set up the default static
position</a> for that element, without an anchor.</p>

<!--CLEANUP-->
<p>When a user agent is to <dfn id=set-up-the-default-static-position>set up the default static
position</dfn> of an element <var title="">subject</var> without an
anchor, it must set up the element such that its top static
anchor, if that element is <a href=#being-rendered>being rendered</a>, it must set up the element such that its top static
position, for the purposes of calculating the used value of the
'top' property, is the value that would place the element's top
margin edge as far from the top of the viewport as the element's
Expand All @@ -57708,19 +57717,22 @@ <h4 id=the-dialog-element><span class=secno>4.11.7 </span>The <dfn><code>dialog<
value that would place the element's top margin edge at the top of
the viewport.</p>

<p>This top static position must remain the element's top static
position until it is next changed by the above algorithm or the next
one. (The element's static position is only used in calculating the
used value of the 'top' property in certain situations; it's not
used, for instance, to position the element if its 'position'
property is set to 'static'.)</p>
<p>If there is a <code><a href=#the-dialog-element>dialog</a></code> element that is <a href=#mundanely-aligned>mundanely aligned</a> and that is
<a href=#being-rendered>being rendered</a> when its <a href=#browsing-context>browsing context</a> changes viewport width (as
measured in CSS pixels), then the user agent must <a href=#set-up-the-default-static-position>set up the default static position</a>
of all such elements in that <a href=#browsing-context>browsing context</a> again, still without anchors.</p>

<p>When a <code><a href=#the-dialog-element>dialog</a></code> element that is <a href=#mundanely-aligned>mundanely aligned</a> starts <a href=#being-rendered>being
rendered</a>, the user agent must <a href=#set-up-the-default-static-position>set up the default static position</a> of that
element, without an anchor.</p>

<p>If there is an element whose top static position was last set by the <a href=#set-up-the-default-static-position>set up the default
static position</a> algorithm (without an anchor) when its <a href=#browsing-context>browsing context</a>
changes viewport width (as measured in CSS pixels), then the user agent must <a href=#set-up-the-default-static-position>set up the
default static position</a> of all such elements in that <a href=#browsing-context>browsing context</a> again
(still without anchors).</p>
<p>This top static position of a <a href=#mundanely-aligned>mundanely aligned</a> <code><a href=#the-dialog-element>dialog</a></code> element must
remain the element's top static position until the <a href=#set-up-the-default-static-position>set up the default static position</a>
algorithm is once again invoked for that element. (The element's static position is only used in
calculating the used value of the 'top' property in certain situations; it's not used, for
instance, to position the element if its 'position' property is set to 'static'.)</p>

<!--CLEANUP-->
<p>When a user agent is to <dfn id=set-up-the-position>set up the position</dfn> of an
element <var title="">subject</var> using an anchor <var title="">anchor</var>, it must run the following steps:</p>

Expand All @@ -57730,7 +57742,8 @@ <h4 id=the-dialog-element><span class=secno>4.11.7 </span>The <dfn><code>dialog<
object, then run these substeps:</p>

<ol><li><p>If <var title="">anchor</var>'s target element does not
have a rendered box, or is in a different document than <var title="">subject</var>, then abort the <a href=#set-up-the-position>set up the
have a rendered box, or is in a different document than <var title="">subject</var>, then let <var title="">subject</var> be <span>mundanely positioned</span>, <a href=#set-up-the-default-static-position>set up the default static
position</a> of <var title="">subject</var> without an anchor, and abort the <a href=#set-up-the-position>set up the
position</a> steps.</li>

<li><p>Let <var title="">anchor element</var> be an anonymous
Expand All @@ -57747,11 +57760,20 @@ <h4 id=the-dialog-element><span class=secno>4.11.7 </span>The <dfn><code>dialog<
<li><p>Let <var title="">subject</var> be <a href=#magically-aligned>magically
aligned</a> to <var title="">anchor element</var>.</li>

</ol><p>While an element <var title="">A</var> is <dfn id=magically-aligned>magically aligned</dfn> to an element <var title="">B</var>, <var title="">A</var> and <var title="">B</var> both have rendered boxes, <var title="">A</var> and <var title="">B</var> are both in the same <code><a href=#document>Document</a></code>, and <var title="">B</var> is earlier than <var title="">A</var> in <a href=#tree-order>tree order</a>, the following
requirements apply:</p>
</ol><p>While an element <var title="">A</var> is <a href=#magically-aligned>magically aligned</a> to an element <var title="">B</var>, the following requirements apply:</p>

<ul><li>

<p>If at any time either <var title="">A</var> or <var title="">B</var> cease having rendered
boxes, <var title="">A</var> and <var title="">B</var> cease being in the same
<code><a href=#document>Document</a></code>, or <var title="">B</var> ceases being earlier than <var title="">A</var>
in <a href=#tree-order>tree order</a>, let <var title="">subject</var> be <span>mundanely
positioned</span>, and <a href=#set-up-the-default-static-position>set up the default static position</a> of <var title="">subject</var> without an anchor.</li>



<li>

<p><var title="">A</var>'s 'position' property must compute to the keyword '<a href=#css-position-absolute-anchored title=css-position-absolute-anchored>absolute-anchored</a>' rather than whatever it would
otherwise compute to (i.e. the 'position' property's specified value is ignored).</p>

Expand Down Expand Up @@ -57889,33 +57911,36 @@ <h4 id=the-dialog-element><span class=secno>4.11.7 </span>The <dfn><code>dialog<

</li>

</ul><p class=note>The trivial example of an element that does not have
<li>

<p>When an element's 'position' property computes to '<dfn id=css-position-absolute-anchored title=css-position-absolute-anchored>absolute-anchored</dfn>', the 'float' property does not
apply and must compute to 'none', the 'display' property must compute to a value as described by
the table in <a href=http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo>the section of CSS
2.1 describing the <cite>relationships between 'display', 'position', and 'float'</cite></a>,
and the element's box must be positioned using the rules for absolute positioning but with its
static position set such that if the box is positioned in its static position, its anchor point
is exactly aligned over the anchor point of the element to which it is <a href=#magically-aligned>magically
aligned</a>. Elements aligned in this way are <i>absolutely positioned</i>. For the purposes
of determining the containing block of other elements, the '<a href=#css-position-absolute-anchored title=css-position-absolute-anchored>absolute-anchored</a>' keyword must be treated like
the 'absolute' keyword.</p>

</li>

</ul><!--CLEANUP--><p class=note>The trivial example of an element that does not have
a rendered box is one whose 'display' property computes to 'none'.
However, there are many other cases; e.g. table columns do not have
boxes (their properties merely affect other boxes).</p>

<p>When an element's 'position' property computes to '<dfn id=css-position-absolute-anchored title=css-position-absolute-anchored>absolute-anchored</dfn>', the 'float' property does not
apply and must compute to 'none', the 'display' property must compute to a value as described by
the table in <a href=http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo>the section of CSS 2.1
describing the <cite>relationships between 'display', 'position', and 'float'</cite></a>, the
element's containing block is the initial containing block, and the element's box must be
positioned using the rules for absolute positioning but with its static position set such that if
the box is positioned in its static position, its anchor point is exactly aligned over the anchor
point of the element to which it is <a href=#magically-aligned>magically aligned</a>. Elements aligned in this way
are <i>absolutely positioned</i>. For the purposes of determining the containing block of other
elements, the '<a href=#css-position-absolute-anchored title=css-position-absolute-anchored>absolute-anchored</a>' keyword must
be treated like the 'absolute' keyword.</p>

<p>If an element to which another element is anchored changes rendering, the anchored element must
be repositioned accordingly. (In other words, the requirements above are live, they are not just
calculated once per anchored element.)</p>
<p class=note>If an element to which another element is anchored changes rendering, the anchored
element will be be repositioned accordingly. (In other words, the requirements above are live,
they are not just calculated once per anchored element.)</p>

<p class=note>The '<a href=#css-position-absolute-anchored title=css-position-absolute-anchored>absolute-anchored</a>'
keyword is not a keyword that can be specified in CSS; the 'position' property can only compute to
this value if the <code><a href=#the-dialog-element>dialog</a></code> element is positioned via the APIs described above.</p>

<p class=note>Elements positioned in this way are not clipped by the 'overflow' property of
ancestors (nor moved by the resulting scrolling mechanisms). Anchoring to an element that
ancestors (nor moved by the resulting scrolling mechanisms), since the containing block is the initial containing block. Anchoring to an element that
<em>is</em> so clipped (and shifted) can therefore result in unexpected effects (where the
anchored element moves along with the clipped element, but isn't itself clipped).</p>

Expand Down

0 comments on commit 513630e

Please sign in to comment.