| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 bool applyAuthorStyles() const; | 96 bool applyAuthorStyles() const; |
| 97 | 97 |
| 98 // Used by the basic DOM mutation methods (e.g., appendChild()). | 98 // Used by the basic DOM mutation methods (e.g., appendChild()). |
| 99 void adoptIfNeeded(Node&); | 99 void adoptIfNeeded(Node&); |
| 100 | 100 |
| 101 Node& rootNode() const { return m_rootNode; } | 101 Node& rootNode() const { return m_rootNode; } |
| 102 | 102 |
| 103 IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTar
getObserverRegistry.get(); } | 103 IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTar
getObserverRegistry.get(); } |
| 104 | 104 |
| 105 |
| 106 #if !ENABLE(OILPAN) |
| 105 // Nodes belonging to this scope hold guard references - | 107 // Nodes belonging to this scope hold guard references - |
| 106 // these are enough to keep the scope from being destroyed, but | 108 // these are enough to keep the scope from being destroyed, but |
| 107 // not enough to keep it from removing its children. This allows a | 109 // not enough to keep it from removing its children. This allows a |
| 108 // node that outlives its scope to still have a valid document | 110 // node that outlives its scope to still have a valid document |
| 109 // pointer without introducing reference cycles. | 111 // pointer without introducing reference cycles. |
| 110 void guardRef() | 112 void guardRef() |
| 111 { | 113 { |
| 112 #if ENABLE(OILPAN) | 114 #if ENABLE(OILPAN) |
| 113 if (!m_guardRefCount) { | 115 if (!m_guardRefCount) { |
| 114 ASSERT(!m_keepAlive); | 116 ASSERT(!m_keepAlive); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 130 #if ENABLE(OILPAN) | 132 #if ENABLE(OILPAN) |
| 131 if (!m_guardRefCount) | 133 if (!m_guardRefCount) |
| 132 clearKeepAlive(); | 134 clearKeepAlive(); |
| 133 #else | 135 #else |
| 134 if (!m_guardRefCount && !refCount() && !rootNodeHasTreeSharedParent()) { | 136 if (!m_guardRefCount && !refCount() && !rootNodeHasTreeSharedParent()) { |
| 135 beginDeletion(); | 137 beginDeletion(); |
| 136 delete this; | 138 delete this; |
| 137 } | 139 } |
| 138 #endif | 140 #endif |
| 139 } | 141 } |
| 142 #endif |
| 140 | 143 |
| 141 void removedLastRefToScope(); | 144 void removedLastRefToScope(); |
| 142 | 145 |
| 143 #if ENABLE(OILPAN) | 146 #if ENABLE(OILPAN) |
| 144 void clearKeepAlive() | 147 void clearKeepAlive() |
| 145 { | 148 { |
| 146 ASSERT(m_keepAlive); | 149 ASSERT(m_keepAlive); |
| 147 m_keepAlive = nullptr; | 150 m_keepAlive = nullptr; |
| 148 } | 151 } |
| 149 #endif | 152 #endif |
| 150 | 153 |
| 151 bool isInclusiveAncestorOf(const TreeScope&) const; | 154 bool isInclusiveAncestorOf(const TreeScope&) const; |
| 152 unsigned short comparePosition(const TreeScope&) const; | 155 unsigned short comparePosition(const TreeScope&) const; |
| 153 | 156 |
| 154 Element* getElementByAccessKey(const String& key) const; | 157 Element* getElementByAccessKey(const String& key) const; |
| 155 | 158 |
| 159 virtual void trace(Visitor*); |
| 160 |
| 156 protected: | 161 protected: |
| 157 TreeScope(ContainerNode&, Document&); | 162 TreeScope(ContainerNode&, Document&); |
| 158 TreeScope(Document&); | 163 TreeScope(Document&); |
| 159 virtual ~TreeScope(); | 164 virtual ~TreeScope(); |
| 160 | 165 |
| 161 void destroyTreeScopeData(); | 166 void destroyTreeScopeData(); |
| 162 void setDocument(Document& document) { m_document = &document; } | 167 void setDocument(Document& document) { m_document = &document; } |
| 163 void setParentTreeScope(TreeScope&); | 168 void setParentTreeScope(TreeScope&); |
| 164 | 169 |
| 165 bool hasGuardRefCount() const { return m_guardRefCount; } | 170 bool hasGuardRefCount() const { return m_guardRefCount; } |
| 166 | 171 |
| 167 void setNeedsStyleRecalcForViewportUnits(); | 172 void setNeedsStyleRecalcForViewportUnits(); |
| 168 | 173 |
| 169 private: | 174 private: |
| 170 virtual void dispose() { } | 175 virtual void dispose() { } |
| 171 | 176 |
| 172 int refCount() const; | 177 int refCount() const; |
| 173 #if SECURITY_ASSERT_ENABLED | 178 #if SECURITY_ASSERT_ENABLED |
| 174 bool deletionHasBegun(); | 179 bool deletionHasBegun(); |
| 175 void beginDeletion(); | 180 void beginDeletion(); |
| 176 #else | 181 #else |
| 177 bool deletionHasBegun() { return false; } | 182 bool deletionHasBegun() { return false; } |
| 178 void beginDeletion() { } | 183 void beginDeletion() { } |
| 179 #endif | 184 #endif |
| 180 | 185 |
| 181 bool rootNodeHasTreeSharedParent() const; | 186 bool rootNodeHasTreeSharedParent() const; |
| 182 | 187 |
| 183 Node& m_rootNode; | 188 Node& m_rootNode; |
| 184 Document* m_document; | 189 Document* m_document; |
| 185 TreeScope* m_parentTreeScope; | 190 RawPtrWillBeMember<TreeScope> m_parentTreeScope; |
| 186 int m_guardRefCount; | 191 int m_guardRefCount; |
| 187 | 192 |
| 188 OwnPtr<DocumentOrderedMap> m_elementsById; | 193 OwnPtr<DocumentOrderedMap> m_elementsById; |
| 189 OwnPtr<DocumentOrderedMap> m_imageMapsByName; | 194 OwnPtr<DocumentOrderedMap> m_imageMapsByName; |
| 190 OwnPtr<DocumentOrderedMap> m_labelsByForAttribute; | 195 OwnPtr<DocumentOrderedMap> m_labelsByForAttribute; |
| 191 | 196 |
| 192 OwnPtr<IdTargetObserverRegistry> m_idTargetObserverRegistry; | 197 OwnPtr<IdTargetObserverRegistry> m_idTargetObserverRegistry; |
| 193 | 198 |
| 194 #if ENABLE(OILPAN) | 199 #if ENABLE(OILPAN) |
| 195 // With Oilpan, a non-zero reference count will keep the TreeScope alive | 200 // With Oilpan, a non-zero reference count will keep the TreeScope alive |
| (...skipping 29 matching lines...) Expand all Loading... |
| 225 inline bool operator!=(const TreeScope& a, const TreeScope& b) { return !(a == b
); } | 230 inline bool operator!=(const TreeScope& a, const TreeScope& b) { return !(a == b
); } |
| 226 inline bool operator!=(const TreeScope& a, const TreeScope* b) { return !(a == b
); } | 231 inline bool operator!=(const TreeScope& a, const TreeScope* b) { return !(a == b
); } |
| 227 inline bool operator!=(const TreeScope* a, const TreeScope& b) { return !(a == b
); } | 232 inline bool operator!=(const TreeScope* a, const TreeScope& b) { return !(a == b
); } |
| 228 | 233 |
| 229 HitTestResult hitTestInDocument(const Document*, int x, int y); | 234 HitTestResult hitTestInDocument(const Document*, int x, int y); |
| 230 TreeScope* commonTreeScope(Node*, Node*); | 235 TreeScope* commonTreeScope(Node*, Node*); |
| 231 | 236 |
| 232 } // namespace WebCore | 237 } // namespace WebCore |
| 233 | 238 |
| 234 #endif // TreeScope_h | 239 #endif // TreeScope_h |
| OLD | NEW |