<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>82653</bug_id>
          
          <creation_ts>2012-03-29 13:54:34 -0700</creation_ts>
          <short_desc>Merge FrameLoader::finishedLoading() into DocumentLoader::finishedLoading()</short_desc>
          <delta_ts>2012-03-30 14:42:24 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nate Chapin">japhet</reporter>
          <assigned_to name="Nate Chapin">japhet</assigned_to>
          <cc>abarth</cc>
    
    <cc>ap</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>591528</commentid>
    <comment_count>0</comment_count>
    <who name="Nate Chapin">japhet</who>
    <bug_when>2012-03-29 13:54:34 -0700</bug_when>
    <thetext>FrameLoader::finishedLoading(): Calls a bunch of stuff on DocumentLoader (including finishedLoading), then calls FrameLoader::checkLoadComplete.  There&apos;s no reason for this division, so long as we&apos;re careful to handle the fact that DocumentLoader::finishedLoading() is called by FrameLoader::init(), when things aren&apos;t yet in a fully consistent state..</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>591531</commentid>
    <comment_count>1</comment_count>
      <attachid>134661</attachid>
    <who name="Nate Chapin">japhet</who>
    <bug_when>2012-03-29 13:57:42 -0700</bug_when>
    <thetext>Created attachment 134661
patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>591563</commentid>
    <comment_count>2</comment_count>
      <attachid>134661</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-03-29 14:25:23 -0700</bug_when>
    <thetext>Comment on attachment 134661
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=134661&amp;action=review

&gt; Source/WebCore/loader/FrameLoader.cpp:-1979
&gt; -    // Retain because the stop may release the last reference to it.
&gt; -    RefPtr&lt;Frame&gt; protect(m_frame);

Do we not need this protect variable?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>591566</commentid>
    <comment_count>3</comment_count>
    <who name="Nate Chapin">japhet</who>
    <bug_when>2012-03-29 14:27:44 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 134661 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=134661&amp;action=review
&gt; 
&gt; &gt; Source/WebCore/loader/FrameLoader.cpp:-1979
&gt; &gt; -    // Retain because the stop may release the last reference to it.
&gt; &gt; -    RefPtr&lt;Frame&gt; protect(m_frame);
&gt; 
&gt; Do we not need this protect variable?

Nothing obviously broke, but I don&apos;t have proof that we don&apos;t need it. Will look more before committing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>591684</commentid>
    <comment_count>4</comment_count>
    <who name="Nate Chapin">japhet</who>
    <bug_when>2012-03-29 16:15:20 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; (From update of attachment 134661 [details] [details])
&gt; &gt; View in context: https://bugs.webkit.org/attachment.cgi?id=134661&amp;action=review
&gt; &gt; 
&gt; &gt; &gt; Source/WebCore/loader/FrameLoader.cpp:-1979
&gt; &gt; &gt; -    // Retain because the stop may release the last reference to it.
&gt; &gt; &gt; -    RefPtr&lt;Frame&gt; protect(m_frame);
&gt; &gt; 
&gt; &gt; Do we not need this protect variable?
&gt; 
&gt; Nothing obviously broke, but I don&apos;t have proof that we don&apos;t need it. Will look more before committing.

I&apos;m not sure there&apos;s a good way to tell whether it&apos;s necessary. Nothing in the callstack below is protecting the Frame, and DocumentLoader::m_frame is a raw pointer. On the other hand, I don&apos;t want to just cargo-cult it, especially when the comment uses a term as vague as &quot;the stop&quot; and was added in r17652.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>591693</commentid>
    <comment_count>5</comment_count>
      <attachid>134661</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-03-29 16:28:47 -0700</bug_when>
    <thetext>Comment on attachment 134661
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=134661&amp;action=review

&gt;&gt;&gt;&gt; Source/WebCore/loader/FrameLoader.cpp:-1979
&gt;&gt;&gt;&gt; -    RefPtr&lt;Frame&gt; protect(m_frame);
&gt;&gt;&gt; 
&gt;&gt;&gt; Do we not need this protect variable?
&gt;&gt; 
&gt;&gt; Nothing obviously broke, but I don&apos;t have proof that we don&apos;t need it. Will look more before committing.
&gt; 
&gt; I&apos;m not sure there&apos;s a good way to tell whether it&apos;s necessary. Nothing in the callstack below is protecting the Frame, and DocumentLoader::m_frame is a raw pointer. On the other hand, I don&apos;t want to just cargo-cult it, especially when the comment uses a term as vague as &quot;the stop&quot; and was added in r17652.

