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

Unified Diff: Source/core/dom/Node.cpp

Issue 23526031: Revert 157422 "Remove lots of code related synchronously attaching" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index 650af854a80758d418cecf057cc2897e2bc8857b..2bc7123aa6726290d5c648d1121d86e115467482 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -987,6 +987,9 @@ inline void Node::detachNode(Node* root, const AttachContext& context)
continue;
}
// Handle normal reattaches from style recalc (ex. display type changes)
+ // or descendants of lazy attached nodes that got actually attached, for example,
+ // by innerHTML or editing.
+ // FIXME: innerHTML and editing should also lazyAttach.
if (node->attached())
node->detach(context);
node = NodeTraversal::nextSkippingChildren(node, root);
@@ -995,6 +998,7 @@ inline void Node::detachNode(Node* root, const AttachContext& context)
void Node::reattach(const AttachContext& context)
{
+ ASSERT(document().inStyleRecalc());
AttachContext reattachContext(context);
reattachContext.performingReattach = true;
@@ -1004,10 +1008,30 @@ void Node::reattach(const AttachContext& context)
void Node::attach(const AttachContext&)
{
- ASSERT(document().inStyleRecalc());
ASSERT(!attached());
ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || renderer()->isRenderView())));
+ // If this node got a renderer it may be the previousRenderer() of sibling text nodes and thus affect the
+ // result of Text::textRendererIsNeeded() for those nodes.
+ // FIXME: This loop is no longer required once we lazy attach all the time.
+ if (renderer() && !document().inStyleRecalc()) {
+ for (Node* next = nextSibling(); next; next = next->nextSibling()) {
+ if (next->renderer())
+ break;
+ if (!next->attached())
+ break; // Assume this means none of the following siblings are attached.
+ if (!next->isTextNode())
+ continue;
+ ASSERT(!next->renderer());
+ toText(next)->reattach();
+ // If we again decided not to create a renderer for next, we can bail out the loop,
+ // because it won't affect the result of Text::textRendererIsNeeded() for the rest
+ // of sibling nodes.
+ if (!next->renderer())
+ break;
+ }
+ }
+
setAttached();
clearNeedsStyleRecalc();
« 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