Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / HTMLDataListOptionsCollection.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef HTMLDataListOptionsCollection_h
6 #define HTMLDataListOptionsCollection_h
7
8 #include "core/html/HTMLCollection.h"
9 #include "core/html/HTMLOptionElement.h"
10
11 namespace blink {
12
13 class HTMLDataListOptionsCollection : public HTMLCollection {
14 public:
15     static PassRefPtrWillBeRawPtr<HTMLDataListOptionsCollection> create(ContainerNode& ownerNode, CollectionType type)
16     {
17         ASSERT_UNUSED(type, type == DataListOptions);
18         return adoptRefWillBeNoop(new HTMLDataListOptionsCollection(ownerNode));
19     }
20
21     HTMLOptionElement* item(unsigned offset) const { return toHTMLOptionElement(HTMLCollection::item(offset)); }
22
23     bool elementMatches(const HTMLElement&) const;
24 private:
25     explicit HTMLDataListOptionsCollection(ContainerNode& ownerNode)
26         : HTMLCollection(ownerNode, DataListOptions, DoesNotOverrideItemAfter)
27     { }
28 };
29
30 DEFINE_TYPE_CASTS(HTMLDataListOptionsCollection, LiveNodeListBase, collection, collection->type() == DataListOptions, collection.type() == DataListOptions);
31
32 inline bool HTMLDataListOptionsCollection::elementMatches(const HTMLElement& element) const
33 {
34     if (isHTMLOptionElement(element)) {
35         const HTMLOptionElement& option = toHTMLOptionElement(element);
36         if (!option.isDisabledFormControl() && !option.value().isEmpty())
37             return true;
38     }
39     return false;
40 }
41
42 } // namespace blink
43
44 #endif // HTMLDataListOptionsCollection_h