Changeset 179770 in webkit
- Timestamp:
- Feb 6, 2015 5:08:52 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r179768 r179770 1 2015-02-06 Andreas Kling <akling@apple.com> 2 3 Ref-ify various getters that return HTMLCollection. 4 <https://webkit.org/b/141336> 5 6 Reviewed by Anders Carlsson. 7 8 Make all the getters that return HTMLCollection objects (and never return nullptr) 9 return Ref instead of RefPtr. 10 11 Removed a couple of useless null checks that were exposed by this change. 12 13 * accessibility/AccessibilityRenderObject.cpp: 14 (WebCore::AccessibilityRenderObject::getDocumentLinks): 15 * bindings/js/JSDOMWindowCustom.cpp: 16 (WebCore::namedItemGetter): 17 * bindings/js/JSHTMLDocumentCustom.cpp: 18 (WebCore::JSHTMLDocument::nameGetter): 19 * dom/Document.cpp: 20 (WebCore::Document::ensureCachedCollection): 21 (WebCore::Document::images): 22 (WebCore::Document::applets): 23 (WebCore::Document::embeds): 24 (WebCore::Document::plugins): 25 (WebCore::Document::scripts): 26 (WebCore::Document::links): 27 (WebCore::Document::forms): 28 (WebCore::Document::anchors): 29 (WebCore::Document::all): 30 (WebCore::Document::windowNamedItems): 31 (WebCore::Document::documentNamedItems): 32 (WebCore::Document::iconURLs): 33 * dom/Document.h: 34 * dom/Element.cpp: 35 (WebCore::Element::ensureCachedHTMLCollection): 36 * dom/Element.h: 37 * html/ColorInputType.cpp: 38 (WebCore::ColorInputType::suggestions): 39 * html/HTMLDataListElement.cpp: 40 (WebCore::HTMLDataListElement::options): 41 * html/HTMLDataListElement.h: 42 * html/HTMLElement.cpp: 43 (WebCore::HTMLElement::children): 44 * html/HTMLElement.h: 45 * html/HTMLFieldSetElement.cpp: 46 (WebCore::HTMLFieldSetElement::elements): 47 * html/HTMLFieldSetElement.h: 48 * html/HTMLFormElement.cpp: 49 (WebCore::HTMLFormElement::elements): 50 * html/HTMLFormElement.h: 51 * html/HTMLInputElement.cpp: 52 (WebCore::HTMLInputElement::setupDateTimeChooserParameters): 53 * html/HTMLMapElement.cpp: 54 (WebCore::HTMLMapElement::areas): 55 * html/HTMLMapElement.h: 56 * html/HTMLSelectElement.cpp: 57 (WebCore::HTMLSelectElement::selectedOptions): 58 (WebCore::HTMLSelectElement::options): 59 * html/HTMLSelectElement.h: 60 * html/HTMLTableElement.cpp: 61 (WebCore::HTMLTableElement::rows): 62 (WebCore::HTMLTableElement::tBodies): 63 * html/HTMLTableElement.h: 64 * html/HTMLTableRowElement.cpp: 65 (WebCore::HTMLTableRowElement::insertCell): 66 (WebCore::HTMLTableRowElement::deleteCell): 67 (WebCore::HTMLTableRowElement::cells): 68 * html/HTMLTableRowElement.h: 69 * html/HTMLTableSectionElement.cpp: 70 (WebCore::HTMLTableSectionElement::insertRow): 71 (WebCore::HTMLTableSectionElement::deleteRow): 72 (WebCore::HTMLTableSectionElement::rows): 73 * html/HTMLTableSectionElement.h: 74 * html/RangeInputType.cpp: 75 (WebCore::RangeInputType::updateTickMarkValues): 76 * rendering/RenderTheme.cpp: 77 (WebCore::RenderTheme::paintSliderTicks): 78 1 79 2015-02-06 Brent Fulgham <bfulgham@apple.com> 2 80 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r179626 r179770 1742 1742 { 1743 1743 Document& document = m_renderer->document(); 1744 Ref Ptr<HTMLCollection> links = document.links();1744 Ref<HTMLCollection> links = document.links(); 1745 1745 for (unsigned i = 0; Node* curr = links->item(i); i++) { 1746 1746 RenderObject* obj = curr->renderer(); -
trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
r178928 r179770 82 82 83 83 if (UNLIKELY(downcast<HTMLDocument>(*document).windowNamedItemContainsMultipleElements(*atomicPropertyName))) { 84 Ref Ptr<HTMLCollection> collection = document->windowNamedItems(atomicPropertyName);84 Ref<HTMLCollection> collection = document->windowNamedItems(atomicPropertyName); 85 85 ASSERT(collection->length() > 1); 86 86 return JSValue::encode(toJS(exec, thisObj->globalObject(), WTF::getPtr(collection))); -
trunk/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
r178966 r179770 95 95 96 96 if (UNLIKELY(document.documentNamedItemContainsMultipleElements(*atomicPropertyName))) { 97 Ref Ptr<HTMLCollection> collection = document.documentNamedItems(atomicPropertyName);97 Ref<HTMLCollection> collection = document.documentNamedItems(atomicPropertyName); 98 98 ASSERT(collection->length() > 1); 99 99 return JSValue::encode(toJS(exec, thisObj->globalObject(), WTF::getPtr(collection))); -
trunk/Source/WebCore/dom/Document.cpp
r179242 r179770 4538 4538 } 4539 4539 4540 Ref Ptr<HTMLCollection> Document::ensureCachedCollection(CollectionType type)4540 Ref<HTMLCollection> Document::ensureCachedCollection(CollectionType type) 4541 4541 { 4542 4542 return ensureRareData().ensureNodeLists().addCachedCollection<HTMLCollection>(*this, type); 4543 4543 } 4544 4544 4545 Ref Ptr<HTMLCollection> Document::images()4545 Ref<HTMLCollection> Document::images() 4546 4546 { 4547 4547 return ensureCachedCollection(DocImages); 4548 4548 } 4549 4549 4550 Ref Ptr<HTMLCollection> Document::applets()4550 Ref<HTMLCollection> Document::applets() 4551 4551 { 4552 4552 return ensureCachedCollection(DocApplets); 4553 4553 } 4554 4554 4555 Ref Ptr<HTMLCollection> Document::embeds()4555 Ref<HTMLCollection> Document::embeds() 4556 4556 { 4557 4557 return ensureCachedCollection(DocEmbeds); 4558 4558 } 4559 4559 4560 Ref Ptr<HTMLCollection> Document::plugins()4560 Ref<HTMLCollection> Document::plugins() 4561 4561 { 4562 4562 // This is an alias for embeds() required for the JS DOM bindings. … … 4564 4564 } 4565 4565 4566 Ref Ptr<HTMLCollection> Document::scripts()4566 Ref<HTMLCollection> Document::scripts() 4567 4567 { 4568 4568 return ensureCachedCollection(DocScripts); 4569 4569 } 4570 4570 4571 Ref Ptr<HTMLCollection> Document::links()4571 Ref<HTMLCollection> Document::links() 4572 4572 { 4573 4573 return ensureCachedCollection(DocLinks); 4574 4574 } 4575 4575 4576 Ref Ptr<HTMLCollection> Document::forms()4576 Ref<HTMLCollection> Document::forms() 4577 4577 { 4578 4578 return ensureCachedCollection(DocForms); 4579 4579 } 4580 4580 4581 Ref Ptr<HTMLCollection> Document::anchors()4581 Ref<HTMLCollection> Document::anchors() 4582 4582 { 4583 4583 return ensureCachedCollection(DocAnchors); 4584 4584 } 4585 4585 4586 Ref Ptr<HTMLCollection> Document::all()4586 Ref<HTMLCollection> Document::all() 4587 4587 { 4588 4588 return ensureRareData().ensureNodeLists().addCachedCollection<HTMLAllCollection>(*this, DocAll); 4589 4589 } 4590 4590 4591 Ref Ptr<HTMLCollection> Document::windowNamedItems(const AtomicString& name)4591 Ref<HTMLCollection> Document::windowNamedItems(const AtomicString& name) 4592 4592 { 4593 4593 return ensureRareData().ensureNodeLists().addCachedCollection<WindowNameCollection>(*this, WindowNamedItems, name); 4594 4594 } 4595 4595 4596 Ref Ptr<HTMLCollection> Document::documentNamedItems(const AtomicString& name)4596 Ref<HTMLCollection> Document::documentNamedItems(const AtomicString& name) 4597 4597 { 4598 4598 return ensureRareData().ensureNodeLists().addCachedCollection<DocumentNameCollection>(*this, DocumentNamedItems, name); … … 4705 4705 m_iconURLs.clear(); 4706 4706 4707 if (!head() || !(head()->children()))4707 if (!head()) 4708 4708 return m_iconURLs; 4709 4709 4710 Ref Ptr<HTMLCollection> children = head()->children();4710 Ref<HTMLCollection> children = head()->children(); 4711 4711 unsigned int length = children->length(); 4712 4712 for (unsigned int i = 0; i < length; ++i) { -
trunk/Source/WebCore/dom/Document.h
r179242 r179770 507 507 RefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&); 508 508 509 Ref Ptr<HTMLCollection> images();510 Ref Ptr<HTMLCollection> embeds();511 Ref Ptr<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.512 Ref Ptr<HTMLCollection> applets();513 Ref Ptr<HTMLCollection> links();514 Ref Ptr<HTMLCollection> forms();515 Ref Ptr<HTMLCollection> anchors();516 Ref Ptr<HTMLCollection> scripts();517 Ref Ptr<HTMLCollection> all();518 519 Ref Ptr<HTMLCollection> windowNamedItems(const AtomicString& name);520 Ref Ptr<HTMLCollection> documentNamedItems(const AtomicString& name);509 Ref<HTMLCollection> images(); 510 Ref<HTMLCollection> embeds(); 511 Ref<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings. 512 Ref<HTMLCollection> applets(); 513 Ref<HTMLCollection> links(); 514 Ref<HTMLCollection> forms(); 515 Ref<HTMLCollection> anchors(); 516 Ref<HTMLCollection> scripts(); 517 Ref<HTMLCollection> all(); 518 519 Ref<HTMLCollection> windowNamedItems(const AtomicString& name); 520 Ref<HTMLCollection> documentNamedItems(const AtomicString& name); 521 521 522 522 // Other methods (not part of DOM) … … 1352 1352 Node* nodeFromPoint(const LayoutPoint& clientPoint, LayoutPoint* localPoint = nullptr); 1353 1353 1354 Ref Ptr<HTMLCollection> ensureCachedCollection(CollectionType);1354 Ref<HTMLCollection> ensureCachedCollection(CollectionType); 1355 1355 1356 1356 #if ENABLE(FULLSCREEN_API) -
trunk/Source/WebCore/dom/Element.cpp
r179497 r179770 2902 2902 } 2903 2903 2904 Ref Ptr<HTMLCollection> Element::ensureCachedHTMLCollection(CollectionType type)2904 Ref<HTMLCollection> Element::ensureCachedHTMLCollection(CollectionType type) 2905 2905 { 2906 2906 if (HTMLCollection* collection = cachedHTMLCollection(type)) 2907 return collection;2907 return *collection; 2908 2908 2909 2909 if (type == TableRows) { -
trunk/Source/WebCore/dom/Element.h
r179497 r179770 571 571 void setTabIndexExplicitly(short); 572 572 573 Ref Ptr<HTMLCollection> ensureCachedHTMLCollection(CollectionType);573 Ref<HTMLCollection> ensureCachedHTMLCollection(CollectionType); 574 574 HTMLCollection* cachedHTMLCollection(CollectionType); 575 575 -
trunk/Source/WebCore/html/ColorInputType.cpp
r177306 r179770 230 230 HTMLDataListElement* dataList = element().dataList(); 231 231 if (dataList) { 232 Ref Ptr<HTMLCollection> options = dataList->options();232 Ref<HTMLCollection> options = dataList->options(); 233 233 for (unsigned i = 0; HTMLOptionElement* option = downcast<HTMLOptionElement>(options->item(i)); ++i) { 234 234 if (!element().isValidValue(option->value())) -
trunk/Source/WebCore/html/HTMLDataListElement.cpp
r177996 r179770 49 49 } 50 50 51 Ref Ptr<HTMLCollection> HTMLDataListElement::options()51 Ref<HTMLCollection> HTMLDataListElement::options() 52 52 { 53 53 return ensureCachedHTMLCollection(DataListOptions); -
trunk/Source/WebCore/html/HTMLDataListElement.h
r177996 r179770 43 43 static Ref<HTMLDataListElement> create(const QualifiedName&, Document&); 44 44 45 Ref Ptr<HTMLCollection> options();45 Ref<HTMLCollection> options(); 46 46 47 47 void optionElementChildrenChanged(); -
trunk/Source/WebCore/html/HTMLElement.cpp
r179181 r179770 807 807 } 808 808 809 Ref Ptr<HTMLCollection> HTMLElement::children()809 Ref<HTMLCollection> HTMLElement::children() 810 810 { 811 811 return ensureCachedHTMLCollection(NodeChildren); -
trunk/Source/WebCore/html/HTMLElement.h
r179181 r179770 43 43 static Ref<HTMLElement> create(const QualifiedName& tagName, Document&); 44 44 45 Ref Ptr<HTMLCollection> children();45 Ref<HTMLCollection> children(); 46 46 47 47 WEBCORE_EXPORT virtual String title() const override final; -
trunk/Source/WebCore/html/HTMLFieldSetElement.cpp
r179143 r179770 160 160 } 161 161 162 Ref Ptr<HTMLCollection> HTMLFieldSetElement::elements()162 Ref<HTMLCollection> HTMLFieldSetElement::elements() 163 163 { 164 164 return ensureCachedHTMLCollection(FormControls); -
trunk/Source/WebCore/html/HTMLFieldSetElement.h
r177996 r179770 38 38 39 39 HTMLLegendElement* legend() const; 40 Ref Ptr<HTMLCollection> elements();40 Ref<HTMLCollection> elements(); 41 41 42 42 const Vector<FormAssociatedElement*>& associatedElements() const; -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r179599 r179770 645 645 } 646 646 647 Ref Ptr<HTMLCollection> HTMLFormElement::elements()647 Ref<HTMLCollection> HTMLFormElement::elements() 648 648 { 649 649 return ensureCachedHTMLCollection(FormControls); -
trunk/Source/WebCore/html/HTMLFormElement.h
r177996 r179770 51 51 virtual ~HTMLFormElement(); 52 52 53 Ref Ptr<HTMLCollection> elements();53 Ref<HTMLCollection> elements(); 54 54 bool hasNamedElement(const AtomicString&); 55 55 Vector<Ref<Element>> namedElements(const AtomicString&); -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r177996 r179770 1888 1888 #if ENABLE(DATALIST_ELEMENT) 1889 1889 if (HTMLDataListElement* dataList = this->dataList()) { 1890 Ref Ptr<HTMLCollection> options = dataList->options();1890 Ref<HTMLCollection> options = dataList->options(); 1891 1891 for (unsigned i = 0; HTMLOptionElement* option = downcast<HTMLOptionElement>(options->item(i)); ++i) { 1892 1892 if (!isValidValue(option->value())) -
trunk/Source/WebCore/html/HTMLMapElement.cpp
r177996 r179770 111 111 } 112 112 113 Ref Ptr<HTMLCollection> HTMLMapElement::areas()113 Ref<HTMLCollection> HTMLMapElement::areas() 114 114 { 115 115 return ensureCachedHTMLCollection(MapAreas); -
trunk/Source/WebCore/html/HTMLMapElement.h
r177996 r179770 42 42 43 43 HTMLImageElement* imageElement(); 44 Ref Ptr<HTMLCollection> areas();44 Ref<HTMLCollection> areas(); 45 45 46 46 private: -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r179143 r179770 374 374 } 375 375 376 Ref Ptr<HTMLCollection> HTMLSelectElement::selectedOptions()376 Ref<HTMLCollection> HTMLSelectElement::selectedOptions() 377 377 { 378 378 return ensureCachedHTMLCollection(SelectedOptions); 379 379 } 380 380 381 Ref Ptr<HTMLOptionsCollection> HTMLSelectElement::options()381 Ref<HTMLOptionsCollection> HTMLSelectElement::options() 382 382 { 383 383 return downcast<HTMLOptionsCollection>(ensureCachedHTMLCollection(SelectOptions).get()); -
trunk/Source/WebCore/html/HTMLSelectElement.h
r178097 r179770 68 68 void setValue(const String&); 69 69 70 Ref Ptr<HTMLOptionsCollection> options();71 Ref Ptr<HTMLCollection> selectedOptions();70 Ref<HTMLOptionsCollection> options(); 71 Ref<HTMLCollection> selectedOptions(); 72 72 73 73 void optionElementChildrenChanged(); -
trunk/Source/WebCore/html/HTMLTableElement.cpp
r179143 r179770 551 551 } 552 552 553 Ref Ptr<HTMLCollection> HTMLTableElement::rows()553 Ref<HTMLCollection> HTMLTableElement::rows() 554 554 { 555 555 return ensureCachedHTMLCollection(TableRows); 556 556 } 557 557 558 Ref Ptr<HTMLCollection> HTMLTableElement::tBodies()558 Ref<HTMLCollection> HTMLTableElement::tBodies() 559 559 { 560 560 return ensureCachedHTMLCollection(TableTBodies); -
trunk/Source/WebCore/html/HTMLTableElement.h
r177996 r179770 61 61 void deleteRow(int index, ExceptionCode&); 62 62 63 Ref Ptr<HTMLCollection> rows();64 Ref Ptr<HTMLCollection> tBodies();63 Ref<HTMLCollection> rows(); 64 Ref<HTMLCollection> tBodies(); 65 65 66 66 const AtomicString& rules() const; -
trunk/Source/WebCore/html/HTMLTableRowElement.cpp
r177996 r179770 121 121 RefPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionCode& ec) 122 122 { 123 Ref Ptr<HTMLCollection> children = cells();124 int numCells = children ? children->length() : 0;123 Ref<HTMLCollection> children = cells(); 124 int numCells = children->length(); 125 125 if (index < -1 || index > numCells) { 126 126 ec = INDEX_SIZE_ERR; … … 144 144 void HTMLTableRowElement::deleteCell(int index, ExceptionCode& ec) 145 145 { 146 Ref Ptr<HTMLCollection> children = cells();147 int numCells = children ? children->length() : 0;146 Ref<HTMLCollection> children = cells(); 147 int numCells = children->length(); 148 148 if (index == -1) 149 149 index = numCells-1; … … 155 155 } 156 156 157 Ref Ptr<HTMLCollection> HTMLTableRowElement::cells()157 Ref<HTMLCollection> HTMLTableRowElement::cells() 158 158 { 159 159 return ensureCachedHTMLCollection(TRCells); -
trunk/Source/WebCore/html/HTMLTableRowElement.h
r177996 r179770 46 46 void deleteCell(int index, ExceptionCode&); 47 47 48 Ref Ptr<HTMLCollection> cells();48 Ref<HTMLCollection> cells(); 49 49 void setCells(HTMLCollection *, ExceptionCode&); 50 50 -
trunk/Source/WebCore/html/HTMLTableSectionElement.cpp
r177996 r179770 60 60 { 61 61 RefPtr<HTMLTableRowElement> row; 62 Ref Ptr<HTMLCollection> children = rows();63 int numRows = children ? (int)children->length() : 0;62 Ref<HTMLCollection> children = rows(); 63 int numRows = children->length(); 64 64 if (index < -1 || index > numRows) 65 65 ec = INDEX_SIZE_ERR; // per the DOM … … 82 82 void HTMLTableSectionElement::deleteRow(int index, ExceptionCode& ec) 83 83 { 84 Ref Ptr<HTMLCollection> children = rows();85 int numRows = children ? (int)children->length() : 0;84 Ref<HTMLCollection> children = rows(); 85 int numRows = children->length(); 86 86 if (index == -1) 87 87 index = numRows - 1; … … 146 146 } 147 147 148 Ref Ptr<HTMLCollection> HTMLTableSectionElement::rows()148 Ref<HTMLCollection> HTMLTableSectionElement::rows() 149 149 { 150 150 return ensureCachedHTMLCollection(TSectionRows); -
trunk/Source/WebCore/html/HTMLTableSectionElement.h
r177996 r179770 54 54 void setVAlign(const AtomicString&); 55 55 56 Ref Ptr<HTMLCollection> rows();56 Ref<HTMLCollection> rows(); 57 57 58 58 private: -
trunk/Source/WebCore/html/RangeInputType.cpp
r177259 r179770 369 369 if (!dataList) 370 370 return; 371 Ref Ptr<HTMLCollection> options = dataList->options();371 Ref<HTMLCollection> options = dataList->options(); 372 372 m_tickMarkValues.reserveCapacity(options->length()); 373 373 for (unsigned i = 0; i < options->length(); ++i) { -
trunk/Source/WebCore/rendering/RenderTheme.cpp
r179050 r179770 1031 1031 tickRegionWidth = trackBounds.height() - thumbSize.width(); 1032 1032 } 1033 Ref Ptr<HTMLCollection> options = dataList->options();1033 Ref<HTMLCollection> options = dataList->options(); 1034 1034 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1035 1035 paintInfo.context->setFillColor(o.style().visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB); -
trunk/Source/WebKit/win/DOMHTMLClasses.cpp
r179157 r179770 704 704 HTMLSelectElement& selectElement = downcast<HTMLSelectElement>(*m_element); 705 705 706 if (!selectElement.options())707 return E_FAIL;708 709 706 *result = nullptr; 710 707 RefPtr<HTMLOptionsCollection> options = selectElement.options();
Note: See TracChangeset
for help on using the changeset viewer.