#include "config.h"
#include "ContainerNode.h"
#include "AXObjectCache.h"
#include "ChildListMutationScope.h"
#include "Chrome.h"
#include "ChromeClient.h"
#include "ClassNodeList.h"
#include "ContainerNodeAlgorithms.h"
#include "Editor.h"
#include "FloatRect.h"
#include "FrameView.h"
#include "InlineTextBox.h"
#include "InsertionPoint.h"
#include "JSLazyEventListener.h"
#include "JSNode.h"
#include "LabelsNodeList.h"
#include "MutationEvent.h"
#include "NameNodeList.h"
#include "NodeRareData.h"
#include "NodeRenderStyle.h"
#include "RadioNodeList.h"
#include "RenderBox.h"
#include "RenderTheme.h"
#include "RenderWidget.h"
#include "ResourceLoadScheduler.h"
#include "RootInlineBox.h"
#include "SVGDocumentExtensions.h"
#include "SVGElement.h"
#include "SVGNames.h"
#include "SelectorQuery.h"
#include "TemplateContentDocumentFragment.h"
#include <wtf/CurrentTime.h>
#if ENABLE(DELETION_UI)
#include "DeleteButtonController.h"
#endif
namespace WebCore {
static void dispatchChildInsertionEvents(Node&);
static void dispatchChildRemovalEvents(Node&);
ChildNodesLazySnapshot* ChildNodesLazySnapshot::latestSnapshot = 0;
#ifndef NDEBUG
unsigned NoEventDispatchAssertion::s_count = 0;
#endif
static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes, ExceptionCode& ec)
{
if (!node.isDocumentFragment()) {
nodes.append(node);
if (ContainerNode* oldParent = node.parentNode())
oldParent->removeChild(&node, ec);
return;
}
getChildNodes(node, nodes);
toContainerNode(node).removeChildren();
}
void ContainerNode::removeDetachedChildren()
{
if (connectedSubframeCount()) {
for (Node* child = firstChild(); child; child = child->nextSibling())
child->updateAncestorConnectedSubframeCountForRemoval();
}
removeDetachedChildrenInContainer<Node, ContainerNode>(*this);
}
static inline void destroyRenderTreeIfNeeded(Node& child)
{
if (!child.renderer() && !child.isNamedFlowContentNode())
return;
if (child.isElementNode())
Style::detachRenderTree(toElement(child));
else if (child.isTextNode())
Style::detachTextRenderer(toText(child));
}
void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
{
ASSERT(oldParent);
NodeVector children;
getChildNodes(*oldParent, children);
if (oldParent->document().hasMutationObserversOfType(MutationObserver::ChildList)) {
ChildListMutationScope mutation(*oldParent);
for (unsigned i = 0; i < children.size(); ++i)
mutation.willRemoveChild(children[i].get());
}
oldParent->removeDetachedChildren();
for (unsigned i = 0; i < children.size(); ++i) {
Node& child = children[i].get();
destroyRenderTreeIfNeeded(child);
RefPtr<Node> adoptedChild = document().adoptNode(&children[i].get(), ASSERT_NO_EXCEPTION);
parserAppendChild(adoptedChild.get());
treeScope().adoptIfNeeded(adoptedChild.get());
}
}
ContainerNode::~ContainerNode()
{
if (!isDocumentNode())
willBeDeletedFrom(document());
removeDetachedChildren();
}
static inline bool isChildTypeAllowed(ContainerNode* newParent, Node* child)
{
if (!child->isDocumentFragment())
return newParent->childTypeAllowed(child->nodeType());
for (Node* node = child->firstChild(); node; node = node->nextSibling()) {
if (!newParent->childTypeAllowed(node->nodeType()))
return false;
}
return true;
}
static inline bool isInTemplateContent(const Node* node)
{
#if ENABLE(TEMPLATE_ELEMENT)
Document& document = node->document();
return &document == document.templateDocument();
#else
UNUSED_PARAM(node);
return false;
#endif
}
static inline bool containsConsideringHostElements(const Node* newChild, const Node* newParent)
{
return (newParent->isInShadowTree() || isInTemplateContent(newParent))
? newChild->containsIncludingHostElements(newParent)
: newChild->contains(newParent);
}
static inline ExceptionCode checkAcceptChild(ContainerNode* newParent, Node* newChild, Node* oldChild)
{
if (!newChild)
return NOT_FOUND_ERR;
if ((newChild->isElementNode() || newChild->isTextNode()) && newParent->isElementNode()) {
ASSERT(!newParent->isReadOnlyNode());
ASSERT(!newParent->isDocumentTypeNode());
ASSERT(isChildTypeAllowed(newParent, newChild));
if (containsConsideringHostElements(newChild, newParent))
return HIERARCHY_REQUEST_ERR;
return 0;
}
ASSERT(!newChild->isPseudoElement());
if (newChild->isPseudoElement())
return HIERARCHY_REQUEST_ERR;
if (newParent->isReadOnlyNode())
return NO_MODIFICATION_ALLOWED_ERR;
if (containsConsideringHostElements(newChild, newParent))
return HIERARCHY_REQUEST_ERR;
if (oldChild && newParent->isDocumentNode()) {
if (!toDocument(newParent)->canReplaceChild(newChild, oldChild))
return HIERARCHY_REQUEST_ERR;
} else if (!isChildTypeAllowed(newParent, newChild))
return HIERARCHY_REQUEST_ERR;
return 0;
}
static inline bool checkAcceptChildGuaranteedNodeTypes(ContainerNode* newParent, Node* newChild, ExceptionCode& ec)
{
ASSERT(!newParent->isReadOnlyNode());
ASSERT(!newParent->isDocumentTypeNode());
ASSERT(isChildTypeAllowed(newParent, newChild));
if (newChild->contains(newParent)) {
ec = HIERARCHY_REQUEST_ERR;
return false;
}
return true;
}
static inline bool checkAddChild(ContainerNode* newParent, Node* newChild, ExceptionCode& ec)
{
ec = checkAcceptChild(newParent, newChild, 0);
if (ec)
return false;
return true;
}
static inline bool checkReplaceChild(ContainerNode* newParent, Node* newChild, Node* oldChild, ExceptionCode& ec)
{
ec = checkAcceptChild(newParent, newChild, oldChild);
if (ec)
return false;
return true;
}
bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& ec)
{
ASSERT(refCount() || parentOrShadowHostNode());
Ref<ContainerNode> protect(*this);
ec = 0;
if (!refChild)
return appendChild(newChild, ec);
if (!checkAddChild(this, newChild.get(), ec))
return false;
if (refChild->parentNode() != this) {
ec = NOT_FOUND_ERR;
return false;
}
if (refChild->previousSibling() == newChild || refChild == newChild) return true;
Ref<Node> next(*refChild);
NodeVector targets;
collectChildrenAndRemoveFromOldParent(*newChild.get(), targets, ec);
if (ec)
return false;
if (targets.isEmpty())
return true;
if (!checkAcceptChildGuaranteedNodeTypes(this, newChild.get(), ec))
return false;
InspectorInstrumentation::willInsertDOMNode(&document(), this);
ChildListMutationScope mutation(*this);
for (auto it = targets.begin(), end = targets.end(); it != end; ++it) {
Node& child = it->get();
if (next->parentNode() != this)
break;
if (child.parentNode())
break;
treeScope().adoptIfNeeded(&child);
insertBeforeCommon(next.get(), child);
updateTreeAfterInsertion(child);
}
dispatchSubtreeModifiedEvent();
return true;
}
void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild)
{
NoEventDispatchAssertion assertNoEventDispatch;
ASSERT(!newChild.parentNode()); ASSERT(!newChild.nextSibling());
ASSERT(!newChild.previousSibling());
ASSERT(!newChild.isShadowRoot());
Node* prev = nextChild.previousSibling();
ASSERT(m_lastChild != prev);
nextChild.setPreviousSibling(&newChild);
if (prev) {
ASSERT(m_firstChild != &nextChild);
ASSERT(prev->nextSibling() == &nextChild);
prev->setNextSibling(&newChild);
} else {
ASSERT(m_firstChild == &nextChild);
m_firstChild = &newChild;
}
newChild.setParentNode(this);
newChild.setPreviousSibling(prev);
newChild.setNextSibling(&nextChild);
}
void ContainerNode::notifyChildInserted(Node& child, ChildChangeSource source)
{
ChildListMutationScope(*this).childAdded(child);
NodeVector postInsertionNotificationTargets;
ChildNodeInsertionNotifier(*this).notify(child, postInsertionNotificationTargets);
ChildChange change;
change.type = child.isElementNode() ? ElementInserted : child.isTextNode() ? TextInserted : NonContentsChildChanged;
change.previousSiblingElement = ElementTraversal::previousSibling(&child);
change.nextSiblingElement = ElementTraversal::nextSibling(&child);
change.source = source;
childrenChanged(change);
for (auto& target : postInsertionNotificationTargets)
target->didNotifySubtreeInsertions(this);
}
void ContainerNode::notifyChildRemoved(Node& child, Node* previousSibling, Node* nextSibling, ChildChangeSource source)
{
ChildNodeRemovalNotifier(*this).notify(child);
ChildChange change;
change.type = child.isElementNode() ? ElementRemoved : child.isTextNode() ? TextRemoved : NonContentsChildChanged;
change.previousSiblingElement = (!previousSibling || previousSibling->isElementNode()) ? toElement(previousSibling) : ElementTraversal::previousSibling(previousSibling);
change.nextSiblingElement = (!nextSibling || nextSibling->isElementNode()) ? toElement(nextSibling) : ElementTraversal::nextSibling(nextSibling);
change.source = source;
childrenChanged(change);
}
void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node* nextChild)
{
ASSERT(newChild);
ASSERT(nextChild);
ASSERT(nextChild->parentNode() == this);
ASSERT(!newChild->isDocumentFragment());
#if ENABLE(TEMPLATE_ELEMENT)
ASSERT(!hasTagName(HTMLNames::templateTag));
#endif
if (nextChild->previousSibling() == newChild || nextChild == newChild) return;
if (&document() != &newChild->document())
document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
insertBeforeCommon(*nextChild, *newChild.get());
newChild->updateAncestorConnectedSubframeCountForInsertion();
notifyChildInserted(*newChild, ChildChangeSourceParser);
newChild->setNeedsStyleRecalc(ReconstructRenderTree);
}
bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& ec)
{
ASSERT(refCount() || parentOrShadowHostNode());
Ref<ContainerNode> protect(*this);
ec = 0;
if (oldChild == newChild) return true;
if (!oldChild) {
ec = NOT_FOUND_ERR;
return false;
}
if (!checkReplaceChild(this, newChild.get(), oldChild, ec))
return false;
if (oldChild->parentNode() != this) {
ec = NOT_FOUND_ERR;
return false;
}
ChildListMutationScope mutation(*this);
RefPtr<Node> next = oldChild->nextSibling();
Ref<Node> removedChild(*oldChild);
removeChild(oldChild, ec);
if (ec)
return false;
if (next && (next->previousSibling() == newChild || next == newChild)) return true;
if (!checkReplaceChild(this, newChild.get(), oldChild, ec))
return false;
NodeVector targets;
collectChildrenAndRemoveFromOldParent(*newChild.get(), targets, ec);
if (ec)
return false;
if (!checkReplaceChild(this, newChild.get(), oldChild, ec))
return false;
InspectorInstrumentation::willInsertDOMNode(&document(), this);
for (auto it = targets.begin(), end = targets.end(); it != end; ++it) {
Node& child = it->get();
if (next && next->parentNode() != this)
break;
if (child.parentNode())
break;
treeScope().adoptIfNeeded(&child);
{
NoEventDispatchAssertion assertNoEventDispatch;
if (next)
insertBeforeCommon(*next, child);
else
appendChildToContainer(&child, *this);
}
updateTreeAfterInsertion(child);
}
dispatchSubtreeModifiedEvent();
return true;
}
void ContainerNode::willRemoveChild(Node& child)
{
ASSERT(child.parentNode());
ChildListMutationScope(*child.parentNode()).willRemoveChild(child);
child.notifyMutationObserversNodeWillDetach();
dispatchChildRemovalEvents(child);
if (child.parentNode() != this)
return;
child.document().nodeWillBeRemoved(&child); if (child.isContainerNode())
disconnectSubframesIfNeeded(toContainerNode(child), RootAndDescendants);
}
static void willRemoveChildren(ContainerNode& container)
{
NodeVector children;
getChildNodes(container, children);
ChildListMutationScope mutation(container);
for (auto it = children.begin(); it != children.end(); ++it) {
Node& child = it->get();
mutation.willRemoveChild(child);
child.notifyMutationObserversNodeWillDetach();
dispatchChildRemovalEvents(child);
}
container.document().nodeChildrenWillBeRemoved(container);
disconnectSubframesIfNeeded(container, DescendantsOnly);
}
void ContainerNode::disconnectDescendantFrames()
{
disconnectSubframesIfNeeded(*this, RootAndDescendants);
}
bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec)
{
ASSERT(refCount() || parentOrShadowHostNode());
Ref<ContainerNode> protect(*this);
ec = 0;
if (isReadOnlyNode()) {
ec = NO_MODIFICATION_ALLOWED_ERR;
return false;
}
if (!oldChild || oldChild->parentNode() != this) {
ec = NOT_FOUND_ERR;
return false;
}
Ref<Node> child(*oldChild);
document().removeFocusedNodeOfSubtree(&child.get());
#if ENABLE(FULLSCREEN_API)
document().removeFullScreenElementOfSubtree(&child.get());
#endif
if (child->parentNode() != this) {
ec = NOT_FOUND_ERR;
return false;
}
willRemoveChild(child.get());
if (child->parentNode() != this) {
ec = NOT_FOUND_ERR;
return false;
}
{
WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
Node* prev = child->previousSibling();
Node* next = child->nextSibling();
removeBetween(prev, next, child.get());
notifyChildRemoved(child.get(), prev, next, ChildChangeSourceAPI);
}
if (document().svgExtensions()) {
Element* shadowHost = this->shadowHost();
if (!shadowHost || !shadowHost->hasTagName(SVGNames::useTag))
document().accessSVGExtensions()->rebuildElements();
}
dispatchSubtreeModifiedEvent();
return true;
}
void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& oldChild)
{
InspectorInstrumentation::didRemoveDOMNode(&oldChild.document(), &oldChild);
NoEventDispatchAssertion assertNoEventDispatch;
ASSERT(oldChild.parentNode() == this);
destroyRenderTreeIfNeeded(oldChild);
if (nextChild)
nextChild->setPreviousSibling(previousChild);
if (previousChild)
previousChild->setNextSibling(nextChild);
if (m_firstChild == &oldChild)
m_firstChild = nextChild;
if (m_lastChild == &oldChild)
m_lastChild = previousChild;
oldChild.setPreviousSibling(0);
oldChild.setNextSibling(0);
oldChild.setParentNode(0);
document().adoptIfNeeded(&oldChild);
}
void ContainerNode::parserRemoveChild(Node& oldChild)
{
ASSERT(oldChild.parentNode() == this);
ASSERT(!oldChild.isDocumentFragment());
Node* prev = oldChild.previousSibling();
Node* next = oldChild.nextSibling();
oldChild.updateAncestorConnectedSubframeCountForRemoval();
ChildListMutationScope(*this).willRemoveChild(oldChild);
oldChild.notifyMutationObserversNodeWillDetach();
removeBetween(prev, next, oldChild);
notifyChildRemoved(oldChild, prev, next, ChildChangeSourceParser);
}
void ContainerNode::removeChildren()
{
if (!m_firstChild)
return;
Ref<ContainerNode> protect(*this);
document().removeFocusedNodeOfSubtree(this, true);
#if ENABLE(FULLSCREEN_API)
document().removeFullScreenElementOfSubtree(this, true);
#endif
willRemoveChildren(*this);
{
WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
{
NoEventDispatchAssertion assertNoEventDispatch;
while (RefPtr<Node> n = m_firstChild) {
removeBetween(0, m_firstChild->nextSibling(), *m_firstChild);
ChildNodeRemovalNotifier(*this).notify(*n);
}
}
ChildChange change = { AllChildrenRemoved, nullptr, nullptr, ChildChangeSourceAPI };
childrenChanged(change);
}
if (document().svgExtensions()) {
Element* shadowHost = this->shadowHost();
if (!shadowHost || !shadowHost->hasTagName(SVGNames::useTag))
document().accessSVGExtensions()->rebuildElements();
}
dispatchSubtreeModifiedEvent();
}
bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec)
{
Ref<ContainerNode> protect(*this);
ASSERT(refCount() || parentOrShadowHostNode());
ec = 0;
if (!checkAddChild(this, newChild.get(), ec))
return false;
if (newChild == m_lastChild) return newChild;
NodeVector targets;
collectChildrenAndRemoveFromOldParent(*newChild.get(), targets, ec);
if (ec)
return false;
if (targets.isEmpty())
return true;
if (!checkAcceptChildGuaranteedNodeTypes(this, newChild.get(), ec))
return false;
InspectorInstrumentation::willInsertDOMNode(&document(), this);
ChildListMutationScope mutation(*this);
for (auto it = targets.begin(), end = targets.end(); it != end; ++it) {
Node& child = it->get();
if (child.parentNode())
break;
treeScope().adoptIfNeeded(&child);
{
NoEventDispatchAssertion assertNoEventDispatch;
appendChildToContainer(&child, *this);
}
updateTreeAfterInsertion(child);
}
dispatchSubtreeModifiedEvent();
return true;
}
void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild)
{
ASSERT(newChild);
ASSERT(!newChild->parentNode()); ASSERT(!newChild->isDocumentFragment());
#if ENABLE(TEMPLATE_ELEMENT)
ASSERT(!hasTagName(HTMLNames::templateTag));
#endif
if (&document() != &newChild->document())
document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
{
NoEventDispatchAssertion assertNoEventDispatch;
appendChildToContainer(newChild.get(), *this);
treeScope().adoptIfNeeded(newChild.get());
}
newChild->updateAncestorConnectedSubframeCountForInsertion();
notifyChildInserted(*newChild, ChildChangeSourceParser);
newChild->setNeedsStyleRecalc(ReconstructRenderTree);
}
void ContainerNode::childrenChanged(const ChildChange& change)
{
document().incDOMTreeVersion();
if (change.source == ChildChangeSourceAPI && change.type != TextChanged)
document().updateRangesAfterChildrenChanged(*this);
invalidateNodeListAndCollectionCachesInAncestors();
}
inline static void cloneChildNodesAvoidingDeleteButton(ContainerNode* parent, ContainerNode* clonedParent, HTMLElement* deleteButtonContainerElement)
{
ExceptionCode ec = 0;
for (Node* child = parent->firstChild(); child && !ec; child = child->nextSibling()) {
#if ENABLE(DELETION_UI)
if (child == deleteButtonContainerElement)
continue;
#else
UNUSED_PARAM(deleteButtonContainerElement);
#endif
RefPtr<Node> clonedChild = child->cloneNode(false);
clonedParent->appendChild(clonedChild, ec);
if (!ec && child->isContainerNode())
cloneChildNodesAvoidingDeleteButton(toContainerNode(child), toContainerNode(clonedChild.get()), deleteButtonContainerElement);
}
}
void ContainerNode::cloneChildNodes(ContainerNode *clone)
{
#if ENABLE(DELETION_UI)
HTMLElement* deleteButtonContainerElement = 0;
if (Frame* frame = document().frame())
deleteButtonContainerElement = frame->editor().deleteButtonController().containerElement();
cloneChildNodesAvoidingDeleteButton(this, clone, deleteButtonContainerElement);
#else
cloneChildNodesAvoidingDeleteButton(this, clone, 0);
#endif
}
unsigned ContainerNode::childNodeCount() const
{
unsigned count = 0;
Node *n;
for (n = firstChild(); n; n = n->nextSibling())
count++;
return count;
}
Node *ContainerNode::childNode(unsigned index) const
{
unsigned i;
Node *n = firstChild();
for (i = 0; n != 0 && i < index; i++)
n = n->nextSibling();
return n;
}
static void dispatchChildInsertionEvents(Node& child)
{
if (child.isInShadowTree())
return;
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
RefPtr<Node> c = &child;
Ref<Document> document(child.document());
if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_LISTENER))
c->dispatchScopedEvent(MutationEvent::create(eventNames().DOMNodeInsertedEvent, true, c->parentNode()));
if (c->inDocument() && document->hasListenerType(Document::DOMNODEINSERTEDINTODOCUMENT_LISTENER)) {
for (; c; c = NodeTraversal::next(c.get(), &child))
c->dispatchScopedEvent(MutationEvent::create(eventNames().DOMNodeInsertedIntoDocumentEvent, false));
}
}
static void dispatchChildRemovalEvents(Node& child)
{
if (child.isInShadowTree()) {
InspectorInstrumentation::willRemoveDOMNode(&child.document(), &child);
return;
}
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
willCreatePossiblyOrphanedTreeByRemoval(&child);
InspectorInstrumentation::willRemoveDOMNode(&child.document(), &child);
RefPtr<Node> c = &child;
Ref<Document> document(child.document());
if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LISTENER))
c->dispatchScopedEvent(MutationEvent::create(eventNames().DOMNodeRemovedEvent, true, c->parentNode()));
if (c->inDocument() && document->hasListenerType(Document::DOMNODEREMOVEDFROMDOCUMENT_LISTENER)) {
for (; c; c = NodeTraversal::next(c.get(), &child))
c->dispatchScopedEvent(MutationEvent::create(eventNames().DOMNodeRemovedFromDocumentEvent, false));
}
}
void ContainerNode::updateTreeAfterInsertion(Node& child)
{
ASSERT(child.refCount());
notifyChildInserted(child, ChildChangeSourceAPI);
child.setNeedsStyleRecalc(ReconstructRenderTree);
dispatchChildInsertionEvents(child);
}
void ContainerNode::setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& attributeValue)
{
setAttributeEventListener(eventType, JSLazyEventListener::createForNode(*this, attributeName, attributeValue));
}
Element* ContainerNode::querySelector(const String& selectors, ExceptionCode& ec)
{
if (SelectorQuery* selectorQuery = document().selectorQueryForString(selectors, ec))
return selectorQuery->queryFirst(*this);
return nullptr;
}
RefPtr<NodeList> ContainerNode::querySelectorAll(const String& selectors, ExceptionCode& ec)
{
if (SelectorQuery* selectorQuery = document().selectorQueryForString(selectors, ec))
return selectorQuery->queryAll(*this);
return nullptr;
}
PassRefPtr<NodeList> ContainerNode::getElementsByTagName(const AtomicString& localName)
{
if (localName.isNull())
return 0;
if (document().isHTMLDocument())
return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, localName);
return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(*this, localName);
}
PassRefPtr<NodeList> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName)
{
if (localName.isNull())
return 0;
if (namespaceURI == starAtom)
return getElementsByTagName(localName);
return ensureRareData().ensureNodeLists().addCacheWithQualifiedName(*this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);
}
PassRefPtr<NodeList> ContainerNode::getElementsByName(const String& elementName)
{
return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, elementName);
}
PassRefPtr<NodeList> ContainerNode::getElementsByClassName(const String& classNames)
{
return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(*this, classNames);
}
PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name)
{
ASSERT(hasTagName(HTMLNames::formTag) || hasTagName(HTMLNames::fieldsetTag));
return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, name);
}
}