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

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: 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 RELEASE_ASSERT(!renderer()); 268 RELEASE_ASSERT(!renderer());
269 269
270 if (!isContainerNode()) 270 if (!isContainerNode())
271 willBeDeletedFromDocument(); 271 willBeDeletedFromDocument();
272 272
273 if (m_previous) 273 if (m_previous)
274 m_previous->setNextSibling(0); 274 m_previous->setNextSibling(0);
275 if (m_next) 275 if (m_next)
276 m_next->setPreviousSibling(0); 276 m_next->setPreviousSibling(0);
277 277
278 #if !ENABLE(OILPAN)
278 if (m_treeScope) 279 if (m_treeScope)
279 m_treeScope->guardDeref(); 280 m_treeScope->guardDeref();
281 #endif
280 282
281 InspectorCounters::decrementCounter(InspectorCounters::NodeCounter); 283 InspectorCounters::decrementCounter(InspectorCounters::NodeCounter);
282 } 284 }
283 285
284 void Node::willBeDeletedFromDocument() 286 void Node::willBeDeletedFromDocument()
285 { 287 {
288 #if !ENABLE(OILPAN)
286 if (!isTreeScopeInitialized()) 289 if (!isTreeScopeInitialized())
287 return; 290 return;
288 291
289 Document& document = this->document(); 292 Document& document = this->document();
290 293
291 if (hasEventTargetData()) { 294 if (hasEventTargetData()) {
292 clearEventTargetData(); 295 clearEventTargetData();
293 document.didClearTouchEventHandlers(this); 296 document.didClearTouchEventHandlers(this);
294 } 297 }
295 298
296 if (AXObjectCache* cache = document.existingAXObjectCache()) 299 if (AXObjectCache* cache = document.existingAXObjectCache())
297 cache->remove(this); 300 cache->remove(this);
298 301
299 document.markers().removeMarkers(this); 302 document.markers().removeMarkers(this);
303 #endif
300 } 304 }
301 305
302 NodeRareData* Node::rareData() const 306 NodeRareData* Node::rareData() const
303 { 307 {
304 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData()); 308 ASSERT_WITH_SECURITY_IMPLICATION(hasRareData());
305 return static_cast<NodeRareData*>(m_data.m_rareData); 309 return static_cast<NodeRareData*>(m_data.m_rareData);
306 } 310 }
307 311
308 NodeRareData& Node::ensureRareData() 312 NodeRareData& Node::ensureRareData()
309 { 313 {
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 2006
2003 void Node::removeAllEventListenersRecursively() 2007 void Node::removeAllEventListenersRecursively()
2004 { 2008 {
2005 for (Node* node = this; node; node = NodeTraversal::next(*node)) { 2009 for (Node* node = this; node; node = NodeTraversal::next(*node)) {
2006 node->removeAllEventListeners(); 2010 node->removeAllEventListeners();
2007 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o lderShadowRoot()) 2011 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o lderShadowRoot())
2008 root->removeAllEventListenersRecursively(); 2012 root->removeAllEventListenersRecursively();
2009 } 2013 }
2010 } 2014 }
2011 2015
2012 typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap; 2016 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Node>, OwnPtr<EventTargetData> > EventTargetDataMap;
2013 2017
2014 static EventTargetDataMap& eventTargetDataMap() 2018 static EventTargetDataMap& eventTargetDataMap()
2015 { 2019 {
2020 #if ENABLE(OILPAN)
2021 DEFINE_STATIC_LOCAL(Persistent<EventTargetDataMap>, map, (new EventTargetDat aMap()));
2022 return *map;
2023 #else
2016 DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ()); 2024 DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ());
2017 return map; 2025 return map;
2026 #endif
2018 } 2027 }
2019 2028
2020 EventTargetData* Node::eventTargetData() 2029 EventTargetData* Node::eventTargetData()
2021 { 2030 {
2022 return hasEventTargetData() ? eventTargetDataMap().get(this) : 0; 2031 return hasEventTargetData() ? eventTargetDataMap().get(this) : 0;
2023 } 2032 }
2024 2033
2025 EventTargetData& Node::ensureEventTargetData() 2034 EventTargetData& Node::ensureEventTargetData()
2026 { 2035 {
2027 if (hasEventTargetData()) 2036 if (hasEventTargetData())
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 } 2336 }
2328 2337
2329 bool Node::willRespondToTouchEvents() 2338 bool Node::willRespondToTouchEvents()
2330 { 2339 {
2331 if (isDisabledFormControl(this)) 2340 if (isDisabledFormControl(this))
2332 return false; 2341 return false;
2333 return hasEventListeners(EventTypeNames::touchstart) || hasEventListeners(Ev entTypeNames::touchmove) || hasEventListeners(EventTypeNames::touchcancel) || ha sEventListeners(EventTypeNames::touchend); 2342 return hasEventListeners(EventTypeNames::touchstart) || hasEventListeners(Ev entTypeNames::touchmove) || hasEventListeners(EventTypeNames::touchcancel) || ha sEventListeners(EventTypeNames::touchend);
2334 } 2343 }
2335 2344
2336 // This is here for inlining 2345 // This is here for inlining
2346 #if ENABLE(OILPAN)
2347 inline void TreeScope::removedLastRefToScope()
2348 {
2349 dispose();
2350 }
2351 #else
2337 inline void TreeScope::removedLastRefToScope() 2352 inline void TreeScope::removedLastRefToScope()
2338 { 2353 {
2339 ASSERT_WITH_SECURITY_IMPLICATION(!deletionHasBegun()); 2354 ASSERT_WITH_SECURITY_IMPLICATION(!deletionHasBegun());
2340 if (m_guardRefCount) { 2355 if (m_guardRefCount) {
2341 // If removing a child removes the last self-only ref, we don't 2356 // If removing a child removes the last self-only ref, we don't
2342 // want the scope to be destructed until after 2357 // want the scope to be destructed until after
2343 // removeDetachedChildren returns, so we guard ourselves with an 2358 // removeDetachedChildren returns, so we guard ourselves with an
2344 // extra self-only ref. 2359 // extra self-only ref.
2345 guardRef(); 2360 guardRef();
2346 dispose(); 2361 dispose();
2347 #if !ASSERT_DISABLED 2362 #if !ASSERT_DISABLED
2348 // We need to do this right now since guardDeref() can delete this. 2363 // We need to do this right now since guardDeref() can delete this.
2349 rootNode().m_inRemovedLastRefFunction = false; 2364 rootNode().m_inRemovedLastRefFunction = false;
2350 #endif 2365 #endif
2351 guardDeref(); 2366 guardDeref();
2352 } else { 2367 } else {
2353 #if !ASSERT_DISABLED 2368 #if !ASSERT_DISABLED
2354 rootNode().m_inRemovedLastRefFunction = false; 2369 rootNode().m_inRemovedLastRefFunction = false;
2355 #endif 2370 #endif
2356 #if !ENABLE(OILPAN)
2357 #if SECURITY_ASSERT_ENABLED 2371 #if SECURITY_ASSERT_ENABLED
2358 beginDeletion(); 2372 beginDeletion();
2359 #endif 2373 #endif
2360 delete this; 2374 delete this;
2361 #endif
2362 } 2375 }
2363 } 2376 }
2377 #endif
2364 2378
2365 // It's important not to inline removedLastRef, because we don't want to inline the code to 2379 // It's important not to inline removedLastRef, because we don't want to inline the code to
2366 // delete a Node at each deref call site. 2380 // delete a Node at each deref call site.
2367 void Node::removedLastRef() 2381 void Node::removedLastRef()
2368 { 2382 {
2369 // An explicit check for Document here is better than a virtual function sin ce it is 2383 // An explicit check for Document here is better than a virtual function sin ce it is
2370 // faster for non-Document nodes, and because the call to removedLastRef tha t is inlined 2384 // faster for non-Document nodes, and because the call to removedLastRef tha t is inlined
2371 // at all deref call sites is smaller if it's a non-virtual function. 2385 // at all deref call sites is smaller if it's a non-virtual function.
2372 if (isTreeScope()) { 2386 if (isTreeScope()) {
2373 treeScope().removedLastRefToScope(); 2387 treeScope().removedLastRefToScope();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 } 2529 }
2516 2530
2517 ASSERT(isHTMLElement() || isSVGElement()); 2531 ASSERT(isHTMLElement() || isSVGElement());
2518 setFlag(CustomElement); 2532 setFlag(CustomElement);
2519 setFlag(newState == Upgraded, CustomElementUpgraded); 2533 setFlag(newState == Upgraded, CustomElementUpgraded);
2520 2534
2521 if (oldState == NotCustomElement || newState == Upgraded) 2535 if (oldState == NotCustomElement || newState == Upgraded)
2522 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed 2536 setNeedsStyleRecalc(SubtreeStyleChange); // :unresolved has changed
2523 } 2537 }
2524 2538
2539 void Node::trace(Visitor* visitor)
2540 {
2541 visitor->trace(m_treeScope);
2542 }
2543
2525 } // namespace WebCore 2544 } // namespace WebCore
2526 2545
2527 #ifndef NDEBUG 2546 #ifndef NDEBUG
2528 2547
2529 void showNode(const WebCore::Node* node) 2548 void showNode(const WebCore::Node* node)
2530 { 2549 {
2531 if (node) 2550 if (node)
2532 node->showNode(""); 2551 node->showNode("");
2533 } 2552 }
2534 2553
2535 void showTree(const WebCore::Node* node) 2554 void showTree(const WebCore::Node* node)
2536 { 2555 {
2537 if (node) 2556 if (node)
2538 node->showTreeForThis(); 2557 node->showTreeForThis();
2539 } 2558 }
2540 2559
2541 void showNodePath(const WebCore::Node* node) 2560 void showNodePath(const WebCore::Node* node)
2542 { 2561 {
2543 if (node) 2562 if (node)
2544 node->showNodePathForThis(); 2563 node->showNodePathForThis();
2545 } 2564 }
2546 2565
2547 #endif 2566 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698