| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 #if !ENABLE(OILPAN) | 126 #if !ENABLE(OILPAN) |
| 127 void TreeScope::destroyTreeScopeData() | 127 void TreeScope::destroyTreeScopeData() |
| 128 { | 128 { |
| 129 m_elementsById.clear(); | 129 m_elementsById.clear(); |
| 130 m_imageMapsByName.clear(); | 130 m_imageMapsByName.clear(); |
| 131 m_labelsByForAttribute.clear(); | 131 m_labelsByForAttribute.clear(); |
| 132 } | 132 } |
| 133 #endif | 133 #endif |
| 134 | 134 |
| 135 void TreeScope::setDocument(Document& document) | |
| 136 { | |
| 137 m_document = &document; | |
| 138 } | |
| 139 | |
| 140 void TreeScope::setParentTreeScope(TreeScope& newParentScope) | 135 void TreeScope::setParentTreeScope(TreeScope& newParentScope) |
| 141 { | 136 { |
| 142 // A document node cannot be re-parented. | 137 // A document node cannot be re-parented. |
| 143 ASSERT(!rootNode().isDocumentNode()); | 138 ASSERT(!rootNode().isDocumentNode()); |
| 144 | 139 |
| 145 #if !ENABLE(OILPAN) | 140 #if !ENABLE(OILPAN) |
| 146 newParentScope.guardRef(); | 141 newParentScope.guardRef(); |
| 147 if (m_parentTreeScope) | 142 if (m_parentTreeScope) |
| 148 m_parentTreeScope->guardDeref(); | 143 m_parentTreeScope->guardDeref(); |
| 149 #endif | 144 #endif |
| 150 m_parentTreeScope = &newParentScope; | 145 m_parentTreeScope = &newParentScope; |
| 151 setDocument(newParentScope.document()); | 146 setDocument(newParentScope.document()); |
| 152 } | 147 } |
| 153 | 148 |
| 154 ScopedStyleResolver* TreeScope::scopedStyleResolver() const | |
| 155 { | |
| 156 return m_scopedStyleResolver.get(); | |
| 157 } | |
| 158 | |
| 159 ScopedStyleResolver& TreeScope::ensureScopedStyleResolver() | 149 ScopedStyleResolver& TreeScope::ensureScopedStyleResolver() |
| 160 { | 150 { |
| 161 RELEASE_ASSERT(this); | 151 RELEASE_ASSERT(this); |
| 162 if (!m_scopedStyleResolver) | 152 if (!m_scopedStyleResolver) |
| 163 m_scopedStyleResolver = ScopedStyleResolver::create(*this); | 153 m_scopedStyleResolver = ScopedStyleResolver::create(*this); |
| 164 return *m_scopedStyleResolver; | 154 return *m_scopedStyleResolver; |
| 165 } | 155 } |
| 166 | 156 |
| 167 void TreeScope::clearScopedStyleResolver() | 157 void TreeScope::clearScopedStyleResolver() |
| 168 { | 158 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 197 } | 187 } |
| 198 | 188 |
| 199 void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen
t) | 189 void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen
t) |
| 200 { | 190 { |
| 201 if (!m_elementsById) | 191 if (!m_elementsById) |
| 202 return; | 192 return; |
| 203 m_elementsById->remove(elementId, element); | 193 m_elementsById->remove(elementId, element); |
| 204 m_idTargetObserverRegistry->notifyObservers(elementId); | 194 m_idTargetObserverRegistry->notifyObservers(elementId); |
| 205 } | 195 } |
| 206 | 196 |
| 207 Document& TreeScope::document() const | |
| 208 { | |
| 209 ASSERT(m_document); | |
| 210 return *m_document; | |
| 211 } | |
| 212 | |
| 213 Node* TreeScope::ancestorInThisScope(Node* node) const | 197 Node* TreeScope::ancestorInThisScope(Node* node) const |
| 214 { | 198 { |
| 215 while (node) { | 199 while (node) { |
| 216 if (node->treeScope() == this) | 200 if (node->treeScope() == this) |
| 217 return node; | 201 return node; |
| 218 if (!node->isInShadowTree()) | 202 if (!node->isInShadowTree()) |
| 219 return 0; | 203 return 0; |
| 220 | 204 |
| 221 node = node->shadowHost(); | 205 node = node->shadowHost(); |
| 222 } | 206 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 ASSERT(this); | 412 ASSERT(this); |
| 429 ASSERT(!node.isDocumentNode()); | 413 ASSERT(!node.isDocumentNode()); |
| 430 #if !ENABLE(OILPAN) | 414 #if !ENABLE(OILPAN) |
| 431 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun); | 415 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun); |
| 432 #endif | 416 #endif |
| 433 TreeScopeAdopter adopter(node, *this); | 417 TreeScopeAdopter adopter(node, *this); |
| 434 if (adopter.needsScopeChange()) | 418 if (adopter.needsScopeChange()) |
| 435 adopter.execute(); | 419 adopter.execute(); |
| 436 } | 420 } |
| 437 | 421 |
| 438 IdTargetObserverRegistry& TreeScope::idTargetObserverRegistry() const | |
| 439 { | |
| 440 return *m_idTargetObserverRegistry.get(); | |
| 441 } | |
| 442 | |
| 443 Element* TreeScope::adjustedFocusedElement() const | 422 Element* TreeScope::adjustedFocusedElement() const |
| 444 { | 423 { |
| 445 Document& document = rootNode().document(); | 424 Document& document = rootNode().document(); |
| 446 Element* element = document.focusedElement(); | 425 Element* element = document.focusedElement(); |
| 447 if (!element && document.page()) | 426 if (!element && document.page()) |
| 448 element = document.page()->focusController().focusedFrameOwnerElement(*d
ocument.frame()); | 427 element = document.page()->focusController().focusedFrameOwnerElement(*d
ocument.frame()); |
| 449 if (!element) | 428 if (!element) |
| 450 return 0; | 429 return 0; |
| 451 | 430 |
| 452 OwnPtrWillBeRawPtr<EventPath> eventPath = adoptPtrWillBeNoop(new EventPath(*
element)); | 431 OwnPtrWillBeRawPtr<EventPath> eventPath = adoptPtrWillBeNoop(new EventPath(*
element)); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 visitor->trace(m_parentTreeScope); | 574 visitor->trace(m_parentTreeScope); |
| 596 visitor->trace(m_idTargetObserverRegistry); | 575 visitor->trace(m_idTargetObserverRegistry); |
| 597 visitor->trace(m_selection); | 576 visitor->trace(m_selection); |
| 598 visitor->trace(m_elementsById); | 577 visitor->trace(m_elementsById); |
| 599 visitor->trace(m_imageMapsByName); | 578 visitor->trace(m_imageMapsByName); |
| 600 visitor->trace(m_labelsByForAttribute); | 579 visitor->trace(m_labelsByForAttribute); |
| 601 visitor->trace(m_scopedStyleResolver); | 580 visitor->trace(m_scopedStyleResolver); |
| 602 } | 581 } |
| 603 | 582 |
| 604 } // namespace blink | 583 } // namespace blink |
| OLD | NEW |