Diff
Modified: trunk/Source/WebCore/ChangeLog (173648 => 173649)
--- trunk/Source/WebCore/ChangeLog 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/ChangeLog 2014-09-16 05:36:37 UTC (rev 173649)
@@ -1,5 +1,64 @@
2014-09-15 Chris Dumez <[email protected]>
+ Rename LiveNodeLists / HTMLCollections's nodeMatches() to elementMatches()
+ https://bugs.webkit.org/show_bug.cgi?id=136844
+
+ Reviewed by Sam Weinig.
+
+ Rename LiveNodeLists / HTMLCollections's nodeMatches() to elementMatches()
+ for clarity as the argument is an Element.
+
+ No new tests, no behavior change.
+
+ * dom/ClassNodeList.h:
+ (WebCore::ClassNodeList::elementMatches):
+ (WebCore::ClassNodeList::nodeMatches): Deleted.
+ * dom/DocumentOrderedMap.cpp:
+ (WebCore::keyMatchesWindowNamedItem):
+ (WebCore::keyMatchesDocumentNamedItem):
+ * dom/Element.cpp:
+ (WebCore::Element::updateNameForDocument):
+ (WebCore::Element::updateIdForDocument):
+ * dom/LiveNodeList.cpp:
+ (WebCore::LiveNodeList::namedItem):
+ * dom/LiveNodeList.h:
+ (WebCore::CachedLiveNodeList<NodeListType>::collectionBegin):
+ (WebCore::CachedLiveNodeList<NodeListType>::collectionLast):
+ (WebCore::CachedLiveNodeList<NodeListType>::collectionTraverseForward):
+ (WebCore::CachedLiveNodeList<NodeListType>::collectionTraverseBackward):
+ * dom/NameNodeList.h:
+ (WebCore::NameNodeList::elementMatches):
+ (WebCore::NameNodeList::nodeMatches): Deleted.
+ * dom/TagNodeList.h:
+ (WebCore::TagNodeList::elementMatches):
+ (WebCore::HTMLTagNodeList::elementMatches):
+ (WebCore::TagNodeList::nodeMatches): Deleted.
+ (WebCore::HTMLTagNodeList::nodeMatches): Deleted.
+ * html/HTMLCollection.cpp:
+ (WebCore::isMatchingElement):
+ * html/HTMLNameCollection.cpp:
+ (WebCore::WindowNameCollection::elementMatchesIfNameAttributeMatch):
+ (WebCore::WindowNameCollection::elementMatches):
+ (WebCore::DocumentNameCollection::elementMatchesIfIdAttributeMatch):
+ (WebCore::DocumentNameCollection::elementMatchesIfNameAttributeMatch):
+ (WebCore::DocumentNameCollection::elementMatches):
+ (WebCore::WindowNameCollection::nodeMatchesIfNameAttributeMatch): Deleted.
+ (WebCore::WindowNameCollection::nodeMatches): Deleted.
+ (WebCore::DocumentNameCollection::nodeMatchesIfIdAttributeMatch): Deleted.
+ (WebCore::DocumentNameCollection::nodeMatchesIfNameAttributeMatch): Deleted.
+ (WebCore::DocumentNameCollection::nodeMatches): Deleted.
+ * html/HTMLNameCollection.h:
+ * html/LabelsNodeList.cpp:
+ (WebCore::LabelsNodeList::elementMatches):
+ (WebCore::LabelsNodeList::nodeMatches): Deleted.
+ * html/LabelsNodeList.h:
+ * html/RadioNodeList.cpp:
+ (WebCore::RadioNodeList::elementMatches):
+ (WebCore::RadioNodeList::nodeMatches): Deleted.
+ * html/RadioNodeList.h:
+
+2014-09-15 Chris Dumez <[email protected]>
+
Use an AtomicString as key for caching ClassNodeList objects
https://bugs.webkit.org/show_bug.cgi?id=136830
Modified: trunk/Source/WebCore/dom/ClassNodeList.h (173648 => 173649)
--- trunk/Source/WebCore/dom/ClassNodeList.h 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/dom/ClassNodeList.h 2014-09-16 05:36:37 UTC (rev 173649)
@@ -43,7 +43,7 @@
virtual ~ClassNodeList();
- virtual bool nodeMatches(Element*) const override;
+ virtual bool elementMatches(Element*) const override;
virtual bool isRootedAtDocument() const override { return false; }
private:
@@ -60,7 +60,7 @@
{
}
-inline bool ClassNodeList::nodeMatches(Element* element) const
+inline bool ClassNodeList::elementMatches(Element* element) const
{
if (!element->hasClass())
return false;
Modified: trunk/Source/WebCore/dom/DocumentOrderedMap.cpp (173648 => 173649)
--- trunk/Source/WebCore/dom/DocumentOrderedMap.cpp 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/dom/DocumentOrderedMap.cpp 2014-09-16 05:36:37 UTC (rev 173649)
@@ -74,12 +74,12 @@
inline bool keyMatchesWindowNamedItem(const AtomicStringImpl& key, const Element& element)
{
- return WindowNameCollection::nodeMatches(const_cast<Element*>(&element), &key);
+ return WindowNameCollection::elementMatches(const_cast<Element*>(&element), &key);
}
inline bool keyMatchesDocumentNamedItem(const AtomicStringImpl& key, const Element& element)
{
- return DocumentNameCollection::nodeMatches(const_cast<Element*>(&element), &key);
+ return DocumentNameCollection::elementMatches(const_cast<Element*>(&element), &key);
}
void DocumentOrderedMap::clear()
Modified: trunk/Source/WebCore/dom/Element.cpp (173648 => 173649)
--- trunk/Source/WebCore/dom/Element.cpp 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/dom/Element.cpp 2014-09-16 05:36:37 UTC (rev 173649)
@@ -2606,16 +2606,16 @@
{
ASSERT(oldName != newName);
- if (WindowNameCollection::nodeMatchesIfNameAttributeMatch(this)) {
- const AtomicString& id = WindowNameCollection::nodeMatchesIfIdAttributeMatch(this) ? getIdAttribute() : nullAtom;
+ if (WindowNameCollection::elementMatchesIfNameAttributeMatch(this)) {
+ const AtomicString& id = WindowNameCollection::elementMatchesIfIdAttributeMatch(this) ? getIdAttribute() : nullAtom;
if (!oldName.isEmpty() && oldName != id)
document.removeWindowNamedItem(*oldName.impl(), *this);
if (!newName.isEmpty() && newName != id)
document.addWindowNamedItem(*newName.impl(), *this);
}
- if (DocumentNameCollection::nodeMatchesIfNameAttributeMatch(this)) {
- const AtomicString& id = DocumentNameCollection::nodeMatchesIfIdAttributeMatch(this) ? getIdAttribute() : nullAtom;
+ if (DocumentNameCollection::elementMatchesIfNameAttributeMatch(this)) {
+ const AtomicString& id = DocumentNameCollection::elementMatchesIfIdAttributeMatch(this) ? getIdAttribute() : nullAtom;
if (!oldName.isEmpty() && oldName != id)
document.removeDocumentNamedItem(*oldName.impl(), *this);
if (!newName.isEmpty() && newName != id)
@@ -2656,16 +2656,16 @@
ASSERT(inDocument());
ASSERT(oldId != newId);
- if (WindowNameCollection::nodeMatchesIfIdAttributeMatch(this)) {
- const AtomicString& name = condition == UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute && WindowNameCollection::nodeMatchesIfNameAttributeMatch(this) ? getNameAttribute() : nullAtom;
+ if (WindowNameCollection::elementMatchesIfIdAttributeMatch(this)) {
+ const AtomicString& name = condition == UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute && WindowNameCollection::elementMatchesIfNameAttributeMatch(this) ? getNameAttribute() : nullAtom;
if (!oldId.isEmpty() && oldId != name)
document.removeWindowNamedItem(*oldId.impl(), *this);
if (!newId.isEmpty() && newId != name)
document.addWindowNamedItem(*newId.impl(), *this);
}
- if (DocumentNameCollection::nodeMatchesIfIdAttributeMatch(this)) {
- const AtomicString& name = condition == UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute && DocumentNameCollection::nodeMatchesIfNameAttributeMatch(this) ? getNameAttribute() : nullAtom;
+ if (DocumentNameCollection::elementMatchesIfIdAttributeMatch(this)) {
+ const AtomicString& name = condition == UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute && DocumentNameCollection::elementMatchesIfNameAttributeMatch(this) ? getNameAttribute() : nullAtom;
if (!oldId.isEmpty() && oldId != name)
document.removeDocumentNamedItem(*oldId.impl(), *this);
if (!newId.isEmpty() && newId != name)
Modified: trunk/Source/WebCore/dom/LiveNodeList.cpp (173648 => 173649)
--- trunk/Source/WebCore/dom/LiveNodeList.cpp 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/dom/LiveNodeList.cpp 2014-09-16 05:36:37 UTC (rev 173649)
@@ -58,7 +58,7 @@
if (rootNode.inDocument()) {
Element* element = rootNode.treeScope().getElementById(elementId);
- if (element && nodeMatches(element) && element->isDescendantOf(&rootNode))
+ if (element && elementMatches(element) && element->isDescendantOf(&rootNode))
return element;
if (!element)
return nullptr;
Modified: trunk/Source/WebCore/dom/LiveNodeList.h (173648 => 173649)
--- trunk/Source/WebCore/dom/LiveNodeList.h 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/dom/LiveNodeList.h 2014-09-16 05:36:37 UTC (rev 173649)
@@ -46,7 +46,7 @@
virtual Node* namedItem(const AtomicString&) const override final;
- virtual bool nodeMatches(Element*) const = 0;
+ virtual bool elementMatches(Element*) const = 0;
virtual bool isRootedAtDocument() const = 0;
ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); }
@@ -159,7 +159,7 @@
auto descendants = elementDescendants(rootNode());
auto end = descendants.end();
for (auto it = descendants.begin(); it != end; ++it) {
- if (nodeList.nodeMatches(&*it))
+ if (nodeList.elementMatches(&*it))
return it;
}
return end;
@@ -172,7 +172,7 @@
auto descendants = elementDescendants(rootNode());
auto end = descendants.end();
for (auto it = descendants.last(); it != end; --it) {
- if (nodeList.nodeMatches(&*it))
+ if (nodeList.elementMatches(&*it))
return it;
}
return end;
@@ -182,14 +182,14 @@
void CachedLiveNodeList<NodeListType>::collectionTraverseForward(ElementDescendantIterator& current, unsigned count, unsigned& traversedCount) const
{
auto& nodeList = static_cast<const NodeListType&>(*this);
- ASSERT(nodeList.nodeMatches(&*current));
+ ASSERT(nodeList.elementMatches(&*current));
auto end = collectionEnd();
for (traversedCount = 0; traversedCount < count; ++traversedCount) {
do {
++current;
if (current == end)
return;
- } while (!nodeList.nodeMatches(&*current));
+ } while (!nodeList.elementMatches(&*current));
}
}
@@ -197,14 +197,14 @@
void CachedLiveNodeList<NodeListType>::collectionTraverseBackward(ElementDescendantIterator& current, unsigned count) const
{
auto& nodeList = static_cast<const NodeListType&>(*this);
- ASSERT(nodeList.nodeMatches(&*current));
+ ASSERT(nodeList.elementMatches(&*current));
auto end = collectionEnd();
for (; count; --count) {
do {
--current;
if (current == end)
return;
- } while (!nodeList.nodeMatches(&*current));
+ } while (!nodeList.elementMatches(&*current));
}
}
Modified: trunk/Source/WebCore/dom/NameNodeList.h (173648 => 173649)
--- trunk/Source/WebCore/dom/NameNodeList.h 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/dom/NameNodeList.h 2014-09-16 05:36:37 UTC (rev 173649)
@@ -40,7 +40,7 @@
virtual ~NameNodeList();
- virtual bool nodeMatches(Element*) const override;
+ virtual bool elementMatches(Element*) const override;
virtual bool isRootedAtDocument() const override { return false; }
private:
@@ -49,7 +49,7 @@
AtomicString m_name;
};
-inline bool NameNodeList::nodeMatches(Element* element) const
+inline bool NameNodeList::elementMatches(Element* element) const
{
return element->getNameAttribute() == m_name;
}
Modified: trunk/Source/WebCore/dom/TagNodeList.h (173648 => 173649)
--- trunk/Source/WebCore/dom/TagNodeList.h 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/dom/TagNodeList.h 2014-09-16 05:36:37 UTC (rev 173649)
@@ -46,7 +46,7 @@
virtual ~TagNodeList();
- virtual bool nodeMatches(Element*) const override;
+ virtual bool elementMatches(Element*) const override;
virtual bool isRootedAtDocument() const override { return false; }
protected:
@@ -56,7 +56,7 @@
AtomicString m_localName;
};
-inline bool TagNodeList::nodeMatches(Element* element) const
+inline bool TagNodeList::elementMatches(Element* element) const
{
// Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-getelementsbytagnamens
if (m_localName != starAtom && m_localName != element->localName())
@@ -74,7 +74,7 @@
virtual ~HTMLTagNodeList();
- virtual bool nodeMatches(Element*) const override;
+ virtual bool elementMatches(Element*) const override;
virtual bool isRootedAtDocument() const override { return false; }
private:
@@ -84,7 +84,7 @@
AtomicString m_loweredLocalName;
};
-inline bool HTMLTagNodeList::nodeMatches(Element* element) const
+inline bool HTMLTagNodeList::elementMatches(Element* element) const
{
// Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-getelementsbytagname
if (m_localName == starAtom)
Modified: trunk/Source/WebCore/html/HTMLCollection.cpp (173648 => 173649)
--- trunk/Source/WebCore/html/HTMLCollection.cpp 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/html/HTMLCollection.cpp 2014-09-16 05:36:37 UTC (rev 173649)
@@ -213,9 +213,9 @@
case NodeChildren:
return true;
case DocumentNamedItems:
- return static_cast<const DocumentNameCollection&>(htmlCollection).nodeMatches(&element);
+ return static_cast<const DocumentNameCollection&>(htmlCollection).elementMatches(&element);
case WindowNamedItems:
- return static_cast<const WindowNameCollection&>(htmlCollection).nodeMatches(&element);
+ return static_cast<const WindowNameCollection&>(htmlCollection).elementMatches(&element);
case FormControls:
case TableRows:
break;
Modified: trunk/Source/WebCore/html/HTMLNameCollection.cpp (173648 => 173649)
--- trunk/Source/WebCore/html/HTMLNameCollection.cpp 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/html/HTMLNameCollection.cpp 2014-09-16 05:36:37 UTC (rev 173649)
@@ -49,35 +49,35 @@
document().nodeLists()->removeCachedCollection(this, m_name);
}
-bool WindowNameCollection::nodeMatchesIfNameAttributeMatch(Element* element)
+bool WindowNameCollection::elementMatchesIfNameAttributeMatch(Element* element)
{
return isHTMLImageElement(element) || isHTMLFormElement(element) || element->hasTagName(appletTag)
|| element->hasTagName(embedTag) || element->hasTagName(objectTag);
}
-bool WindowNameCollection::nodeMatches(Element* element, const AtomicStringImpl* name)
+bool WindowNameCollection::elementMatches(Element* element, const AtomicStringImpl* name)
{
// Find only images, forms, applets, embeds and objects by name, but anything by id
- if (nodeMatchesIfNameAttributeMatch(element) && element->getNameAttribute().impl() == name)
+ if (elementMatchesIfNameAttributeMatch(element) && element->getNameAttribute().impl() == name)
return true;
return element->getIdAttribute().impl() == name;
}
-bool DocumentNameCollection::nodeMatchesIfIdAttributeMatch(Element* element)
+bool DocumentNameCollection::elementMatchesIfIdAttributeMatch(Element* element)
{
// FIXME: we need to fix HTMLImageElement to update the hash map for us when name attribute has been removed.
return element->hasTagName(appletTag) || (element->hasTagName(objectTag) && toHTMLObjectElement(element)->isDocNamedItem())
|| (isHTMLImageElement(element) && element->hasName());
}
-bool DocumentNameCollection::nodeMatchesIfNameAttributeMatch(Element* element)
+bool DocumentNameCollection::elementMatchesIfNameAttributeMatch(Element* element)
{
return isHTMLFormElement(element) || element->hasTagName(embedTag) || element->hasTagName(iframeTag)
|| element->hasTagName(appletTag) || (element->hasTagName(objectTag) && toHTMLObjectElement(element)->isDocNamedItem())
|| isHTMLImageElement(element);
}
-bool DocumentNameCollection::nodeMatches(Element* element, const AtomicStringImpl* name)
+bool DocumentNameCollection::elementMatches(Element* element, const AtomicStringImpl* name)
{
// Find images, forms, applets, embeds, objects and iframes by name, applets and object by id, and images by id
// but only if they have a name attribute (this very strange rule matches IE)
Modified: trunk/Source/WebCore/html/HTMLNameCollection.h (173648 => 173649)
--- trunk/Source/WebCore/html/HTMLNameCollection.h 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/html/HTMLNameCollection.h 2014-09-16 05:36:37 UTC (rev 173649)
@@ -50,11 +50,11 @@
return adoptRef(*new WindowNameCollection(document, type, name));
}
- bool nodeMatches(Element* element) const { return nodeMatches(element, m_name.impl()); }
+ bool elementMatches(Element* element) const { return elementMatches(element, m_name.impl()); }
- static bool nodeMatchesIfIdAttributeMatch(Element*) { return true; }
- static bool nodeMatchesIfNameAttributeMatch(Element*);
- static bool nodeMatches(Element*, const AtomicStringImpl*);
+ static bool elementMatchesIfIdAttributeMatch(Element*) { return true; }
+ static bool elementMatchesIfNameAttributeMatch(Element*);
+ static bool elementMatches(Element*, const AtomicStringImpl*);
private:
WindowNameCollection(Document& document, CollectionType type, const AtomicString& name)
@@ -71,11 +71,11 @@
return adoptRef(*new DocumentNameCollection(document, type, name));
}
- static bool nodeMatchesIfIdAttributeMatch(Element*);
- static bool nodeMatchesIfNameAttributeMatch(Element*);
- bool nodeMatches(Element* element) const { return nodeMatches(element, m_name.impl()); }
+ static bool elementMatchesIfIdAttributeMatch(Element*);
+ static bool elementMatchesIfNameAttributeMatch(Element*);
+ bool elementMatches(Element* element) const { return elementMatches(element, m_name.impl()); }
- static bool nodeMatches(Element*, const AtomicStringImpl*);
+ static bool elementMatches(Element*, const AtomicStringImpl*);
private:
DocumentNameCollection(Document& document, CollectionType type, const AtomicString& name)
Modified: trunk/Source/WebCore/html/LabelsNodeList.cpp (173648 => 173649)
--- trunk/Source/WebCore/html/LabelsNodeList.cpp 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/html/LabelsNodeList.cpp 2014-09-16 05:36:37 UTC (rev 173649)
@@ -43,7 +43,7 @@
ownerNode().nodeLists()->removeCacheWithAtomicName(this, starAtom);
}
-bool LabelsNodeList::nodeMatches(Element* testNode) const
+bool LabelsNodeList::elementMatches(Element* testNode) const
{
return isHTMLLabelElement(testNode) && toHTMLLabelElement(testNode)->control() == &ownerNode();
}
Modified: trunk/Source/WebCore/html/LabelsNodeList.h (173648 => 173649)
--- trunk/Source/WebCore/html/LabelsNodeList.h 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/html/LabelsNodeList.h 2014-09-16 05:36:37 UTC (rev 173649)
@@ -38,7 +38,7 @@
}
~LabelsNodeList();
- virtual bool nodeMatches(Element*) const override;
+ virtual bool elementMatches(Element*) const override;
virtual bool isRootedAtDocument() const override { return true; }
private:
Modified: trunk/Source/WebCore/html/RadioNodeList.cpp (173648 => 173649)
--- trunk/Source/WebCore/html/RadioNodeList.cpp 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/html/RadioNodeList.cpp 2014-09-16 05:36:37 UTC (rev 173649)
@@ -99,7 +99,7 @@
return testElement->getIdAttribute() == m_name || testElement->getNameAttribute() == m_name;
}
-bool RadioNodeList::nodeMatches(Element* testElement) const
+bool RadioNodeList::elementMatches(Element* testElement) const
{
if (!testElement->hasTagName(objectTag) && !testElement->isFormControlElement())
return false;
Modified: trunk/Source/WebCore/html/RadioNodeList.h (173648 => 173649)
--- trunk/Source/WebCore/html/RadioNodeList.h 2014-09-16 04:09:58 UTC (rev 173648)
+++ trunk/Source/WebCore/html/RadioNodeList.h 2014-09-16 05:36:37 UTC (rev 173649)
@@ -45,7 +45,7 @@
String value() const;
void setValue(const String&);
- virtual bool nodeMatches(Element*) const override;
+ virtual bool elementMatches(Element*) const override;
virtual bool isRootedAtDocument() const override { return m_isRootedAtDocument; }
private: