@@ -110734,15 +110734,34 @@ location.href = '#foo';</code></pre>
110734110734 given <var>document</var>'s <span>relevant global object</span> to run these steps:</p>
110735110735
110736110736 <ol>
110737- <li><p>If <var>document</var> has no parser, or its parser has <span data-x="stop
110738- parsing">stopped parsing</span>, or the user agent has reason to believe the user is no longer
110739- interested in scrolling to the <span data-x="concept-url-fragment">fragment</span>, then abort
110740- these steps.</p></li>
110737+ <li><p>If the user agent has reason to believe the user is no longer interested in scrolling to
110738+ the <span data-x="concept-url-fragment">fragment</span>, then set <var>document</var>'s
110739+ <span>pending text directives</span> to null and abort these steps.</p></li>
110740+
110741+ <li>
110742+ <p>If <var>document</var> has no parser, or its parser has <span data-x="stop parsing">stopped
110743+ parsing</span>, then.</p>
110744+
110745+ <ol>
110746+ <li>
110747+ <p>If <var>document</var>'s <span>pending text directives</span> is not null, then.</p>
110748+
110749+ <ol>
110750+ <li><p>Set <var>document</var>'s <span>pending text directives</span> to null.</p></li>
110751+
110752+ <li><p><span>Scroll to the fragment</span> given <var>document</var>.</p></li>
110753+ </ol>
110754+ </li>
110755+
110756+ <li><p>Abort these steps.</p></li>
110757+ </ol>
110758+ </li>
110741110759
110742110760 <li><p><span>Scroll to the fragment</span> given <var>document</var>.</p></li>
110743110761
110744110762 <li><p>If <var>document</var>'s <span>indicated part</span> is still null, then <span>try to
110745- scroll to the fragment</span> for <var>document</var>.</p></li>
110763+ scroll to the fragment</span> for <var>document</var>. Otherwise, set <var>document</var>'s
110764+ <span>pending text directives</span> to null.</p></li>
110746110765 </ol>
110747110766 </li>
110748110767 </ol>
@@ -110973,18 +110992,63 @@ location.href = '#foo';</code></pre>
110973110992 <p>Otherwise:</p>
110974110993
110975110994 <ol>
110976- <li><p><span>Assert</span>: <var>document</var>'s <span>indicated part</span> is an
110977- element.</p></li>
110995+ <li><p><span>Assert</span>: <var>document</var>'s <span>indicated part</span> is an element or
110996+ a <span>range</span>.</p></li>
110997+
110998+ <li><p>Let <var>scrollTarget</var> be <var>document</var>'s <span>indicated part</span>.</p></li>
110999+
111000+ <li><p>Let <var>target</var> be <var>scrollTarget</var>.</p></li>
111001+
111002+ <li>
111003+ <p>If <var>target</var> is a <span>range</span>, then:</p>
111004+
111005+ <ol>
111006+ <li><p>Set <var>target</var> to the <span>first common ancestor</span> of <var>target</var>'s
111007+ <span data-x="concept-range-start-node">start node</span> and <var>target</var>'s <span
111008+ data-x="concept-range-end-node">end node</span>.</p></li>
111009+
111010+ <li>
111011+ <p><span>While</span> <var>target</var> is not null and is not an <span>element</span>, set
111012+ <var>target</var> to <var>target</var>'s <span>parent</span>.</p>
111013+
111014+ <p class="XXX">What should this do if <var>target</var> is inside a shadow tree? See <a
111015+ href="https://github.com/WICG/scroll-to-text-fragment/issues/190">WICG/scroll-to-text-fragment#190</a>
111016+ for discussion.</p>
111017+ </li>
111018+ </ol>
111019+ </li>
110978111020
110979- <li><p>Let <var>target</var> be <var>document </var>'s <span>indicated part </span>.</p></li>
111021+ <li><p><span>Assert</span>: <var>target </var> is an <span>element </span>.</p></li>
110980111022
110981111023 <li><p>Set <var>document</var>'s <span>target element</span> to <var>target</var>.</p></li>
110982111024
110983- <li><p>Run the <span>ancestor revealing algorithm</span> on <var>target</var>.</p></li>
111025+ <li>
111026+ <p>Run the <span>ancestor revealing algorithm</span> on <var>target</var>.</p>
111027+
111028+ <p class="XXX">This currently won't work well with <span data-x="text directive">text
111029+ directives</span>, since <var>target</var> could be an ancestor or even the root document
111030+ node. <a
111031+ href="https://github.com/WICG/scroll-to-text-fragment/issues/89">WICG/scroll-to-text-fragment#89</a>
111032+ proposes restricting matches to "<code data-x="">contain:style layout</code>" blocks which
111033+ would resolve this problem.</p>
111034+ </li>
110984111035
110985- <li><p><span data-x="scroll a target into view">Scroll <var>target</var> into view</span>,
110986- with <i>behavior</i> set to "auto", <i>block</i> set to "start", and <i>inline</i>
110987- set to "nearest". <ref>CSSOMVIEW</ref></p></li>
111036+ <li>
111037+ <p>Let <var>blockPosition</var> be "<code data-x="">center</code>" if <var>scrollTarget</var>
111038+ is a <span>range</span>, and "<code data-x="">start</code>" otherwise.</p>
111039+
111040+ <p class="note">Scrolling to a <span>text directive</span> centers it in the block flow
111041+ direction.</p>
111042+ </li>
111043+
111044+ <li>
111045+ <p><span data-x="scroll a target into view">Scroll <var>scrollTarget</var> into
111046+ view</span>, with <i>behavior</i> set to "auto", <i>block</i> set to <var>blockPosition</var>,
111047+ and <i>inline</i> set to "nearest". <ref>CSSOMVIEW</ref></p>
111048+
111049+ <p>Implementations may avoid scrolling to the target if it is produced from a <span>text
111050+ directive</span>.</p>
111051+ </li>
110988111052
110989111053 <li><p>Run the <span>focusing steps</span> for <var>target</var>, with the
110990111054 <code>Document</code>'s <span>viewport</span> as the <var>fallback target</var>.</p></li>
@@ -115798,6 +115862,32 @@ Add a helper algorithm for removing and returning a fragment directive string fr
115798115862 </ol>
115799115863 </div>
115800115864
115865+ <div algorithm>
115866+ <p>To find the <dfn>first common ancestor</dfn> of two nodes <var>nodeA</var> and
115867+ <var>nodeB</var>, follow these steps:</p>
115868+
115869+ <ol>
115870+ <li><p>Let <var>commonAncestor</var> be <var>nodeA</var>.</p></li>
115871+
115872+ <li><p><span>While</span> <var>commonAncestor</var> is non-null and is not a
115873+ <span>shadow-including inclusive ancestor</span> of <var>nodeB</var>, let
115874+ <var>commonAncestor</var> be <var>commonAncestor</var>'s
115875+ <span>shadow-including parent</span>.</p></li>
115876+
115877+ <li><p>Return <var>commonAncestor</var>.</p></li>
115878+ </ol>
115879+ </div>
115880+
115881+ <div algorithm>
115882+ <p>To find the <dfn>shadow-including parent</dfn> of <var>node</var> follow these steps:</p>
115883+
115884+ <ol>
115885+ <li><p>If <var>node</var> is a <span>shadow root</span>, then return <var>node</var>'s <span
115886+ data-x="concept-DocumentFragment-host">host</span>.</p></li>
115887+
115888+ <li><p>Otherwise, return <var>node</var>'s <span>parent</span>.</p></li>
115889+ </ol>
115890+ </div>
115801115891
115802115892 <div algorithm>
115803115893 <p>To <dfn>find a range from a node list</dfn> given a search string <var>queryString</var>, a <span>range</span> <var>searchRange</var>, a <span>list</span> of <code>Text</code> nodes <var>nodes</var>, and booleans <var>wordStartBounded</var>, <var>wordEndBounded</var> and <var>matchMustBeAtBeginning</var>, follow these steps:
0 commit comments