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

Unified Diff: Source/core/html/RadioNodeList.cpp

Issue 119063002: Have HTMLFormElement's named getter return a RadioNodeList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test style adjustments + const'ify new RadioNodeList field. Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/RadioNodeList.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/RadioNodeList.cpp
diff --git a/Source/core/html/RadioNodeList.cpp b/Source/core/html/RadioNodeList.cpp
index f7cbfa982a2f55660b47bc3c18b2d3d583b25664..9468b75e79d13bd0c6254371cb0656a32c3b0c4a 100644
--- a/Source/core/html/RadioNodeList.cpp
+++ b/Source/core/html/RadioNodeList.cpp
@@ -37,16 +37,17 @@ namespace WebCore {
using namespace HTMLNames;
-RadioNodeList::RadioNodeList(Node* rootNode, const AtomicString& name)
- : LiveNodeList(rootNode, RadioNodeListType, InvalidateForFormControls, rootNode->hasTagName(formTag) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)
+RadioNodeList::RadioNodeList(Node* rootNode, const AtomicString& name, CollectionType type)
+ : LiveNodeList(rootNode, type, InvalidateForFormControls, rootNode->hasTagName(formTag) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)
, m_name(name)
+ , m_onlyMatchImgElements(type == RadioImgNodeListType)
{
ScriptWrappable::init(this);
}
RadioNodeList::~RadioNodeList()
{
- ownerNode()->nodeLists()->removeCacheWithAtomicName(this, RadioNodeListType, m_name);
+ ownerNode()->nodeLists()->removeCacheWithAtomicName(this, m_onlyMatchImgElements ? RadioImgNodeListType : RadioNodeListType, m_name);
}
static inline HTMLInputElement* toRadioButtonInputElement(Node* node)
@@ -62,6 +63,8 @@ static inline HTMLInputElement* toRadioButtonInputElement(Node* node)
String RadioNodeList::value() const
{
+ if (m_onlyMatchImgElements)
+ return String();
for (unsigned i = 0; i < length(); ++i) {
Node* node = item(i);
const HTMLInputElement* inputElement = toRadioButtonInputElement(node);
@@ -74,6 +77,8 @@ String RadioNodeList::value() const
void RadioNodeList::setValue(const String& value)
{
+ if (m_onlyMatchImgElements)
+ return;
for (unsigned i = 0; i < length(); ++i) {
Node* node = item(i);
HTMLInputElement* inputElement = toRadioButtonInputElement(node);
@@ -86,6 +91,7 @@ void RadioNodeList::setValue(const String& value)
bool RadioNodeList::checkElementMatchesRadioNodeListFilter(Element* testElement) const
{
+ ASSERT(!m_onlyMatchImgElements);
ASSERT(testElement->hasTagName(objectTag) || testElement->isFormControlElement());
if (ownerNode()->hasTagName(formTag)) {
HTMLFormElement* formElement = toHTMLElement(testElement)->formOwner();
@@ -98,6 +104,9 @@ bool RadioNodeList::checkElementMatchesRadioNodeListFilter(Element* testElement)
bool RadioNodeList::nodeMatches(Element* testElement) const
{
+ if (m_onlyMatchImgElements)
+ return testElement->hasTagName(imgTag);
+
if (!testElement->hasTagName(objectTag) && !testElement->isFormControlElement())
return false;
@@ -107,5 +116,5 @@ bool RadioNodeList::nodeMatches(Element* testElement) const
return checkElementMatchesRadioNodeListFilter(testElement);
}
-} // namspace
+} // namespace
« 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