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

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

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

Powered by Google App Engine
This is Rietveld 408576698