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

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

Issue 2548453003: FIELDSET element: |elements| IDL attribute should return an HTMLCollection, not HTMLFormControlsCol… (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
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 * Copyright (C) 2003-2008, 2011, 2012, 2014 Apple Inc. All rights reserved. 4 * Copyright (C) 2003-2008, 2011, 2012, 2014 Apple Inc. All rights reserved.
5 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 5 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 12 matching lines...) Expand all
23 23
24 #include "core/html/HTMLCollection.h" 24 #include "core/html/HTMLCollection.h"
25 25
26 #include "core/HTMLNames.h" 26 #include "core/HTMLNames.h"
27 #include "core/dom/ClassCollection.h" 27 #include "core/dom/ClassCollection.h"
28 #include "core/dom/ElementTraversal.h" 28 #include "core/dom/ElementTraversal.h"
29 #include "core/dom/NodeRareData.h" 29 #include "core/dom/NodeRareData.h"
30 #include "core/html/DocumentNameCollection.h" 30 #include "core/html/DocumentNameCollection.h"
31 #include "core/html/HTMLDataListOptionsCollection.h" 31 #include "core/html/HTMLDataListOptionsCollection.h"
32 #include "core/html/HTMLElement.h" 32 #include "core/html/HTMLElement.h"
33 #include "core/html/HTMLFormControlElement.h"
33 #include "core/html/HTMLObjectElement.h" 34 #include "core/html/HTMLObjectElement.h"
34 #include "core/html/HTMLOptionElement.h" 35 #include "core/html/HTMLOptionElement.h"
35 #include "core/html/HTMLOptionsCollection.h" 36 #include "core/html/HTMLOptionsCollection.h"
36 #include "core/html/HTMLTagCollection.h" 37 #include "core/html/HTMLTagCollection.h"
37 #include "core/html/WindowNameCollection.h" 38 #include "core/html/WindowNameCollection.h"
38 #include "wtf/HashSet.h" 39 #include "wtf/HashSet.h"
39 40
40 namespace blink { 41 namespace blink {
41 42
42 using namespace HTMLNames; 43 using namespace HTMLNames;
(...skipping 28 matching lines...) Expand all
71 case NameNodeListType: 72 case NameNodeListType:
72 case RadioNodeListType: 73 case RadioNodeListType:
73 case RadioImgNodeListType: 74 case RadioImgNodeListType:
74 case LabelsNodeListType: 75 case LabelsNodeListType:
75 break; 76 break;
76 } 77 }
77 NOTREACHED(); 78 NOTREACHED();
78 return false; 79 return false;
79 } 80 }
80 81
81 static NodeListRootType rootTypeFromCollectionType(CollectionType type) { 82 static NodeListRootType rootTypeFromCollectionType(const ContainerNode& owner,
83 CollectionType type) {
82 switch (type) { 84 switch (type) {
83 case DocImages: 85 case DocImages:
84 case DocApplets: 86 case DocApplets:
85 case DocEmbeds: 87 case DocEmbeds:
86 case DocForms: 88 case DocForms:
87 case DocLinks: 89 case DocLinks:
88 case DocAnchors: 90 case DocAnchors:
89 case DocScripts: 91 case DocScripts:
90 case DocAll: 92 case DocAll:
91 case WindowNamedItems: 93 case WindowNamedItems:
92 case DocumentNamedItems: 94 case DocumentNamedItems:
93 case FormControls:
94 return NodeListRootType::TreeScope; 95 return NodeListRootType::TreeScope;
95 case ClassCollectionType: 96 case ClassCollectionType:
96 case TagCollectionType: 97 case TagCollectionType:
97 case HTMLTagCollectionType: 98 case HTMLTagCollectionType:
98 case NodeChildren: 99 case NodeChildren:
99 case TableTBodies: 100 case TableTBodies:
100 case TSectionRows: 101 case TSectionRows:
101 case TableRows: 102 case TableRows:
102 case TRCells: 103 case TRCells:
103 case SelectOptions: 104 case SelectOptions:
104 case SelectedOptions: 105 case SelectedOptions:
105 case DataListOptions: 106 case DataListOptions:
106 case MapAreas: 107 case MapAreas:
107 return NodeListRootType::Node; 108 return NodeListRootType::Node;
109 case FormControls:
110 if (isHTMLFieldSetElement(owner))
111 return NodeListRootType::Node;
112 DCHECK(isHTMLFormElement(owner));
113 return NodeListRootType::TreeScope;
108 case NameNodeListType: 114 case NameNodeListType:
109 case RadioNodeListType: 115 case RadioNodeListType:
110 case RadioImgNodeListType: 116 case RadioImgNodeListType:
111 case LabelsNodeListType: 117 case LabelsNodeListType:
112 break; 118 break;
113 } 119 }
114 NOTREACHED(); 120 NOTREACHED();
115 return NodeListRootType::Node; 121 return NodeListRootType::Node;
116 } 122 }
117 123
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 break; 163 break;
158 } 164 }
159 NOTREACHED(); 165 NOTREACHED();
160 return DoNotInvalidateOnAttributeChanges; 166 return DoNotInvalidateOnAttributeChanges;
161 } 167 }
162 168
163 HTMLCollection::HTMLCollection(ContainerNode& ownerNode, 169 HTMLCollection::HTMLCollection(ContainerNode& ownerNode,
164 CollectionType type, 170 CollectionType type,
165 ItemAfterOverrideType itemAfterOverrideType) 171 ItemAfterOverrideType itemAfterOverrideType)
166 : LiveNodeListBase(ownerNode, 172 : LiveNodeListBase(ownerNode,
167 rootTypeFromCollectionType(type), 173 rootTypeFromCollectionType(ownerNode, type),
168 invalidationTypeExcludingIdAndNameAttributes(type), 174 invalidationTypeExcludingIdAndNameAttributes(type),
169 type), 175 type),
170 m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter), 176 m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter),
171 m_shouldOnlyIncludeDirectChildren( 177 m_shouldOnlyIncludeDirectChildren(
172 shouldTypeOnlyIncludeDirectChildren(type)) { 178 shouldTypeOnlyIncludeDirectChildren(type)) {
173 // Keep this in the child class because |registerNodeList| requires wrapper 179 // Keep this in the child class because |registerNodeList| requires wrapper
174 // tracing and potentially calls virtual methods which is not allowed in a 180 // tracing and potentially calls virtual methods which is not allowed in a
175 // base class constructor. 181 // base class constructor.
176 document().registerNodeList(this); 182 document().registerNodeList(this);
177 } 183 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 case DocApplets: 232 case DocApplets:
227 return isHTMLObjectElement(element) && 233 return isHTMLObjectElement(element) &&
228 toHTMLObjectElement(element).containsJavaApplet(); 234 toHTMLObjectElement(element).containsJavaApplet();
229 case DocEmbeds: 235 case DocEmbeds:
230 return element.hasTagName(embedTag); 236 return element.hasTagName(embedTag);
231 case DocLinks: 237 case DocLinks:
232 return (element.hasTagName(aTag) || element.hasTagName(areaTag)) && 238 return (element.hasTagName(aTag) || element.hasTagName(areaTag)) &&
233 element.fastHasAttribute(hrefAttr); 239 element.fastHasAttribute(hrefAttr);
234 case DocAnchors: 240 case DocAnchors:
235 return element.hasTagName(aTag) && element.fastHasAttribute(nameAttr); 241 return element.hasTagName(aTag) && element.fastHasAttribute(nameAttr);
242
kochi 2016/12/02 09:15:19 nit: no empty lines on L242 & L246? (following th
tkent 2016/12/02 13:09:23 Done.
243 case FormControls:
244 DCHECK(isHTMLFieldSetElement(htmlCollection.ownerNode()));
245 return isHTMLObjectElement(element) || isHTMLFormControlElement(element);
246
236 case ClassCollectionType: 247 case ClassCollectionType:
237 case TagCollectionType: 248 case TagCollectionType:
238 case HTMLTagCollectionType: 249 case HTMLTagCollectionType:
239 case DocAll: 250 case DocAll:
240 case NodeChildren: 251 case NodeChildren:
241 case FormControls:
242 case TableRows: 252 case TableRows:
243 case WindowNamedItems: 253 case WindowNamedItems:
244 case NameNodeListType: 254 case NameNodeListType:
245 case RadioNodeListType: 255 case RadioNodeListType:
246 case RadioImgNodeListType: 256 case RadioImgNodeListType:
247 case LabelsNodeListType: 257 case LabelsNodeListType:
248 NOTREACHED(); 258 NOTREACHED();
249 } 259 }
250 return false; 260 return false;
251 } 261 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 526
517 HTMLCollection::NamedItemCache::NamedItemCache() {} 527 HTMLCollection::NamedItemCache::NamedItemCache() {}
518 528
519 DEFINE_TRACE(HTMLCollection) { 529 DEFINE_TRACE(HTMLCollection) {
520 visitor->trace(m_namedItemCache); 530 visitor->trace(m_namedItemCache);
521 visitor->trace(m_collectionItemsCache); 531 visitor->trace(m_collectionItemsCache);
522 LiveNodeListBase::trace(visitor); 532 LiveNodeListBase::trace(visitor);
523 } 533 }
524 534
525 } // namespace blink 535 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | third_party/WebKit/Source/core/html/HTMLFieldSetElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698