Changeset 87566 in webkit


Ignore:
Timestamp:
May 27, 2011 2:15:46 PM (13 years ago)
Author:
beidson@apple.com
Message:

First swipe at resolving <rdar://problem/9125145> and https://bugs.webkit.org/show_bug.cgi?id=61494

Reviewed by Darin Adler.

Make the Document be intelligent about returning its DocumentLoader, including the possibility that
the DocumentLoader will be null.

No new tests. No change in behavior.

Instead of storing the DocumentLoader at construction and never changing it,
always calculate it based on the FrameLoader's current DocumentLoader:

  • dom/Document.cpp:

(WebCore::Document::Document):
(WebCore::Document::suggestedMIMEType):
(WebCore::Document::lastModified):
(WebCore::Document::initSecurityContext):
(WebCore::Document::updateURLForPushOrReplaceState):
(WebCore::Document::loader):

  • dom/Document.h:

Null-check or ASSERT that the DocumentLoader exists (or both) depending on the scenario:

  • bindings/ScriptControllerBase.cpp:

(WebCore::ScriptController::executeIfJavaScriptURL):

  • html/MediaDocument.cpp:

(WebCore::MediaDocument::replaceMediaElementTimerFired):

  • html/PluginDocument.cpp:

(WebCore::PluginDocumentParser::createDocumentStructure):

  • platform/mac/HTMLConverter.mm:

