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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 template <> inline bool isMatchingElement(const HTMLTagCollection& collection, c
onst Element& element) | 277 template <> inline bool isMatchingElement(const HTMLTagCollection& collection, c
onst Element& element) |
278 { | 278 { |
279 return collection.elementMatches(element); | 279 return collection.elementMatches(element); |
280 } | 280 } |
281 | 281 |
282 template <> inline bool isMatchingElement(const LiveNodeList& nodeList, const El
ement& element) | 282 template <> inline bool isMatchingElement(const LiveNodeList& nodeList, const El
ement& element) |
283 { | 283 { |
284 return nodeList.nodeMatches(element); | 284 return nodeList.nodeMatches(element); |
285 } | 285 } |
286 | 286 |
287 static Node* previousNode(const Node& base, const Node& previous, bool onlyInclu
deDirectChildren) | 287 static Node* previousNode(const ContainerNode& base, const Node& previous, bool
onlyIncludeDirectChildren) |
288 { | 288 { |
289 return onlyIncludeDirectChildren ? previous.previousSibling() : NodeTraversa
l::previous(previous, &base); | 289 return onlyIncludeDirectChildren ? previous.previousSibling() : NodeTraversa
l::previous(previous, &base); |
290 } | 290 } |
291 | 291 |
292 static inline Node* lastDescendant(const Node& node) | 292 static inline Node* lastDescendant(const ContainerNode& node) |
293 { | 293 { |
294 Node* descendant = node.lastChild(); | 294 Node* descendant = node.lastChild(); |
295 for (Node* current = descendant; current; current = current->lastChild()) | 295 for (Node* current = descendant; current; current = current->lastChild()) |
296 descendant = current; | 296 descendant = current; |
297 return descendant; | 297 return descendant; |
298 } | 298 } |
299 | 299 |
300 static Node* lastNode(const Node& rootNode, bool onlyIncludeDirectChildren) | 300 static Node* lastNode(const ContainerNode& rootNode, bool onlyIncludeDirectChild
ren) |
301 { | 301 { |
302 return onlyIncludeDirectChildren ? rootNode.lastChild() : lastDescendant(roo
tNode); | 302 return onlyIncludeDirectChildren ? rootNode.lastChild() : lastDescendant(roo
tNode); |
303 } | 303 } |
304 | 304 |
305 template <typename Collection> | 305 template <typename Collection> |
306 ALWAYS_INLINE Element* LiveNodeListBase::iterateForPreviousNode(const Collection
& collection, Node* current) | 306 ALWAYS_INLINE Element* LiveNodeListBase::iterateForPreviousNode(const Collection
& collection, Node* current) |
307 { | 307 { |
308 bool onlyIncludeDirectChildren = collection.shouldOnlyIncludeDirectChildren(
); | 308 bool onlyIncludeDirectChildren = collection.shouldOnlyIncludeDirectChildren(
); |
309 Node& rootNode = collection.rootNode(); | 309 ContainerNode& rootNode = collection.rootNode(); |
310 for (; current; current = previousNode(rootNode, *current, onlyIncludeDirect
Children)) { | 310 for (; current; current = previousNode(rootNode, *current, onlyIncludeDirect
Children)) { |
311 if (current->isElementNode() && isMatchingElement(collection, toElement(
*current))) | 311 if (current->isElementNode() && isMatchingElement(collection, toElement(
*current))) |
312 return toElement(current); | 312 return toElement(current); |
313 } | 313 } |
314 return 0; | 314 return 0; |
315 } | 315 } |
316 | 316 |
317 template <typename Collection> | 317 template <typename Collection> |
318 Element* LiveNodeListBase::itemBefore(const Collection& collection, const Node*
previous) | 318 Element* LiveNodeListBase::itemBefore(const Collection& collection, const Node*
previous) |
319 { | 319 { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 580 |
581 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element*
element) | 581 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element*
element) |
582 { | 582 { |
583 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v
alue; | 583 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->v
alue; |
584 if (!vector) | 584 if (!vector) |
585 vector = adoptPtr(new Vector<Element*>); | 585 vector = adoptPtr(new Vector<Element*>); |
586 vector->append(element); | 586 vector->append(element); |
587 } | 587 } |
588 | 588 |
589 } // namespace WebCore | 589 } // namespace WebCore |
OLD | NEW |