Avoid reloading iframe on re-parenting between documents.
https://bugs.webkit.org/show_bug.cgi?id=32848

Reviewed by David Levin.

WebCore:

Achieved by setting a flag on iframe element when it is a target of document.adoptNode(node) operation.
The flag prevents unload/load cycle and is reset once element is attached to a new document.
If iframe is adopted but not actually inserted into the tree, it gets unloaded by async timer
once JS yields, to avoid having active content in non-attached iframe.

Test: fast/frames/iframe-reparenting.html

* dom/Document.cpp:
(WebCore::Document::adoptNode): If the adopted node is iframe, set a remainsAliveOnRemovalFromTree on it.
* html/HTMLFrameElementBase.h:
* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::HTMLFrameElementBase):
(WebCore::HTMLFrameElementBase::attach): Skip actual loading of the frame if it has remainsAliveOnRemovalFromTree flag. Reset the flag.
(WebCore::HTMLFrameElementBase::willRemove): Skip unloading the frame if it has remainsAliveOnRemovalFromTree flag set.
(WebCore::HTMLFrameElementBase::setRemainsAliveOnRemovalFromTree): Set the flag, start the async timer to check if the frame was actually attached.
(WebCore::HTMLFrameElementBase::checkAttachedTimerFired):
* html/HTMLFrameOwnerElement.h:
(WebCore::HTMLFrameOwnerElement::willRemove): Move from private to protected, since it is conditionally called in HTMLFrameElementBase::willRemove now.

LayoutTests:

* fast/frames/iframe-reparenting-expected.txt: Added.
* fast/frames/iframe-reparenting.html: Added.
* fast/frames/resources/iframe-reparenting-frame1.html: Added.
* fast/frames/resources/iframe-reparenting-frame2.html: Added.
* fast/frames/resources/iframe-reparenting-iframe-content.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53871 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/html/HTMLFrameOwnerElement.h b/WebCore/html/HTMLFrameOwnerElement.h
index 308a100..4a56e45 100644
--- a/WebCore/html/HTMLFrameOwnerElement.h
+++ b/WebCore/html/HTMLFrameOwnerElement.h
@@ -48,19 +48,19 @@
     virtual ScrollbarMode scrollingMode() const { return ScrollbarAuto; }
 
     SandboxFlags sandboxFlags() const { return m_sandboxFlags; }
-    
+
 protected:
     HTMLFrameOwnerElement(const QualifiedName& tagName, Document*);
 
     void setSandboxFlags(SandboxFlags);
-    
+
+    virtual void willRemove();
+
 private:
     friend class Frame;
 
     virtual bool isFrameOwnerElement() const { return true; }
     virtual bool isKeyboardFocusable(KeyboardEvent*) const { return m_contentFrame; }
-    
-    virtual void willRemove();
 
     Frame* m_contentFrame;
     SandboxFlags m_sandboxFlags;