Have more getElementsBy*() methods return a Ref<>
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Aug 2015 16:05:20 +0000 (16:05 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Aug 2015 16:05:20 +0000 (16:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148287

Reviewed by Sam Weinig.

Have more getElementsBy*() methods return a Ref<> instaed of a RefPtr<>
as they cannot return null.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::getElementsByTagName):
(WebCore::ContainerNode::getElementsByTagNameNS):
(WebCore::ContainerNode::getElementsByName):
(WebCore::ContainerNode::getElementsByClassName):
(WebCore::ContainerNode::getElementsByClassNameForObjC):
(WebCore::ContainerNode::radioNodeList):
* dom/ContainerNode.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188754 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNode.h

index 51de28a..2f5f5a7 100644 (file)
@@ -1,5 +1,24 @@
 2015-08-21  Chris Dumez  <cdumez@apple.com>
 
+        Have more getElementsBy*() methods return a Ref<>
+        https://bugs.webkit.org/show_bug.cgi?id=148287
+
+        Reviewed by Sam Weinig.
+
+        Have more getElementsBy*() methods return a Ref<> instaed of a RefPtr<>
+        as they cannot return null.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::getElementsByTagName):
+        (WebCore::ContainerNode::getElementsByTagNameNS):
+        (WebCore::ContainerNode::getElementsByName):
+        (WebCore::ContainerNode::getElementsByClassName):
+        (WebCore::ContainerNode::getElementsByClassNameForObjC):
+        (WebCore::ContainerNode::radioNodeList):
+        * dom/ContainerNode.h:
+
+2015-08-21  Chris Dumez  <cdumez@apple.com>
+
         Drop NodeListBase class
         https://bugs.webkit.org/show_bug.cgi?id=148290
 
index b47a651..08d2ce6 100644 (file)
@@ -867,7 +867,7 @@ RefPtr<NodeList> ContainerNode::querySelectorAll(const String& selectors, Except
 RefPtr<NodeList> ContainerNode::getElementsByTagName(const AtomicString& localName)
 {
     if (localName.isNull())
-        return 0;
+        return nullptr;
 
     if (document().isHTMLDocument())
         return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, localName);
@@ -877,7 +877,7 @@ RefPtr<NodeList> ContainerNode::getElementsByTagName(const AtomicString& localNa
 RefPtr<NodeList> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName)
 {
     if (localName.isNull())
-        return 0;
+        return nullptr;
 
     if (namespaceURI == starAtom)
         return getElementsByTagName(localName);
@@ -885,22 +885,22 @@ RefPtr<NodeList> ContainerNode::getElementsByTagNameNS(const AtomicString& names
     return ensureRareData().ensureNodeLists().addCacheWithQualifiedName(*this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);
 }
 
-RefPtr<NodeList> ContainerNode::getElementsByName(const String& elementName)
+Ref<NodeList> ContainerNode::getElementsByName(const String& elementName)
 {
     return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, elementName);
 }
 
-RefPtr<HTMLCollection> ContainerNode::getElementsByClassName(const AtomicString& classNames)
+Ref<HTMLCollection> ContainerNode::getElementsByClassName(const AtomicString& classNames)
 {
     return ensureRareData().ensureNodeLists().addCachedCollection<ClassCollection>(*this, ByClass, classNames);
 }
 
-RefPtr<NodeList> ContainerNode::getElementsByClassNameForObjC(const AtomicString& classNames)
+Ref<NodeList> ContainerNode::getElementsByClassNameForObjC(const AtomicString& classNames)
 {
     return getElementsByClassName(classNames);
 }
 
-RefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name)
+Ref<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name)
 {
     ASSERT(hasTagName(HTMLNames::formTag) || hasTagName(HTMLNames::fieldsetTag));
     return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, name);
index dfab00e..a069331 100644 (file)
@@ -145,10 +145,10 @@ public:
 
     RefPtr<NodeList> getElementsByTagName(const AtomicString&);
     RefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName);
-    RefPtr<NodeList> getElementsByName(const String& elementName);
-    RefPtr<HTMLCollection> getElementsByClassName(const AtomicString& classNames);
-    RefPtr<NodeList> getElementsByClassNameForObjC(const AtomicString& classNames);
-    RefPtr<RadioNodeList> radioNodeList(const AtomicString&);
+    Ref<NodeList> getElementsByName(const String& elementName);
+    Ref<HTMLCollection> getElementsByClassName(const AtomicString& classNames);
+    Ref<NodeList> getElementsByClassNameForObjC(const AtomicString& classNames);
+    Ref<RadioNodeList> radioNodeList(const AtomicString&);
 
     // From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode
     Ref<HTMLCollection> children();