Title: [191351] trunk/Source/WebCore
Revision
191351
Author
[email protected]
Date
2015-10-20 11:48:26 -0700 (Tue, 20 Oct 2015)

Log Message

Use tighter typing for collections / node lists' item() / namedItem() methods
https://bugs.webkit.org/show_bug.cgi?id=150347

Reviewed by Darin Adler.

Use tighter typing for collections / node lists' item() / namedItem() methods.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::getDocumentLinks):
* dom/LiveNodeList.h:
* dom/StaticNodeList.cpp:
(WebCore::StaticElementList::item):
* dom/StaticNodeList.h:
* html/CachedHTMLCollection.h:
* html/HTMLAllCollection.idl:
* html/HTMLCollection.idl:
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::elements):
(WebCore::HTMLFieldSetElement::elementsForObjC):
* html/HTMLFieldSetElement.h:
* html/HTMLFieldSetElement.idl:
* html/HTMLFormControlsCollection.cpp:
(WebCore::HTMLFormControlsCollection::customElementAfter):
* html/HTMLFormControlsCollection.h:
* html/HTMLFormControlsCollection.idl:
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::item):
(WebCore::HTMLFormElement::elements):
(WebCore::HTMLFormElement::elementsForObjC):
* html/HTMLFormElement.h:
* html/HTMLFormElement.idl:
* html/HTMLOptionsCollection.cpp:
(WebCore::HTMLOptionsCollection::add):
* html/HTMLOptionsCollection.h:
* html/HTMLOptionsCollection.idl:
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::namedItem):
(WebCore::HTMLSelectElement::item):
(WebCore::HTMLSelectElement::setOption):
* html/HTMLSelectElement.idl:
* html/HTMLTableRowElement.cpp:
(WebCore::HTMLTableRowElement::deleteCell):
* html/HTMLTableSectionElement.cpp:
(WebCore::HTMLTableSectionElement::deleteRow):
* html/RadioNodeList.cpp:
(WebCore::toRadioButtonInputElement):
(WebCore::RadioNodeList::value):
(WebCore::RadioNodeList::setValue):
* html/RadioNodeList.h:
* html/RadioNodeList.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (191350 => 191351)


--- trunk/Source/WebCore/ChangeLog	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/ChangeLog	2015-10-20 18:48:26 UTC (rev 191351)
@@ -1,5 +1,58 @@
 2015-10-20  Chris Dumez  <[email protected]>
 
