| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 Node::~Node() | 259 Node::~Node() |
| 260 { | 260 { |
| 261 #ifndef NDEBUG | 261 #ifndef NDEBUG |
| 262 nodeCounter.decrement(); | 262 nodeCounter.decrement(); |
| 263 #endif | 263 #endif |
| 264 | 264 |
| 265 #if DUMP_NODE_STATISTICS | 265 #if DUMP_NODE_STATISTICS |
| 266 liveNodeSet.remove(this); | 266 liveNodeSet.remove(this); |
| 267 #endif | 267 #endif |
| 268 | 268 |
| 269 #if !ENABLE(OILPAN) |
| 269 if (hasRareData()) | 270 if (hasRareData()) |
| 270 clearRareData(); | 271 clearRareData(); |
| 271 | 272 |
| 272 RELEASE_ASSERT(!renderer()); | 273 RELEASE_ASSERT(!renderer()); |
| 273 | 274 |
| 274 #if !ENABLE(OILPAN) | |
| 275 if (!isContainerNode()) | 275 if (!isContainerNode()) |
| 276 willBeDeletedFromDocument(); | 276 willBeDeletedFromDocument(); |
| 277 | 277 |
| 278 if (m_previous) | 278 if (m_previous) |
| 279 m_previous->setNextSibling(0); | 279 m_previous->setNextSibling(0); |
| 280 if (m_next) | 280 if (m_next) |
| 281 m_next->setPreviousSibling(0); | 281 m_next->setPreviousSibling(0); |
| 282 | 282 |
| 283 if (m_treeScope) | 283 if (m_treeScope) |
| 284 m_treeScope->guardDeref(); | 284 m_treeScope->guardDeref(); |
| 285 #else |
| 286 // With Oilpan, the rare data finalizer also asserts for |
| 287 // this condition (we cannot directly access it here.) |
| 288 RELEASE_ASSERT(hasRareData() || !renderer()); |
| 285 #endif | 289 #endif |
| 286 | 290 |
| 287 InspectorCounters::decrementCounter(InspectorCounters::NodeCounter); | 291 InspectorCounters::decrementCounter(InspectorCounters::NodeCounter); |
| 288 | 292 |
| 289 if (getFlag(HasWeakReferencesFlag)) | 293 if (getFlag(HasWeakReferencesFlag)) |
| 290 WeakNodeMap::notifyNodeDestroyed(this); | 294 WeakNodeMap::notifyNodeDestroyed(this); |
| 291 } | 295 } |
| 292 | 296 |
| 293 #if !ENABLE(OILPAN) | 297 #if !ENABLE(OILPAN) |
| 294 // With Oilpan all of this is handled with weak processing of the document. | 298 // With Oilpan all of this is handled with weak processing of the document. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 317 { | 321 { |
| 318 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); | 322 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); |
| 319 return static_cast<NodeRareData*>(m_data.m_rareData); | 323 return static_cast<NodeRareData*>(m_data.m_rareData); |
| 320 } | 324 } |
| 321 | 325 |
| 322 NodeRareData& Node::ensureRareData() | 326 NodeRareData& Node::ensureRareData() |
| 323 { | 327 { |
| 324 if (hasRareData()) | 328 if (hasRareData()) |
| 325 return *rareData(); | 329 return *rareData(); |
| 326 | 330 |
| 327 NodeRareData* data; | |
| 328 if (isElementNode()) | 331 if (isElementNode()) |
| 329 data = ElementRareData::create(m_data.m_renderer).leakPtr(); | 332 m_data.m_rareData = ElementRareData::create(m_data.m_renderer); |
| 330 else | 333 else |
| 331 data = NodeRareData::create(m_data.m_renderer).leakPtr(); | 334 m_data.m_rareData = NodeRareData::create(m_data.m_renderer); |
| 332 ASSERT(data); | |
| 333 | 335 |
| 334 m_data.m_rareData = data; | 336 ASSERT(m_data.m_rareData); |
| 337 |
| 335 setFlag(HasRareDataFlag); | 338 setFlag(HasRareDataFlag); |
| 336 return *data; | 339 return *rareData(); |
| 337 } | 340 } |
| 338 | 341 |
| 342 #if !ENABLE(OILPAN) |
| 339 void Node::clearRareData() | 343 void Node::clearRareData() |
| 340 { | 344 { |
| 341 ASSERT(hasRareData()); | 345 ASSERT(hasRareData()); |
| 342 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi
stry()->isEmpty()); | 346 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi
stry()->isEmpty()); |
| 343 | 347 |
| 344 RenderObject* renderer = m_data.m_rareData->renderer(); | 348 RenderObject* renderer = m_data.m_rareData->renderer(); |
| 345 if (isElementNode()) { | 349 if (isElementNode()) |
| 346 ElementRareData* rareData = static_cast<ElementRareData*>(m_data.m_rareD
ata); | 350 delete static_cast<ElementRareData*>(m_data.m_rareData); |
| 347 rareData->dispose(); | 351 else |
| 348 delete rareData; | 352 delete static_cast<NodeRareData*>(m_data.m_rareData); |
| 349 } else { | |
| 350 NodeRareData* rareData = static_cast<NodeRareData*>(m_data.m_rareData); | |
| 351 rareData->dispose(); | |
| 352 delete rareData; | |
| 353 } | |
| 354 m_data.m_renderer = renderer; | 353 m_data.m_renderer = renderer; |
| 355 clearFlag(HasRareDataFlag); | 354 clearFlag(HasRareDataFlag); |
| 356 } | 355 } |
| 356 #endif |
| 357 | 357 |
| 358 Node* Node::toNode() | 358 Node* Node::toNode() |
| 359 { | 359 { |
| 360 return this; | 360 return this; |
| 361 } | 361 } |
| 362 | 362 |
| 363 short Node::tabIndex() const | 363 short Node::tabIndex() const |
| 364 { | 364 { |
| 365 return 0; | 365 return 0; |
| 366 } | 366 } |
| (...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 MutationObserverRegistration* registration = 0; | 2129 MutationObserverRegistration* registration = 0; |
| 2130 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >& registr
y = ensureRareData().ensureMutationObserverData().registry; | 2130 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >& registr
y = ensureRareData().ensureMutationObserverData().registry; |
| 2131 for (size_t i = 0; i < registry.size(); ++i) { | 2131 for (size_t i = 0; i < registry.size(); ++i) { |
| 2132 if (®istry[i]->observer() == &observer) { | 2132 if (®istry[i]->observer() == &observer) { |
| 2133 registration = registry[i].get(); | 2133 registration = registry[i].get(); |
| 2134 registration->resetObservation(options, attributeFilter); | 2134 registration->resetObservation(options, attributeFilter); |
| 2135 } | 2135 } |
| 2136 } | 2136 } |
| 2137 | 2137 |
| 2138 if (!registration) { | 2138 if (!registration) { |
| 2139 registry.append(MutationObserverRegistration::create(observer, *this, op
tions, attributeFilter)); | 2139 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); |
| 2140 registration = registry.last().get(); | 2140 registration = registry.last().get(); |
| 2141 } | 2141 } |
| 2142 | 2142 |
| 2143 document().addMutationObserverTypes(registration->mutationTypes()); | 2143 document().addMutationObserverTypes(registration->mutationTypes()); |
| 2144 } | 2144 } |
| 2145 | 2145 |
| 2146 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) | 2146 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) |
| 2147 { | 2147 { |
| 2148 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registr
y = mutationObserverRegistry(); | 2148 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registr
y = mutationObserverRegistry(); |
| 2149 ASSERT(registry); | 2149 ASSERT(registry); |
| 2150 if (!registry) | 2150 if (!registry) |
| 2151 return; | 2151 return; |
| 2152 | 2152 |
| 2153 size_t index = registry->find(registration); | 2153 size_t index = registry->find(registration); |
| 2154 ASSERT(index != kNotFound); | 2154 ASSERT(index != kNotFound); |
| 2155 if (index == kNotFound) | 2155 if (index == kNotFound) |
| 2156 return; | 2156 return; |
| 2157 | 2157 |
| 2158 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes | 2158 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes |
| 2159 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). | 2159 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). |
| 2160 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. | 2160 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. |
| 2161 RefPtr<Node> protect(this); | 2161 RefPtr<Node> protect(this); |
| 2162 // The explicit dispose() is motivated by Oilpan; the registration | 2162 #if ENABLE(OILPAN) |
| 2163 // object needs to unregister itself promptly. | 2163 // The explicit dispose() is needed to have the registration |
| 2164 // object unregister itself promptly. |
| 2164 registration->dispose(); | 2165 registration->dispose(); |
| 2166 #endif |
| 2165 registry->remove(index); | 2167 registry->remove(index); |
| 2166 } | 2168 } |
| 2167 | 2169 |
| 2168 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis
tration) | 2170 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis
tration) |
| 2169 { | 2171 { |
| 2170 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra
tion); | 2172 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra
tion); |
| 2171 } | 2173 } |
| 2172 | 2174 |
| 2173 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg
istration) | 2175 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg
istration) |
| 2174 { | 2176 { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2558 | 2560 |
| 2559 if (oldState == NotCustomElement || newState == Upgraded) | 2561 if (oldState == NotCustomElement || newState == Upgraded) |
| 2560 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed | 2562 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed |
| 2561 } | 2563 } |
| 2562 | 2564 |
| 2563 void Node::trace(Visitor* visitor) | 2565 void Node::trace(Visitor* visitor) |
| 2564 { | 2566 { |
| 2565 visitor->trace(m_parentOrShadowHostNode); | 2567 visitor->trace(m_parentOrShadowHostNode); |
| 2566 visitor->trace(m_previous); | 2568 visitor->trace(m_previous); |
| 2567 visitor->trace(m_next); | 2569 visitor->trace(m_next); |
| 2570 if (hasRareData()) |
| 2571 visitor->trace(rareData()); |
| 2572 |
| 2568 visitor->trace(m_treeScope); | 2573 visitor->trace(m_treeScope); |
| 2569 } | 2574 } |
| 2570 | 2575 |
| 2571 } // namespace WebCore | 2576 } // namespace WebCore |
| 2572 | 2577 |
| 2573 #ifndef NDEBUG | 2578 #ifndef NDEBUG |
| 2574 | 2579 |
| 2575 void showNode(const WebCore::Node* node) | 2580 void showNode(const WebCore::Node* node) |
| 2576 { | 2581 { |
| 2577 if (node) | 2582 if (node) |
| 2578 node->showNode(""); | 2583 node->showNode(""); |
| 2579 } | 2584 } |
| 2580 | 2585 |
| 2581 void showTree(const WebCore::Node* node) | 2586 void showTree(const WebCore::Node* node) |
| 2582 { | 2587 { |
| 2583 if (node) | 2588 if (node) |
| 2584 node->showTreeForThis(); | 2589 node->showTreeForThis(); |
| 2585 } | 2590 } |
| 2586 | 2591 |
| 2587 void showNodePath(const WebCore::Node* node) | 2592 void showNodePath(const WebCore::Node* node) |
| 2588 { | 2593 { |
| 2589 if (node) | 2594 if (node) |
| 2590 node->showNodePathForThis(); | 2595 node->showNodePathForThis(); |
| 2591 } | 2596 } |
| 2592 | 2597 |
| 2593 #endif | 2598 #endif |
| OLD | NEW |