| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Motorola Mobility, Inc. All rights reserved. | 2 * Copyright (c) 2012 Motorola Mobility, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY MOTOROLA MOBILITY, INC. AND ITS CONTRIBUTORS | 13 * THIS SOFTWARE IS PROVIDED BY MOTOROLA MOBILITY, INC. AND ITS CONTRIBUTORS |
| 14 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED T
O, | 14 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED T
O, |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MOTOROLA MOBILITY, INC. OR ITS | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MOTOROLA MOBILITY, INC. OR ITS |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHER
WISE) | 21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHER
WISE) |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/html/RadioNodeList.h" | 27 #include "core/html/RadioNodeList.h" |
| 28 | 28 |
| 29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 30 #include "core/InputTypeNames.h" |
| 30 #include "core/dom/Element.h" | 31 #include "core/dom/Element.h" |
| 31 #include "core/dom/NodeRareData.h" | 32 #include "core/dom/NodeRareData.h" |
| 32 #include "core/html/HTMLFormElement.h" | 33 #include "core/html/HTMLFormElement.h" |
| 33 #include "core/html/HTMLImageElement.h" | 34 #include "core/html/HTMLImageElement.h" |
| 34 #include "core/html/HTMLInputElement.h" | 35 #include "core/html/HTMLInputElement.h" |
| 35 #include "core/html/HTMLObjectElement.h" | 36 #include "core/html/HTMLObjectElement.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 using namespace HTMLNames; | 40 using namespace HTMLNames; |
| 40 | 41 |
| 41 RadioNodeList::RadioNodeList(ContainerNode& rootNode, const AtomicString& name,
CollectionType type) | 42 RadioNodeList::RadioNodeList(ContainerNode& rootNode, const AtomicString& name,
CollectionType type) |
| 42 : LiveNodeList(rootNode, type, InvalidateForFormControls, isHTMLFormElement(
rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode) | 43 : LiveNodeList(rootNode, type, InvalidateForFormControls, isHTMLFormElement(
rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode) |
| 43 , m_name(name) | 44 , m_name(name) |
| 44 { | 45 { |
| 45 } | 46 } |
| 46 | 47 |
| 47 RadioNodeList::~RadioNodeList() | 48 RadioNodeList::~RadioNodeList() |
| 48 { | 49 { |
| 49 #if !ENABLE(OILPAN) | 50 #if !ENABLE(OILPAN) |
| 50 ownerNode().nodeLists()->removeCache(this, type(), m_name); | 51 ownerNode().nodeLists()->removeCache(this, type(), m_name); |
| 51 #endif | 52 #endif |
| 52 } | 53 } |
| 53 | 54 |
| 54 static inline HTMLInputElement* toRadioButtonInputElement(Element& element) | 55 static inline HTMLInputElement* toRadioButtonInputElement(Element& element) |
| 55 { | 56 { |
| 56 if (!isHTMLInputElement(element)) | 57 if (!isHTMLInputElement(element)) |
| 57 return 0; | 58 return 0; |
| 58 HTMLInputElement& inputElement = toHTMLInputElement(element); | 59 HTMLInputElement& inputElement = toHTMLInputElement(element); |
| 59 if (!inputElement.isRadioButton() || inputElement.value().isEmpty()) | 60 if (inputElement.type() != InputTypeNames::radio || inputElement.value().isE
mpty()) |
| 60 return 0; | 61 return 0; |
| 61 return &inputElement; | 62 return &inputElement; |
| 62 } | 63 } |
| 63 | 64 |
| 64 String RadioNodeList::value() const | 65 String RadioNodeList::value() const |
| 65 { | 66 { |
| 66 if (shouldOnlyMatchImgElements()) | 67 if (shouldOnlyMatchImgElements()) |
| 67 return String(); | 68 return String(); |
| 68 unsigned length = this->length(); | 69 unsigned length = this->length(); |
| 69 for (unsigned i = 0; i < length; ++i) { | 70 for (unsigned i = 0; i < length; ++i) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 116 |
| 116 if (toHTMLImageElement(element).formOwner() != ownerNode()) | 117 if (toHTMLImageElement(element).formOwner() != ownerNode()) |
| 117 return false; | 118 return false; |
| 118 | 119 |
| 119 return matchesByIdOrName(element); | 120 return matchesByIdOrName(element); |
| 120 } | 121 } |
| 121 | 122 |
| 122 if (!isHTMLObjectElement(element) && !element.isFormControlElement()) | 123 if (!isHTMLObjectElement(element) && !element.isFormControlElement()) |
| 123 return false; | 124 return false; |
| 124 | 125 |
| 125 if (isHTMLInputElement(element) && toHTMLInputElement(element).isImageButton
()) | 126 if (isHTMLInputElement(element) && toHTMLInputElement(element).type() == Inp
utTypeNames::image) |
| 126 return false; | 127 return false; |
| 127 | 128 |
| 128 return checkElementMatchesRadioNodeListFilter(element); | 129 return checkElementMatchesRadioNodeListFilter(element); |
| 129 } | 130 } |
| 130 | 131 |
| 131 } // namespace | 132 } // namespace |
| OLD | NEW |