| 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 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 RadioNodeList::RadioNodeList(Node* rootNode, const AtomicString& name) | 40 RadioNodeList::RadioNodeList(Node* rootNode, const AtomicString& name) |
| 41 : DynamicSubtreeNodeList(rootNode, rootNode->hasTagName(formTag) ? RootedAtD
ocument : RootedAtNode) | 41 : DynamicSubtreeNodeList(rootNode, rootNode->hasTagName(formTag) ? RootedAtD
ocument : RootedAtNode) |
| 42 , m_name(name) | 42 , m_name(name) |
| 43 { | 43 { |
| 44 document()->registerDynamicSubtreeNodeList(this); | 44 document()->registerDynamicSubtreeNodeList(this); |
| 45 } | 45 } |
| 46 | 46 |
| 47 RadioNodeList::~RadioNodeList() | 47 RadioNodeList::~RadioNodeList() |
| 48 { | 48 { |
| 49 m_node->nodeLists()->removeCacheWithAtomicName(this, DynamicNodeList::RadioN
odeListType, m_name); | 49 ownerNode()->nodeLists()->removeCacheWithAtomicName(this, DynamicNodeList::R
adioNodeListType, m_name); |
| 50 document()->unregisterDynamicSubtreeNodeList(this); | 50 document()->unregisterDynamicSubtreeNodeList(this); |
| 51 } | 51 } |
| 52 | 52 |
| 53 static inline HTMLInputElement* toRadioButtonInputElement(Node* node) | 53 static inline HTMLInputElement* toRadioButtonInputElement(Node* node) |
| 54 { | 54 { |
| 55 ASSERT(node->isElementNode()); | 55 ASSERT(node->isElementNode()); |
| 56 HTMLInputElement* inputElement = node->toInputElement(); | 56 HTMLInputElement* inputElement = node->toInputElement(); |
| 57 if (!inputElement || !inputElement->isRadioButton() || inputElement->value()
.isEmpty()) | 57 if (!inputElement || !inputElement->isRadioButton() || inputElement->value()
.isEmpty()) |
| 58 return 0; | 58 return 0; |
| 59 return inputElement; | 59 return inputElement; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 79 if (!inputElement || inputElement->value() != value) | 79 if (!inputElement || inputElement->value() != value) |
| 80 continue; | 80 continue; |
| 81 inputElement->setChecked(true); | 81 inputElement->setChecked(true); |
| 82 return; | 82 return; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool RadioNodeList::checkElementMatchesRadioNodeListFilter(Element* testElement)
const | 86 bool RadioNodeList::checkElementMatchesRadioNodeListFilter(Element* testElement)
const |
| 87 { | 87 { |
| 88 ASSERT(testElement->hasTagName(objectTag) || testElement->isFormControlEleme
nt()); | 88 ASSERT(testElement->hasTagName(objectTag) || testElement->isFormControlEleme
nt()); |
| 89 if (m_node->hasTagName(formTag)) { | 89 if (ownerNode()->hasTagName(formTag)) { |
| 90 HTMLFormElement* formElement = 0; | 90 HTMLFormElement* formElement = 0; |
| 91 if (testElement->hasTagName(objectTag)) | 91 if (testElement->hasTagName(objectTag)) |
| 92 formElement = static_cast<HTMLObjectElement*>(testElement)->form(); | 92 formElement = static_cast<HTMLObjectElement*>(testElement)->form(); |
| 93 else | 93 else |
| 94 formElement = static_cast<HTMLFormControlElement*>(testElement)->for
m(); | 94 formElement = static_cast<HTMLFormControlElement*>(testElement)->for
m(); |
| 95 if (!formElement || formElement != m_node) | 95 if (!formElement || formElement != ownerNode()) |
| 96 return false; | 96 return false; |
| 97 } | 97 } |
| 98 | 98 |
| 99 return testElement->getIdAttribute() == m_name || testElement->getNameAttrib
ute() == m_name; | 99 return testElement->getIdAttribute() == m_name || testElement->getNameAttrib
ute() == m_name; |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool RadioNodeList::nodeMatches(Element* testElement) const | 102 bool RadioNodeList::nodeMatches(Element* testElement) const |
| 103 { | 103 { |
| 104 if (!testElement->hasTagName(objectTag) && !testElement->isFormControlElemen
t()) | 104 if (!testElement->hasTagName(objectTag) && !testElement->isFormControlElemen
t()) |
| 105 return false; | 105 return false; |
| 106 | 106 |
| 107 if (HTMLInputElement* inputElement = testElement->toInputElement()) { | 107 if (HTMLInputElement* inputElement = testElement->toInputElement()) { |
| 108 if (inputElement->isImageButton()) | 108 if (inputElement->isImageButton()) |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 return checkElementMatchesRadioNodeListFilter(testElement); | 112 return checkElementMatchesRadioNodeListFilter(testElement); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namspace | 115 } // namspace |
| 116 | 116 |
| OLD | NEW |