| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "core/page/Page.h" | 49 #include "core/page/Page.h" |
| 50 #include "core/rendering/HitTestResult.h" | 50 #include "core/rendering/HitTestResult.h" |
| 51 #include "core/rendering/RenderView.h" | 51 #include "core/rendering/RenderView.h" |
| 52 #include "wtf/Vector.h" | 52 #include "wtf/Vector.h" |
| 53 | 53 |
| 54 namespace WebCore { | 54 namespace WebCore { |
| 55 | 55 |
| 56 using namespace HTMLNames; | 56 using namespace HTMLNames; |
| 57 | 57 |
| 58 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) | 58 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) |
| 59 : m_rootNode(rootNode) | 59 : m_rootNode(&rootNode) |
| 60 , m_document(&document) | 60 , m_document(&document) |
| 61 , m_parentTreeScope(&document) | 61 , m_parentTreeScope(&document) |
| 62 #if !ENABLE(OILPAN) | 62 #if !ENABLE(OILPAN) |
| 63 , m_guardRefCount(0) | 63 , m_guardRefCount(0) |
| 64 #endif | 64 #endif |
| 65 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create()) | 65 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create()) |
| 66 { | 66 { |
| 67 ASSERT(rootNode != document); | 67 ASSERT(rootNode != document); |
| 68 #if !ENABLE(OILPAN) | 68 #if !ENABLE(OILPAN) |
| 69 m_parentTreeScope->guardRef(); | 69 m_parentTreeScope->guardRef(); |
| 70 #endif | 70 #endif |
| 71 m_rootNode.setTreeScope(this); | 71 m_rootNode->setTreeScope(this); |
| 72 } | 72 } |
| 73 | 73 |
| 74 TreeScope::TreeScope(Document& document) | 74 TreeScope::TreeScope(Document& document) |
| 75 : m_rootNode(document) | 75 : m_rootNode(document) |
| 76 , m_document(&document) | 76 , m_document(&document) |
| 77 , m_parentTreeScope(nullptr) | 77 , m_parentTreeScope(nullptr) |
| 78 #if !ENABLE(OILPAN) | 78 #if !ENABLE(OILPAN) |
| 79 , m_guardRefCount(0) | 79 , m_guardRefCount(0) |
| 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 | 90 m_rootNode->setTreeScope(0); |
| 91 m_rootNode.setTreeScope(0); | |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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); |
| 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 |
| OLD | NEW |