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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 (hasRareData()) | 269 if (hasRareData()) |
270 clearRareData(); | 270 clearRareData(); |
271 | 271 |
272 RELEASE_ASSERT(!renderer()); | 272 RELEASE_ASSERT(!renderer()); |
273 | 273 |
| 274 #if !ENABLE(OILPAN) |
274 if (!isContainerNode()) | 275 if (!isContainerNode()) |
275 willBeDeletedFromDocument(); | 276 willBeDeletedFromDocument(); |
| 277 #endif |
276 | 278 |
277 if (m_previous) | 279 if (m_previous) |
278 m_previous->setNextSibling(0); | 280 m_previous->setNextSibling(0); |
279 if (m_next) | 281 if (m_next) |
280 m_next->setPreviousSibling(0); | 282 m_next->setPreviousSibling(0); |
281 | 283 |
| 284 #if !ENABLE(OILPAN) |
282 if (m_treeScope) | 285 if (m_treeScope) |
283 m_treeScope->guardDeref(); | 286 m_treeScope->guardDeref(); |
| 287 #endif |
284 | 288 |
285 InspectorCounters::decrementCounter(InspectorCounters::NodeCounter); | 289 InspectorCounters::decrementCounter(InspectorCounters::NodeCounter); |
286 | 290 |
287 if (getFlag(HasWeakReferences)) | 291 if (getFlag(HasWeakReferences)) |
288 WeakNodeMap::notifyNodeDestroyed(this); | 292 WeakNodeMap::notifyNodeDestroyed(this); |
289 } | 293 } |
290 | 294 |
| 295 #if !ENABLE(OILPAN) |
| 296 // With Oilpan all of this is handled with weak processing of the document. |
291 void Node::willBeDeletedFromDocument() | 297 void Node::willBeDeletedFromDocument() |
292 { | 298 { |
293 if (!isTreeScopeInitialized()) | 299 if (!isTreeScopeInitialized()) |
294 return; | 300 return; |
295 | 301 |
296 Document& document = this->document(); | 302 Document& document = this->document(); |
297 | 303 |
298 if (hasEventTargetData()) { | 304 if (hasEventTargetData()) { |
299 clearEventTargetData(); | 305 clearEventTargetData(); |
300 document.didClearTouchEventHandlers(this); | 306 document.didClearTouchEventHandlers(this); |
301 EventHandlerRegistry::from(document)->didRemoveAllEventHandlers(*this); | 307 EventHandlerRegistry::from(document)->didRemoveAllEventHandlers(*this); |
302 } | 308 } |
303 | 309 |
304 if (AXObjectCache* cache = document.existingAXObjectCache()) | 310 if (AXObjectCache* cache = document.existingAXObjectCache()) |
305 cache->remove(this); | 311 cache->remove(this); |
306 | 312 |
307 document.markers().removeMarkers(this); | 313 document.markers().removeMarkers(this); |
308 } | 314 } |
| 315 #endif |
309 | 316 |
310 NodeRareData* Node::rareData() const | 317 NodeRareData* Node::rareData() const |
311 { | 318 { |
312 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); | 319 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); |
313 return static_cast<NodeRareData*>(m_data.m_rareData); | 320 return static_cast<NodeRareData*>(m_data.m_rareData); |
314 } | 321 } |
315 | 322 |
316 NodeRareData& Node::ensureRareData() | 323 NodeRareData& Node::ensureRareData() |
317 { | 324 { |
318 if (hasRareData()) | 325 if (hasRareData()) |
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 | 2029 |
2023 void Node::removeAllEventListenersRecursively() | 2030 void Node::removeAllEventListenersRecursively() |
2024 { | 2031 { |
2025 for (Node* node = this; node; node = NodeTraversal::next(*node)) { | 2032 for (Node* node = this; node; node = NodeTraversal::next(*node)) { |
2026 node->removeAllEventListeners(); | 2033 node->removeAllEventListeners(); |
2027 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) | 2034 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) |
2028 root->removeAllEventListenersRecursively(); | 2035 root->removeAllEventListenersRecursively(); |
2029 } | 2036 } |
2030 } | 2037 } |
2031 | 2038 |
2032 typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap; | 2039 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Node>, OwnPtr<EventTargetData>
> EventTargetDataMap; |
2033 | 2040 |
2034 static EventTargetDataMap& eventTargetDataMap() | 2041 static EventTargetDataMap& eventTargetDataMap() |
2035 { | 2042 { |
| 2043 #if ENABLE(OILPAN) |
| 2044 DEFINE_STATIC_LOCAL(Persistent<EventTargetDataMap>, map, (new EventTargetDat
aMap())); |
| 2045 return *map; |
| 2046 #else |
2036 DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ()); | 2047 DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ()); |
2037 return map; | 2048 return map; |
| 2049 #endif |
2038 } | 2050 } |
2039 | 2051 |
2040 EventTargetData* Node::eventTargetData() | 2052 EventTargetData* Node::eventTargetData() |
2041 { | 2053 { |
2042 return hasEventTargetData() ? eventTargetDataMap().get(this) : 0; | 2054 return hasEventTargetData() ? eventTargetDataMap().get(this) : 0; |
2043 } | 2055 } |
2044 | 2056 |
2045 EventTargetData& Node::ensureEventTargetData() | 2057 EventTargetData& Node::ensureEventTargetData() |
2046 { | 2058 { |
2047 if (hasEventTargetData()) | 2059 if (hasEventTargetData()) |
2048 return *eventTargetDataMap().get(this); | 2060 return *eventTargetDataMap().get(this); |
2049 setHasEventTargetData(true); | 2061 setHasEventTargetData(true); |
2050 EventTargetData* data = new EventTargetData; | 2062 EventTargetData* data = new EventTargetData; |
2051 eventTargetDataMap().set(this, adoptPtr(data)); | 2063 eventTargetDataMap().set(this, adoptPtr(data)); |
2052 return *data; | 2064 return *data; |
2053 } | 2065 } |
2054 | 2066 |
| 2067 #if !ENABLE(OILPAN) |
2055 void Node::clearEventTargetData() | 2068 void Node::clearEventTargetData() |
2056 { | 2069 { |
2057 eventTargetDataMap().remove(this); | 2070 eventTargetDataMap().remove(this); |
2058 } | 2071 } |
| 2072 #endif |
2059 | 2073 |
2060 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* Node::mutat
ionObserverRegistry() | 2074 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* Node::mutat
ionObserverRegistry() |
2061 { | 2075 { |
2062 if (!hasRareData()) | 2076 if (!hasRareData()) |
2063 return 0; | 2077 return 0; |
2064 NodeMutationObserverData* data = rareData()->mutationObserverData(); | 2078 NodeMutationObserverData* data = rareData()->mutationObserverData(); |
2065 if (!data) | 2079 if (!data) |
2066 return 0; | 2080 return 0; |
2067 return &data->registry; | 2081 return &data->registry; |
2068 } | 2082 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 } | 2361 } |
2348 | 2362 |
2349 bool Node::willRespondToTouchEvents() | 2363 bool Node::willRespondToTouchEvents() |
2350 { | 2364 { |
2351 if (isDisabledFormControl(this)) | 2365 if (isDisabledFormControl(this)) |
2352 return false; | 2366 return false; |
2353 return hasEventListeners(EventTypeNames::touchstart) || hasEventListeners(Ev
entTypeNames::touchmove) || hasEventListeners(EventTypeNames::touchcancel) || ha
sEventListeners(EventTypeNames::touchend); | 2367 return hasEventListeners(EventTypeNames::touchstart) || hasEventListeners(Ev
entTypeNames::touchmove) || hasEventListeners(EventTypeNames::touchcancel) || ha
sEventListeners(EventTypeNames::touchend); |
2354 } | 2368 } |
2355 | 2369 |
2356 // This is here for inlining | 2370 // This is here for inlining |
| 2371 #if ENABLE(OILPAN) |
| 2372 inline void TreeScope::removedLastRefToScope() |
| 2373 { |
| 2374 dispose(); |
| 2375 } |
| 2376 #else |
2357 inline void TreeScope::removedLastRefToScope() | 2377 inline void TreeScope::removedLastRefToScope() |
2358 { | 2378 { |
2359 ASSERT_WITH_SECURITY_IMPLICATION(!deletionHasBegun()); | 2379 ASSERT_WITH_SECURITY_IMPLICATION(!deletionHasBegun()); |
2360 if (m_guardRefCount) { | 2380 if (m_guardRefCount) { |
2361 // If removing a child removes the last self-only ref, we don't | 2381 // If removing a child removes the last self-only ref, we don't |
2362 // want the scope to be destructed until after | 2382 // want the scope to be destructed until after |
2363 // removeDetachedChildren returns, so we guard ourselves with an | 2383 // removeDetachedChildren returns, so we guard ourselves with an |
2364 // extra self-only ref. | 2384 // extra self-only ref. |
2365 guardRef(); | 2385 guardRef(); |
2366 dispose(); | 2386 dispose(); |
2367 #if !ASSERT_DISABLED | 2387 #if !ASSERT_DISABLED |
2368 // We need to do this right now since guardDeref() can delete this. | 2388 // We need to do this right now since guardDeref() can delete this. |
2369 rootNode().m_inRemovedLastRefFunction = false; | 2389 rootNode().m_inRemovedLastRefFunction = false; |
2370 #endif | 2390 #endif |
2371 guardDeref(); | 2391 guardDeref(); |
2372 } else { | 2392 } else { |
2373 #if !ASSERT_DISABLED | 2393 #if !ASSERT_DISABLED |
2374 rootNode().m_inRemovedLastRefFunction = false; | 2394 rootNode().m_inRemovedLastRefFunction = false; |
2375 #endif | 2395 #endif |
2376 #if !ENABLE(OILPAN) | |
2377 #if SECURITY_ASSERT_ENABLED | 2396 #if SECURITY_ASSERT_ENABLED |
2378 beginDeletion(); | 2397 beginDeletion(); |
2379 #endif | 2398 #endif |
2380 delete this; | 2399 delete this; |
2381 #endif | |
2382 } | 2400 } |
2383 } | 2401 } |
| 2402 #endif |
2384 | 2403 |
2385 // It's important not to inline removedLastRef, because we don't want to inline
the code to | 2404 // It's important not to inline removedLastRef, because we don't want to inline
the code to |
2386 // delete a Node at each deref call site. | 2405 // delete a Node at each deref call site. |
2387 void Node::removedLastRef() | 2406 void Node::removedLastRef() |
2388 { | 2407 { |
2389 // An explicit check for Document here is better than a virtual function sin
ce it is | 2408 // An explicit check for Document here is better than a virtual function sin
ce it is |
2390 // faster for non-Document nodes, and because the call to removedLastRef tha
t is inlined | 2409 // faster for non-Document nodes, and because the call to removedLastRef tha
t is inlined |
2391 // at all deref call sites is smaller if it's a non-virtual function. | 2410 // at all deref call sites is smaller if it's a non-virtual function. |
2392 if (isTreeScope()) { | 2411 if (isTreeScope()) { |
2393 treeScope().removedLastRefToScope(); | 2412 treeScope().removedLastRefToScope(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 } | 2554 } |
2536 | 2555 |
2537 ASSERT(isHTMLElement() || isSVGElement()); | 2556 ASSERT(isHTMLElement() || isSVGElement()); |
2538 setFlag(CustomElement); | 2557 setFlag(CustomElement); |
2539 setFlag(newState == Upgraded, CustomElementUpgraded); | 2558 setFlag(newState == Upgraded, CustomElementUpgraded); |
2540 | 2559 |
2541 if (oldState == NotCustomElement || newState == Upgraded) | 2560 if (oldState == NotCustomElement || newState == Upgraded) |
2542 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed | 2561 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed |
2543 } | 2562 } |
2544 | 2563 |
| 2564 void Node::trace(Visitor* visitor) |
| 2565 { |
| 2566 visitor->trace(m_treeScope); |
| 2567 } |
| 2568 |
2545 } // namespace WebCore | 2569 } // namespace WebCore |
2546 | 2570 |
2547 #ifndef NDEBUG | 2571 #ifndef NDEBUG |
2548 | 2572 |
2549 void showNode(const WebCore::Node* node) | 2573 void showNode(const WebCore::Node* node) |
2550 { | 2574 { |
2551 if (node) | 2575 if (node) |
2552 node->showNode(""); | 2576 node->showNode(""); |
2553 } | 2577 } |
2554 | 2578 |
2555 void showTree(const WebCore::Node* node) | 2579 void showTree(const WebCore::Node* node) |
2556 { | 2580 { |
2557 if (node) | 2581 if (node) |
2558 node->showTreeForThis(); | 2582 node->showTreeForThis(); |
2559 } | 2583 } |
2560 | 2584 |
2561 void showNodePath(const WebCore::Node* node) | 2585 void showNodePath(const WebCore::Node* node) |
2562 { | 2586 { |
2563 if (node) | 2587 if (node) |
2564 node->showNodePathForThis(); | 2588 node->showNodePathForThis(); |
2565 } | 2589 } |
2566 | 2590 |
2567 #endif | 2591 #endif |
OLD | NEW |