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 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 return String(); | 373 return String(); |
374 } | 374 } |
375 | 375 |
376 void Node::setNodeValue(const String&) | 376 void Node::setNodeValue(const String&) |
377 { | 377 { |
378 // By default, setting nodeValue has no effect. | 378 // By default, setting nodeValue has no effect. |
379 } | 379 } |
380 | 380 |
381 PassRefPtr<NodeList> Node::childNodes() | 381 PassRefPtr<NodeList> Node::childNodes() |
382 { | 382 { |
383 return ensureRareData().ensureNodeLists()->ensureChildNodeList(this); | 383 return ensureRareData().ensureNodeLists().ensureChildNodeList(this); |
384 } | 384 } |
385 | 385 |
386 Node *Node::lastDescendant() const | 386 Node *Node::lastDescendant() const |
387 { | 387 { |
388 Node *n = const_cast<Node *>(this); | 388 Node *n = const_cast<Node *>(this); |
389 while (n && n->lastChild()) | 389 while (n && n->lastChild()) |
390 n = n->lastChild(); | 390 n = n->lastChild(); |
391 return n; | 391 return n; |
392 } | 392 } |
393 | 393 |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 } | 1196 } |
1197 | 1197 |
1198 // FIXME: End of obviously misplaced HTML editing functions. Try to move these
out of Node. | 1198 // FIXME: End of obviously misplaced HTML editing functions. Try to move these
out of Node. |
1199 | 1199 |
1200 PassRefPtr<NodeList> Node::getElementsByTagName(const AtomicString& localName) | 1200 PassRefPtr<NodeList> Node::getElementsByTagName(const AtomicString& localName) |
1201 { | 1201 { |
1202 if (localName.isNull()) | 1202 if (localName.isNull()) |
1203 return 0; | 1203 return 0; |
1204 | 1204 |
1205 if (document().isHTMLDocument()) | 1205 if (document().isHTMLDocument()) |
1206 return ensureRareData().ensureNodeLists()->addCacheWithAtomicName<HTMLTa
gNodeList>(this, HTMLTagNodeListType, localName); | 1206 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTag
NodeList>(this, HTMLTagNodeListType, localName); |
1207 return ensureRareData().ensureNodeLists()->addCacheWithAtomicName<TagNodeLis
t>(this, TagNodeListType, localName); | 1207 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList
>(this, TagNodeListType, localName); |
1208 } | 1208 } |
1209 | 1209 |
1210 PassRefPtr<NodeList> Node::getElementsByTagNameNS(const AtomicString& namespaceU
RI, const AtomicString& localName) | 1210 PassRefPtr<NodeList> Node::getElementsByTagNameNS(const AtomicString& namespaceU
RI, const AtomicString& localName) |
1211 { | 1211 { |
1212 if (localName.isNull()) | 1212 if (localName.isNull()) |
1213 return 0; | 1213 return 0; |
1214 | 1214 |
1215 if (namespaceURI == starAtom) | 1215 if (namespaceURI == starAtom) |
1216 return getElementsByTagName(localName); | 1216 return getElementsByTagName(localName); |
1217 | 1217 |
1218 return ensureRareData().ensureNodeLists()->addCacheWithQualifiedName(this, n
amespaceURI.isEmpty() ? nullAtom : namespaceURI, localName); | 1218 return ensureRareData().ensureNodeLists().addCacheWithQualifiedName(this, na
mespaceURI.isEmpty() ? nullAtom : namespaceURI, localName); |
1219 } | 1219 } |
1220 | 1220 |
1221 PassRefPtr<NodeList> Node::getElementsByName(const String& elementName) | 1221 PassRefPtr<NodeList> Node::getElementsByName(const String& elementName) |
1222 { | 1222 { |
1223 return ensureRareData().ensureNodeLists()->addCacheWithAtomicName<NameNodeLi
st>(this, NameNodeListType, elementName); | 1223 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeLis
t>(this, NameNodeListType, elementName); |
1224 } | 1224 } |
1225 | 1225 |
1226 PassRefPtr<NodeList> Node::getElementsByClassName(const String& classNames) | 1226 PassRefPtr<NodeList> Node::getElementsByClassName(const String& classNames) |
1227 { | 1227 { |
1228 return ensureRareData().ensureNodeLists()->addCacheWithName<ClassNodeList>(t
his, ClassNodeListType, classNames); | 1228 return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(th
is, ClassNodeListType, classNames); |
1229 } | 1229 } |
1230 | 1230 |
1231 PassRefPtr<RadioNodeList> Node::radioNodeList(const AtomicString& name) | 1231 PassRefPtr<RadioNodeList> Node::radioNodeList(const AtomicString& name) |
1232 { | 1232 { |
1233 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag)); | 1233 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag)); |
1234 return ensureRareData().ensureNodeLists()->addCacheWithAtomicName<RadioNodeL
ist>(this, RadioNodeListType, name); | 1234 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeLi
st>(this, RadioNodeListType, name); |
1235 } | 1235 } |
1236 | 1236 |
1237 PassRefPtr<Element> Node::querySelector(const AtomicString& selectors, Exception
State& es) | 1237 PassRefPtr<Element> Node::querySelector(const AtomicString& selectors, Exception
State& es) |
1238 { | 1238 { |
1239 if (selectors.isEmpty()) { | 1239 if (selectors.isEmpty()) { |
1240 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("qu
erySelector", "Node", "The provided selector is empty.")); | 1240 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("qu
erySelector", "Node", "The provided selector is empty.")); |
1241 return 0; | 1241 return 0; |
1242 } | 1242 } |
1243 | 1243 |
1244 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector
s, document(), es); | 1244 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector
s, document(), es); |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 collectMatchingObserversForMutation(observers, transientMutationObserverRegi
stry(), this, type, attributeName); | 2153 collectMatchingObserversForMutation(observers, transientMutationObserverRegi
stry(), this, type, attributeName); |
2154 for (Node* node = parentNode(); node; node = node->parentNode()) { | 2154 for (Node* node = parentNode(); node; node = node->parentNode()) { |
2155 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), this, type, attributeName); | 2155 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), this, type, attributeName); |
2156 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), this, type, attributeName); | 2156 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), this, type, attributeName); |
2157 } | 2157 } |
2158 } | 2158 } |
2159 | 2159 |
2160 void Node::registerMutationObserver(MutationObserver* observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) | 2160 void Node::registerMutationObserver(MutationObserver* observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) |
2161 { | 2161 { |
2162 MutationObserverRegistration* registration = 0; | 2162 MutationObserverRegistration* registration = 0; |
2163 Vector<OwnPtr<MutationObserverRegistration> >& registry = ensureRareData().e
nsureMutationObserverData()->registry; | 2163 Vector<OwnPtr<MutationObserverRegistration> >& registry = ensureRareData().e
nsureMutationObserverData().registry; |
2164 for (size_t i = 0; i < registry.size(); ++i) { | 2164 for (size_t i = 0; i < registry.size(); ++i) { |
2165 if (registry[i]->observer() == observer) { | 2165 if (registry[i]->observer() == observer) { |
2166 registration = registry[i].get(); | 2166 registration = registry[i].get(); |
2167 registration->resetObservation(options, attributeFilter); | 2167 registration->resetObservation(options, attributeFilter); |
2168 } | 2168 } |
2169 } | 2169 } |
2170 | 2170 |
2171 if (!registration) { | 2171 if (!registration) { |
2172 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); | 2172 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); |
2173 registration = registry.last().get(); | 2173 registration = registry.last().get(); |
(...skipping 16 matching lines...) Expand all Loading... |
2190 | 2190 |
2191 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes | 2191 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes |
2192 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). | 2192 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). |
2193 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. | 2193 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. |
2194 RefPtr<Node> protect(this); | 2194 RefPtr<Node> protect(this); |
2195 registry->remove(index); | 2195 registry->remove(index); |
2196 } | 2196 } |
2197 | 2197 |
2198 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis
tration) | 2198 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis
tration) |
2199 { | 2199 { |
2200 ensureRareData().ensureMutationObserverData()->transientRegistry.add(registr
ation); | 2200 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra
tion); |
2201 } | 2201 } |
2202 | 2202 |
2203 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg
istration) | 2203 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg
istration) |
2204 { | 2204 { |
2205 HashSet<MutationObserverRegistration*>* transientRegistry = transientMutatio
nObserverRegistry(); | 2205 HashSet<MutationObserverRegistration*>* transientRegistry = transientMutatio
nObserverRegistry(); |
2206 ASSERT(transientRegistry); | 2206 ASSERT(transientRegistry); |
2207 if (!transientRegistry) | 2207 if (!transientRegistry) |
2208 return; | 2208 return; |
2209 | 2209 |
2210 ASSERT(transientRegistry->contains(registration)); | 2210 ASSERT(transientRegistry->contains(registration)); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2624 node->showTreeForThis(); | 2624 node->showTreeForThis(); |
2625 } | 2625 } |
2626 | 2626 |
2627 void showNodePath(const WebCore::Node* node) | 2627 void showNodePath(const WebCore::Node* node) |
2628 { | 2628 { |
2629 if (node) | 2629 if (node) |
2630 node->showNodePathForThis(); | 2630 node->showNodePathForThis(); |
2631 } | 2631 } |
2632 | 2632 |
2633 #endif | 2633 #endif |
OLD | NEW |