checkLoadComplete() triggers the load event, right?  We must have a test that rips and iframe out of the DOM when the load event fires.  If this was necessary, we&apos;d run into trouble on that test.  I&apos;m inclined to think it&apos;s not necessary, but I&apos;m not sure how to become completely convinced.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>592459</commentid>
    <comment_count>6</comment_count>
    <who name="Nate Chapin">japhet</who>
    <bug_when>2012-03-30 13:43:07 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; (From update of attachment 134661 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=134661&amp;action=review
&gt; 
&gt; &gt;&gt;&gt;&gt; Source/WebCore/loader/FrameLoader.cpp:-1979
&gt; &gt;&gt;&gt;&gt; -    RefPtr&lt;Frame&gt; protect(m_frame);
&gt; &gt;&gt;&gt; 
&gt; &gt;&gt;&gt; Do we not need this protect variable?
&gt; &gt;&gt; 
&gt; &gt;&gt; Nothing obviously broke, but I don&apos;t have proof that we don&apos;t need it. Will look more before committing.
&gt; &gt; 
&gt; &gt; I&apos;m not sure there&apos;s a good way to tell whether it&apos;s necessary. Nothing in the callstack below is protecting the Frame, and DocumentLoader::m_frame is a raw pointer. On the other hand, I don&apos;t want to just cargo-cult it, especially when the comment uses a term as vague as &quot;the stop&quot; and was added in r17652.
&gt; 
&gt; checkLoadComplete() triggers the load event, right?  We must have a test that rips and iframe out of the DOM when the load event fires.  If this was necessary, we&apos;d run into trouble on that test.  I&apos;m inclined to think it&apos;s not necessary, but I&apos;m not sure how to become completely convinced.

Ok, I think I&apos;m convinced.

1. DocumentLoader is protected in MainResourceLoader::didFinishLoading(), so we don&apos;t need to worry about it.
2. The load event is fired from within m_writer.end() in DocumentLoader::finishedLoading().
2a. Inside DocumentWrtier::end(), the callstack passes through the parser, then calls Document::finishedParsing(), which protects the Frame until it exits.
2b. Nothing happens between exiting finishedParsing() and exiting DocumentWriter::end() except nulling the parser.
3. Suppose that the Frame was detached during the load event. We therefore called FrameLoader::detachFromParent(), which called DocumentLoader::detachFromFrame(), which called DocumentLoader::stopLoading().
4. stopLoading() called DocumentLoader::setMainResourceError() either directly, through mainReceivedError() or through MainResourceLoader::cancel().
5. Therefore, when control returns to DocumentLoader::finishedLoading(), though m_frame is null, m_mainResourceError is now non-null. We exit finishedLoading() before dereferencing m_frame again.

...and indeed, if I reverse the 2 clauses in &quot;if (!m_mainDocumentError.isNull() || frameLoader()-&gt;stateMachine()-&gt;creatingInitialEmptyDocument())&quot;, I get a null Frame* deref on, among others, fast/dom/Document/document-close-iframe-load.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>592509</commentid>
    <comment_count>7</comment_count>
      <attachid>134661</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-03-30 14:42:20 -0700</bug_when>
    <thetext>Comment on attachment 134661
patch

Clearing flags on attachment: 134661

Committed r112728: &lt;http://trac.webkit.org/changeset/112728&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>592510</commentid>
    <comment_count>8</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-03-30 14:42:24 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>134661</attachid>
            <date>2012-03-29 13:57:42 -0700</date>
            <delta_ts>2012-03-30 14:42:19 -0700</delta_ts>
            <desc>patch</desc>
            <filename>finish.txt</filename>
            <type>text/plain</type>
            <size>3611</size>
            <attacher name="Nate Chapin">japhet</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDExMjU3MSkKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE5IEBACisyMDEyLTAzLTI5ICBOYXRlIENo
YXBpbiAgPGphcGhldEBjaHJvbWl1bS5vcmc+CisKKyAgICAgICAgTWVyZ2UgRnJhbWVMb2FkZXI6
OmZpbmlzaGVkTG9hZGluZygpIGludG8gRG9jdW1lbnRMb2FkZXI6OmZpbmlzaGVkTG9hZGluZygp
LgorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9ODI2NTMK
KworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFM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lzaGVkTG9hZGluZ0RvY3VtZW50KHRoaXMpOworICAgIG1f
d3JpdGVyLmVuZCgpOworICAgIGlmICghbV9tYWluRG9jdW1lbnRFcnJvci5pc051bGwoKSB8fCBm
cmFtZUxvYWRlcigpLT5zdGF0ZU1hY2hpbmUoKS0+Y3JlYXRpbmdJbml0aWFsRW1wdHlEb2N1bWVu
dCgpKQorICAgICAgICByZXR1cm47CisgICAgc2V0UHJpbWFyeUxvYWRDb21wbGV0ZSh0cnVlKTsK
KyAgICBmcmFtZUxvYWRlcigpLT5jaGVja0xvYWRDb21wbGV0ZSgpOwogfQogCiB2b2lkIERvY3Vt
ZW50TG9hZGVyOjpjb21taXRMb2FkKGNvbnN0IGNoYXIqIGRhdGEsIGludCBsZW5ndGgpCkluZGV4
OiBTb3VyY2UvV2ViQ29yZS9sb2FkZXIvRnJhbWVMb2FkZXIuaAo9PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3Vy
Y2UvV2ViQ29yZS9sb2FkZXIvRnJhbWVMb2FkZXIuaAkocmV2aXNpb24gMTEyNTcwKQorKysgU291
cmNlL1dlYkNvcmUvbG9hZGVyL0ZyYW1lTG9hZGVyLmgJKHdvcmtpbmcgY29weSkKQEAgLTE1Niw4
ICsxNTYsNiBAQAogCiAgICAgdm9pZCBoYW5kbGVGYWxsYmFja0NvbnRlbnQoKTsKIAotICAgIHZv
aWQgZmluaXNoZWRMb2FkaW5nKCk7Ci0KICAgICBSZXNvdXJjZUVycm9yIGNhbmNlbGxlZEVycm9y
KGNvbnN0IFJlc291cmNlUmVxdWVzdCYpIGNvbnN0OwogCiAgICAgYm9vbCBpc0hvc3RlZEJ5T2Jq
ZWN0RWxlbWVudCgpIGNvbnN0Owo=
</data>

          </attachment>
      

    </bug>

</bugzilla>