| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 } | 534 } |
| 535 | 535 |
| 536 void HTMLFormElement::didAssociateByParser() | 536 void HTMLFormElement::didAssociateByParser() |
| 537 { | 537 { |
| 538 if (!m_didFinishParsingChildren) | 538 if (!m_didFinishParsingChildren) |
| 539 return; | 539 return; |
| 540 m_hasElementsAssociatedByParser = true; | 540 m_hasElementsAssociatedByParser = true; |
| 541 UseCounter::count(document(), UseCounter::FormAssociationByParser); | 541 UseCounter::count(document(), UseCounter::FormAssociationByParser); |
| 542 } | 542 } |
| 543 | 543 |
| 544 PassRefPtr<HTMLCollection> HTMLFormElement::elements() | 544 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLFormElement::elements() |
| 545 { | 545 { |
| 546 return ensureCachedHTMLCollection(FormControls); | 546 return ensureCachedHTMLCollection(FormControls); |
| 547 } | 547 } |
| 548 | 548 |
| 549 void HTMLFormElement::collectAssociatedElements(Node& root, FormAssociatedElemen
t::List& elements) const | 549 void HTMLFormElement::collectAssociatedElements(Node& root, FormAssociatedElemen
t::List& elements) const |
| 550 { | 550 { |
| 551 elements.clear(); | 551 elements.clear(); |
| 552 for (HTMLElement* element = Traversal<HTMLElement>::firstWithin(root); eleme
nt; element = Traversal<HTMLElement>::next(*element)) { | 552 for (HTMLElement* element = Traversal<HTMLElement>::firstWithin(root); eleme
nt; element = Traversal<HTMLElement>::next(*element)) { |
| 553 FormAssociatedElement* associatedElement = 0; | 553 FormAssociatedElement* associatedElement = 0; |
| 554 if (element->isFormControlElement()) | 554 if (element->isFormControlElement()) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 return; | 711 return; |
| 712 PastNamesMap::iterator end = m_pastNamesMap->end(); | 712 PastNamesMap::iterator end = m_pastNamesMap->end(); |
| 713 for (PastNamesMap::iterator it = m_pastNamesMap->begin(); it != end; ++it) { | 713 for (PastNamesMap::iterator it = m_pastNamesMap->begin(); it != end; ++it) { |
| 714 if (it->value.get() == &element) { | 714 if (it->value.get() == &element) { |
| 715 it->value = nullptr; | 715 it->value = nullptr; |
| 716 // Keep looping. Single element can have multiple names. | 716 // Keep looping. Single element can have multiple names. |
| 717 } | 717 } |
| 718 } | 718 } |
| 719 } | 719 } |
| 720 | 720 |
| 721 void HTMLFormElement::getNamedElements(const AtomicString& name, Vector<RefPtr<E
lement> >& namedItems) | 721 void HTMLFormElement::getNamedElements(const AtomicString& name, WillBeHeapVecto
r<RefPtrWillBeMember<Element> >& namedItems) |
| 722 { | 722 { |
| 723 // http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#do
m-form-nameditem | 723 // http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#do
m-form-nameditem |
| 724 elements()->namedItems(name, namedItems); | 724 elements()->namedItems(name, namedItems); |
| 725 | 725 |
| 726 Element* elementFromPast = elementFromPastNamesMap(name); | 726 Element* elementFromPast = elementFromPastNamesMap(name); |
| 727 if (namedItems.size() && namedItems.first() != elementFromPast) { | 727 if (namedItems.size() && namedItems.first() != elementFromPast) { |
| 728 addToPastNamesMap(namedItems.first().get(), name); | 728 addToPastNamesMap(namedItems.first().get(), name); |
| 729 } else if (elementFromPast && namedItems.isEmpty()) { | 729 } else if (elementFromPast && namedItems.isEmpty()) { |
| 730 namedItems.append(elementFromPast); | 730 namedItems.append(elementFromPast); |
| 731 UseCounter::count(document(), UseCounter::FormNameAccessForPastNamesMap)
; | 731 UseCounter::count(document(), UseCounter::FormNameAccessForPastNamesMap)
; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 743 document().formController().restoreControlStateIn(*this); | 743 document().formController().restoreControlStateIn(*this); |
| 744 m_didFinishParsingChildren = true; | 744 m_didFinishParsingChildren = true; |
| 745 } | 745 } |
| 746 | 746 |
| 747 void HTMLFormElement::copyNonAttributePropertiesFromElement(const Element& sourc
e) | 747 void HTMLFormElement::copyNonAttributePropertiesFromElement(const Element& sourc
e) |
| 748 { | 748 { |
| 749 m_wasDemoted = static_cast<const HTMLFormElement&>(source).m_wasDemoted; | 749 m_wasDemoted = static_cast<const HTMLFormElement&>(source).m_wasDemoted; |
| 750 HTMLElement::copyNonAttributePropertiesFromElement(source); | 750 HTMLElement::copyNonAttributePropertiesFromElement(source); |
| 751 } | 751 } |
| 752 | 752 |
| 753 void HTMLFormElement::anonymousNamedGetter(const AtomicString& name, bool& retur
nValue0Enabled, RefPtr<RadioNodeList>& returnValue0, bool& returnValue1Enabled,
RefPtr<Element>& returnValue1) | 753 void HTMLFormElement::anonymousNamedGetter(const AtomicString& name, bool& retur
nValue0Enabled, RefPtrWillBeRawPtr<RadioNodeList>& returnValue0, bool& returnVal
ue1Enabled, RefPtr<Element>& returnValue1) |
| 754 { | 754 { |
| 755 // Call getNamedElements twice, first time check if it has a value | 755 // Call getNamedElements twice, first time check if it has a value |
| 756 // and let HTMLFormElement update its cache. | 756 // and let HTMLFormElement update its cache. |
| 757 // See issue: 867404 | 757 // See issue: 867404 |
| 758 { | 758 { |
| 759 Vector<RefPtr<Element> > elements; | 759 WillBeHeapVector<RefPtrWillBeMember<Element> > elements; |
| 760 getNamedElements(name, elements); | 760 getNamedElements(name, elements); |
| 761 if (elements.isEmpty()) | 761 if (elements.isEmpty()) |
| 762 return; | 762 return; |
| 763 } | 763 } |
| 764 | 764 |
| 765 // Second call may return different results from the first call, | 765 // Second call may return different results from the first call, |
| 766 // but if the first the size cannot be zero. | 766 // but if the first the size cannot be zero. |
| 767 Vector<RefPtr<Element> > elements; | 767 WillBeHeapVector<RefPtrWillBeMember<Element> > elements; |
| 768 getNamedElements(name, elements); | 768 getNamedElements(name, elements); |
| 769 ASSERT(!elements.isEmpty()); | 769 ASSERT(!elements.isEmpty()); |
| 770 | 770 |
| 771 if (elements.size() == 1) { | 771 if (elements.size() == 1) { |
| 772 returnValue1Enabled = true; | 772 returnValue1Enabled = true; |
| 773 #if ENABLE(OILPAN) |
| 774 // FIXME: Oilpan: remove once Element becomes [GarbageCollected]. |
| 775 returnValue1 = PassRefPtr<Element>(elements.at(0).get()); |
| 776 #else |
| 773 returnValue1 = elements.at(0); | 777 returnValue1 = elements.at(0); |
| 778 #endif |
| 774 return; | 779 return; |
| 775 } | 780 } |
| 776 | 781 |
| 777 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs
t()); | 782 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs
t()); |
| 778 returnValue0Enabled = true; | 783 returnValue0Enabled = true; |
| 779 returnValue0 = radioNodeList(name, onlyMatchImg); | 784 returnValue0 = radioNodeList(name, onlyMatchImg); |
| 780 } | 785 } |
| 781 | 786 |
| 782 void HTMLFormElement::setDemoted(bool demoted) | 787 void HTMLFormElement::setDemoted(bool demoted) |
| 783 { | 788 { |
| 784 if (demoted) | 789 if (demoted) |
| 785 UseCounter::count(document(), UseCounter::DemotedFormElement); | 790 UseCounter::count(document(), UseCounter::DemotedFormElement); |
| 786 m_wasDemoted = demoted; | 791 m_wasDemoted = demoted; |
| 787 } | 792 } |
| 788 | 793 |
| 789 } // namespace | 794 } // namespace |
| OLD | NEW |