<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:rniwa&#64;webkit.org" title="Ryosuke Niwa &lt;rniwa&#64;webkit.org&gt;"> <span class="fn">Ryosuke Niwa</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Implement iterator for traversing composed DOM"
   href="https://bugs.webkit.org/show_bug.cgi?id=149997">bug 149997</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #262914 Flags</td>
           <td>review?
           </td>
           <td>review+
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Implement iterator for traversing composed DOM"
   href="https://bugs.webkit.org/show_bug.cgi?id=149997#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Implement iterator for traversing composed DOM"
   href="https://bugs.webkit.org/show_bug.cgi?id=149997">bug 149997</a>
              from <span class="vcard"><a class="email" href="mailto:rniwa&#64;webkit.org" title="Ryosuke Niwa &lt;rniwa&#64;webkit.org&gt;"> <span class="fn">Ryosuke Niwa</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=262914&amp;action=diff" name="attach_262914" title="patch">attachment 262914</a> <a href="attachment.cgi?id=262914&amp;action=edit" title="patch">[details]</a></span>
patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=262914&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=262914&amp;action=review</a>

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:35
&gt; +    auto* node = m_current;</span >

Please add a change log note saying this code doesn't run in most cases.

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:79
&gt; +    if (is&lt;HTMLSlotElement&gt;(*m_current) &amp;&amp; !m_shadowStack.last().currentSlot) {</span >

shadowStack.last() appears many times in this function.
Can we store that in a local variable?

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:83
&gt; +            m_shadowStack.last().currentSlot = &amp;slot;
&gt; +            m_shadowStack.last().currentSlotNodeIndex = 0;</span >

Should we add a helper function to set slot + offset?

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:95
&gt; +            if (++m_shadowStack.last().currentSlotNodeIndex &lt; slot-&gt;assignedNodes()-&gt;size()) {</span >

Can we add a descriptive local variable like:
bool nextNodeIsInSameSlot = ++m_shadowStack.last().currentSlotNodeIndex &lt; slot-&gt;assignedNodes()-&gt;size()
?

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:121
&gt; +        ASSERT(m_shadowStack.last().host == downcast&lt;ShadowRoot&gt;(*parent).host());</span >

Ditto about storing m_shadowStack.last() in a local variable.

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:151
&gt; +    ASSERT(m_shadowStack.last().host == m_current-&gt;parentNode());
&gt; +    if (!m_shadowStack.last().currentSlot) {</span >

Can we put a blank line after all these assertions?
It's hard to read it.
Also, can we store m_shadowStack.last() in a local variable?

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:157
&gt; +    if (++m_shadowStack.last().currentSlotNodeIndex &lt; slotNodes-&gt;size())</span >

Ditto about defining a descriptive local variable.

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:168
&gt; +    ASSERT(m_shadowStack.last().host == m_current-&gt;parentNode());
&gt; +    if (!m_shadowStack.last().currentSlot) {</span >

Ditto about adding a blank line here.

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.cpp:175
&gt; +    auto* slotNodes = m_shadowStack.last().currentSlot-&gt;assignedNodes();
&gt; +    ASSERT(slotNodes-&gt;at(m_shadowStack.last().currentSlotNodeIndex) == m_current);
&gt; +    if (m_shadowStack.last().currentSlotNodeIndex &gt; 0)
&gt; +        m_current = slotNodes-&gt;at(--m_shadowStack.last().currentSlotNodeIndex);</span >

Same comments about defining a local variable for m_shadowStack.last()
and defining a descriptive local variable like previousNodeIsInSameSlot.

<span class="quote">&gt; Source/WebCore/dom/ComposedTreeIterator.h:75
&gt; +        HTMLSlotElement* currentSlot { nullptr };
&gt; +        unsigned currentSlotNodeIndex { 0 };</span >

It seems useful to have a helper method that sets both of these variables.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>