1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights 5 * reserved. 6 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public License 19 * along with this library; see the file COPYING.LIB. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 * 23 */ 24 25 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_HTML_FORMS_HTML_FORM_CONTROLS_COLLECTION_H_ 26 #define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_FORMS_HTML_FORM_CONTROLS_COLLECTION_H_ 27 28 #include "third_party/blink/renderer/core/html/forms/listed_element.h" 29 #include "third_party/blink/renderer/core/html/forms/radio_node_list.h" 30 #include "third_party/blink/renderer/core/html/html_collection.h" 31 #include "third_party/blink/renderer/core/html/html_element.h" 32 33 namespace blink { 34 35 class HTMLImageElement; 36 class RadioNodeListOrElement; 37 38 // This class is just a big hack to find form elements even in malformed HTML 39 // elements. The famous <table><tr><form><td> problem. 40 41 class HTMLFormControlsCollection final : public HTMLCollection { 42 DEFINE_WRAPPERTYPEINFO(); 43 44 public: 45 explicit HTMLFormControlsCollection(ContainerNode&); 46 HTMLFormControlsCollection(ContainerNode&, CollectionType); 47 48 ~HTMLFormControlsCollection() override; 49 item(unsigned offset)50 HTMLElement* item(unsigned offset) const { 51 return To<HTMLElement>(HTMLCollection::item(offset)); 52 } 53 54 HTMLElement* namedItem(const AtomicString& name) const override; 55 void namedGetter(const AtomicString& name, RadioNodeListOrElement&); 56 57 void Trace(Visitor*) override; 58 59 private: 60 void UpdateIdNameCache() const override; 61 void SupportedPropertyNames(Vector<String>& names) override; 62 63 const ListedElement::List& ListedElements() const; 64 const HeapVector<Member<HTMLImageElement>>& FormImageElements() const; 65 HTMLElement* VirtualItemAfter(Element*) const override; 66 void InvalidateCache(Document* old_document = nullptr) const override; 67 68 mutable Member<HTMLElement> cached_element_; 69 mutable unsigned cached_element_offset_in_array_; 70 }; 71 72 } // namespace blink 73 74 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_FORMS_HTML_FORM_CONTROLS_COLLECTION_H_ 75