+        Use tighter typing for collections / node lists' item() / namedItem() methods
+        https://bugs.webkit.org/show_bug.cgi?id=150347
+
+        Reviewed by Darin Adler.
+
+        Use tighter typing for collections / node lists' item() / namedItem() methods.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::getDocumentLinks):
+        * dom/LiveNodeList.h:
+        * dom/StaticNodeList.cpp:
+        (WebCore::StaticElementList::item):
+        * dom/StaticNodeList.h:
+        * html/CachedHTMLCollection.h:
+        * html/HTMLAllCollection.idl:
+        * html/HTMLCollection.idl:
+        * html/HTMLFieldSetElement.cpp:
+        (WebCore::HTMLFieldSetElement::elements):
+        (WebCore::HTMLFieldSetElement::elementsForObjC):
+        * html/HTMLFieldSetElement.h:
+        * html/HTMLFieldSetElement.idl:
+        * html/HTMLFormControlsCollection.cpp:
+        (WebCore::HTMLFormControlsCollection::customElementAfter):
+        * html/HTMLFormControlsCollection.h:
+        * html/HTMLFormControlsCollection.idl:
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::item):
+        (WebCore::HTMLFormElement::elements):
+        (WebCore::HTMLFormElement::elementsForObjC):
+        * html/HTMLFormElement.h:
+        * html/HTMLFormElement.idl:
+        * html/HTMLOptionsCollection.cpp:
+        (WebCore::HTMLOptionsCollection::add):
+        * html/HTMLOptionsCollection.h:
+        * html/HTMLOptionsCollection.idl:
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::namedItem):
+        (WebCore::HTMLSelectElement::item):
+        (WebCore::HTMLSelectElement::setOption):
+        * html/HTMLSelectElement.idl:
+        * html/HTMLTableRowElement.cpp:
+        (WebCore::HTMLTableRowElement::deleteCell):
+        * html/HTMLTableSectionElement.cpp:
+        (WebCore::HTMLTableSectionElement::deleteRow):
+        * html/RadioNodeList.cpp:
+        (WebCore::toRadioButtonInputElement):
+        (WebCore::RadioNodeList::value):
+        (WebCore::RadioNodeList::setValue):
+        * html/RadioNodeList.h:
+        * html/RadioNodeList.idl:
+
+2015-10-20  Chris Dumez  <[email protected]>
+
         Only HTML spaces should be stripped from a <script>'s 'for' / 'event' attributes
         https://bugs.webkit.org/show_bug.cgi?id=150335
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (191350 => 191351)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -1780,19 +1780,18 @@
 {
     Document& document = m_renderer->document();
     Ref<HTMLCollection> links = document.links();
-    for (unsigned i = 0; Node* curr = links->item(i); i++) {
-        RenderObject* obj = curr->renderer();
-        if (obj) {
-            RefPtr<AccessibilityObject> axobj = document.axObjectCache()->getOrCreate(obj);
-            ASSERT(axobj);
-            if (!axobj->accessibilityIsIgnored() && axobj->isLink())
-                result.append(axobj);
+    for (unsigned i = 0; auto* current = links->item(i); ++i) {
+        if (auto* renderer = current->renderer()) {
+            RefPtr<AccessibilityObject> axObject = document.axObjectCache()->getOrCreate(renderer);
+            ASSERT(axObject);
+            if (!axObject->accessibilityIsIgnored() && axObject->isLink())
+                result.append(axObject);
         } else {
-            Node* parent = curr->parentNode();
-            if (is<HTMLAreaElement>(*curr) && is<HTMLMapElement>(parent)) {
+            auto* parent = current->parentNode();
+            if (is<HTMLAreaElement>(*current) && is<HTMLMapElement>(parent)) {
                 auto& areaObject = downcast<AccessibilityImageMapLink>(*axObjectCache()->getOrCreate(ImageMapLinkRole));
                 HTMLMapElement& map = downcast<HTMLMapElement>(*parent);
-                areaObject.setHTMLAreaElement(downcast<HTMLAreaElement>(curr));
+                areaObject.setHTMLAreaElement(downcast<HTMLAreaElement>(current));
                 areaObject.setHTMLMapElement(&map);
                 areaObject.setParent(accessibilityParentForImageMap(&map));
 

Modified: trunk/Source/WebCore/dom/LiveNodeList.h (191350 => 191351)


--- trunk/Source/WebCore/dom/LiveNodeList.h	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/dom/LiveNodeList.h	2015-10-20 18:48:26 UTC (rev 191351)
@@ -80,7 +80,7 @@
     virtual ~CachedLiveNodeList();
 
     unsigned length() const override final { return m_indexCache.nodeCount(nodeList()); }
-    Node* item(unsigned offset) const override final { return m_indexCache.nodeAt(nodeList(), offset); }
+    Element* item(unsigned offset) const override { return m_indexCache.nodeAt(nodeList(), offset); }
 
     // For CollectionIndexCache
     ElementDescendantIterator collectionBegin() const { return CollectionTraversal<CollectionTraversalType::Descendants>::begin(nodeList(), rootNode()); }

Modified: trunk/Source/WebCore/dom/StaticNodeList.cpp (191350 => 191351)


--- trunk/Source/WebCore/dom/StaticNodeList.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/dom/StaticNodeList.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -48,7 +48,7 @@
     return m_elements.size();
 }
 
-Node* StaticElementList::item(unsigned index) const
+Element* StaticElementList::item(unsigned index) const
 {
     if (index < m_elements.size())
         return const_cast<Element*>(m_elements[index].ptr());

Modified: trunk/Source/WebCore/dom/StaticNodeList.h (191350 => 191351)


--- trunk/Source/WebCore/dom/StaticNodeList.h	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/dom/StaticNodeList.h	2015-10-20 18:48:26 UTC (rev 191351)
@@ -75,7 +75,7 @@
     }
 
     virtual unsigned length() const override;
-    virtual Node* item(unsigned index) const override;
+    virtual Element* item(unsigned index) const override;
 
 private:
     StaticElementList()

Modified: trunk/Source/WebCore/html/CachedHTMLCollection.h (191350 => 191351)


--- trunk/Source/WebCore/html/CachedHTMLCollection.h	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/CachedHTMLCollection.h	2015-10-20 18:48:26 UTC (rev 191351)
@@ -40,7 +40,7 @@
     virtual ~CachedHTMLCollection();
 
     virtual unsigned length() const override final { return m_indexCache.nodeCount(collection()); }
-    virtual Element* item(unsigned offset) const override final { return m_indexCache.nodeAt(collection(), offset); }
+    virtual Element* item(unsigned offset) const override { return m_indexCache.nodeAt(collection(), offset); }
     virtual Element* namedItem(const AtomicString& name) const override;
     virtual size_t memoryCost() const override final { return m_indexCache.memoryCost() + HTMLCollection::memoryCost(); }
 

Modified: trunk/Source/WebCore/html/HTMLAllCollection.idl (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLAllCollection.idl	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLAllCollection.idl	2015-10-20 18:48:26 UTC (rev 191351)
@@ -29,8 +29,8 @@
     GenerateIsReachable=ImplOwnerNodeRoot,
 ] interface HTMLAllCollection {
     readonly attribute unsigned long length;
-    [Custom] getter Node item([Default=Undefined] optional unsigned long index);
-    [Custom] getter Node namedItem(DOMString name);
+    [Custom] getter Element item([Default=Undefined] optional unsigned long index);
+    [Custom] getter Element namedItem(DOMString name);
     // FIXME: This should return an HTMLAllCollection.
     NodeList tags(DOMString name);
 };

Modified: trunk/Source/WebCore/html/HTMLCollection.idl (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLCollection.idl	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLCollection.idl	2015-10-20 18:48:26 UTC (rev 191351)
@@ -25,8 +25,14 @@
     ReportExtraMemoryCost,
 ] interface HTMLCollection {
     readonly attribute unsigned long length;
+
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
     getter Node item([Default=Undefined] optional unsigned long index);
     getter Node namedItem([Default=Undefined] optional DOMString name);
+#else
+    getter Element item([Default=Undefined] optional unsigned long index);
+    getter Element namedItem([Default=Undefined] optional DOMString name);
+#endif
 
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
     NodeList tags([Default=Undefined] optional DOMString name);

Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.cpp (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFieldSetElement.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -160,11 +160,16 @@
     return const_cast<HTMLLegendElement*>(childrenOfType<HTMLLegendElement>(*this).first());
 }
 
-Ref<HTMLCollection> HTMLFieldSetElement::elements()
+Ref<HTMLFormControlsCollection> HTMLFieldSetElement::elements()
 {
     return ensureRareData().ensureNodeLists().addCachedCollection<HTMLFormControlsCollection>(*this, FormControls);
 }
 
+Ref<HTMLCollection> HTMLFieldSetElement::elementsForObjC()
+{
+    return elements();
+}
+
 void HTMLFieldSetElement::refreshElementsIfNeeded() const
 {
     uint64_t documentVersion = document().domTreeVersion();

Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.h (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFieldSetElement.h	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.h	2015-10-20 18:48:26 UTC (rev 191351)
@@ -30,15 +30,17 @@
 namespace WebCore {
 
 class FormAssociatedElement;
-class HTMLCollection;
+class HTMLFormControlsCollection;
 
 class HTMLFieldSetElement final : public HTMLFormControlElement {
 public:
     static Ref<HTMLFieldSetElement> create(const QualifiedName&, Document&, HTMLFormElement*);
 
     HTMLLegendElement* legend() const;
-    Ref<HTMLCollection> elements();
 
+    Ref<HTMLFormControlsCollection> elements();
+    Ref<HTMLCollection> elementsForObjC();
+
     const Vector<FormAssociatedElement*>& associatedElements() const;
     unsigned length() const;
 

Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.idl (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFieldSetElement.idl	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.idl	2015-10-20 18:48:26 UTC (rev 191351)
@@ -24,7 +24,11 @@
 
     readonly attribute DOMString type;
 
-    readonly attribute HTMLCollection elements;
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
+    [ImplementedAs=elementsForObjC] readonly attribute HTMLCollection elements;
+#else
+    readonly attribute HTMLFormControlsCollection elements;
+#endif
 
     readonly attribute boolean         willValidate;
     readonly attribute ValidityState   validity;

Modified: trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -76,7 +76,7 @@
     return elements.size();
 }
 
-Element* HTMLFormControlsCollection::customElementAfter(Element* current) const
+HTMLElement* HTMLFormControlsCollection::customElementAfter(Element* current) const
 {
     const Vector<FormAssociatedElement*>& elements = formControlElements();
     unsigned start;

Modified: trunk/Source/WebCore/html/HTMLFormControlsCollection.h (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFormControlsCollection.h	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFormControlsCollection.h	2015-10-20 18:48:26 UTC (rev 191351)
@@ -39,8 +39,10 @@
     static Ref<HTMLFormControlsCollection> create(ContainerNode&, CollectionType);
     virtual ~HTMLFormControlsCollection();
 
+    virtual HTMLElement* item(unsigned offset) const override;
+
     // For CachedHTMLCollection.
-    Element* customElementAfter(Element*) const;
+    HTMLElement* customElementAfter(Element*) const;
 
 private:
     explicit HTMLFormControlsCollection(ContainerNode&);
@@ -56,6 +58,11 @@
     mutable unsigned m_cachedElementOffsetInArray;
 };
 
+inline HTMLElement* HTMLFormControlsCollection::item(unsigned offset) const
+{
+    return downcast<HTMLElement>(CachedHTMLCollection<HTMLFormControlsCollection, CollectionTypeTraits<FormControls>::traversalType>::item(offset));
+}
+
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_HTMLCOLLECTION(HTMLFormControlsCollection, FormControls)

Modified: trunk/Source/WebCore/html/HTMLFormControlsCollection.idl (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFormControlsCollection.idl	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFormControlsCollection.idl	2015-10-20 18:48:26 UTC (rev 191351)
@@ -21,6 +21,6 @@
 [
     GenerateIsReachable=ImplOwnerNodeRoot,
 ] interface HTMLFormControlsCollection : HTMLCollection {
-    getter Node ([Default=Undefined] optional unsigned long index);
-    [Custom] getter Node namedItem([Default=Undefined] optional DOMString name);
+    getter HTMLElement ([Default=Undefined] optional unsigned long index);
+    [Custom] getter HTMLElement namedItem([Default=Undefined] optional DOMString name);
 };

Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFormElement.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -172,7 +172,7 @@
     return len;
 }
 
-Node* HTMLFormElement::item(unsigned index)
+HTMLElement* HTMLFormElement::item(unsigned index)
 {
     return elements()->item(index);
 }
@@ -634,11 +634,16 @@
     ASSERT_UNUSED(removed, removed);
 }
 
-Ref<HTMLCollection> HTMLFormElement::elements()
+Ref<HTMLFormControlsCollection> HTMLFormElement::elements()
 {
     return ensureRareData().ensureNodeLists().addCachedCollection<HTMLFormControlsCollection>(*this, FormControls);
 }
 
+Ref<HTMLCollection> HTMLFormElement::elementsForObjC()
+{
+    return elements();
+}
+
 String HTMLFormElement::name() const
 {
     return getNameAttribute();

Modified: trunk/Source/WebCore/html/HTMLFormElement.h (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFormElement.h	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFormElement.h	2015-10-20 18:48:26 UTC (rev 191351)
@@ -40,6 +40,7 @@
 class FormAssociatedElement;
 class FormData;
 class HTMLFormControlElement;
+class HTMLFormControlsCollection;
 class HTMLImageElement;
 class HTMLInputElement;
 class TextEncoding;
@@ -50,11 +51,12 @@
     static Ref<HTMLFormElement> create(const QualifiedName&, Document&);
     virtual ~HTMLFormElement();
 
-    Ref<HTMLCollection> elements();
+    Ref<HTMLFormControlsCollection> elements();
+    Ref<HTMLCollection> elementsForObjC();
     Vector<Ref<Element>> namedElements(const AtomicString&);
 
     unsigned length() const;
-    Node* item(unsigned index);
+    HTMLElement* item(unsigned index);
 
     String enctype() const { return m_attributes.encodingType(); }
     void setEnctype(const String&);

Modified: trunk/Source/WebCore/html/HTMLFormElement.idl (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLFormElement.idl	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLFormElement.idl	2015-10-20 18:48:26 UTC (rev 191351)
@@ -32,7 +32,11 @@
     [Reflect] attribute boolean noValidate;
     [Reflect] attribute DOMString target;
 
-    readonly attribute HTMLCollection elements;
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
+    [ImplementedAs=elementsForObjC] readonly attribute HTMLCollection elements;
+#else
+    readonly attribute HTMLFormControlsCollection elements;
+#endif
     readonly attribute long length;
 
     getter Element (unsigned long index);

Modified: trunk/Source/WebCore/html/HTMLOptionsCollection.cpp (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLOptionsCollection.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLOptionsCollection.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -43,7 +43,7 @@
 
 void HTMLOptionsCollection::add(HTMLElement* element, int beforeIndex, ExceptionCode& ec)
 {
-    add(element, downcast<HTMLElement>(item(beforeIndex)), ec);
+    add(element, item(beforeIndex), ec);
 }
 
 void HTMLOptionsCollection::remove(int index)

Modified: trunk/Source/WebCore/html/HTMLOptionsCollection.h (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLOptionsCollection.h	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLOptionsCollection.h	2015-10-20 18:48:26 UTC (rev 191351)
@@ -40,6 +40,9 @@
     HTMLSelectElement& selectElement() { return downcast<HTMLSelectElement>(ownerNode()); }
     const HTMLSelectElement& selectElement() const { return downcast<HTMLSelectElement>(ownerNode()); }
 
+    virtual HTMLOptionElement* item(unsigned offset) const override;
+    virtual HTMLOptionElement* namedItem(const AtomicString& name) const override;
+
     void add(HTMLElement*, HTMLElement* beforeElement, ExceptionCode&);
     void add(HTMLElement*, int beforeIndex, ExceptionCode&);
     void remove(int index);
@@ -57,6 +60,16 @@
     explicit HTMLOptionsCollection(HTMLSelectElement&);
 };
 
+inline HTMLOptionElement* HTMLOptionsCollection::item(unsigned offset) const
+{
+    return downcast<HTMLOptionElement>(CachedHTMLCollection<HTMLOptionsCollection, CollectionTypeTraits<SelectOptions>::traversalType>::item(offset));
+}
+
+inline HTMLOptionElement* HTMLOptionsCollection::namedItem(const AtomicString& name) const
+{
+    return downcast<HTMLOptionElement>(CachedHTMLCollection<HTMLOptionsCollection, CollectionTypeTraits<SelectOptions>::traversalType>::namedItem(name));
+}
+
 inline bool HTMLOptionsCollection::elementMatches(Element& element) const
 {
     return element.hasTagName(HTMLNames::optionTag);

Modified: trunk/Source/WebCore/html/HTMLOptionsCollection.idl (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLOptionsCollection.idl	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLOptionsCollection.idl	2015-10-20 18:48:26 UTC (rev 191351)
@@ -26,7 +26,11 @@
     attribute long selectedIndex;
     [CustomSetter, SetterRaisesException] attribute unsigned long length;
 
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
     getter Node namedItem([Default=Undefined] optional DOMString name);
+#else
+    getter HTMLOptionElement namedItem([Default=Undefined] optional DOMString name);
+#endif
 
 #if (!defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C) && (!defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT)
     [RaisesException] void add(HTMLElement element, [Default=Undefined] optional HTMLElement? before);

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -435,12 +435,12 @@
 
 HTMLOptionElement* HTMLSelectElement::namedItem(const AtomicString& name)
 {
-    return downcast<HTMLOptionElement>(options()->namedItem(name));
+    return options()->namedItem(name);
 }
 
 HTMLOptionElement* HTMLSelectElement::item(unsigned index)
 {
-    return downcast<HTMLOptionElement>(options()->item(index));
+    return options()->item(index);
 }
 
 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, ExceptionCode& ec)
@@ -449,13 +449,13 @@
     if (index > maxSelectItems - 1)
         index = maxSelectItems - 1;
     int diff = index - length();
-    RefPtr<HTMLElement> before = 0;
+    RefPtr<HTMLOptionElement> before;
     // Out of array bounds? First insert empty dummies.
     if (diff > 0) {
         setLength(index, ec);
         // Replace an existing entry?
     } else if (diff < 0) {
-        before = downcast<HTMLElement>(options()->item(index + 1));
+        before = item(index + 1);
         removeByIndex(index);
     }
     // Finally add the new element.

Modified: trunk/Source/WebCore/html/HTMLSelectElement.idl (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLSelectElement.idl	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLSelectElement.idl	2015-10-20 18:48:26 UTC (rev 191351)
@@ -39,8 +39,15 @@
 #else
     [SetterRaisesException] attribute unsigned long length;
 #endif
+
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
     getter Node item(unsigned long index);
     Node namedItem([Default=Undefined] optional DOMString name);
+#else
+    getter HTMLOptionElement item(unsigned long index);
+    HTMLOptionElement namedItem([Default=Undefined] optional DOMString name);
+#endif
+
     [ObjCLegacyUnnamedParameters, RaisesException] void add(HTMLElement element, [Default=Undefined] optional HTMLElement? before);
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
     [RaisesException] void add(HTMLElement element, [Default=Undefined] optional long index);

Modified: trunk/Source/WebCore/html/HTMLTableRowElement.cpp (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLTableRowElement.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLTableRowElement.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -132,10 +132,9 @@
     int numCells = children->length();
     if (index == -1)
         index = numCells-1;
-    if (index >= 0 && index < numCells) {
-        RefPtr<Node> cell = children->item(index);
-        HTMLElement::removeChild(*cell, ec);
-    } else
+    if (index >= 0 && index < numCells)
+        HTMLElement::removeChild(*children->item(index), ec);
+    else
         ec = INDEX_SIZE_ERR;
 }
 

Modified: trunk/Source/WebCore/html/HTMLTableSectionElement.cpp (191350 => 191351)


--- trunk/Source/WebCore/html/HTMLTableSectionElement.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/HTMLTableSectionElement.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -87,10 +87,9 @@
     int numRows = children->length();
     if (index == -1)
         index = numRows - 1;
-    if (index >= 0 && index < numRows) {
-        RefPtr<Node> row = children->item(index);
-        HTMLElement::removeChild(*row, ec);
-    } else
+    if (index >= 0 && index < numRows)
+        HTMLElement::removeChild(*children->item(index), ec);
+    else
         ec = INDEX_SIZE_ERR;
 }
 

Modified: trunk/Source/WebCore/html/RadioNodeList.cpp (191350 => 191351)


--- trunk/Source/WebCore/html/RadioNodeList.cpp	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/RadioNodeList.cpp	2015-10-20 18:48:26 UTC (rev 191351)
@@ -27,7 +27,6 @@
 #include "config.h"
 #include "RadioNodeList.h"
 
-#include "Element.h"
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
@@ -50,12 +49,12 @@
     ownerNode().nodeLists()->removeCacheWithAtomicName(this, m_name);
 }
 
-static inline HTMLInputElement* toRadioButtonInputElement(Node& node)
+static inline HTMLInputElement* toRadioButtonInputElement(HTMLElement& element)
 {
-    if (!is<HTMLInputElement>(node))
+    if (!is<HTMLInputElement>(element))
         return nullptr;
 
-    auto& inputElement = downcast<HTMLInputElement>(node);
+    auto& inputElement = downcast<HTMLInputElement>(element);
     if (!inputElement.isRadioButton() || inputElement.value().isEmpty())
         return nullptr;
     return &inputElement;

Modified: trunk/Source/WebCore/html/RadioNodeList.h (191350 => 191351)


--- trunk/Source/WebCore/html/RadioNodeList.h	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/RadioNodeList.h	2015-10-20 18:48:26 UTC (rev 191351)
@@ -27,6 +27,7 @@
 #ifndef RadioNodeList_h
 #define RadioNodeList_h
 
+#include "HTMLElement.h"
 #include "LiveNodeList.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/text/AtomicString.h>
@@ -40,8 +41,10 @@
         return adoptRef(*new RadioNodeList(rootNode, name));
     }
 
-    ~RadioNodeList();
+    virtual ~RadioNodeList();
 
+    HTMLElement* item(unsigned offset) const override;
+
     String value() const;
     void setValue(const String&);
 
@@ -56,6 +59,11 @@
     bool m_isRootedAtDocument;
 };
 
+inline HTMLElement* RadioNodeList::item(unsigned offset) const
+{
+    return downcast<HTMLElement>(CachedLiveNodeList<RadioNodeList>::item(offset));
+}
+
 } // namepsace
 
 #endif

Modified: trunk/Source/WebCore/html/RadioNodeList.idl (191350 => 191351)


--- trunk/Source/WebCore/html/RadioNodeList.idl	2015-10-20 18:37:38 UTC (rev 191350)
+++ trunk/Source/WebCore/html/RadioNodeList.idl	2015-10-20 18:48:26 UTC (rev 191351)
@@ -29,5 +29,5 @@
 ] interface RadioNodeList : NodeList {
     attribute DOMString value;
 
-    getter Node (unsigned long index);
+    getter HTMLElement (unsigned long index);
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to