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

Side by Side Diff: Source/core/dom/ChildNodeList.cpp

Issue 154693002: Have ChildNodeList subclass NodeList instead of LiveNodeList (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update copyright Created 6 years, 10 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
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 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
6 * 7 *
7 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
11 * 12 *
12 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 16 * Library General Public License for more details.
16 * 17 *
17 * You should have received a copy of the GNU Library General Public License 18 * 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 19 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
21 */ 22 */
22 23
23 #include "config.h" 24 #include "config.h"
24 #include "core/dom/ChildNodeList.h" 25 #include "core/dom/ChildNodeList.h"
25 26
26 #include "core/dom/Element.h" 27 #include "core/dom/Element.h"
27 #include "core/dom/NodeRareData.h" 28 #include "core/dom/NodeRareData.h"
28 29
29 namespace WebCore { 30 namespace WebCore {
30 31
31 ChildNodeList::ChildNodeList(PassRefPtr<ContainerNode> node) 32 ChildNodeList::ChildNodeList(PassRefPtr<ContainerNode> parent)
32 : LiveNodeList(node, ChildNodeListType, DoNotInvalidateOnAttributeChanges) 33 : m_parent(parent)
33 { 34 {
35 ASSERT(m_parent);
34 } 36 }
35 37
36 ChildNodeList::~ChildNodeList() 38 ChildNodeList::~ChildNodeList()
37 { 39 {
38 ownerNode()->nodeLists()->removeChildNodeList(this); 40 m_parent->nodeLists()->removeChildNodeList(this);
39 } 41 }
40 42
41 bool ChildNodeList::nodeMatches(const Element& testNode) const 43 Node* ChildNodeList::itemBefore(const Node* previous) const
42 { 44 {
43 // This function will be called only by LiveNodeList::namedItem, 45 return LIKELY(!!previous) ? previous->previousSibling() : rootNode().lastChi ld();
44 // for an element that was located with getElementById. 46 }
45 return testNode.parentNode() == rootNode(); 47
48 Node* ChildNodeList::traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, const ContainerNode&) const
49 {
50 ASSERT(currentOffset < offset);
51 Node* next = &currentNode;
52 while ((next = next->nextSibling())) {
53 if (++currentOffset == offset)
54 return next;
55 }
56 return 0;
46 } 57 }
47 58
48 } // namespace WebCore 59 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698