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

Unified Diff: Source/core/html/HTMLDataListOptionsCollection.h

Issue 488763002: Introduce HTMLDataListOptionsCollection subclass for HTMLCollection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLDataListOptionsCollection.h
diff --git a/Source/core/html/HTMLDataListOptionsCollection.h b/Source/core/html/HTMLDataListOptionsCollection.h
new file mode 100644
index 0000000000000000000000000000000000000000..ccb9c57f9eaac320d858fb167fbd8e30b848e0da
--- /dev/null
+++ b/Source/core/html/HTMLDataListOptionsCollection.h
@@ -0,0 +1,44 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef HTMLDataListOptionsCollection_h
+#define HTMLDataListOptionsCollection_h
+
+#include "core/html/HTMLCollection.h"
+#include "core/html/HTMLOptionElement.h"
+
+namespace blink {
+
+class HTMLDataListOptionsCollection : public HTMLCollection {
+public:
+ static PassRefPtrWillBeRawPtr<HTMLDataListOptionsCollection> create(ContainerNode& ownerNode, CollectionType type)
+ {
+ ASSERT_UNUSED(type, type == DataListOptions);
+ return adoptRefWillBeNoop(new HTMLDataListOptionsCollection(ownerNode));
+ }
+
+ HTMLOptionElement* item(unsigned offset) const { return toHTMLOptionElement(HTMLCollection::item(offset)); }
+
+ bool elementMatches(const HTMLElement&) const;
+private:
+ explicit HTMLDataListOptionsCollection(ContainerNode& ownerNode)
+ : HTMLCollection(ownerNode, DataListOptions, DoesNotOverrideItemAfter)
+ { }
+};
+
+DEFINE_TYPE_CASTS(HTMLDataListOptionsCollection, LiveNodeListBase, collection, collection->type() == DataListOptions, collection.type() == DataListOptions);
+
+inline bool HTMLDataListOptionsCollection::elementMatches(const HTMLElement& element) const
+{
+ if (isHTMLOptionElement(element)) {
+ const HTMLOptionElement& option = toHTMLOptionElement(element);
+ if (!option.isDisabledFormControl() && !option.value().isEmpty())
+ return true;
+ }
+ return false;
+}
+
+} // namespace blink
+
+#endif // HTMLDataListOptionsCollection_h

Powered by Google App Engine
This is Rietveld 408576698