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 #else | |
278 // With Oilpan, the rare data finalizer also asserts for | |
279 // this condition (we cannot directly access it here.) | |
280 RELEASE_ASSERT(hasRareData() || !renderer()); | |
277 #endif | 281 #endif |
278 | 282 |
279 if (m_previous) | 283 if (m_previous) |
280 m_previous->setNextSibling(0); | 284 m_previous->setNextSibling(0); |
281 if (m_next) | 285 if (m_next) |
282 m_next->setPreviousSibling(0); | 286 m_next->setPreviousSibling(0); |
283 | 287 |
284 #if !ENABLE(OILPAN) | 288 #if !ENABLE(OILPAN) |
285 if (m_treeScope) | 289 if (m_treeScope) |
286 m_treeScope->guardDeref(); | 290 m_treeScope->guardDeref(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 { | 323 { |
320 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); | 324 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); |
321 return static_cast<NodeRareData*>(m_data.m_rareData); | 325 return static_cast<NodeRareData*>(m_data.m_rareData); |
322 } | 326 } |
323 | 327 |
324 NodeRareData& Node::ensureRareData() | 328 NodeRareData& Node::ensureRareData() |
325 { | 329 { |
326 if (hasRareData()) | 330 if (hasRareData()) |
327 return *rareData(); | 331 return *rareData(); |
328 | 332 |
329 NodeRareData* data; | |
330 if (isElementNode()) | 333 if (isElementNode()) |
331 data = ElementRareData::create(m_data.m_renderer).leakPtr(); | 334 m_data.m_rareData = ElementRareData::create(m_data.m_renderer); |
332 else | 335 else |
333 data = NodeRareData::create(m_data.m_renderer).leakPtr(); | 336 m_data.m_rareData = NodeRareData::create(m_data.m_renderer); |
334 ASSERT(data); | |
335 | 337 |
336 m_data.m_rareData = data; | 338 ASSERT(m_data.m_rareData); |
339 | |
337 setFlag(HasRareDataFlag); | 340 setFlag(HasRareDataFlag); |
338 return *data; | 341 return *rareData(); |
339 } | 342 } |
340 | 343 |
344 #if !ENABLE(OILPAN) | |
341 void Node::clearRareData() | 345 void Node::clearRareData() |
342 { | 346 { |
343 ASSERT(hasRareData()); | 347 ASSERT(hasRareData()); |
344 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi stry()->isEmpty()); | 348 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi stry()->isEmpty()); |
haraken
2014/05/05 16:54:52
I'd like to keep this ASSERT somewhere. The ASSERT
haraken
2014/05/05 16:59:33
^^^ Ignore this comment. This comment is inconsist
| |
345 | 349 |
346 RenderObject* renderer = m_data.m_rareData->renderer(); | 350 RenderObject* renderer = m_data.m_rareData->renderer(); |
347 if (isElementNode()) { | 351 if (isElementNode()) |
348 ElementRareData* rareData = static_cast<ElementRareData*>(m_data.m_rareD ata); | 352 delete static_cast<ElementRareData*>(m_data.m_rareData); |
349 rareData->dispose(); | 353 else |
350 delete rareData; | 354 delete static_cast<NodeRareData*>(m_data.m_rareData); |
351 } else { | |
352 NodeRareData* rareData = static_cast<NodeRareData*>(m_data.m_rareData); | |
353 rareData->dispose(); | |
354 delete rareData; | |
355 } | |
356 m_data.m_renderer = renderer; | 355 m_data.m_renderer = renderer; |
357 clearFlag(HasRareDataFlag); | 356 clearFlag(HasRareDataFlag); |
358 } | 357 } |
358 #endif | |
359 | 359 |
360 Node* Node::toNode() | 360 Node* Node::toNode() |
361 { | 361 { |
362 return this; | 362 return this; |
363 } | 363 } |
364 | 364 |
365 short Node::tabIndex() const | 365 short Node::tabIndex() const |
366 { | 366 { |
367 return 0; | 367 return 0; |
368 } | 368 } |
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2131 MutationObserverRegistration* registration = 0; | 2131 MutationObserverRegistration* registration = 0; |
2132 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >& registr y = ensureRareData().ensureMutationObserverData().registry; | 2132 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >& registr y = ensureRareData().ensureMutationObserverData().registry; |
2133 for (size_t i = 0; i < registry.size(); ++i) { | 2133 for (size_t i = 0; i < registry.size(); ++i) { |
2134 if (®istry[i]->observer() == &observer) { | 2134 if (®istry[i]->observer() == &observer) { |
2135 registration = registry[i].get(); | 2135 registration = registry[i].get(); |
2136 registration->resetObservation(options, attributeFilter); | 2136 registration->resetObservation(options, attributeFilter); |
2137 } | 2137 } |
2138 } | 2138 } |
2139 | 2139 |
2140 if (!registration) { | 2140 if (!registration) { |
2141 registry.append(MutationObserverRegistration::create(observer, *this, op tions, attributeFilter)); | 2141 registry.append(MutationObserverRegistration::create(observer, this, opt ions, attributeFilter)); |
2142 registration = registry.last().get(); | 2142 registration = registry.last().get(); |
2143 } | 2143 } |
2144 | 2144 |
2145 document().addMutationObserverTypes(registration->mutationTypes()); | 2145 document().addMutationObserverTypes(registration->mutationTypes()); |
2146 } | 2146 } |
2147 | 2147 |
2148 void Node::unregisterMutationObserver(MutationObserverRegistration* registration ) | 2148 void Node::unregisterMutationObserver(MutationObserverRegistration* registration ) |
2149 { | 2149 { |
2150 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registr y = mutationObserverRegistry(); | 2150 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registr y = mutationObserverRegistry(); |
2151 ASSERT(registry); | 2151 ASSERT(registry); |
2152 if (!registry) | 2152 if (!registry) |
2153 return; | 2153 return; |
2154 | 2154 |
2155 size_t index = registry->find(registration); | 2155 size_t index = registry->find(registration); |
2156 ASSERT(index != kNotFound); | 2156 ASSERT(index != kNotFound); |
2157 if (index == kNotFound) | 2157 if (index == kNotFound) |
2158 return; | 2158 return; |
2159 | 2159 |
2160 // Deleting the registration may cause this node to be derefed, so we must m ake sure the Vector operation completes | 2160 // Deleting the registration may cause this node to be derefed, so we must m ake sure the Vector operation completes |
2161 // before that, in case |this| is destroyed (see MutationObserverRegistratio n::m_registrationNodeKeepAlive). | 2161 // before that, in case |this| is destroyed (see MutationObserverRegistratio n::m_registrationNodeKeepAlive). |
2162 // FIXME: Simplify the registration/transient registration logic to make thi s understandable by humans. | 2162 // FIXME: Simplify the registration/transient registration logic to make thi s understandable by humans. |
2163 RefPtr<Node> protect(this); | 2163 RefPtr<Node> protect(this); |
2164 // The explicit dispose() is motivated by Oilpan; the registration | 2164 #if ENABLE(OILPAN) |
2165 // object needs to unregister itself promptly. | 2165 // The explicit dispose() is needed to have the registration |
2166 // object unregister itself promptly. | |
2166 registration->dispose(); | 2167 registration->dispose(); |
2168 #endif | |
2167 registry->remove(index); | 2169 registry->remove(index); |
2168 } | 2170 } |
2169 | 2171 |
2170 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis tration) | 2172 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis tration) |
2171 { | 2173 { |
2172 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra tion); | 2174 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra tion); |
2173 } | 2175 } |
2174 | 2176 |
2175 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg istration) | 2177 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg istration) |
2176 { | 2178 { |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2564 ASSERT(isHTMLElement() || isSVGElement()); | 2566 ASSERT(isHTMLElement() || isSVGElement()); |
2565 setFlag(CustomElementFlag); | 2567 setFlag(CustomElementFlag); |
2566 setFlag(newState == Upgraded, CustomElementUpgradedFlag); | 2568 setFlag(newState == Upgraded, CustomElementUpgradedFlag); |
2567 | 2569 |
2568 if (oldState == NotCustomElement || newState == Upgraded) | 2570 if (oldState == NotCustomElement || newState == Upgraded) |
2569 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed | 2571 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed |
2570 } | 2572 } |
2571 | 2573 |
2572 void Node::trace(Visitor* visitor) | 2574 void Node::trace(Visitor* visitor) |
2573 { | 2575 { |
2576 if (hasRareData()) | |
2577 visitor->trace(rareData()); | |
2578 | |
2574 visitor->trace(m_treeScope); | 2579 visitor->trace(m_treeScope); |
2575 } | 2580 } |
2576 | 2581 |
2577 } // namespace WebCore | 2582 } // namespace WebCore |
2578 | 2583 |
2579 #ifndef NDEBUG | 2584 #ifndef NDEBUG |
2580 | 2585 |
2581 void showNode(const WebCore::Node* node) | 2586 void showNode(const WebCore::Node* node) |
2582 { | 2587 { |
2583 if (node) | 2588 if (node) |
2584 node->showNode(""); | 2589 node->showNode(""); |
2585 } | 2590 } |
2586 | 2591 |
2587 void showTree(const WebCore::Node* node) | 2592 void showTree(const WebCore::Node* node) |
2588 { | 2593 { |
2589 if (node) | 2594 if (node) |
2590 node->showTreeForThis(); | 2595 node->showTreeForThis(); |
2591 } | 2596 } |
2592 | 2597 |
2593 void showNodePath(const WebCore::Node* node) | 2598 void showNodePath(const WebCore::Node* node) |
2594 { | 2599 { |
2595 if (node) | 2600 if (node) |
2596 node->showNodePathForThis(); | 2601 node->showNodePathForThis(); |
2597 } | 2602 } |
2598 | 2603 |
2599 #endif | 2604 #endif |
OLD | NEW |