Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: Source/core/dom/Node.cpp

Issue 23606020: Remove lots of code related synchronously attaching (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix asserts Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 node->clearAttached(); 980 node->clearAttached();
981 node->clearChildNeedsStyleRecalc(); 981 node->clearChildNeedsStyleRecalc();
982 982
983 for (ShadowRoot* shadowRoot = node->youngestShadowRoot(); shadowRoot ; shadowRoot = shadowRoot->olderShadowRoot()) 983 for (ShadowRoot* shadowRoot = node->youngestShadowRoot(); shadowRoot ; shadowRoot = shadowRoot->olderShadowRoot())
984 detachNode(shadowRoot, context); 984 detachNode(shadowRoot, context);
985 985
986 node = NodeTraversal::next(node, root); 986 node = NodeTraversal::next(node, root);
987 continue; 987 continue;
988 } 988 }
989 // Handle normal reattaches from style recalc (ex. display type changes) 989 // Handle normal reattaches from style recalc (ex. display type changes)
990 // or descendants of lazy attached nodes that got actually attached, for example,
991 // by innerHTML or editing.
992 // FIXME: innerHTML and editing should also lazyAttach.
993 if (node->attached()) 990 if (node->attached())
994 node->detach(context); 991 node->detach(context);
995 node = NodeTraversal::nextSkippingChildren(node, root); 992 node = NodeTraversal::nextSkippingChildren(node, root);
996 } 993 }
997 } 994 }
998 995
999 void Node::reattach(const AttachContext& context) 996 void Node::reattach(const AttachContext& context)
1000 { 997 {
1001 ASSERT(document().inStyleRecalc());
1002 AttachContext reattachContext(context); 998 AttachContext reattachContext(context);
1003 reattachContext.performingReattach = true; 999 reattachContext.performingReattach = true;
1004 1000
1005 detachNode(this, reattachContext); 1001 detachNode(this, reattachContext);
1006 attach(reattachContext); 1002 attach(reattachContext);
1007 } 1003 }
1008 1004
1009 void Node::attach(const AttachContext&) 1005 void Node::attach(const AttachContext&)
1010 { 1006 {
1007 ASSERT(document().inStyleRecalc() || isDocumentNode());
1011 ASSERT(!attached()); 1008 ASSERT(!attached());
1012 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende rer()->isRenderView()))); 1009 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende rer()->isRenderView())));
1013 1010
1014 // If this node got a renderer it may be the previousRenderer() of sibling t ext nodes and thus affect the
1015 // result of Text::textRendererIsNeeded() for those nodes.
1016 // FIXME: This loop is no longer required once we lazy attach all the time.
1017 if (renderer() && !document().inStyleRecalc()) {
1018 for (Node* next = nextSibling(); next; next = next->nextSibling()) {
1019 if (next->renderer())
1020 break;
1021 if (!next->attached())
1022 break; // Assume this means none of the following siblings are a ttached.
1023 if (!next->isTextNode())
1024 continue;
1025 ASSERT(!next->renderer());
1026 toText(next)->reattach();
1027 // If we again decided not to create a renderer for next, we can bai l out the loop,
1028 // because it won't affect the result of Text::textRendererIsNeeded( ) for the rest
1029 // of sibling nodes.
1030 if (!next->renderer())
1031 break;
1032 }
1033 }
1034
1035 setAttached(); 1011 setAttached();
1036 clearNeedsStyleRecalc(); 1012 clearNeedsStyleRecalc();
1037 1013
1038 if (Document* doc = documentInternal()) { 1014 if (Document* doc = documentInternal()) {
1039 if (AXObjectCache* cache = doc->axObjectCache()) 1015 if (AXObjectCache* cache = doc->axObjectCache())
1040 cache->updateCacheAfterNodeIsAttached(this); 1016 cache->updateCacheAfterNodeIsAttached(this);
1041 } 1017 }
1042 } 1018 }
1043 1019
1044 #ifndef NDEBUG 1020 #ifndef NDEBUG
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 node->showTreeForThis(); 2679 node->showTreeForThis();
2704 } 2680 }
2705 2681
2706 void showNodePath(const WebCore::Node* node) 2682 void showNodePath(const WebCore::Node* node)
2707 { 2683 {
2708 if (node) 2684 if (node)
2709 node->showNodePathForThis(); 2685 node->showNodePathForThis();
2710 } 2686 }
2711 2687
2712 #endif 2688 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698