Fix an optimisation in ContainerNode::notifyNodeInsertedInternal

R=tkent@chromium.org
BUG=544020

Review URL: https://codereview.chromium.org/1420653003

Cr-Commit-Position: refs/heads/master@{#355240}
Element* ContainerNode::getElementById(const AtomicString& id) const
{
    if (isInTreeScope()) {
        Element* element = treeScope().getElementById(id);
        if (!element)
            return nullptr;
        if (element->isDescendantOf(this))
            return element;
    }

    for (Element& element : ElementTraversal::descendantsOf(*this)) {
        if (element.getIdAttribute() == id)
            return &element;
    }
    return nullptr;
}

Element* ContainerNode::getElementById(const AtomicString& id) const
{
    if (isInTreeScope()) {
        Element* element = treeScope().getElementById(id);
        if (!element)
            return nullptr;
        if (element->isDescendantOf(this))
            return element;
    }

    for (Element& element : ElementTraversal::descendantsOf(*this)) {
        if (element.getIdAttribute() == id)
            return &element;
    }
    return nullptr;
}
