OLD | NEW |
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. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
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/AllDescendantsCollection.h" |
27 #include "core/dom/ClassCollection.h" | 28 #include "core/dom/ClassCollection.h" |
28 #include "core/dom/ElementTraversal.h" | 29 #include "core/dom/ElementTraversal.h" |
29 #include "core/dom/NodeRareData.h" | 30 #include "core/dom/NodeRareData.h" |
30 #include "core/html/DocumentNameCollection.h" | 31 #include "core/html/DocumentNameCollection.h" |
31 #include "core/html/HTMLDataListOptionsCollection.h" | 32 #include "core/html/HTMLDataListOptionsCollection.h" |
32 #include "core/html/HTMLElement.h" | 33 #include "core/html/HTMLElement.h" |
33 #include "core/html/HTMLFormControlElement.h" | 34 #include "core/html/HTMLFormControlElement.h" |
34 #include "core/html/HTMLObjectElement.h" | 35 #include "core/html/HTMLObjectElement.h" |
35 #include "core/html/HTMLOptionElement.h" | 36 #include "core/html/HTMLOptionElement.h" |
36 #include "core/html/HTMLOptionsCollection.h" | 37 #include "core/html/HTMLOptionsCollection.h" |
37 #include "core/html/HTMLTagCollection.h" | 38 #include "core/html/HTMLTagCollection.h" |
38 #include "core/html/WindowNameCollection.h" | 39 #include "core/html/WindowNameCollection.h" |
39 #include "platform/wtf/HashSet.h" | 40 #include "platform/wtf/HashSet.h" |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 using namespace HTMLNames; | 44 using namespace HTMLNames; |
44 | 45 |
45 static bool ShouldTypeOnlyIncludeDirectChildren(CollectionType type) { | 46 static bool ShouldTypeOnlyIncludeDirectChildren(CollectionType type) { |
46 switch (type) { | 47 switch (type) { |
47 case kClassCollectionType: | 48 case kClassCollectionType: |
48 case kTagCollectionType: | 49 case kTagCollectionType: |
| 50 case kTagCollectionNSType: |
49 case kHTMLTagCollectionType: | 51 case kHTMLTagCollectionType: |
| 52 case kAllDescendantsCollectionType: |
50 case kDocAll: | 53 case kDocAll: |
51 case kDocAnchors: | 54 case kDocAnchors: |
52 case kDocApplets: | 55 case kDocApplets: |
53 case kDocEmbeds: | 56 case kDocEmbeds: |
54 case kDocForms: | 57 case kDocForms: |
55 case kDocImages: | 58 case kDocImages: |
56 case kDocLinks: | 59 case kDocLinks: |
57 case kDocScripts: | 60 case kDocScripts: |
58 case kDocumentNamedItems: | 61 case kDocumentNamedItems: |
59 case kMapAreas: | 62 case kMapAreas: |
(...skipping 28 matching lines...) Expand all Loading... |
88 case kDocForms: | 91 case kDocForms: |
89 case kDocLinks: | 92 case kDocLinks: |
90 case kDocAnchors: | 93 case kDocAnchors: |
91 case kDocScripts: | 94 case kDocScripts: |
92 case kDocAll: | 95 case kDocAll: |
93 case kWindowNamedItems: | 96 case kWindowNamedItems: |
94 case kDocumentNamedItems: | 97 case kDocumentNamedItems: |
95 return NodeListRootType::kTreeScope; | 98 return NodeListRootType::kTreeScope; |
96 case kClassCollectionType: | 99 case kClassCollectionType: |
97 case kTagCollectionType: | 100 case kTagCollectionType: |
| 101 case kTagCollectionNSType: |
98 case kHTMLTagCollectionType: | 102 case kHTMLTagCollectionType: |
| 103 case kAllDescendantsCollectionType: |
99 case kNodeChildren: | 104 case kNodeChildren: |
100 case kTableTBodies: | 105 case kTableTBodies: |
101 case kTSectionRows: | 106 case kTSectionRows: |
102 case kTableRows: | 107 case kTableRows: |
103 case kTRCells: | 108 case kTRCells: |
104 case kSelectOptions: | 109 case kSelectOptions: |
105 case kSelectedOptions: | 110 case kSelectedOptions: |
106 case kDataListOptions: | 111 case kDataListOptions: |
107 case kMapAreas: | 112 case kMapAreas: |
108 return NodeListRootType::kNode; | 113 return NodeListRootType::kNode; |
109 case kFormControls: | 114 case kFormControls: |
110 if (isHTMLFieldSetElement(owner)) | 115 if (isHTMLFieldSetElement(owner)) |
111 return NodeListRootType::kNode; | 116 return NodeListRootType::kNode; |
112 DCHECK(isHTMLFormElement(owner)); | 117 DCHECK(isHTMLFormElement(owner)); |
113 return NodeListRootType::kTreeScope; | 118 return NodeListRootType::kTreeScope; |
114 case kNameNodeListType: | 119 case kNameNodeListType: |
115 case kRadioNodeListType: | 120 case kRadioNodeListType: |
116 case kRadioImgNodeListType: | 121 case kRadioImgNodeListType: |
117 case kLabelsNodeListType: | 122 case kLabelsNodeListType: |
118 break; | 123 break; |
119 } | 124 } |
120 NOTREACHED(); | 125 NOTREACHED(); |
121 return NodeListRootType::kNode; | 126 return NodeListRootType::kNode; |
122 } | 127 } |
123 | 128 |
124 static NodeListInvalidationType InvalidationTypeExcludingIdAndNameAttributes( | 129 static NodeListInvalidationType InvalidationTypeExcludingIdAndNameAttributes( |
125 CollectionType type) { | 130 CollectionType type) { |
126 switch (type) { | 131 switch (type) { |
127 case kTagCollectionType: | 132 case kTagCollectionType: |
| 133 case kTagCollectionNSType: |
128 case kHTMLTagCollectionType: | 134 case kHTMLTagCollectionType: |
| 135 case kAllDescendantsCollectionType: |
129 case kDocImages: | 136 case kDocImages: |
130 case kDocEmbeds: | 137 case kDocEmbeds: |
131 case kDocForms: | 138 case kDocForms: |
132 case kDocScripts: | 139 case kDocScripts: |
133 case kDocAll: | 140 case kDocAll: |
134 case kNodeChildren: | 141 case kNodeChildren: |
135 case kTableTBodies: | 142 case kTableTBodies: |
136 case kTSectionRows: | 143 case kTSectionRows: |
137 case kTableRows: | 144 case kTableRows: |
138 case kTRCells: | 145 case kTRCells: |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 case kDocLinks: | 244 case kDocLinks: |
238 return (element.HasTagName(aTag) || element.HasTagName(areaTag)) && | 245 return (element.HasTagName(aTag) || element.HasTagName(areaTag)) && |
239 element.FastHasAttribute(hrefAttr); | 246 element.FastHasAttribute(hrefAttr); |
240 case kDocAnchors: | 247 case kDocAnchors: |
241 return element.HasTagName(aTag) && element.FastHasAttribute(nameAttr); | 248 return element.HasTagName(aTag) && element.FastHasAttribute(nameAttr); |
242 case kFormControls: | 249 case kFormControls: |
243 DCHECK(isHTMLFieldSetElement(html_collection.ownerNode())); | 250 DCHECK(isHTMLFieldSetElement(html_collection.ownerNode())); |
244 return isHTMLObjectElement(element) || IsHTMLFormControlElement(element); | 251 return isHTMLObjectElement(element) || IsHTMLFormControlElement(element); |
245 case kClassCollectionType: | 252 case kClassCollectionType: |
246 case kTagCollectionType: | 253 case kTagCollectionType: |
| 254 case kTagCollectionNSType: |
247 case kHTMLTagCollectionType: | 255 case kHTMLTagCollectionType: |
| 256 case kAllDescendantsCollectionType: |
248 case kDocAll: | 257 case kDocAll: |
249 case kNodeChildren: | 258 case kNodeChildren: |
250 case kTableRows: | 259 case kTableRows: |
251 case kWindowNamedItems: | 260 case kWindowNamedItems: |
252 case kNameNodeListType: | 261 case kNameNodeListType: |
253 case kRadioNodeListType: | 262 case kRadioNodeListType: |
254 case kRadioImgNodeListType: | 263 case kRadioImgNodeListType: |
255 case kLabelsNodeListType: | 264 case kLabelsNodeListType: |
256 NOTREACHED(); | 265 NOTREACHED(); |
257 } | 266 } |
258 return false; | 267 return false; |
259 } | 268 } |
260 | 269 |
261 inline bool HTMLCollection::ElementMatches(const Element& element) const { | 270 inline bool HTMLCollection::ElementMatches(const Element& element) const { |
262 // These collections apply to any kind of Elements, not just HTMLElements. | 271 // These collections apply to any kind of Elements, not just HTMLElements. |
263 switch (GetType()) { | 272 switch (GetType()) { |
264 case kDocAll: | 273 case kDocAll: |
265 case kNodeChildren: | 274 case kNodeChildren: |
266 return true; | 275 return true; |
267 case kClassCollectionType: | 276 case kClassCollectionType: |
268 return ToClassCollection(*this).ElementMatches(element); | 277 return ToClassCollection(*this).ElementMatches(element); |
269 case kTagCollectionType: | 278 case kTagCollectionType: |
270 return ToTagCollection(*this).ElementMatches(element); | 279 return ToTagCollection(*this).ElementMatches(element); |
271 case kHTMLTagCollectionType: | 280 case kHTMLTagCollectionType: |
272 return ToHTMLTagCollection(*this).ElementMatches(element); | 281 return ToHTMLTagCollection(*this).ElementMatches(element); |
| 282 case kTagCollectionNSType: |
| 283 return ToTagCollectionNS(*this).ElementMatches(element); |
| 284 case kAllDescendantsCollectionType: |
| 285 return ToAllDescendantsCollection(*this).ElementMatches(element); |
273 case kWindowNamedItems: | 286 case kWindowNamedItems: |
274 return ToWindowNameCollection(*this).ElementMatches(element); | 287 return ToWindowNameCollection(*this).ElementMatches(element); |
275 default: | 288 default: |
276 break; | 289 break; |
277 } | 290 } |
278 | 291 |
279 // The following only applies to HTMLElements. | 292 // The following only applies to HTMLElements. |
280 return element.IsHTMLElement() && | 293 return element.IsHTMLElement() && |
281 IsMatchingHTMLElement(*this, ToHTMLElement(element)); | 294 IsMatchingHTMLElement(*this, ToHTMLElement(element)); |
282 } | 295 } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 532 |
520 HTMLCollection::NamedItemCache::NamedItemCache() {} | 533 HTMLCollection::NamedItemCache::NamedItemCache() {} |
521 | 534 |
522 DEFINE_TRACE(HTMLCollection) { | 535 DEFINE_TRACE(HTMLCollection) { |
523 visitor->Trace(named_item_cache_); | 536 visitor->Trace(named_item_cache_); |
524 visitor->Trace(collection_items_cache_); | 537 visitor->Trace(collection_items_cache_); |
525 LiveNodeListBase::Trace(visitor); | 538 LiveNodeListBase::Trace(visitor); |
526 } | 539 } |
527 | 540 |
528 } // namespace blink | 541 } // namespace blink |
OLD | NEW |