Use child iterator in HTMLDetailsElement::findMainSummary().
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Feb 2014 02:04:27 +0000 (02:04 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Feb 2014 02:04:27 +0000 (02:04 +0000)
<https://webkit.org/b/128335>

Reviewed by Antti Koivisto.

* html/HTMLDetailsElement.h:
* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::findMainSummary):

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

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLDetailsElement.cpp
Source/WebCore/html/HTMLDetailsElement.h

index d4919296242e52e362e26a9af29cca08e9d5bab4..0f1c641269eb045dae4932db0009edcc43e3774d 100644 (file)
@@ -1,3 +1,14 @@
+2014-02-06  Andreas Kling  <akling@apple.com>
+
+        Use child iterator in HTMLDetailsElement::findMainSummary().
+        <https://webkit.org/b/128335>
+
+        Reviewed by Antti Koivisto.
+
+        * html/HTMLDetailsElement.h:
+        * html/HTMLDetailsElement.cpp:
+        (WebCore::HTMLDetailsElement::findMainSummary):
+
 2014-02-06  Antti Koivisto  <antti@apple.com>
 
         Add missing &.
index 0efa66694f5d504cfed78c3a38b2853ba9f3c5a6..c7bf7c97754ba6b6ab6550d4e3bbdbf68d3dacae 100644 (file)
@@ -22,6 +22,7 @@
 #include "HTMLDetailsElement.h"
 
 #if ENABLE(DETAILS_ELEMENT)
+#include "ElementIterator.h"
 #include "HTMLSummaryElement.h"
 #include "InsertionPoint.h"
 #include "LocalizedStrings.h"
@@ -121,12 +122,10 @@ void HTMLDetailsElement::didAddUserAgentShadowRoot(ShadowRoot* root)
     root->appendChild(DetailsContentElement::create(document()), ASSERT_NO_EXCEPTION);
 }
 
-Element* HTMLDetailsElement::findMainSummary() const
+const Element* HTMLDetailsElement::findMainSummary() const
 {
-    for (Node* child = firstChild(); child; child = child->nextSibling()) {
-        if (child->hasTagName(summaryTag))
-            return toElement(child);
-    }
+    if (auto summary = childrenOfType<HTMLSummaryElement>(*this).first())
+        return summary;
 
     return static_cast<DetailsSummaryElement*>(userAgentShadowRoot()->firstChild())->fallbackSummary();
 }
index a0a18a6544dbf34d9fa3c12f6318f36c0a97eaa4..c41f6f471a04630a79c9f6f43924e62e6498e7c5 100644 (file)
@@ -30,7 +30,7 @@ public:
     static PassRefPtr<HTMLDetailsElement> create(const QualifiedName& tagName, Document& document);
     void toggleOpen();
 
-    Element* findMainSummary() const;
+    const Element* findMainSummary() const;
 
 private:
     HTMLDetailsElement(const QualifiedName&, Document&);