[Webkit-unassigned] [Bug 149997] Implement iterator for traversing composed DOM

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Oct 12 13:05:23 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=149997

--- Comment #5 from Ryosuke Niwa <rniwa at webkit.org> ---
Comment on attachment 262913
  --> https://bugs.webkit.org/attachment.cgi?id=262913
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=262913&action=review

> Source/WebCore/dom/ComposedTreeIterator.cpp:36
> +    auto* node = m_current;
> +    while (node != &m_root) {

Walking up the tree each time seems unnecessary / inefficient
since we may never get out of the current shadow DOM.

It's probably better to figure out the counting shadow root instead
since node->treeScope->root() will just get you that in O(1).

> Source/WebCore/dom/ComposedTreeIterator.cpp:79
> +    if (is<HTMLSlotElement>(*m_current) && !m_shadowStack.last().currentSlot) {

I would put this into a small helper function like findCurrentSlotPosition or something.

> Source/WebCore/dom/ComposedTreeIterator.cpp:95
> +            if (++m_shadowStack.last().currentSlotNodeIndex < slot->assignedNodes()->size()) {

I think it's helpful to have a local boolean like
bool nextNodeIsStilInSameSlot = ++m_shadowStack.last().currentSlotNodeIndex < slot->assignedNodes()->size()

> Source/WebCore/dom/ComposedTreeIterator.h:195
> +// FIXME: We should have const versions too.
> +inline ComposedTreeDescendantAdapter composedTreeDescendants(ContainerNode& parent)
> +{
> +    return ComposedTreeDescendantAdapter(parent);
> +}

It looks like this function isn't used anywhere.  Why don't we add it when we need it?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20151012/fe43cf68/attachment.html>


More information about the webkit-unassigned mailing list