| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "sky/engine/core/rendering/HitTestResult.h" | 47 #include "sky/engine/core/rendering/HitTestResult.h" |
| 48 #include "sky/engine/core/rendering/RenderView.h" | 48 #include "sky/engine/core/rendering/RenderView.h" |
| 49 #include "sky/engine/wtf/Vector.h" | 49 #include "sky/engine/wtf/Vector.h" |
| 50 | 50 |
| 51 namespace blink { | 51 namespace blink { |
| 52 | 52 |
| 53 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) | 53 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) |
| 54 : m_rootNode(&rootNode) | 54 : m_rootNode(&rootNode) |
| 55 , m_document(&document) | 55 , m_document(&document) |
| 56 , m_parentTreeScope(&document) | 56 , m_parentTreeScope(&document) |
| 57 #if !ENABLE(OILPAN) | 57 , m_scopedStyleResolver(ScopedStyleResolver::create(*this)) |
| 58 , m_guardRefCount(0) | 58 , m_guardRefCount(0) |
| 59 #endif | |
| 60 { | 59 { |
| 61 ASSERT(rootNode != document); | 60 ASSERT(rootNode != document); |
| 62 #if !ENABLE(OILPAN) | 61 #if !ENABLE(OILPAN) |
| 63 m_parentTreeScope->guardRef(); | 62 m_parentTreeScope->guardRef(); |
| 64 #endif | 63 #endif |
| 65 m_rootNode->setTreeScope(this); | 64 m_rootNode->setTreeScope(this); |
| 66 } | 65 } |
| 67 | 66 |
| 68 TreeScope::TreeScope(Document& document) | 67 TreeScope::TreeScope(Document& document) |
| 69 : m_rootNode(document) | 68 : m_rootNode(document) |
| 70 , m_document(&document) | 69 , m_document(&document) |
| 71 , m_parentTreeScope(nullptr) | 70 , m_parentTreeScope(nullptr) |
| 72 #if !ENABLE(OILPAN) | 71 , m_scopedStyleResolver(ScopedStyleResolver::create(*this)) |
| 73 , m_guardRefCount(0) | 72 , m_guardRefCount(0) |
| 74 #endif | |
| 75 { | 73 { |
| 76 m_rootNode->setTreeScope(this); | 74 m_rootNode->setTreeScope(this); |
| 77 } | 75 } |
| 78 | 76 |
| 79 TreeScope::~TreeScope() | 77 TreeScope::~TreeScope() |
| 80 { | 78 { |
| 81 #if !ENABLE(OILPAN) | |
| 82 ASSERT(!m_guardRefCount); | 79 ASSERT(!m_guardRefCount); |
| 83 m_rootNode->setTreeScope(0); | 80 m_rootNode->setTreeScope(0); |
| 84 | 81 |
| 85 if (m_selection) { | 82 if (m_selection) { |
| 86 m_selection->clearTreeScope(); | 83 m_selection->clearTreeScope(); |
| 87 m_selection = nullptr; | 84 m_selection = nullptr; |
| 88 } | 85 } |
| 89 | 86 |
| 90 if (m_parentTreeScope) | 87 if (m_parentTreeScope) |
| 91 m_parentTreeScope->guardDeref(); | 88 m_parentTreeScope->guardDeref(); |
| 92 #endif | |
| 93 } | 89 } |
| 94 | 90 |
| 95 bool TreeScope::isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(const Tre
eScope& scope) const | 91 bool TreeScope::isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(const Tre
eScope& scope) const |
| 96 { | 92 { |
| 97 for (const TreeScope* current = &scope; current; current = current->parentTr
eeScope()) { | 93 for (const TreeScope* current = &scope; current; current = current->parentTr
eeScope()) { |
| 98 if (current == this) | 94 if (current == this) |
| 99 return true; | 95 return true; |
| 100 } | 96 } |
| 101 return false; | 97 return false; |
| 102 } | 98 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 122 | 118 |
| 123 #if !ENABLE(OILPAN) | 119 #if !ENABLE(OILPAN) |
| 124 newParentScope.guardRef(); | 120 newParentScope.guardRef(); |
| 125 if (m_parentTreeScope) | 121 if (m_parentTreeScope) |
| 126 m_parentTreeScope->guardDeref(); | 122 m_parentTreeScope->guardDeref(); |
| 127 #endif | 123 #endif |
| 128 m_parentTreeScope = &newParentScope; | 124 m_parentTreeScope = &newParentScope; |
| 129 setDocument(newParentScope.document()); | 125 setDocument(newParentScope.document()); |
| 130 } | 126 } |
| 131 | 127 |
| 132 ScopedStyleResolver& TreeScope::ensureScopedStyleResolver() | |
| 133 { | |
| 134 RELEASE_ASSERT(this); | |
| 135 if (!m_scopedStyleResolver) | |
| 136 m_scopedStyleResolver = ScopedStyleResolver::create(*this); | |
| 137 return *m_scopedStyleResolver; | |
| 138 } | |
| 139 | |
| 140 void TreeScope::clearScopedStyleResolver() | |
| 141 { | |
| 142 m_scopedStyleResolver.clear(); | |
| 143 } | |
| 144 | |
| 145 Element* TreeScope::getElementById(const AtomicString& elementId) const | 128 Element* TreeScope::getElementById(const AtomicString& elementId) const |
| 146 { | 129 { |
| 147 if (elementId.isEmpty()) | 130 if (elementId.isEmpty()) |
| 148 return 0; | 131 return 0; |
| 149 if (!m_elementsById) | 132 if (!m_elementsById) |
| 150 return 0; | 133 return 0; |
| 151 return m_elementsById->getElementById(elementId, this); | 134 return m_elementsById->getElementById(elementId, this); |
| 152 } | 135 } |
| 153 | 136 |
| 154 void TreeScope::addElementById(const AtomicString& elementId, Element* element) | 137 void TreeScope::addElementById(const AtomicString& elementId, Element* element) |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 415 |
| 433 for (size_t i = 0; i < list.size(); i++) { | 416 for (size_t i = 0; i < list.size(); i++) { |
| 434 if (list[i]->contents() != otherList[i]->contents()) | 417 if (list[i]->contents() != otherList[i]->contents()) |
| 435 return false; | 418 return false; |
| 436 } | 419 } |
| 437 | 420 |
| 438 return true; | 421 return true; |
| 439 } | 422 } |
| 440 | 423 |
| 441 } // namespace blink | 424 } // namespace blink |
| OLD | NEW |