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, 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 template <> inline bool isMatchingElement(const HTMLTagNodeList* nodeList, Eleme
nt* element) | 246 template <> inline bool isMatchingElement(const HTMLTagNodeList* nodeList, Eleme
nt* element) |
247 { | 247 { |
248 return nodeList->nodeMatchesInlined(element); | 248 return nodeList->nodeMatchesInlined(element); |
249 } | 249 } |
250 | 250 |
251 template <> inline bool isMatchingElement(const ClassNodeList* nodeList, Element
* element) | 251 template <> inline bool isMatchingElement(const ClassNodeList* nodeList, Element
* element) |
252 { | 252 { |
253 return nodeList->nodeMatchesInlined(element); | 253 return nodeList->nodeMatchesInlined(element); |
254 } | 254 } |
255 | 255 |
256 static Node* previousNode(Node* base, Node* previous, bool onlyIncludeDirectChil
dren) | 256 static Node* previousNode(Node& base, Node& previous, bool onlyIncludeDirectChil
dren) |
257 { | 257 { |
258 return onlyIncludeDirectChildren ? previous->previousSibling() : NodeTravers
al::previous(previous, base); | 258 return onlyIncludeDirectChildren ? previous.previousSibling() : NodeTraversa
l::previous(&previous, &base); |
259 } | 259 } |
260 | 260 |
261 static inline Node* lastDescendent(Node* node) | 261 static inline Node* lastDescendent(Node& node) |
262 { | 262 { |
263 node = node->lastChild(); | 263 Node* descendent = node.lastChild(); |
264 for (Node* current = node; current; current = current->lastChild()) | 264 for (Node* current = descendent; current; current = current->lastChild()) |
265 node = current; | 265 descendent = current; |
266 return node; | 266 return descendent; |
267 } | 267 } |
268 | 268 |
269 static Node* lastNode(Node* rootNode, bool onlyIncludeDirectChildren) | 269 static Node* lastNode(Node& rootNode, bool onlyIncludeDirectChildren) |
270 { | 270 { |
271 return onlyIncludeDirectChildren ? rootNode->lastChild() : lastDescendent(ro
otNode); | 271 return onlyIncludeDirectChildren ? rootNode.lastChild() : lastDescendent(roo
tNode); |
272 } | 272 } |
273 | 273 |
274 ALWAYS_INLINE Node* LiveNodeListBase::iterateForPreviousNode(Node* current) cons
t | 274 ALWAYS_INLINE Node* LiveNodeListBase::iterateForPreviousNode(Node* current) cons
t |
275 { | 275 { |
276 bool onlyIncludeDirectChildren = shouldOnlyIncludeDirectChildren(); | 276 bool onlyIncludeDirectChildren = shouldOnlyIncludeDirectChildren(); |
277 CollectionType collectionType = type(); | 277 CollectionType collectionType = type(); |
278 Node* rootNode = this->rootNode(); | 278 Node& rootNode = this->rootNode(); |
279 for (; current; current = previousNode(rootNode, current, onlyIncludeDirectC
hildren)) { | 279 for (; current; current = previousNode(rootNode, *current, onlyIncludeDirect
Children)) { |
280 if (isNodeList(collectionType)) { | 280 if (isNodeList(collectionType)) { |
281 if (current->isElementNode() && isMatchingElement(static_cast<const
LiveNodeList*>(this), toElement(current))) | 281 if (current->isElementNode() && isMatchingElement(static_cast<const
LiveNodeList*>(this), toElement(current))) |
282 return toElement(current); | 282 return toElement(current); |
283 } else { | 283 } else { |
284 if (current->isElementNode() && isMatchingElement(static_cast<const
HTMLCollection*>(this), toElement(current))) | 284 if (current->isElementNode() && isMatchingElement(static_cast<const
HTMLCollection*>(this), toElement(current))) |
285 return toElement(current); | 285 return toElement(current); |
286 } | 286 } |
287 } | 287 } |
288 return 0; | 288 return 0; |
289 } | 289 } |
290 | 290 |
291 ALWAYS_INLINE Node* LiveNodeListBase::itemBefore(Node* previous) const | 291 ALWAYS_INLINE Node* LiveNodeListBase::itemBefore(Node* previous) const |
292 { | 292 { |
293 Node* current; | 293 Node* current; |
294 if (LIKELY(!!previous)) // Without this LIKELY, length() and item() can be 1
0% slower. | 294 if (LIKELY(!!previous)) // Without this LIKELY, length() and item() can be 1
0% slower. |
295 current = previousNode(rootNode(), previous, shouldOnlyIncludeDirectChil
dren()); | 295 current = previousNode(rootNode(), *previous, shouldOnlyIncludeDirectChi
ldren()); |
296 else | 296 else |
297 current = lastNode(rootNode(), shouldOnlyIncludeDirectChildren()); | 297 current = lastNode(rootNode(), shouldOnlyIncludeDirectChildren()); |
298 | 298 |
299 if (type() == ChildNodeListType) | 299 if (type() == ChildNodeListType) |
300 return current; | 300 return current; |
301 return iterateForPreviousNode(current); | 301 return iterateForPreviousNode(current); |
302 } | 302 } |
303 | 303 |
304 template <class NodeListType> | 304 template <class NodeListType> |
305 inline Element* firstMatchingElement(const NodeListType* nodeList, ContainerNode
* root) | 305 inline Element* firstMatchingElement(const NodeListType* nodeList, ContainerNode
* root) |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 | 678 |
679 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element*
element) | 679 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element*
element) |
680 { | 680 { |
681 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v
alue; | 681 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v
alue; |
682 if (!vector) | 682 if (!vector) |
683 vector = adoptPtr(new Vector<Element*>); | 683 vector = adoptPtr(new Vector<Element*>); |
684 vector->append(element); | 684 vector->append(element); |
685 } | 685 } |
686 | 686 |
687 } // namespace WebCore | 687 } // namespace WebCore |
OLD | NEW |