| 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..11525e951b4d42aff316d2d806fcf7b3db847956 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,38 @@ static inline void executeReparentTask(HTMLConstructionSiteTask& task)
|
| task.child->lazyAttach();
|
| }
|
|
|
| +static inline void executeInsertAlreadyParsedChildTask(HTMLConstructionSiteTask& task)
|
| +{
|
| + ASSERT(task.operation == HTMLConstructionSiteTask::InsertAlreadyParsedChild);
|
| +
|
| + insert(task);
|
| +}
|
| +
|
| +static inline void executeTakeAllChildrenTask(HTMLConstructionSiteTask& task)
|
| +{
|
| + ASSERT(task.operation == HTMLConstructionSiteTask::TakeAllChildren);
|
| +
|
| + task.parent->takeAllChildrenFrom(task.oldParent());
|
| + // Notice that we don't need to manually attach the moved children
|
| + // because takeAllChildrenFrom does that work for us.
|
| +}
|
| +
|
| static inline void executeTask(HTMLConstructionSiteTask& task)
|
| {
|
| if (task.operation == HTMLConstructionSiteTask::Insert)
|
| return executeInsertTask(task);
|
|
|
| + // All the cases below this point are only used by the adoption agency.
|
| +
|
| + if (task.operation == HTMLConstructionSiteTask::InsertAlreadyParsedChild)
|
| + return executeInsertAlreadyParsedChildTask(task);
|
| +
|
| if (task.operation == HTMLConstructionSiteTask::Reparent)
|
| return executeReparentTask(task);
|
|
|
| + if (task.operation == HTMLConstructionSiteTask::TakeAllChildren)
|
| + return executeTakeAllChildrenTask(task);
|
| +
|
| ASSERT_NOT_REACHED();
|
| }
|
|
|
| @@ -549,6 +581,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::insertAlreadyParsedChild(HTMLStackItem* newParent, HTMLElementStack::ElementRecord* child)
|
| +{
|
| + if (newParent->causesFosterParenting()) {
|
| + fosterParent(child->element());
|
| + return;
|
| + }
|
| +
|
| + HTMLConstructionSiteTask task(HTMLConstructionSiteTask::InsertAlreadyParsedChild);
|
| + 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);
|
|
|