Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(771)

Side by Side Diff: Source/WebCore/html/RadioNodeList.cpp

Issue 10695128: Merge 120979 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/html/RadioNodeList.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "RadioNodeList.h" 27 #include "RadioNodeList.h"
28 28
29 #include "Element.h" 29 #include "Element.h"
30 #include "HTMLFormElement.h" 30 #include "HTMLFormElement.h"
31 #include "HTMLInputElement.h" 31 #include "HTMLInputElement.h"
32 #include "HTMLNames.h" 32 #include "HTMLNames.h"
33 #include "HTMLObjectElement.h" 33 #include "HTMLObjectElement.h"
34 #include "NodeRareData.h"
34 35
35 namespace WebCore { 36 namespace WebCore {
36 37
37 using namespace HTMLNames; 38 using namespace HTMLNames;
38 39
39 RadioNodeList::RadioNodeList(Element* baseElement, const AtomicString& name) 40 RadioNodeList::RadioNodeList(Node* rootNode, const AtomicString& name)
40 : DynamicSubtreeNodeList(baseElement, baseElement->hasTagName(formTag) ? Roo tedAtDocument : RootedAtNode) 41 : DynamicSubtreeNodeList(rootNode, rootNode->hasTagName(formTag) ? RootedAtD ocument : RootedAtNode)
41 , m_name(name) 42 , m_name(name)
42 , m_baseElement(baseElement)
43 { 43 {
44 m_baseElement->document()->registerDynamicSubtreeNodeList(this); 44 document()->registerDynamicSubtreeNodeList(this);
45 } 45 }
46 46
47 RadioNodeList::~RadioNodeList() 47 RadioNodeList::~RadioNodeList()
48 { 48 {
49 m_baseElement->removeCachedRadioNodeList(this, m_name); 49 m_node->nodeLists()->removeCacheWithAtomicName(this, DynamicNodeList::RadioN odeListType, m_name);
50 m_baseElement->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;
60 } 60 }
(...skipping 18 matching lines...) Expand all
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_baseElement->hasTagName(formTag)) { 89 if (m_node->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_baseElement) 95 if (!formElement || formElement != m_node)
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
OLDNEW
« no previous file with comments | « Source/WebCore/html/RadioNodeList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698