Changeset 248728 in webkit


Ignore:
Timestamp:
Aug 15, 2019 10:44:07 AM (5 years ago)
Author:
youenn@apple.com
Message:

Always create a Document with a valid SessionID
https://bugs.webkit.org/show_bug.cgi?id=200727

Reviewed by Alex Christensen.

Source/WebCore:

Pass a valid SessionID to the Document constructor.
This allows getting us closer to use SessionID like ObjectIdentifier.
Add a SessionID getter from Frame and use it when constructing a Document.
Otherwise, retrieve the SessionID from the corresponding context.
No change of behavior.

  • dom/DOMImplementation.cpp:

(WebCore::createXMLDocument):
(WebCore::DOMImplementation::createDocument):
(WebCore::DOMImplementation::createHTMLDocument):

  • dom/DOMImplementation.h:
  • dom/Document.cpp:

(WebCore::Document::Document):
(WebCore::m_undoManager):
(WebCore::Document::create):
(WebCore::Document::createNonRenderedPlaceholder):
(WebCore::Document::cloneDocumentWithoutChildren const):
(WebCore::Document::ensureTemplateDocument):

  • dom/Document.h:

(WebCore::Document::create):
(WebCore::Document::createNonRenderedPlaceholder): Deleted.

  • dom/XMLDocument.h:

(WebCore::XMLDocument::create):
(WebCore::XMLDocument::createXHTML):
(WebCore::XMLDocument::XMLDocument):

  • html/FTPDirectoryDocument.cpp:

(WebCore::FTPDirectoryDocument::FTPDirectoryDocument):

  • html/FTPDirectoryDocument.h:
  • html/HTMLDocument.cpp:

(WebCore::HTMLDocument::createSynthesizedDocument):
(WebCore::HTMLDocument::HTMLDocument):
(WebCore::HTMLDocument::cloneDocumentWithoutChildren const):

  • html/HTMLDocument.h:

(WebCore::HTMLDocument::create):
(WebCore::HTMLDocument::createSynthesizedDocument): Deleted.

  • html/ImageDocument.cpp:

(WebCore::ImageDocument::ImageDocument):

  • html/MediaDocument.cpp:

(WebCore::MediaDocument::MediaDocument):

  • html/MediaDocument.h:
  • html/PluginDocument.cpp:

(WebCore::PluginDocument::PluginDocument):

  • html/PluginDocument.h:
  • html/TextDocument.cpp:

(WebCore::TextDocument::TextDocument):

  • html/TextDocument.h:
  • inspector/DOMPatchSupport.cpp:

(WebCore::DOMPatchSupport::patchDocument):

  • loader/DocumentWriter.cpp:

(WebCore::DocumentWriter::createDocument):
(WebCore::DocumentWriter::begin):

  • loader/SinkDocument.cpp:

(WebCore::SinkDocument::SinkDocument):

  • loader/SinkDocument.h:
  • loader/cache/CachedSVGDocument.cpp:

(WebCore::CachedSVGDocument::finishLoading):

  • loader/cache/CachedSVGFont.cpp:

(WebCore::CachedSVGFont::ensureCustomFontData):

  • page/Frame.cpp:

(WebCore::Frame::sessionID const):

  • page/Frame.h:
  • svg/SVGDocument.cpp:

(WebCore::SVGDocument::SVGDocument):
(WebCore::SVGDocument::cloneDocumentWithoutChildren const):

  • svg/SVGDocument.h:

(WebCore::SVGDocument::create):

  • xml/DOMParser.cpp:

(WebCore::DOMParser::parseFromString):

  • xml/DOMParser.h:
  • xml/DOMParser.idl:
  • xml/XMLHttpRequest.cpp:
  • xml/XSLTProcessor.cpp:

(WebCore::XSLTProcessor::createDocumentFromSource):

Source/WebKitLegacy/mac:

Implement WebKit1 sessionID getter like done for WebKit2.
Either the loader client has a page in which case the page session ID is used
or the client has no page, in which case the default session ID is used.
This is the same behavior as CachedResourceLoader.

  • WebCoreSupport/WebFrameLoaderClient.mm:

(WebFrameLoaderClient::sessionID const):

Source/WebKitLegacy/win:

Implement WebKit1 sessionID getter like done for WebKit2.
Either the loader client has a page in which case the page session ID is used
or the client has no page, in which case the default session ID is used.
This is the same behavior as CachedResourceLoader.

  • WebCoreSupport/WebFrameLoaderClient.cpp:

(WebFrameLoaderClient::sessionID const):

