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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 } | 533 } |
534 | 534 |
535 void HTMLFormElement::didAssociateByParser() | 535 void HTMLFormElement::didAssociateByParser() |
536 { | 536 { |
537 if (!m_didFinishParsingChildren) | 537 if (!m_didFinishParsingChildren) |
538 return; | 538 return; |
539 m_hasElementsAssociatedByParser = true; | 539 m_hasElementsAssociatedByParser = true; |
540 UseCounter::count(document(), UseCounter::FormAssociationByParser); | 540 UseCounter::count(document(), UseCounter::FormAssociationByParser); |
541 } | 541 } |
542 | 542 |
543 PassRefPtr<HTMLCollection> HTMLFormElement::elements() | 543 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLFormElement::elements() |
544 { | 544 { |
545 return ensureCachedHTMLCollection(FormControls); | 545 return ensureCachedHTMLCollection(FormControls); |
546 } | 546 } |
547 | 547 |
548 void HTMLFormElement::collectAssociatedElements(Node& root, FormAssociatedElemen
t::List& elements) const | 548 void HTMLFormElement::collectAssociatedElements(Node& root, FormAssociatedElemen
t::List& elements) const |
549 { | 549 { |
550 elements.clear(); | 550 elements.clear(); |
551 for (HTMLElement* element = Traversal<HTMLElement>::firstWithin(root); eleme
nt; element = Traversal<HTMLElement>::next(*element)) { | 551 for (HTMLElement* element = Traversal<HTMLElement>::firstWithin(root); eleme
nt; element = Traversal<HTMLElement>::next(*element)) { |
552 FormAssociatedElement* associatedElement = 0; | 552 FormAssociatedElement* associatedElement = 0; |
553 if (element->isFormControlElement()) | 553 if (element->isFormControlElement()) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 return; | 710 return; |
711 PastNamesMap::iterator end = m_pastNamesMap->end(); | 711 PastNamesMap::iterator end = m_pastNamesMap->end(); |
712 for (PastNamesMap::iterator it = m_pastNamesMap->begin(); it != end; ++it) { | 712 for (PastNamesMap::iterator it = m_pastNamesMap->begin(); it != end; ++it) { |
713 if (it->value.get() == &element) { | 713 if (it->value.get() == &element) { |
714 it->value = nullptr; | 714 it->value = nullptr; |
715 // Keep looping. Single element can have multiple names. | 715 // Keep looping. Single element can have multiple names. |
716 } | 716 } |
717 } | 717 } |
718 } | 718 } |
719 | 719 |
720 void HTMLFormElement::getNamedElements(const AtomicString& name, Vector<RefPtr<E
lement> >& namedItems) | 720 void HTMLFormElement::getNamedElements(const AtomicString& name, WillBeHeapVecto
r<RefPtrWillBeMember<Element> >& namedItems) |
721 { | 721 { |
722 // http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#do
m-form-nameditem | 722 // http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#do
m-form-nameditem |
723 elements()->namedItems(name, namedItems); | 723 elements()->namedItems(name, namedItems); |
724 | 724 |
725 Element* elementFromPast = elementFromPastNamesMap(name); | 725 Element* elementFromPast = elementFromPastNamesMap(name); |
726 if (namedItems.size() && namedItems.first() != elementFromPast) { | 726 if (namedItems.size() && namedItems.first() != elementFromPast) { |
727 addToPastNamesMap(namedItems.first().get(), name); | 727 addToPastNamesMap(namedItems.first().get(), name); |
728 } else if (elementFromPast && namedItems.isEmpty()) { | 728 } else if (elementFromPast && namedItems.isEmpty()) { |
729 namedItems.append(elementFromPast); | 729 namedItems.append(elementFromPast); |
730 UseCounter::count(document(), UseCounter::FormNameAccessForPastNamesMap)
; | 730 UseCounter::count(document(), UseCounter::FormNameAccessForPastNamesMap)
; |
(...skipping 11 matching lines...) Expand all Loading... |
742 document().formController().restoreControlStateIn(*this); | 742 document().formController().restoreControlStateIn(*this); |
743 m_didFinishParsingChildren = true; | 743 m_didFinishParsingChildren = true; |
744 } | 744 } |
745 | 745 |
746 void HTMLFormElement::copyNonAttributePropertiesFromElement(const Element& sourc
e) | 746 void HTMLFormElement::copyNonAttributePropertiesFromElement(const Element& sourc
e) |
747 { | 747 { |
748 m_wasDemoted = static_cast<const HTMLFormElement&>(source).m_wasDemoted; | 748 m_wasDemoted = static_cast<const HTMLFormElement&>(source).m_wasDemoted; |
749 HTMLElement::copyNonAttributePropertiesFromElement(source); | 749 HTMLElement::copyNonAttributePropertiesFromElement(source); |
750 } | 750 } |
751 | 751 |
752 void HTMLFormElement::anonymousNamedGetter(const AtomicString& name, bool& retur
nValue0Enabled, RefPtr<RadioNodeList>& returnValue0, bool& returnValue1Enabled,
RefPtr<Element>& returnValue1) | 752 void HTMLFormElement::anonymousNamedGetter(const AtomicString& name, bool& retur
nValue0Enabled, RefPtrWillBeRawPtr<RadioNodeList>& returnValue0, bool& returnVal
ue1Enabled, RefPtr<Element>& returnValue1) |
753 { | 753 { |
754 // Call getNamedElements twice, first time check if it has a value | 754 // Call getNamedElements twice, first time check if it has a value |
755 // and let HTMLFormElement update its cache. | 755 // and let HTMLFormElement update its cache. |
756 // See issue: 867404 | 756 // See issue: 867404 |
757 { | 757 { |
758 Vector<RefPtr<Element> > elements; | 758 WillBeHeapVector<RefPtrWillBeMember<Element> > elements; |
759 getNamedElements(name, elements); | 759 getNamedElements(name, elements); |
760 if (elements.isEmpty()) | 760 if (elements.isEmpty()) |
761 return; | 761 return; |
762 } | 762 } |
763 | 763 |
764 // Second call may return different results from the first call, | 764 // Second call may return different results from the first call, |
765 // but if the first the size cannot be zero. | 765 // but if the first the size cannot be zero. |
766 Vector<RefPtr<Element> > elements; | 766 WillBeHeapVector<RefPtrWillBeMember<Element> > elements; |
767 getNamedElements(name, elements); | 767 getNamedElements(name, elements); |
768 ASSERT(!elements.isEmpty()); | 768 ASSERT(!elements.isEmpty()); |
769 | 769 |
770 if (elements.size() == 1) { | 770 if (elements.size() == 1) { |
771 returnValue1Enabled = true; | 771 returnValue1Enabled = true; |
| 772 #if ENABLE(OILPAN) |
| 773 // FIXME: Oilpan: remove once Element becomes [GarbageCollected]. |
| 774 returnValue1 = PassRefPtr<Element>(elements.at(0).get()); |
| 775 #else |
772 returnValue1 = elements.at(0); | 776 returnValue1 = elements.at(0); |
| 777 #endif |
773 return; | 778 return; |
774 } | 779 } |
775 | 780 |
776 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs
t()); | 781 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs
t()); |
777 returnValue0Enabled = true; | 782 returnValue0Enabled = true; |
778 returnValue0 = radioNodeList(name, onlyMatchImg); | 783 returnValue0 = radioNodeList(name, onlyMatchImg); |
779 } | 784 } |
780 | 785 |
781 void HTMLFormElement::setDemoted(bool demoted) | 786 void HTMLFormElement::setDemoted(bool demoted) |
782 { | 787 { |
783 if (demoted) | 788 if (demoted) |
784 UseCounter::count(document(), UseCounter::DemotedFormElement); | 789 UseCounter::count(document(), UseCounter::DemotedFormElement); |
785 m_wasDemoted = demoted; | 790 m_wasDemoted = demoted; |
786 } | 791 } |
787 | 792 |
788 } // namespace | 793 } // namespace |
OLD | NEW |