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

Unified Diff: Source/core/html/parser/HTMLConstructionSite.cpp

Issue 14759017: callTheAdoptionAgency should work asynchronously (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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
Index: Source/core/html/parser/HTMLConstructionSite.cpp
diff --git a/Source/core/html/parser/HTMLConstructionSite.cpp b/Source/core/html/parser/HTMLConstructionSite.cpp
index 749dacfc6afef4603e895b2bc2769b6af67143fb..cee1c50acd6cb696ff0765bd410b2f96bbdafcbb 100644
--- a/Source/core/html/parser/HTMLConstructionSite.cpp
+++ b/Source/core/html/parser/HTMLConstructionSite.cpp
@@ -83,13 +83,14 @@ static inline bool isAllWhitespace(const String& string)
return string.isAllSpecialCharacters<isHTMLSpace>();
}
-static inline void executeInsertTask(HTMLConstructionSiteTask& task)
+static inline void insert(HTMLConstructionSiteTask& task)
{
- ASSERT(task.operation == HTMLConstructionSiteTask::Insert);
-
if (task.parent->hasTagName(templateTag))
task.parent = toHTMLTemplateElement(task.parent.get())->content();
+ if (ContainerNode* parent = task.child->parentNode())
+ parent->parserRemoveChild(task.child.get());
+
if (task.nextChild)
task.parent->parserInsertBefore(task.child.get(), task.nextChild.get());
else
@@ -100,6 +101,13 @@ static inline void executeInsertTask(HTMLConstructionSiteTask& task)
if (task.child->parentNode() && task.parent->attached() && !task.child->attached())
task.child->attach();
+}
+
+static inline void executeInsertTask(HTMLConstructionSiteTask& task)
+{
+ ASSERT(task.operation == HTMLConstructionSiteTask::Insert);
+
+ insert(task);
task.child->beginParsingChildren();
@@ -120,14 +128,41 @@ static inline void executeReparentTask(HTMLConstructionSiteTask& task)
task.child->lazyAttach();
}
+static inline void executeInsertAgainTask(HTMLConstructionSiteTask& task)
+{
+ ASSERT(task.operation == HTMLConstructionSiteTask::InsertAgain);
+
+ insert(task);
+}
+
+static inline void executeTakeAllChildrenTask(HTMLConstructionSiteTask& task)
+{
+ ASSERT(task.operation == HTMLConstructionSiteTask::TakeAllChildren);
+
+ // It's sort of ugly, but we store the |oldParent| in the |child| field
+ // of the task so that we don't bloat the HTMLConstructionSiteTask
+ // object in the common case of the Insert operation.
+ ContainerNode* oldParent = static_cast<ContainerNode*>(task.child.get());
eseidel 2013/05/07 00:11:37 The only thing I would change here is making this
+
+ task.parent->takeAllChildrenFrom(oldParent);
+ // Notice that we don't need to manually attack the moved children
eseidel 2013/05/07 00:11:37 attack!
+ // because takeAllChildrenFrom does that work for us.
+}
+
static inline void executeTask(HTMLConstructionSiteTask& task)
{
if (task.operation == HTMLConstructionSiteTask::Insert)
return executeInsertTask(task);
+ if (task.operation == HTMLConstructionSiteTask::InsertAgain)
eseidel 2013/05/07 00:11:37 I would put a comment that these below this commen
+ return executeInsertAgainTask(task);
+
if (task.operation == HTMLConstructionSiteTask::Reparent)
return executeReparentTask(task);
+ if (task.operation == HTMLConstructionSiteTask::TakeAllChildren)
+ return executeTakeAllChildrenTask(task);
+
ASSERT_NOT_REACHED();
}
@@ -549,6 +584,35 @@ void HTMLConstructionSite::reparent(HTMLElementStack::ElementRecord* newParent,
m_taskQueue.append(task);
}
+void HTMLConstructionSite::reparent(HTMLElementStack::ElementRecord* newParent, HTMLStackItem* child)
+{
+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Reparent);
+ task.parent = newParent->element();
+ task.child = child->element();
+ m_taskQueue.append(task);
+}
+
+void HTMLConstructionSite::insertAgain(HTMLStackItem* newParent, HTMLElementStack::ElementRecord* child)
eseidel 2013/05/07 00:11:37 Need a name so that folks have a prayer of knowing
+{
+ if (newParent->causesFosterParenting()) {
+ fosterParent(child->element());
+ return;
+ }
+
+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::InsertAgain);
+ task.parent = newParent->element();
+ task.child = child->element();
+ m_taskQueue.append(task);
+}
+
+void HTMLConstructionSite::takeAllChildren(HTMLStackItem* newParent, HTMLElementStack::ElementRecord* oldParent)
+{
+ HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren);
+ task.parent = newParent->element();
+ task.child = oldParent->element();
+ m_taskQueue.append(task);
+}
+
PassRefPtr<Element> HTMLConstructionSite::createElement(AtomicHTMLToken* token, const AtomicString& namespaceURI)
{
QualifiedName tagName(nullAtom, token->name(), namespaceURI);

Powered by Google App Engine
This is Rietveld 408576698