Location:
trunk/Source
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r248722 r248728  
     12019-08-15  Youenn Fablet  <youenn@apple.com>
     2
     3        Always create a Document with a valid SessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=200727
     5
     6        Reviewed by Alex Christensen.
     7
     8        Pass a valid SessionID to the Document constructor.
     9        This allows getting us closer to use SessionID like ObjectIdentifier.
     10        Add a SessionID getter from Frame and use it when constructing a Document.
     11        Otherwise, retrieve the SessionID from the corresponding context.
     12        No change of behavior.
     13
     14        * dom/DOMImplementation.cpp:
     15        (WebCore::createXMLDocument):
     16        (WebCore::DOMImplementation::createDocument):
     17        (WebCore::DOMImplementation::createHTMLDocument):
     18        * dom/DOMImplementation.h:
     19        * dom/Document.cpp:
     20        (WebCore::Document::Document):
     21        (WebCore::m_undoManager):
     22        (WebCore::Document::create):
     23        (WebCore::Document::createNonRenderedPlaceholder):
     24        (WebCore::Document::cloneDocumentWithoutChildren const):
     25        (WebCore::Document::ensureTemplateDocument):
     26        * dom/Document.h:
     27        (WebCore::Document::create):
     28        (WebCore::Document::createNonRenderedPlaceholder): Deleted.
     29        * dom/XMLDocument.h:
     30        (WebCore::XMLDocument::create):
     31        (WebCore::XMLDocument::createXHTML):
     32        (WebCore::XMLDocument::XMLDocument):
     33        * html/FTPDirectoryDocument.cpp:
     34        (WebCore::FTPDirectoryDocument::FTPDirectoryDocument):
     35        * html/FTPDirectoryDocument.h:
     36        * html/HTMLDocument.cpp:
     37        (WebCore::HTMLDocument::createSynthesizedDocument):
     38        (WebCore::HTMLDocument::HTMLDocument):
     39        (WebCore::HTMLDocument::cloneDocumentWithoutChildren const):
     40        * html/HTMLDocument.h:
     41        (WebCore::HTMLDocument::create):
     42        (WebCore::HTMLDocument::createSynthesizedDocument): Deleted.
     43        * html/ImageDocument.cpp:
     44        (WebCore::ImageDocument::ImageDocument):
     45        * html/MediaDocument.cpp:
     46        (WebCore::MediaDocument::MediaDocument):
     47        * html/MediaDocument.h:
     48        * html/PluginDocument.cpp:
     49        (WebCore::PluginDocument::PluginDocument):
     50        * html/PluginDocument.h:
     51        * html/TextDocument.cpp:
     52        (WebCore::TextDocument::TextDocument):
     53        * html/TextDocument.h:
     54        * inspector/DOMPatchSupport.cpp:
     55        (WebCore::DOMPatchSupport::patchDocument):
     56        * loader/DocumentWriter.cpp:
     57        (WebCore::DocumentWriter::createDocument):
     58        (WebCore::DocumentWriter::begin):
     59        * loader/SinkDocument.cpp:
     60        (WebCore::SinkDocument::SinkDocument):
     61        * loader/SinkDocument.h:
     62        * loader/cache/CachedSVGDocument.cpp:
     63        (WebCore::CachedSVGDocument::finishLoading):
     64        * loader/cache/CachedSVGFont.cpp:
     65        (WebCore::CachedSVGFont::ensureCustomFontData):
     66        * page/Frame.cpp:
     67        (WebCore::Frame::sessionID const):
     68        * page/Frame.h:
     69        * svg/SVGDocument.cpp:
     70        (WebCore::SVGDocument::SVGDocument):
     71        (WebCore::SVGDocument::cloneDocumentWithoutChildren const):
     72        * svg/SVGDocument.h:
     73        (WebCore::SVGDocument::create):
     74        * xml/DOMParser.cpp:
     75        (WebCore::DOMParser::parseFromString):
     76        * xml/DOMParser.h:
     77        * xml/DOMParser.idl:
     78        * xml/XMLHttpRequest.cpp:
     79        * xml/XSLTProcessor.cpp:
     80        (WebCore::XSLTProcessor::createDocumentFromSource):
     81
    1822019-08-15  Antti Koivisto  <antti@apple.com>
    283
  • trunk/Source/WebCore/dom/DOMImplementation.cpp

    r243887 r248728  
    7878}
    7979
    80 static inline Ref<XMLDocument> createXMLDocument(const String& namespaceURI)
     80static inline Ref<XMLDocument> createXMLDocument(PAL::SessionID sessionID, const String& namespaceURI)
    8181{
    8282    if (namespaceURI == SVGNames::svgNamespaceURI)
    83         return SVGDocument::create(nullptr, URL());
     83        return SVGDocument::create(sessionID, nullptr, URL());
    8484    if (namespaceURI == HTMLNames::xhtmlNamespaceURI)
    85         return XMLDocument::createXHTML(nullptr, URL());
    86     return XMLDocument::create(nullptr, URL());
     85        return XMLDocument::createXHTML(sessionID, nullptr, URL());
     86    return XMLDocument::create(sessionID, nullptr, URL());
    8787}
    8888
    8989ExceptionOr<Ref<XMLDocument>> DOMImplementation::createDocument(const String& namespaceURI, const String& qualifiedName, DocumentType* documentType)
    9090{
    91     auto document = createXMLDocument(namespaceURI);
     91    auto document = createXMLDocument(m_document.sessionID(), namespaceURI);
    9292    document->setContextDocument(m_document.contextDocument());
    9393    document->setSecurityOriginPolicy(m_document.securityOriginPolicy());
     
    121121Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
    122122{
    123     auto document = HTMLDocument::create(nullptr, URL());
     123    auto document = HTMLDocument::create(m_document.sessionID(), nullptr, URL());
    124124    document->open();
    125125    document->write(nullptr, { "<!doctype html><html><head></head><body></body></html>"_s });
     
    135135}
    136136
    137 Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url)
     137Ref<Document> DOMImplementation::createDocument(PAL::SessionID sessionID, const String& type, Frame* frame, const URL& url)
    138138{
    139139    // FIXME: Inelegant to have this here just because this is the home of DOM APIs for creating documents.
     
    143143    // Plug-ins cannot take over for HTML, XHTML, plain text, or non-PDF images.
    144144    if (equalLettersIgnoringASCIICase(type, "text/html"))
    145         return HTMLDocument::create(frame, url);
     145        return HTMLDocument::create(sessionID, frame, url);
    146146    if (equalLettersIgnoringASCIICase(type, "application/xhtml+xml"))
    147         return XMLDocument::createXHTML(frame, url);
     147        return XMLDocument::createXHTML(sessionID, frame, url);
    148148    if (equalLettersIgnoringASCIICase(type, "text/plain"))
    149         return TextDocument::create(frame, url);
     149        return TextDocument::create(sessionID, frame, url);
    150150    bool isImage = MIMETypeRegistry::isSupportedImageMIMEType(type);
    151151    if (frame && isImage && !MIMETypeRegistry::isPDFOrPostScriptMIMEType(type))
     
    161161    parameters.url = url;
    162162    if (MediaPlayer::supportsType(parameters))
    163         return MediaDocument::create(frame, url);
     163        return MediaDocument::create(sessionID, frame, url);
    164164#endif
    165165
    166166#if ENABLE(FTPDIR)
    167167    if (equalLettersIgnoringASCIICase(type, "application/x-ftp-directory"))
    168         return FTPDirectoryDocument::create(frame, url);
     168        return FTPDirectoryDocument::create(sessionID, frame, url);
    169169#endif
    170170
    171171    if (frame && frame->loader().client().shouldAlwaysUsePluginDocument(type))
    172         return PluginDocument::create(frame, url);
     172        return PluginDocument::create(*frame, url);
    173173
    174174    // The following is the relatively costly lookup that requires initializing the plug-in database.
     
    177177            ? PluginData::AllPlugins : PluginData::OnlyApplicationPlugins;
    178178        if (frame->page()->pluginData().supportsWebVisibleMimeType(type, allowedPluginTypes))
    179             return PluginDocument::create(frame, url);
     179            return PluginDocument::create(*frame, url);
    180180    }
    181181
     
    185185        return ImageDocument::create(*frame, url);
    186186    if (MIMETypeRegistry::isTextMIMEType(type))
    187         return TextDocument::create(frame, url);
     187        return TextDocument::create(sessionID, frame, url);
    188188    if (equalLettersIgnoringASCIICase(type, "image/svg+xml"))
    189         return SVGDocument::create(frame, url);
     189        return SVGDocument::create(sessionID, frame, url);
    190190    if (MIMETypeRegistry::isXMLMIMEType(type))
    191         return XMLDocument::create(frame, url);
    192     return HTMLDocument::create(frame, url);
     191        return XMLDocument::create(sessionID, frame, url);
     192    return HTMLDocument::create(sessionID, frame, url);
    193193}
    194194
  • trunk/Source/WebCore/dom/DOMImplementation.h

    r243887 r248728  
    4444    WEBCORE_EXPORT static Ref<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media);
    4545
    46     static Ref<Document> createDocument(const String& MIMEType, Frame*, const URL&);
     46    static Ref<Document> createDocument(PAL::SessionID, const String& MIMEType, Frame*, const URL&);
    4747
    4848private:
  • trunk/Source/WebCore/dom/Document.cpp

    r248668 r248728  
    511511}
    512512
    513 Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsigned constructionFlags)
     513Document::Document(PAL::SessionID sessionID, Frame* frame, const URL& url, unsigned documentClasses, unsigned constructionFlags)
    514514    : ContainerNode(*this, CreateDocument)
    515515    , TreeScope(*this)
     
    561561    , m_isNonRenderedPlaceholder(constructionFlags & NonRenderedPlaceholder)
    562562    , m_orientationNotifier(currentOrientation(frame))
    563     , m_sessionID(PAL::SessionID::emptySessionID())
     563    , m_sessionID(sessionID)
    564564    , m_identifier(DocumentIdentifier::generate())
    565565    , m_undoManager(UndoManager::create(*this))
    566566{
     567    ASSERT(!frame || frame->sessionID() == m_sessionID);
     568
    567569    auto addResult = allDocumentsMap().add(m_identifier, this);
    568570    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     
    595597Ref<Document> Document::create(Document& contextDocument)
    596598{
    597     auto document = adoptRef(*new Document(nullptr, URL()));
     599    auto document = adoptRef(*new Document(contextDocument.sessionID(), nullptr, URL()));
    598600    document->setContextDocument(contextDocument);
    599601    document->setSecurityOriginPolicy(contextDocument.securityOriginPolicy());
    600602    return document;
     603}
     604
     605Ref<Document> Document::createNonRenderedPlaceholder(Frame& frame, const URL& url)
     606{
     607    return adoptRef(*new Document(frame.sessionID(), &frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
    601608}
    602609
     
    38713878    if (isXMLDocument()) {
    38723879        if (isXHTMLDocument())
    3873             return XMLDocument::createXHTML(nullptr, url());
    3874         return XMLDocument::create(nullptr, url());
    3875     }
    3876     return create(url());
     3880            return XMLDocument::createXHTML(sessionID(), nullptr, url());
     3881        return XMLDocument::create(sessionID(), nullptr, url());
     3882    }
     3883    return create(sessionID(), url());
    38773884}
    38783885
     
    68856892
    68866893    if (isHTMLDocument())
    6887         m_templateDocument = HTMLDocument::create(nullptr, WTF::blankURL());
     6894        m_templateDocument = HTMLDocument::create(sessionID(), nullptr, WTF::blankURL());
    68886895    else
    6889         m_templateDocument = create(WTF::blankURL());
     6896        m_templateDocument = create(sessionID(), WTF::blankURL());
    68906897
    68916898    m_templateDocument->setContextDocument(contextDocument());
  • trunk/Source/WebCore/dom/Document.h

    r248667 r248728  
    351351    WTF_MAKE_ISO_ALLOCATED(Document);
    352352public:
    353     static Ref<Document> create(const URL&);
     353    static Ref<Document> create(PAL::SessionID, const URL&);
    354354    static Ref<Document> createNonRenderedPlaceholder(Frame&, const URL&);
    355355    static Ref<Document> create(Document&);
     
    15321532protected:
    15331533    enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
    1534     Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
     1534    Document(PAL::SessionID, Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
    15351535
    15361536    void clearXMLVersion() { m_xmlVersion = String(); }
     
    20762076}
    20772077
    2078 inline Ref<Document> Document::create(const URL& url)
     2078inline Ref<Document> Document::create(PAL::SessionID sessionID, const URL& url)
    20792079{
    2080     return adoptRef(*new Document(nullptr, url));
    2081 }
    2082 
    2083 inline Ref<Document> Document::createNonRenderedPlaceholder(Frame& frame, const URL& url)
    2084 {
    2085     return adoptRef(*new Document(&frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
     2080    return adoptRef(*new Document(sessionID, nullptr, url));
    20862081}
    20872082
  • trunk/Source/WebCore/dom/XMLDocument.h

    r229694 r248728  
    3333    WTF_MAKE_ISO_ALLOCATED(XMLDocument);
    3434public:
    35     static Ref<XMLDocument> create(Frame* frame, const URL& url)
     35    static Ref<XMLDocument> create(PAL::SessionID sessionID, Frame* frame, const URL& url)
    3636    {
    37         return adoptRef(*new XMLDocument(frame, url));
     37        return adoptRef(*new XMLDocument(sessionID, frame, url));
    3838    }
    3939
    40     static Ref<XMLDocument> createXHTML(Frame* frame, const URL& url)
     40    static Ref<XMLDocument> createXHTML(PAL::SessionID sessionID, Frame* frame, const URL& url)
    4141    {
    42         return adoptRef(*new XMLDocument(frame, url, XHTMLDocumentClass));
     42        return adoptRef(*new XMLDocument(sessionID, frame, url, XHTMLDocumentClass));
    4343    }
    4444
    4545protected:
    46     XMLDocument(Frame* frame, const URL& url, unsigned documentClasses = DefaultDocumentClass)
    47         : Document(frame, url, XMLDocumentClass | documentClasses)
     46    XMLDocument(PAL::SessionID sessionID, Frame* frame, const URL& url, unsigned documentClasses = DefaultDocumentClass)
     47        : Document(sessionID, frame, url, XMLDocumentClass | documentClasses)
    4848    { }
    4949};
  • trunk/Source/WebCore/html/FTPDirectoryDocument.cpp

    r246490 r248728  
    422422}
    423423
    424 FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame, const URL& url)
    425     : HTMLDocument(frame, url)
     424FTPDirectoryDocument::FTPDirectoryDocument(PAL::SessionID sessionID, Frame* frame, const URL& url)
     425    : HTMLDocument(sessionID, frame, url)
    426426{
    427427#if !LOG_DISABLED
  • trunk/Source/WebCore/html/FTPDirectoryDocument.h

    r229694 r248728  
    3232    WTF_MAKE_ISO_ALLOCATED(FTPDirectoryDocument);
    3333public:
    34     static Ref<FTPDirectoryDocument> create(Frame* frame, const URL& url)
     34    static Ref<FTPDirectoryDocument> create(PAL::SessionID sessionID, Frame* frame, const URL& url)
    3535    {
    36         return adoptRef(*new FTPDirectoryDocument(frame, url));
     36        return adoptRef(*new FTPDirectoryDocument(sessionID, frame, url));
    3737    }
    3838
    3939private:
    40     FTPDirectoryDocument(Frame*, const URL&);
     40    FTPDirectoryDocument(PAL::SessionID, Frame*, const URL&);
    4141    Ref<DocumentParser> createParser() override;
    4242};
  • trunk/Source/WebCore/html/HTMLDocument.cpp

    r246490 r248728  
    8888using namespace HTMLNames;
    8989
    90 HTMLDocument::HTMLDocument(Frame* frame, const URL& url, DocumentClassFlags documentClasses, unsigned constructionFlags)
    91     : Document(frame, url, documentClasses | HTMLDocumentClass, constructionFlags)
     90Ref<HTMLDocument> HTMLDocument::createSynthesizedDocument(Frame& frame, const URL& url)
     91{
     92    return adoptRef(*new HTMLDocument(frame.sessionID(), &frame, url, HTMLDocumentClass, Synthesized));
     93}
     94
     95HTMLDocument::HTMLDocument(PAL::SessionID sessionID, Frame* frame, const URL& url, DocumentClassFlags documentClasses, unsigned constructionFlags)
     96    : Document(sessionID, frame, url, documentClasses | HTMLDocumentClass, constructionFlags)
    9297{
    9398    clearXMLVersion();
     
    248253Ref<Document> HTMLDocument::cloneDocumentWithoutChildren() const
    249254{
    250     return create(nullptr, url());
    251 }
    252 
    253 }
     255    return create(sessionID(), nullptr, url());
     256}
     257
     258}
  • trunk/Source/WebCore/html/HTMLDocument.h

    r246490 r248728  
    3030    WTF_MAKE_ISO_ALLOCATED(HTMLDocument);
    3131public:
    32     static Ref<HTMLDocument> create(Frame*, const URL&);
     32    static Ref<HTMLDocument> create(PAL::SessionID, Frame*, const URL&);
    3333    static Ref<HTMLDocument> createSynthesizedDocument(Frame&, const URL&);
    3434    virtual ~HTMLDocument();
     
    5555
    5656protected:
    57     HTMLDocument(Frame*, const URL&, DocumentClassFlags = 0, unsigned constructionFlags = 0);
     57    HTMLDocument(PAL::SessionID, Frame*, const URL&, DocumentClassFlags = 0, unsigned constructionFlags = 0);
    5858
    5959private:
     
    6666};
    6767
    68 inline Ref<HTMLDocument> HTMLDocument::create(Frame* frame, const URL& url)
     68inline Ref<HTMLDocument> HTMLDocument::create(PAL::SessionID sessionID, Frame* frame, const URL& url)
    6969{
    70     return adoptRef(*new HTMLDocument(frame, url, HTMLDocumentClass));
    71 }
    72 
    73 inline Ref<HTMLDocument> HTMLDocument::createSynthesizedDocument(Frame& frame, const URL& url)
    74 {
    75     return adoptRef(*new HTMLDocument(&frame, url, HTMLDocumentClass, Synthesized));
     70    return adoptRef(*new HTMLDocument(sessionID, frame, url, HTMLDocumentClass));
    7671}
    7772
  • trunk/Source/WebCore/html/ImageDocument.cpp

    r245823 r248728  
    199199
    200200ImageDocument::ImageDocument(Frame& frame, const URL& url)
    201     : HTMLDocument(&frame, url, ImageDocumentClass)
     201    : HTMLDocument(frame.sessionID(), &frame, url, ImageDocumentClass)
    202202    , m_imageElement(nullptr)
    203203    , m_imageSizeIsKnown(false)
  • trunk/Source/WebCore/html/MediaDocument.cpp

    r246490 r248728  
    145145}
    146146   
    147 MediaDocument::MediaDocument(Frame* frame, const URL& url)
    148     : HTMLDocument(frame, url, MediaDocumentClass)
     147MediaDocument::MediaDocument(PAL::SessionID sessionID, Frame* frame, const URL& url)
     148    : HTMLDocument(sessionID, frame, url, MediaDocumentClass)
    149149    , m_replaceMediaElementTimer(*this, &MediaDocument::replaceMediaElementTimerFired)
    150150{
  • trunk/Source/WebCore/html/MediaDocument.h

    r229694 r248728  
    3535    WTF_MAKE_ISO_ALLOCATED(MediaDocument);
    3636public:
    37     static Ref<MediaDocument> create(Frame* frame, const URL& url)
     37    static Ref<MediaDocument> create(PAL::SessionID sessionID, Frame* frame, const URL& url)
    3838    {
    39         return adoptRef(*new MediaDocument(frame, url));
     39        return adoptRef(*new MediaDocument(sessionID, frame, url));
    4040    }
    4141    virtual ~MediaDocument();
     
    4646
    4747private:
    48     MediaDocument(Frame*, const URL&);
     48    MediaDocument(PAL::SessionID, Frame*, const URL&);
    4949
    5050    Ref<DocumentParser> createParser() override;
  • trunk/Source/WebCore/html/PluginDocument.cpp

    r246490 r248728  
    142142}
    143143
    144 PluginDocument::PluginDocument(Frame* frame, const URL& url)
    145     : HTMLDocument(frame, url, PluginDocumentClass)
     144PluginDocument::PluginDocument(Frame& frame, const URL& url)
     145    : HTMLDocument(frame.sessionID(), &frame, url, PluginDocumentClass)
    146146{
    147147    setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
  • trunk/Source/WebCore/html/PluginDocument.h

    r229694 r248728  
    3535    WTF_MAKE_ISO_ALLOCATED(PluginDocument);
    3636public:
    37     static Ref<PluginDocument> create(Frame* frame, const URL& url)
     37    static Ref<PluginDocument> create(Frame& frame, const URL& url)
    3838    {
    3939        return adoptRef(*new PluginDocument(frame, url));
     
    5151
    5252private:
    53     PluginDocument(Frame*, const URL&);
     53    PluginDocument(Frame&, const URL&);
    5454
    5555    Ref<DocumentParser> createParser() final;
  • trunk/Source/WebCore/html/TextDocument.cpp

    r229694 r248728  
    3333WTF_MAKE_ISO_ALLOCATED_IMPL(TextDocument);
    3434
    35 TextDocument::TextDocument(Frame* frame, const URL& url)
    36     : HTMLDocument(frame, url, TextDocumentClass)
     35TextDocument::TextDocument(PAL::SessionID sessionID, Frame* frame, const URL& url)
     36    : HTMLDocument(sessionID, frame, url, TextDocumentClass)
    3737{
    3838    setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
  • trunk/Source/WebCore/html/TextDocument.h

    r229694 r248728  
    3232    WTF_MAKE_ISO_ALLOCATED(TextDocument);
    3333public:
    34     static Ref<TextDocument> create(Frame* frame, const URL& url)
     34    static Ref<TextDocument> create(PAL::SessionID sessionID, Frame* frame, const URL& url)
    3535    {
    36         return adoptRef(*new TextDocument(frame, url));
     36        return adoptRef(*new TextDocument(sessionID, frame, url));
    3737    }
    3838
    3939private:
    40     TextDocument(Frame*, const URL&);
     40    TextDocument(PAL::SessionID, Frame*, const URL&);
    4141   
    4242    Ref<DocumentParser> createParser() override;
  • trunk/Source/WebCore/inspector/DOMPatchSupport.cpp

    r241183 r248728  
    7777    RefPtr<Document> newDocument;
    7878    if (m_document.isHTMLDocument())
    79         newDocument = HTMLDocument::create(nullptr, URL());
     79        newDocument = HTMLDocument::create(m_document.sessionID(), nullptr, URL());
    8080    else if (m_document.isXHTMLDocument())
    81         newDocument = XMLDocument::createXHTML(nullptr, URL());
     81        newDocument = XMLDocument::createXHTML(m_document.sessionID(), nullptr, URL());
    8282    else if (m_document.isSVGDocument())
    83         newDocument = XMLDocument::create(nullptr, URL());
     83        newDocument = XMLDocument::create(m_document.sessionID(), nullptr, URL());
    8484
    8585    ASSERT(newDocument);
  • trunk/Source/WebCore/loader/DocumentWriter.cpp

    r247399 r248728  
    109109{
    110110    if (!m_frame->loader().stateMachine().isDisplayingInitialEmptyDocument() && m_frame->loader().client().shouldAlwaysUsePluginDocument(m_mimeType))
    111         return PluginDocument::create(m_frame, url);
     111        return PluginDocument::create(*m_frame, url);
    112112#if PLATFORM(IOS_FAMILY)
    113113    if (MIMETypeRegistry::isPDFMIMEType(m_mimeType) && (m_frame->isMainFrame() || !m_frame->settings().useImageDocumentForSubframePDF()))
    114         return SinkDocument::create(m_frame, url);
     114        return SinkDocument::create(*m_frame, url);
    115115#endif
    116116    if (!m_frame->loader().client().hasHTMLView())
    117117        return Document::createNonRenderedPlaceholder(*m_frame, url);
    118     return DOMImplementation::createDocument(m_mimeType, m_frame, url);
     118    return DOMImplementation::createDocument(m_frame->sessionID(), m_mimeType, m_frame, url);
    119119}
    120120
     
    133133    // then replace the document with one whose parser will ignore the incoming data (bug 39323)
    134134    if (document->isPluginDocument() && document->isSandboxed(SandboxPlugins))
    135         document = SinkDocument::create(m_frame, url);
     135        document = SinkDocument::create(*m_frame, url);
    136136
    137137    // FIXME: Do we need to consult the content security policy here about blocked plug-ins?
  • trunk/Source/WebCore/loader/SinkDocument.cpp

    r229694 r248728  
    5353};
    5454
    55 SinkDocument::SinkDocument(Frame* frame, const URL& url)
    56     : HTMLDocument(frame, url)
     55SinkDocument::SinkDocument(Frame& frame, const URL& url)
     56    : HTMLDocument(frame.sessionID(), &frame, url)
    5757{
    5858    setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
  • trunk/Source/WebCore/loader/SinkDocument.h

    r229694 r248728  
    3333    WTF_MAKE_ISO_ALLOCATED(SinkDocument);
    3434public:
    35     static Ref<SinkDocument> create(Frame* frame, const URL& url)
     35    static Ref<SinkDocument> create(Frame& frame, const URL& url)
    3636    {
    3737        return adoptRef(*new SinkDocument(frame, url));
     
    3939
    4040private:
    41     SinkDocument(Frame*, const URL&);
     41    SinkDocument(Frame&, const URL&);
    4242
    4343    Ref<DocumentParser> createParser() final;
  • trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp

    r240014 r248728  
    5050    if (data) {
    5151        // We don't need to create a new frame because the new document belongs to the parent UseElement.
    52         m_document = SVGDocument::create(nullptr, response().url());
     52        m_document = SVGDocument::create(sessionID(), nullptr, response().url());
    5353        m_document->setContent(m_decoder->decodeAndFlush(data->data(), data->size()));
    5454    }
  • trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp

    r246490 r248728  
    7373            // We may get here during render tree updates when events are forbidden.
    7474            // Frameless document can't run scripts or call back to the client so this is safe.
    75             m_externalSVGDocument = SVGDocument::create(nullptr, URL());
     75            m_externalSVGDocument = SVGDocument::create(sessionID(), nullptr, URL());
    7676            auto decoder = TextResourceDecoder::create("application/xml");
    7777
  • trunk/Source/WebCore/page/Frame.cpp

    r247555 r248728  
    10141014}
    10151015
     1016PAL::SessionID Frame::sessionID() const
     1017{
     1018    return m_loader->client().sessionID();
     1019}
     1020
    10161021} // namespace WebCore
  • trunk/Source/WebCore/page/Frame.h

    r247555 r248728  
    5757class RegularExpression;
    5858} }
     59
     60namespace PAL {
     61class SessionID;
     62}
    5963
    6064namespace WebCore {
     
    298302    void selfOnlyDeref();
    299303
     304    PAL::SessionID sessionID() const;
     305
    300306private:
    301307    friend class NavigationDisabler;
  • trunk/Source/WebCore/svg/SVGDocument.cpp

    r229694 r248728  
    3131WTF_MAKE_ISO_ALLOCATED_IMPL(SVGDocument);
    3232
    33 SVGDocument::SVGDocument(Frame* frame, const URL& url)
    34     : XMLDocument(frame, url, SVGDocumentClass)
     33SVGDocument::SVGDocument(PAL::SessionID sessionID, Frame* frame, const URL& url)
     34    : XMLDocument(sessionID, frame, url, SVGDocumentClass)
    3535{
    3636}
     
    7070Ref<Document> SVGDocument::cloneDocumentWithoutChildren() const
    7171{
    72     return create(nullptr, url());
     72    return create(sessionID(), nullptr, url());
    7373}
    7474
  • trunk/Source/WebCore/svg/SVGDocument.h

    r229694 r248728  
    3131    WTF_MAKE_ISO_ALLOCATED(SVGDocument);
    3232public:
    33     static Ref<SVGDocument> create(Frame*, const URL&);
     33    static Ref<SVGDocument> create(PAL::SessionID, Frame*, const URL&);
    3434
    3535    static RefPtr<SVGSVGElement> rootElement(const Document&);
     
    4040
    4141private:
    42     SVGDocument(Frame*, const URL&);
     42    SVGDocument(PAL::SessionID, Frame*, const URL&);
    4343
    4444    Ref<Document> cloneDocumentWithoutChildren() const override;
     
    4747};
    4848
    49 inline Ref<SVGDocument> SVGDocument::create(Frame* frame, const URL& url)
     49inline Ref<SVGDocument> SVGDocument::create(PAL::SessionID sessionID, Frame* frame, const URL& url)
    5050{
    51     return adoptRef(*new SVGDocument(frame, url));
     51    return adoptRef(*new SVGDocument(sessionID, frame, url));
    5252}
    5353
  • trunk/Source/WebCore/xml/DOMParser.cpp

    r243163 r248728  
    3535}
    3636
    37 ExceptionOr<Ref<Document>> DOMParser::parseFromString(const String& string, const String& contentType)
     37ExceptionOr<Ref<Document>> DOMParser::parseFromString(ScriptExecutionContext& context, const String& string, const String& contentType)
    3838{
    3939    if (contentType != "text/html" && contentType != "text/xml" && contentType != "application/xml" && contentType != "application/xhtml+xml" && contentType != "image/svg+xml")
    4040        return Exception { TypeError };
    41     auto document = DOMImplementation::createDocument(contentType, nullptr, URL { });
     41    auto document = DOMImplementation::createDocument(context.sessionID(), contentType, nullptr, URL { });
    4242    if (m_contextDocument)
    4343        document->setContextDocument(*m_contextDocument.get());
  • trunk/Source/WebCore/xml/DOMParser.h

    r207541 r248728  
    2525
    2626class Document;
     27class ScriptExecutionContext;
    2728
    2829class DOMParser : public RefCounted<DOMParser> {
    2930public:
    3031    static Ref<DOMParser> create(Document& contextDocument);
    31     ExceptionOr<Ref<Document>> parseFromString(const String&, const String& contentType);
     32    ExceptionOr<Ref<Document>> parseFromString(ScriptExecutionContext&, const String&, const String& contentType);
    3233
    3334private:
  • trunk/Source/WebCore/xml/DOMParser.idl

    r207541 r248728  
    2323    ImplementationLacksVTable,
    2424] interface DOMParser {
    25     [MayThrowException, NewObject] Document parseFromString(DOMString string, DOMString contentType);
     25    [MayThrowException, NewObject, CallWith=ScriptExecutionContext] Document parseFromString(DOMString string, DOMString contentType);
    2626};
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r248670 r248728  
    174174
    175175    if (!m_createdDocument) {
     176        auto& context = *scriptExecutionContext();
     177
    176178        String mimeType = responseMIMEType();
    177179        bool isHTML = equalLettersIgnoringASCIICase(mimeType, "text/html");
     
    184186        } else {
    185187            if (isHTML)
    186                 m_responseDocument = HTMLDocument::create(nullptr, m_url);
     188                m_responseDocument = HTMLDocument::create(context.sessionID(), nullptr, m_url);
    187189            else
    188                 m_responseDocument = XMLDocument::create(nullptr, m_url);
     190                m_responseDocument = XMLDocument::create(context.sessionID(), nullptr, m_url);
    189191            m_responseDocument->overrideLastModified(m_response.lastModified());
    190192            m_responseDocument->setContent(m_responseBuilder.toStringPreserveCapacity());
    191             m_responseDocument->setContextDocument(downcast<Document>(*scriptExecutionContext()));
    192             m_responseDocument->setSecurityOriginPolicy(scriptExecutionContext()->securityOriginPolicy());
     193            m_responseDocument->setContextDocument(downcast<Document>(context));
     194            m_responseDocument->setSecurityOriginPolicy(context.securityOriginPolicy());
    193195            m_responseDocument->overrideMIMEType(mimeType);
    194196
  • trunk/Source/WebCore/xml/XSLTProcessor.cpp

    r240237 r248728  
    7373    RefPtr<Document> result;
    7474    if (sourceMIMEType == "text/plain") {
    75         result = XMLDocument::createXHTML(frame, sourceIsDocument ? ownerDocument->url() : URL());
     75        result = XMLDocument::createXHTML(ownerDocument->sessionID(), frame, sourceIsDocument ? ownerDocument->url() : URL());
    7676        transformTextStringToXHTMLDocumentString(documentSource);
    7777    } else
    78         result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : URL());
     78        result = DOMImplementation::createDocument(ownerDocument->sessionID(), sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : URL());
    7979
    8080    // Before parsing, we need to save & detach the old document and get the new document
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r248713 r248728  
     12019-08-15  Youenn Fablet  <youenn@apple.com>
     2
     3        Always create a Document with a valid SessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=200727
     5
     6        Reviewed by Alex Christensen.
     7
     8        Implement WebKit1 sessionID getter like done for WebKit2.
     9        Either the loader client has a page in which case the page session ID is used
     10        or the client has no page, in which case the default session ID is used.
     11        This is the same behavior as CachedResourceLoader.
     12
     13        * WebCoreSupport/WebFrameLoaderClient.mm:
     14        (WebFrameLoaderClient::sessionID const):
     15
    1162019-08-15  Simon Fraser  <simon.fraser@apple.com>
    217
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r248713 r248728  
    222222PAL::SessionID WebFrameLoaderClient::sessionID() const
    223223{
    224     RELEASE_ASSERT_NOT_REACHED();
    225     return PAL::SessionID::defaultSessionID();
     224    auto* coreFrame = core(m_webFrame.get());
     225    return coreFrame && coreFrame->page() ? coreFrame->page()->sessionID() : PAL::SessionID::defaultSessionID();
    226226}
    227227
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r248699 r248728  
     12019-08-15  Youenn Fablet  <youenn@apple.com>
     2
     3        Always create a Document with a valid SessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=200727
     5
     6        Reviewed by Alex Christensen.
     7
     8        Implement WebKit1 sessionID getter like done for WebKit2.
     9        Either the loader client has a page in which case the page session ID is used
     10        or the client has no page, in which case the default session ID is used.
     11        This is the same behavior as CachedResourceLoader.
     12
     13        * WebCoreSupport/WebFrameLoaderClient.cpp:
     14        (WebFrameLoaderClient::sessionID const):
     15
    1162019-08-14  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp

    r248713 r248728  
    135135PAL::SessionID WebFrameLoaderClient::sessionID() const
    136136{
    137     RELEASE_ASSERT_NOT_REACHED();
    138     return PAL::SessionID::defaultSessionID();
     137    auto* coreFrame = core(m_webFrame);
     138    return coreFrame && coreFrame->page() ? coreFrame->page()->sessionID() : PAL::SessionID::defaultSessionID();
    139139}
    140140
Note: See TracChangeset for help on using the changeset viewer.