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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLFieldSetElement.cpp

Issue 2550993002: Cleanup of blink::HTMLFieldSetElement (Closed)
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFieldSetElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 10 matching lines...) Expand all
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 * 22 *
23 */ 23 */
24 24
25 #include "core/html/HTMLFieldSetElement.h" 25 #include "core/html/HTMLFieldSetElement.h"
26 26
27 #include "core/HTMLNames.h" 27 #include "core/HTMLNames.h"
28 #include "core/dom/ElementTraversal.h" 28 #include "core/dom/ElementTraversal.h"
29 #include "core/dom/NodeListsNodeData.h" 29 #include "core/dom/NodeListsNodeData.h"
30 #include "core/html/HTMLCollection.h" 30 #include "core/html/HTMLCollection.h"
31 #include "core/html/HTMLFormControlsCollection.h"
32 #include "core/html/HTMLLegendElement.h" 31 #include "core/html/HTMLLegendElement.h"
33 #include "core/html/HTMLObjectElement.h"
34 #include "core/layout/LayoutFieldset.h" 32 #include "core/layout/LayoutFieldset.h"
35 #include "wtf/StdLibExtras.h" 33 #include "wtf/StdLibExtras.h"
36 34
37 namespace blink { 35 namespace blink {
38 36
39 using namespace HTMLNames; 37 using namespace HTMLNames;
40 38
41 inline HTMLFieldSetElement::HTMLFieldSetElement(Document& document, 39 inline HTMLFieldSetElement::HTMLFieldSetElement(Document& document,
42 HTMLFormElement* form) 40 HTMLFormElement* form)
43 : HTMLFormControlElement(fieldsetTag, document, form), 41 : HTMLFormControlElement(fieldsetTag, document, form) {}
44 m_documentVersion(0) {}
45 42
46 HTMLFieldSetElement* HTMLFieldSetElement::create(Document& document, 43 HTMLFieldSetElement* HTMLFieldSetElement::create(Document& document,
47 HTMLFormElement* form) { 44 HTMLFormElement* form) {
48 return new HTMLFieldSetElement(document, form); 45 return new HTMLFieldSetElement(document, form);
49 } 46 }
50 47
51 DEFINE_TRACE(HTMLFieldSetElement) {
52 visitor->trace(m_listedElements);
53 HTMLFormControlElement::trace(visitor);
54 }
55
56 bool HTMLFieldSetElement::matchesValidityPseudoClasses() const { 48 bool HTMLFieldSetElement::matchesValidityPseudoClasses() const {
57 return true; 49 return true;
58 } 50 }
59 51
60 bool HTMLFieldSetElement::isValidElement() { 52 bool HTMLFieldSetElement::isValidElement() {
61 const ListedElement::List& elements = listedElements(); 53 HTMLCollection* elements = this->elements();
62 for (unsigned i = 0; i < elements.size(); ++i) { 54 for (unsigned i = 0; i < elements->length(); ++i) {
63 if (elements[i]->isFormControlElement()) { 55 if (elements->item(i)->isFormControlElement()) {
64 HTMLFormControlElement* control = 56 if (!toHTMLFormControlElement(elements->item(i))
65 toHTMLFormControlElement(elements[i].get()); 57 ->checkValidity(nullptr, CheckValidityDispatchNoEvent))
66 if (!control->checkValidity(0, CheckValidityDispatchNoEvent))
67 return false; 58 return false;
68 } 59 }
69 } 60 }
70 return true; 61 return true;
71 } 62 }
72 63
73 bool HTMLFieldSetElement::isSubmittableElement() { 64 bool HTMLFieldSetElement::isSubmittableElement() {
74 return false; 65 return false;
75 } 66 }
76 67
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 99 }
109 100
110 HTMLLegendElement* HTMLFieldSetElement::legend() const { 101 HTMLLegendElement* HTMLFieldSetElement::legend() const {
111 return Traversal<HTMLLegendElement>::firstChild(*this); 102 return Traversal<HTMLLegendElement>::firstChild(*this);
112 } 103 }
113 104
114 HTMLCollection* HTMLFieldSetElement::elements() { 105 HTMLCollection* HTMLFieldSetElement::elements() {
115 return ensureCachedCollection<HTMLCollection>(FormControls); 106 return ensureCachedCollection<HTMLCollection>(FormControls);
116 } 107 }
117 108
118 void HTMLFieldSetElement::refreshElementsIfNeeded() const {
119 uint64_t docVersion = document().domTreeVersion();
120 if (m_documentVersion == docVersion)
121 return;
122
123 m_documentVersion = docVersion;
124
125 m_listedElements.clear();
126
127 for (HTMLElement& element : Traversal<HTMLElement>::descendantsOf(*this)) {
128 if (isHTMLObjectElement(element)) {
129 m_listedElements.append(toHTMLObjectElement(&element));
130 continue;
131 }
132
133 if (!element.isFormControlElement())
134 continue;
135
136 m_listedElements.append(toHTMLFormControlElement(&element));
137 }
138 }
139
140 const ListedElement::List& HTMLFieldSetElement::listedElements() const {
141 refreshElementsIfNeeded();
142 return m_listedElements;
143 }
144
145 int HTMLFieldSetElement::tabIndex() const { 109 int HTMLFieldSetElement::tabIndex() const {
146 return HTMLElement::tabIndex(); 110 return HTMLElement::tabIndex();
147 } 111 }
148 112
149 } // namespace blink 113 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFieldSetElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698