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

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

Issue 262093006: Oilpan: Make the Node hierarchy RefCountedGarbageCollected instead of TreeShared. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address more comments. Created 6 years, 7 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) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #endif 80 #endif
81 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create()) 81 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
82 { 82 {
83 m_rootNode.setTreeScope(this); 83 m_rootNode.setTreeScope(this);
84 } 84 }
85 85
86 TreeScope::~TreeScope() 86 TreeScope::~TreeScope()
87 { 87 {
88 #if !ENABLE(OILPAN) 88 #if !ENABLE(OILPAN)
89 ASSERT(!m_guardRefCount); 89 ASSERT(!m_guardRefCount);
90 #endif
91 m_rootNode.setTreeScope(0); 90 m_rootNode.setTreeScope(0);
haraken 2014/05/06 04:20:16 You can remove this code because the root Node is
Mads Ager (chromium) 2014/05/06 08:26:00 Yes, it would. m_rootNode is a reference at this p
92 91
93 #if !ENABLE(OILPAN)
94 if (m_selection) { 92 if (m_selection) {
95 m_selection->clearTreeScope(); 93 m_selection->clearTreeScope();
96 m_selection = nullptr; 94 m_selection = nullptr;
97 } 95 }
98 96
99 if (m_parentTreeScope) 97 if (m_parentTreeScope)
100 m_parentTreeScope->guardDeref(); 98 m_parentTreeScope->guardDeref();
101 #endif 99 #endif
102 } 100 }
103 101
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 329
332 bool TreeScope::applyAuthorStyles() const 330 bool TreeScope::applyAuthorStyles() const
333 { 331 {
334 return rootNode().isDocumentNode(); 332 return rootNode().isDocumentNode();
335 } 333 }
336 334
337 void TreeScope::adoptIfNeeded(Node& node) 335 void TreeScope::adoptIfNeeded(Node& node)
338 { 336 {
339 ASSERT(this); 337 ASSERT(this);
340 ASSERT(!node.isDocumentNode()); 338 ASSERT(!node.isDocumentNode());
339 #if !ENABLE(OILPAN)
341 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun); 340 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun);
341 #endif
342 TreeScopeAdopter adopter(node, *this); 342 TreeScopeAdopter adopter(node, *this);
343 if (adopter.needsScopeChange()) 343 if (adopter.needsScopeChange())
344 adopter.execute(); 344 adopter.execute();
345 } 345 }
346 346
347 static Element* focusedFrameOwnerElement(LocalFrame* focusedFrame, LocalFrame* c urrentFrame) 347 static Element* focusedFrameOwnerElement(LocalFrame* focusedFrame, LocalFrame* c urrentFrame)
348 { 348 {
349 for (; focusedFrame; focusedFrame = focusedFrame->tree().parent()) { 349 for (; focusedFrame; focusedFrame = focusedFrame->tree().parent()) {
350 if (focusedFrame->tree().parent() == currentFrame) 350 if (focusedFrame->tree().parent() == currentFrame)
351 return focusedFrame->ownerElement(); 351 return focusedFrame->ownerElement();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 listTreeScopes(nodeB, treeScopesB); 472 listTreeScopes(nodeB, treeScopesB);
473 473
474 size_t indexA = treeScopesA.size(); 474 size_t indexA = treeScopesA.size();
475 size_t indexB = treeScopesB.size(); 475 size_t indexB = treeScopesB.size();
476 476
477 for (; indexA > 0 && indexB > 0 && treeScopesA[indexA - 1] == treeScopesB[in dexB - 1]; --indexA, --indexB) { } 477 for (; indexA > 0 && indexB > 0 && treeScopesA[indexA - 1] == treeScopesB[in dexB - 1]; --indexA, --indexB) { }
478 478
479 return treeScopesA[indexA] == treeScopesB[indexB] ? treeScopesA[indexA] : 0; 479 return treeScopesA[indexA] == treeScopesB[indexB] ? treeScopesA[indexA] : 0;
480 } 480 }
481 481
482 #if SECURITY_ASSERT_ENABLED 482 #if SECURITY_ASSERT_ENABLED && !ENABLE(OILPAN)
483 bool TreeScope::deletionHasBegun() 483 bool TreeScope::deletionHasBegun()
484 { 484 {
485 return rootNode().m_deletionHasBegun; 485 return rootNode().m_deletionHasBegun;
486 } 486 }
487 487
488 void TreeScope::beginDeletion() 488 void TreeScope::beginDeletion()
489 { 489 {
490 rootNode().m_deletionHasBegun = true; 490 rootNode().m_deletionHasBegun = true;
491 } 491 }
492 #endif 492 #endif
493 493
494 #if !ENABLE(OILPAN)
494 int TreeScope::refCount() const 495 int TreeScope::refCount() const
495 { 496 {
496 return rootNode().refCount(); 497 return rootNode().refCount();
497 } 498 }
499 #endif
498 500
499 bool TreeScope::isInclusiveAncestorOf(const TreeScope& scope) const 501 bool TreeScope::isInclusiveAncestorOf(const TreeScope& scope) const
500 { 502 {
501 for (const TreeScope* current = &scope; current; current = current->parentTr eeScope()) { 503 for (const TreeScope* current = &scope; current; current = current->parentTr eeScope()) {
502 if (current == this) 504 if (current == this)
503 return true; 505 return true;
504 } 506 }
505 return false; 507 return false;
506 } 508 }
507 509
(...skipping 20 matching lines...) Expand all
528 for (ShadowRoot* root = element->youngestShadowRoot(); root; root = root ->olderShadowRoot()) 530 for (ShadowRoot* root = element->youngestShadowRoot(); root; root = root ->olderShadowRoot())
529 root->setNeedsStyleRecalcForViewportUnits(); 531 root->setNeedsStyleRecalcForViewportUnits();
530 RenderStyle* style = element->renderStyle(); 532 RenderStyle* style = element->renderStyle();
531 if (style && style->hasViewportUnits()) 533 if (style && style->hasViewportUnits())
532 element->setNeedsStyleRecalc(LocalStyleChange); 534 element->setNeedsStyleRecalc(LocalStyleChange);
533 } 535 }
534 } 536 }
535 537
536 void TreeScope::trace(Visitor* visitor) 538 void TreeScope::trace(Visitor* visitor)
537 { 539 {
540 visitor->trace(&m_rootNode);
haraken 2014/05/06 04:20:16 This looks weird. Shall we change the reference ba
Mads Ager (chromium) 2014/05/06 08:26:00 Yes, done.
541 visitor->trace(m_document);
538 visitor->trace(m_parentTreeScope); 542 visitor->trace(m_parentTreeScope);
539 visitor->trace(m_selection); 543 visitor->trace(m_selection);
540 } 544 }
541 545
542 } // namespace WebCore 546 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698