(fileWrapperForElement):

  • WebCore.exp.in:
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87557 r87566  
     12011-05-27  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        First swipe at resolving <rdar://problem/9125145> and https://bugs.webkit.org/show_bug.cgi?id=61494
     6       
     7        Make the Document be intelligent about returning its DocumentLoader, including the possibility that
     8        the DocumentLoader will be null.
     9
     10        No new tests. No change in behavior.
     11
     12        Instead of storing the DocumentLoader at construction and never changing it,
     13        always calculate it based on the FrameLoader's current DocumentLoader:
     14        * dom/Document.cpp:
     15        (WebCore::Document::Document):
     16        (WebCore::Document::suggestedMIMEType):
     17        (WebCore::Document::lastModified):
     18        (WebCore::Document::initSecurityContext):
     19        (WebCore::Document::updateURLForPushOrReplaceState):
     20        (WebCore::Document::loader):
     21        * dom/Document.h:
     22
     23        Null-check or ASSERT that the DocumentLoader exists (or both) depending on the scenario:
     24        * bindings/ScriptControllerBase.cpp:
     25        (WebCore::ScriptController::executeIfJavaScriptURL):
     26        * html/MediaDocument.cpp:
     27        (WebCore::MediaDocument::replaceMediaElementTimerFired):
     28        * html/PluginDocument.cpp:
     29        (WebCore::PluginDocumentParser::createDocumentStructure):
     30        * platform/mac/HTMLConverter.mm:
     31        (fileWrapperForElement):
     32
     33        * WebCore.exp.in:
     34
    1352011-05-27  Jer Noble  <jer.noble@apple.com>
    236
  • trunk/Source/WebCore/WebCore.exp.in

    r87483 r87566  
    12841284__ZNK7WebCore8Document4bodyEv
    12851285__ZNK7WebCore8Document6domainEv
     1286__ZNK7WebCore8Document6loaderEv
    12861287__ZNK7WebCore8IntPointcv7CGPointEv
    12871288__ZNK7WebCore8IntPointcv8_NSPointEv
  • trunk/Source/WebCore/bindings/ScriptControllerBase.cpp

    r87309 r87566  
    115115    //        synchronously can cause crashes:
    116116    //        http://bugs.webkit.org/show_bug.cgi?id=16782
    117     if (shouldReplaceDocumentIfJavaScriptURL == ReplaceDocumentIfJavaScriptURL)
    118         m_frame->document()->loader()->writer()->replaceDocument(scriptResult);
    119 
     117    if (shouldReplaceDocumentIfJavaScriptURL == ReplaceDocumentIfJavaScriptURL) {
     118        // We're still in a frame, so there should be a DocumentLoader.
     119        ASSERT(m_frame->document()->loader());
     120        if (DocumentLoader* loader = m_frame->document()->loader())
     121            loader->writer()->replaceDocument(scriptResult);
     122    }
    120123    return true;
    121124}
  • trunk/Source/WebCore/dom/Document.cpp

    r87414 r87566  
    436436
    437437    m_frame = frame;
    438     m_documentLoader = frame ? frame->loader()->activeDocumentLoader() : 0;
    439438
    440439    // We depend on the url getting immediately set in subframes, but we
     
    11071106        return "text/html";
    11081107
    1109     return m_documentLoader->responseMIMEType();
     1108    if (DocumentLoader* documentLoader = loader())
     1109        return documentLoader->responseMIMEType();
     1110    return String();
    11101111}
    11111112
     
    37823783    bool foundDate = false;
    37833784    if (m_frame) {
    3784         String httpLastModified = m_documentLoader->response().httpHeaderField("Last-Modified");
     3785        // Since we're still in a Frame, we should have a DocumentLoader.
     3786        ASSERT(loader());
     3787        String httpLastModified;
     3788        if (loader())
     3789            httpLastModified = loader()->response().httpHeaderField("Last-Modified");
    37853790        if (!httpLastModified.isEmpty()) {
    37863791            date.setMillisecondsSinceEpochForDateTime(parseDate(httpLastModified));
     
    45114516        // and https://bugs.webkit.org/show_bug.cgi?id=19760 for further
    45124517        // discussion.
    4513         if (m_documentLoader->substituteData().isValid())
     4518       
     4519        DocumentLoader* documentLoader = loader();
     4520        // Since we're still in a Frame, we should have a DocumentLoader.
     4521        ASSERT(documentLoader);
     4522        if (documentLoader && documentLoader->substituteData().isValid())
    45144523            securityOrigin()->grantLoadLocalResources();
    45154524    }
     
    45924601    setURL(url);
    45934602    f->loader()->setOutgoingReferrer(url);
    4594     m_documentLoader->replaceRequestURLForSameDocumentNavigation(url);
     4603    // Since we're still in a frame, we should have a DocumentLoader.
     4604    ASSERT(loader());
     4605    if (DocumentLoader* documentLoader = loader())
     4606        documentLoader->replaceRequestURLForSameDocumentNavigation(url);
    45954607}
    45964608
     
    51435155}
    51445156
     5157DocumentLoader* Document::loader() const
     5158{
     5159    if (!m_frame)
     5160        return 0;
     5161   
     5162    DocumentLoader* loader = m_frame->loader()->activeDocumentLoader();
     5163    if (!loader)
     5164        return 0;
     5165   
     5166    if (m_frame->document() != this)
     5167        return 0;
     5168   
     5169    return loader;
     5170}
     5171
    51455172} // namespace WebCore
  • trunk/Source/WebCore/dom/Document.h

    r87414 r87566  
    570570    bool visuallyOrdered() const { return m_visuallyOrdered; }
    571571   
    572     void setDocumentLoader(DocumentLoader* documentLoader) { m_documentLoader = documentLoader; }
    573     DocumentLoader* loader() const { return m_documentLoader; }
     572    DocumentLoader* loader() const;
    574573
    575574    void open(Document* ownerDocument = 0);
     
    11751174
    11761175    Frame* m_frame;
    1177     DocumentLoader* m_documentLoader;
    11781176    OwnPtr<CachedResourceLoader> m_cachedResourceLoader;
    11791177    RefPtr<DocumentParser> m_parser;
  • trunk/Source/WebCore/html/MediaDocument.cpp

    r85510 r87566  
    222222        embedElement->setAttribute(nameAttr, "plugin");
    223223        embedElement->setAttribute(srcAttr, url().string());
    224         embedElement->setAttribute(typeAttr, loader()->writer()->mimeType());
     224
     225        DocumentLoader* documentLoader = loader();
     226        ASSERT(documentLoader);
     227        if (documentLoader)
     228            embedElement->setAttribute(typeAttr, documentLoader->writer()->mimeType());
    225229
    226230        ExceptionCode ec;
  • trunk/Source/WebCore/html/PluginDocument.cpp

    r78342 r87566  
    9393    m_embedElement->setAttribute(nameAttr, "plugin");
    9494    m_embedElement->setAttribute(srcAttr, document()->url().string());
    95     m_embedElement->setAttribute(typeAttr, document()->loader()->writer()->mimeType());
     95   
     96    DocumentLoader* loader = document()->loader();
     97    ASSERT(loader);
     98    if (loader)
     99        m_embedElement->setAttribute(typeAttr, loader->writer()->mimeType());
    96100
    97101    static_cast<PluginDocument*>(document())->setPluginNode(m_embedElement);
  • trunk/Source/WebCore/platform/mac/HTMLConverter.mm

    r85036 r87566  
    17541754    if (!attr.isEmpty()) {
    17551755        NSURL *URL = element->document()->completeURL(attr);
    1756         wrapper = fileWrapperForURL(element->document()->loader(), URL);
     1756        if (DocumentLoader* loader = element->document()->loader())
     1757            wrapper = fileWrapperForURL(loader, URL);
    17571758    }
    17581759    if (!wrapper) {
Note: See TracChangeset for help on using the changeset viewer.