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

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

Issue 405383003: Add missing id/name check over img-based RadioNodeLists. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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/core/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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 unsigned length = this->length(); 83 unsigned length = this->length();
84 for (unsigned i = 0; i < length; ++i) { 84 for (unsigned i = 0; i < length; ++i) {
85 HTMLInputElement* inputElement = toRadioButtonInputElement(*item(i)); 85 HTMLInputElement* inputElement = toRadioButtonInputElement(*item(i));
86 if (!inputElement || inputElement->value() != value) 86 if (!inputElement || inputElement->value() != value)
87 continue; 87 continue;
88 inputElement->setChecked(true); 88 inputElement->setChecked(true);
89 return; 89 return;
90 } 90 }
91 } 91 }
92 92
93 bool RadioNodeList::matchesByIdOrName(const Element& testElement) const
94 {
95 return testElement.getIdAttribute() == m_name || testElement.getNameAttribut e() == m_name;
96 }
97
93 bool RadioNodeList::checkElementMatchesRadioNodeListFilter(const Element& testEl ement) const 98 bool RadioNodeList::checkElementMatchesRadioNodeListFilter(const Element& testEl ement) const
94 { 99 {
95 ASSERT(!m_onlyMatchImgElements); 100 ASSERT(!m_onlyMatchImgElements);
96 ASSERT(isHTMLObjectElement(testElement) || testElement.isFormControlElement( )); 101 ASSERT(isHTMLObjectElement(testElement) || testElement.isFormControlElement( ));
97 if (isHTMLFormElement(ownerNode())) { 102 if (isHTMLFormElement(ownerNode())) {
98 HTMLFormElement* formElement = toHTMLElement(testElement).formOwner(); 103 HTMLFormElement* formElement = toHTMLElement(testElement).formOwner();
99 if (!formElement || formElement != ownerNode()) 104 if (!formElement || formElement != ownerNode())
100 return false; 105 return false;
101 } 106 }
102 107
103 return testElement.getIdAttribute() == m_name || testElement.getNameAttribut e() == m_name; 108 return matchesByIdOrName(testElement);
104 } 109 }
105 110
106 bool RadioNodeList::elementMatches(const Element& element) const 111 bool RadioNodeList::elementMatches(const Element& element) const
107 { 112 {
108 if (m_onlyMatchImgElements) { 113 if (m_onlyMatchImgElements) {
109 if (!isHTMLImageElement(element)) 114 if (!isHTMLImageElement(element))
110 return false; 115 return false;
111 return toHTMLElement(element).formOwner() == ownerNode(); 116
117 if (toHTMLElement(element).formOwner() != ownerNode())
118 return false;
119
120 return matchesByIdOrName(element);
112 } 121 }
113 122
114 if (!isHTMLObjectElement(element) && !element.isFormControlElement()) 123 if (!isHTMLObjectElement(element) && !element.isFormControlElement())
115 return false; 124 return false;
116 125
117 if (isHTMLInputElement(element) && toHTMLInputElement(element).isImageButton ()) 126 if (isHTMLInputElement(element) && toHTMLInputElement(element).isImageButton ())
118 return false; 127 return false;
119 128
120 return checkElementMatchesRadioNodeListFilter(element); 129 return checkElementMatchesRadioNodeListFilter(element);
121 } 130 }
122 131
123 } // namespace 132 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/RadioNodeList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698