OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 ASSERT(document().inStyleRecalc() || isDocumentNode()); | 991 ASSERT(document().inStyleRecalc() || isDocumentNode()); |
992 ASSERT(needsAttach()); | 992 ASSERT(needsAttach()); |
993 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende
rer()->isRenderView()))); | 993 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende
rer()->isRenderView()))); |
994 | 994 |
995 clearNeedsStyleRecalc(); | 995 clearNeedsStyleRecalc(); |
996 | 996 |
997 if (AXObjectCache* cache = document().axObjectCache()) | 997 if (AXObjectCache* cache = document().axObjectCache()) |
998 cache->updateCacheAfterNodeIsAttached(this); | 998 cache->updateCacheAfterNodeIsAttached(this); |
999 } | 999 } |
1000 | 1000 |
1001 #ifndef NDEBUG | 1001 #if ENABLE(ASSERT) |
1002 static Node* detachingNode; | 1002 static Node* detachingNode; |
1003 | 1003 |
1004 bool Node::inDetach() const | 1004 bool Node::inDetach() const |
1005 { | 1005 { |
1006 return detachingNode == this; | 1006 return detachingNode == this; |
1007 } | 1007 } |
1008 #endif | 1008 #endif |
1009 | 1009 |
1010 void Node::detach(const AttachContext& context) | 1010 void Node::detach(const AttachContext& context) |
1011 { | 1011 { |
1012 ASSERT(document().lifecycle().stateAllowsDetach()); | 1012 ASSERT(document().lifecycle().stateAllowsDetach()); |
1013 DocumentLifecycle::DetachScope willDetach(document().lifecycle()); | 1013 DocumentLifecycle::DetachScope willDetach(document().lifecycle()); |
1014 | 1014 |
1015 #ifndef NDEBUG | 1015 #if ENABLE(ASSERT) |
1016 ASSERT(!detachingNode); | 1016 ASSERT(!detachingNode); |
1017 detachingNode = this; | 1017 detachingNode = this; |
1018 #endif | 1018 #endif |
1019 | 1019 |
1020 if (renderer()) | 1020 if (renderer()) |
1021 renderer()->destroyAndCleanupAnonymousWrappers(); | 1021 renderer()->destroyAndCleanupAnonymousWrappers(); |
1022 setRenderer(0); | 1022 setRenderer(0); |
1023 | 1023 |
1024 // Do not remove the element's hovered and active status | 1024 // Do not remove the element's hovered and active status |
1025 // if performing a reattach. | 1025 // if performing a reattach. |
1026 if (!context.performingReattach) { | 1026 if (!context.performingReattach) { |
1027 Document& doc = document(); | 1027 Document& doc = document(); |
1028 if (isUserActionElement()) { | 1028 if (isUserActionElement()) { |
1029 if (hovered()) | 1029 if (hovered()) |
1030 doc.hoveredNodeDetached(this); | 1030 doc.hoveredNodeDetached(this); |
1031 if (inActiveChain()) | 1031 if (inActiveChain()) |
1032 doc.activeChainNodeDetached(this); | 1032 doc.activeChainNodeDetached(this); |
1033 doc.userActionElements().didDetach(this); | 1033 doc.userActionElements().didDetach(this); |
1034 } | 1034 } |
1035 } | 1035 } |
1036 | 1036 |
1037 setStyleChange(NeedsReattachStyleChange); | 1037 setStyleChange(NeedsReattachStyleChange); |
1038 setChildNeedsStyleRecalc(); | 1038 setChildNeedsStyleRecalc(); |
1039 | 1039 |
1040 if (StyleResolver* resolver = document().styleResolver()) | 1040 if (StyleResolver* resolver = document().styleResolver()) |
1041 resolver->ruleFeatureSet().styleInvalidator().clearInvalidation(*this); | 1041 resolver->ruleFeatureSet().styleInvalidator().clearInvalidation(*this); |
1042 clearChildNeedsStyleInvalidation(); | 1042 clearChildNeedsStyleInvalidation(); |
1043 clearNeedsStyleInvalidation(); | 1043 clearNeedsStyleInvalidation(); |
1044 | 1044 |
1045 #ifndef NDEBUG | 1045 #if ENABLE(ASSERT) |
1046 detachingNode = 0; | 1046 detachingNode = 0; |
1047 #endif | 1047 #endif |
1048 } | 1048 } |
1049 | 1049 |
1050 void Node::reattachWhitespaceSiblings(Text* start) | 1050 void Node::reattachWhitespaceSiblings(Text* start) |
1051 { | 1051 { |
1052 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { | 1052 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { |
1053 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace())
{ | 1053 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace())
{ |
1054 bool hadRenderer = !!sibling->renderer(); | 1054 bool hadRenderer = !!sibling->renderer(); |
1055 sibling->reattach(); | 1055 sibling->reattach(); |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 inline void TreeScope::removedLastRefToScope() | 2363 inline void TreeScope::removedLastRefToScope() |
2364 { | 2364 { |
2365 ASSERT_WITH_SECURITY_IMPLICATION(!deletionHasBegun()); | 2365 ASSERT_WITH_SECURITY_IMPLICATION(!deletionHasBegun()); |
2366 if (m_guardRefCount) { | 2366 if (m_guardRefCount) { |
2367 // If removing a child removes the last self-only ref, we don't | 2367 // If removing a child removes the last self-only ref, we don't |
2368 // want the scope to be destructed until after | 2368 // want the scope to be destructed until after |
2369 // removeDetachedChildren returns, so we guard ourselves with an | 2369 // removeDetachedChildren returns, so we guard ourselves with an |
2370 // extra self-only ref. | 2370 // extra self-only ref. |
2371 guardRef(); | 2371 guardRef(); |
2372 dispose(); | 2372 dispose(); |
2373 #if ASSERT_ENABLED | 2373 #if ENABLE(ASSERT) |
2374 // We need to do this right now since guardDeref() can delete this. | 2374 // We need to do this right now since guardDeref() can delete this. |
2375 rootNode().m_inRemovedLastRefFunction = false; | 2375 rootNode().m_inRemovedLastRefFunction = false; |
2376 #endif | 2376 #endif |
2377 guardDeref(); | 2377 guardDeref(); |
2378 } else { | 2378 } else { |
2379 #if ASSERT_ENABLED | 2379 #if ENABLE(ASSERT) |
2380 rootNode().m_inRemovedLastRefFunction = false; | 2380 rootNode().m_inRemovedLastRefFunction = false; |
2381 #endif | 2381 #endif |
2382 #if SECURITY_ASSERT_ENABLED | 2382 #if ENABLE(SECURITY_ASSERT) |
2383 beginDeletion(); | 2383 beginDeletion(); |
2384 #endif | 2384 #endif |
2385 delete this; | 2385 delete this; |
2386 } | 2386 } |
2387 } | 2387 } |
2388 | 2388 |
2389 // It's important not to inline removedLastRef, because we don't want to inline
the code to | 2389 // It's important not to inline removedLastRef, because we don't want to inline
the code to |
2390 // delete a Node at each deref call site. | 2390 // delete a Node at each deref call site. |
2391 void Node::removedLastRef() | 2391 void Node::removedLastRef() |
2392 { | 2392 { |
2393 // An explicit check for Document here is better than a virtual function sin
ce it is | 2393 // An explicit check for Document here is better than a virtual function sin
ce it is |
2394 // faster for non-Document nodes, and because the call to removedLastRef tha
t is inlined | 2394 // faster for non-Document nodes, and because the call to removedLastRef tha
t is inlined |
2395 // at all deref call sites is smaller if it's a non-virtual function. | 2395 // at all deref call sites is smaller if it's a non-virtual function. |
2396 if (isTreeScope()) { | 2396 if (isTreeScope()) { |
2397 treeScope().removedLastRefToScope(); | 2397 treeScope().removedLastRefToScope(); |
2398 return; | 2398 return; |
2399 } | 2399 } |
2400 | 2400 |
2401 #if SECURITY_ASSERT_ENABLED | 2401 #if ENABLE(SECURITY_ASSERT) |
2402 m_deletionHasBegun = true; | 2402 m_deletionHasBegun = true; |
2403 #endif | 2403 #endif |
2404 delete this; | 2404 delete this; |
2405 } | 2405 } |
2406 #endif | 2406 #endif |
2407 | 2407 |
2408 unsigned Node::connectedSubframeCount() const | 2408 unsigned Node::connectedSubframeCount() const |
2409 { | 2409 { |
2410 return hasRareData() ? rareData()->connectedSubframeCount() : 0; | 2410 return hasRareData() ? rareData()->connectedSubframeCount() : 0; |
2411 } | 2411 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 node->showTreeForThis(); | 2572 node->showTreeForThis(); |
2573 } | 2573 } |
2574 | 2574 |
2575 void showNodePath(const WebCore::Node* node) | 2575 void showNodePath(const WebCore::Node* node) |
2576 { | 2576 { |
2577 if (node) | 2577 if (node) |
2578 node->showNodePathForThis(); | 2578 node->showNodePathForThis(); |
2579 } | 2579 } |
2580 | 2580 |
2581 #endif | 2581 #endif |
OLD | NEW |