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

Side by Side Diff: Source/WebCore/html/HTMLCollection.cpp

Issue 14028014: Remove MicroData implementation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Also delete all the tests Created 7 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/WebCore/html/HTMLAreaElement.cpp ('k') | Source/WebCore/html/HTMLElement.h » ('j') | 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r ights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 15 matching lines...) Expand all
26 #include "ClassNodeList.h" 26 #include "ClassNodeList.h"
27 #include "HTMLDocument.h" 27 #include "HTMLDocument.h"
28 #include "HTMLElement.h" 28 #include "HTMLElement.h"
29 #include "HTMLNames.h" 29 #include "HTMLNames.h"
30 #include "HTMLObjectElement.h" 30 #include "HTMLObjectElement.h"
31 #include "HTMLOptionElement.h" 31 #include "HTMLOptionElement.h"
32 #include "NodeList.h" 32 #include "NodeList.h"
33 #include "NodeRareData.h" 33 #include "NodeRareData.h"
34 #include "NodeTraversal.h" 34 #include "NodeTraversal.h"
35 35
36 #if ENABLE(MICRODATA)
37 #include "HTMLPropertiesCollection.h"
38 #include "PropertyNodeList.h"
39 #endif
40
41 #include <utility> 36 #include <utility>
42 37
43 namespace WebCore { 38 namespace WebCore {
44 39
45 using namespace HTMLNames; 40 using namespace HTMLNames;
46 41
47 static bool shouldOnlyIncludeDirectChildren(CollectionType type) 42 static bool shouldOnlyIncludeDirectChildren(CollectionType type)
48 { 43 {
49 switch (type) { 44 switch (type) {
50 case DocAll: 45 case DocAll:
51 case DocAnchors: 46 case DocAnchors:
52 case DocApplets: 47 case DocApplets:
53 case DocEmbeds: 48 case DocEmbeds:
54 case DocForms: 49 case DocForms:
55 case DocImages: 50 case DocImages:
56 case DocLinks: 51 case DocLinks:
57 case DocScripts: 52 case DocScripts:
58 case DocumentNamedItems: 53 case DocumentNamedItems:
59 case MapAreas: 54 case MapAreas:
60 case TableRows: 55 case TableRows:
61 case SelectOptions: 56 case SelectOptions:
62 case SelectedOptions: 57 case SelectedOptions:
63 case DataListOptions: 58 case DataListOptions:
64 case WindowNamedItems: 59 case WindowNamedItems:
65 #if ENABLE(MICRODATA)
66 case ItemProperties:
67 #endif
68 case FormControls: 60 case FormControls:
69 return false; 61 return false;
70 case NodeChildren: 62 case NodeChildren:
71 case TRCells: 63 case TRCells:
72 case TSectionRows: 64 case TSectionRows:
73 case TableTBodies: 65 case TableTBodies:
74 return true; 66 return true;
75 case ChildNodeListType: 67 case ChildNodeListType:
76 case ClassNodeListType: 68 case ClassNodeListType:
77 case NameNodeListType: 69 case NameNodeListType:
78 case TagNodeListType: 70 case TagNodeListType:
79 case HTMLTagNodeListType: 71 case HTMLTagNodeListType:
80 case RadioNodeListType: 72 case RadioNodeListType:
81 case LabelsNodeListType: 73 case LabelsNodeListType:
82 case MicroDataItemListType:
83 case PropertyNodeListType:
84 break; 74 break;
85 } 75 }
86 ASSERT_NOT_REACHED(); 76 ASSERT_NOT_REACHED();
87 return false; 77 return false;
88 } 78 }
89 79
90 static NodeListRootType rootTypeFromCollectionType(CollectionType type) 80 static NodeListRootType rootTypeFromCollectionType(CollectionType type)
91 { 81 {
92 switch (type) { 82 switch (type) {
93 case DocImages: 83 case DocImages:
94 case DocApplets: 84 case DocApplets:
95 case DocEmbeds: 85 case DocEmbeds:
96 case DocForms: 86 case DocForms:
97 case DocLinks: 87 case DocLinks:
98 case DocAnchors: 88 case DocAnchors:
99 case DocScripts: 89 case DocScripts:
100 case DocAll: 90 case DocAll:
101 case WindowNamedItems: 91 case WindowNamedItems:
102 case DocumentNamedItems: 92 case DocumentNamedItems:
103 #if ENABLE(MICRODATA)
104 case ItemProperties:
105 #endif
106 case FormControls: 93 case FormControls:
107 return NodeListIsRootedAtDocument; 94 return NodeListIsRootedAtDocument;
108 case NodeChildren: 95 case NodeChildren:
109 case TableTBodies: 96 case TableTBodies:
110 case TSectionRows: 97 case TSectionRows:
111 case TableRows: 98 case TableRows:
112 case TRCells: 99 case TRCells:
113 case SelectOptions: 100 case SelectOptions:
114 case SelectedOptions: 101 case SelectedOptions:
115 case DataListOptions: 102 case DataListOptions:
116 case MapAreas: 103 case MapAreas:
117 return NodeListIsRootedAtNode; 104 return NodeListIsRootedAtNode;
118 case ChildNodeListType: 105 case ChildNodeListType:
119 case ClassNodeListType: 106 case ClassNodeListType:
120 case NameNodeListType: 107 case NameNodeListType:
121 case TagNodeListType: 108 case TagNodeListType:
122 case HTMLTagNodeListType: 109 case HTMLTagNodeListType:
123 case RadioNodeListType: 110 case RadioNodeListType:
124 case LabelsNodeListType: 111 case LabelsNodeListType:
125 case MicroDataItemListType:
126 case PropertyNodeListType:
127 break; 112 break;
128 } 113 }
129 ASSERT_NOT_REACHED(); 114 ASSERT_NOT_REACHED();
130 return NodeListIsRootedAtNode; 115 return NodeListIsRootedAtNode;
131 } 116 }
132 117
133 static NodeListInvalidationType invalidationTypeExcludingIdAndNameAttributes(Col lectionType type) 118 static NodeListInvalidationType invalidationTypeExcludingIdAndNameAttributes(Col lectionType type)
134 { 119 {
135 switch (type) { 120 switch (type) {
136 case DocImages: 121 case DocImages:
(...skipping 15 matching lines...) Expand all
152 // FIXME: We can do better some day. 137 // FIXME: We can do better some day.
153 return InvalidateOnAnyAttrChange; 138 return InvalidateOnAnyAttrChange;
154 case DocAnchors: 139 case DocAnchors:
155 return InvalidateOnNameAttrChange; 140 return InvalidateOnNameAttrChange;
156 case DocLinks: 141 case DocLinks:
157 return InvalidateOnHRefAttrChange; 142 return InvalidateOnHRefAttrChange;
158 case WindowNamedItems: 143 case WindowNamedItems:
159 return InvalidateOnIdNameAttrChange; 144 return InvalidateOnIdNameAttrChange;
160 case DocumentNamedItems: 145 case DocumentNamedItems:
161 return InvalidateOnIdNameAttrChange; 146 return InvalidateOnIdNameAttrChange;
162 #if ENABLE(MICRODATA)
163 case ItemProperties:
164 return InvalidateOnItemAttrChange;
165 #endif
166 case FormControls: 147 case FormControls:
167 return InvalidateForFormControls; 148 return InvalidateForFormControls;
168 case ChildNodeListType: 149 case ChildNodeListType:
169 case ClassNodeListType: 150 case ClassNodeListType:
170 case NameNodeListType: 151 case NameNodeListType:
171 case TagNodeListType: 152 case TagNodeListType:
172 case HTMLTagNodeListType: 153 case HTMLTagNodeListType:
173 case RadioNodeListType: 154 case RadioNodeListType:
174 case LabelsNodeListType: 155 case LabelsNodeListType:
175 case MicroDataItemListType:
176 case PropertyNodeListType:
177 break; 156 break;
178 } 157 }
179 ASSERT_NOT_REACHED(); 158 ASSERT_NOT_REACHED();
180 return DoNotInvalidateOnAttributeChanges; 159 return DoNotInvalidateOnAttributeChanges;
181 } 160 }
182 161
183 HTMLCollection::HTMLCollection(Node* ownerNode, CollectionType type, ItemAfterOv errideType itemAfterOverrideType) 162 HTMLCollection::HTMLCollection(Node* ownerNode, CollectionType type, ItemAfterOv errideType itemAfterOverrideType)
184 : LiveNodeListBase(ownerNode, rootTypeFromCollectionType(type), invalidation TypeExcludingIdAndNameAttributes(type), 163 : LiveNodeListBase(ownerNode, rootTypeFromCollectionType(type), invalidation TypeExcludingIdAndNameAttributes(type),
185 WebCore::shouldOnlyIncludeDirectChildren(type), type, itemAfterOverrideT ype) 164 WebCore::shouldOnlyIncludeDirectChildren(type), type, itemAfterOverrideT ype)
186 { 165 {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return element->hasLocalName(appletTag) || (element->hasLocalName(object Tag) && static_cast<HTMLObjectElement*>(element)->containsJavaApplet()); 217 return element->hasLocalName(appletTag) || (element->hasLocalName(object Tag) && static_cast<HTMLObjectElement*>(element)->containsJavaApplet());
239 case DocEmbeds: 218 case DocEmbeds:
240 return element->hasLocalName(embedTag); 219 return element->hasLocalName(embedTag);
241 case DocLinks: 220 case DocLinks:
242 return (element->hasLocalName(aTag) || element->hasLocalName(areaTag)) & & element->fastHasAttribute(hrefAttr); 221 return (element->hasLocalName(aTag) || element->hasLocalName(areaTag)) & & element->fastHasAttribute(hrefAttr);
243 case DocAnchors: 222 case DocAnchors:
244 return element->hasLocalName(aTag) && element->fastHasAttribute(nameAttr ); 223 return element->hasLocalName(aTag) && element->fastHasAttribute(nameAttr );
245 case DocAll: 224 case DocAll:
246 case NodeChildren: 225 case NodeChildren:
247 return true; 226 return true;
248 #if ENABLE(MICRODATA)
249 case ItemProperties:
250 return element->fastHasAttribute(itempropAttr);
251 #endif
252 case FormControls: 227 case FormControls:
253 case DocumentNamedItems: 228 case DocumentNamedItems:
254 case TableRows: 229 case TableRows:
255 case WindowNamedItems: 230 case WindowNamedItems:
256 case ChildNodeListType: 231 case ChildNodeListType:
257 case ClassNodeListType: 232 case ClassNodeListType:
258 case NameNodeListType: 233 case NameNodeListType:
259 case TagNodeListType: 234 case TagNodeListType:
260 case HTMLTagNodeListType: 235 case HTMLTagNodeListType:
261 case RadioNodeListType: 236 case RadioNodeListType:
262 case LabelsNodeListType: 237 case LabelsNodeListType:
263 case MicroDataItemListType:
264 case PropertyNodeListType:
265 ASSERT_NOT_REACHED(); 238 ASSERT_NOT_REACHED();
266 } 239 }
267 return false; 240 return false;
268 } 241 }
269 242
270 template <> inline bool isMatchingElement(const LiveNodeList* nodeList, Element* element) 243 template <> inline bool isMatchingElement(const LiveNodeList* nodeList, Element* element)
271 { 244 {
272 return nodeList->nodeMatches(element); 245 return nodeList->nodeMatches(element);
273 } 246 }
274 247
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 411
439 // FIXME: It is silly that these functions are in HTMLCollection.cpp. 412 // FIXME: It is silly that these functions are in HTMLCollection.cpp.
440 Node* LiveNodeListBase::item(unsigned offset) const 413 Node* LiveNodeListBase::item(unsigned offset) const
441 { 414 {
442 if (isItemCacheValid() && cachedItemOffset() == offset) 415 if (isItemCacheValid() && cachedItemOffset() == offset)
443 return cachedItem(); 416 return cachedItem();
444 417
445 if (isLengthCacheValid() && cachedLength() <= offset) 418 if (isLengthCacheValid() && cachedLength() <= offset)
446 return 0; 419 return 0;
447 420
448 #if ENABLE(MICRODATA)
449 if (type() == ItemProperties)
450 static_cast<const HTMLPropertiesCollection*>(this)->updateRefElements();
451 else if (type() == PropertyNodeListType)
452 static_cast<const PropertyNodeList*>(this)->updateRefElements();
453 #endif
454
455 ContainerNode* root = rootContainerNode(); 421 ContainerNode* root = rootContainerNode();
456 if (!root) { 422 if (!root) {
457 // FIMXE: In someTextNode.childNodes case the root is Text. We shouldn't even make a LiveNodeList for that. 423 // FIMXE: In someTextNode.childNodes case the root is Text. We shouldn't even make a LiveNodeList for that.
458 setLengthCache(0); 424 setLengthCache(0);
459 return 0; 425 return 0;
460 } 426 }
461 427
462 if (isLengthCacheValid() && !overridesItemAfter() && isLastItemCloserThanLas tOrCachedItem(offset)) { 428 if (isLengthCacheValid() && !overridesItemAfter() && isLastItemCloserThanLas tOrCachedItem(offset)) {
463 Node* lastItem = itemBefore(0); 429 Node* lastItem = itemBefore(0);
464 ASSERT(lastItem); 430 ASSERT(lastItem);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 686
721 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element) 687 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element)
722 { 688 {
723 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v alue; 689 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v alue;
724 if (!vector) 690 if (!vector)
725 vector = adoptPtr(new Vector<Element*>); 691 vector = adoptPtr(new Vector<Element*>);
726 vector->append(element); 692 vector->append(element);
727 } 693 }
728 694
729 } // namespace WebCore 695 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/html/HTMLAreaElement.cpp ('k') | Source/WebCore/html/HTMLElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698