| 1 | /* |
| 2 | * Copyright (c) 2012 Motorola Mobility, Inc. All rights reserved. |
| 3 | * Copyright (C) 2014 Apple Inc. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY MOTOROLA MOBILITY, INC. AND ITS CONTRIBUTORS |
| 15 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MOTOROLA MOBILITY, INC. OR ITS |
| 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 24 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | */ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #include "HTMLElement.h" |
| 30 | #include "LiveNodeList.h" |
| 31 | #include <wtf/text/AtomicString.h> |
| 32 | |
| 33 | namespace WebCore { |
| 34 | |
| 35 | class RadioNodeList final : public CachedLiveNodeList<RadioNodeList> { |
| 36 | WTF_MAKE_ISO_ALLOCATED(RadioNodeList); |
| 37 | public: |
| 38 | static Ref<RadioNodeList> create(ContainerNode& rootNode, const AtomicString& name) |
| 39 | { |
| 40 | return adoptRef(*new RadioNodeList(rootNode, name)); |
| 41 | } |
| 42 | |
| 43 | virtual ~RadioNodeList(); |
| 44 | |
| 45 | HTMLElement* item(unsigned offset) const override; |
| 46 | |
| 47 | String value() const; |
| 48 | void setValue(const String&); |
| 49 | |
| 50 | bool elementMatches(Element&) const override; |
| 51 | bool isRootedAtDocument() const override { return m_isRootedAtDocument; } |
| 52 | |
| 53 | private: |
| 54 | RadioNodeList(ContainerNode&, const AtomicString& name); |
| 55 | bool checkElementMatchesRadioNodeListFilter(const Element&) const; |
| 56 | |
| 57 | AtomicString m_name; |
| 58 | bool m_isRootedAtDocument; |
| 59 | }; |
| 60 | |
| 61 | inline HTMLElement* RadioNodeList::item(unsigned offset) const |
| 62 | { |
| 63 | return downcast<HTMLElement>(CachedLiveNodeList<RadioNodeList>::item(offset)); |
| 64 | } |
| 65 | |
| 66 | } // namepsace WebCore |
| 67 | |