<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:rniwa@webkit.org" title="Ryosuke Niwa <rniwa@webkit.org>"> <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@webkit.org" title="Ryosuke Niwa <rniwa@webkit.org>"> <span class="fn">Ryosuke Niwa</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=262914&action=diff" name="attach_262914" title="patch">attachment 262914</a> <a href="attachment.cgi?id=262914&action=edit" title="patch">[details]</a></span>
patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=262914&action=review">https://bugs.webkit.org/attachment.cgi?id=262914&action=review</a>
<span class="quote">> Source/WebCore/dom/ComposedTreeIterator.cpp:35
> + auto* node = m_current;</span >
Please add a change log note saying this code doesn't run in most cases.
<span class="quote">> Source/WebCore/dom/ComposedTreeIterator.cpp:79
> + if (is<HTMLSlotElement>(*m_current) && !m_shadowStack.last().currentSlot) {</span >
shadowStack.last() appears many times in this function.
Can we store that in a local variable?
<span class="quote">> Source/WebCore/dom/ComposedTreeIterator.cpp:83
> + m_shadowStack.last().currentSlot = &slot;
> + m_shadowStack.last().currentSlotNodeIndex = 0;</span >
Should we add a helper function to set slot + offset?
<span class="quote">> Source/WebCore/dom/ComposedTreeIterator.cpp:95
> + if (++m_shadowStack.last().currentSlotNodeIndex < slot->assignedNodes()->size()) {</span >
Can we add a descriptive local variable like:
bool nextNodeIsInSameSlot = ++m_shadowStack.last().currentSlotNodeIndex < slot->assignedNodes()->size()
?
<span class="quote">> Source/WebCore/dom/ComposedTreeIterator.cpp:121
> + ASSERT(m_shadowStack.last().host == downcast<ShadowRoot>(*parent).host());</span >
Ditto about storing m_shadowStack.last() in a local variable.
<span class="quote">> Source/WebCore/dom/ComposedTreeIterator.cpp:151
> + ASSERT(m_shadowStack.last().host == m_current->parentNode());
> + 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">> Source/WebCore/dom/ComposedTreeIterator.cpp:157
> + if (++m_shadowStack.last().currentSlotNodeIndex < slotNodes->size())</span >
Ditto about defining a descriptive local variable.
<span class="quote">> Source/WebCore/dom/ComposedTreeIterator.cpp:168
> + ASSERT(m_shadowStack.last().host == m_current->parentNode());
> + if (!m_shadowStack.last().currentSlot) {</span >
Ditto about adding a blank line here.
<span class="quote">> Source/WebCore/dom/ComposedTreeIterator.cpp:175
> + auto* slotNodes = m_shadowStack.last().currentSlot->assignedNodes();
> + ASSERT(slotNodes->at(m_shadowStack.last().currentSlotNodeIndex) == m_current);
> + if (m_shadowStack.last().currentSlotNodeIndex > 0)
> + m_current = slotNodes->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">> Source/WebCore/dom/ComposedTreeIterator.h:75
> + HTMLSlotElement* currentSlot { nullptr };
> + 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>