Skip to content
  • dimich@chromium.org's avatar
    Avoid reloading iframe on re-parenting between documents. · 451eabb7
    dimich@chromium.org authored
    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
    451eabb7