Changeset 177366 in webkit


Ignore:
Timestamp:
Dec 16, 2014 10:42:43 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Document.contentType implementation
https://bugs.webkit.org/show_bug.cgi?id=132269

Patch by Tibor Meszaros <tmeszaros.u-szeged@partner.samsung.com> on 2014-12-16
Reviewed by Darin Adler.

Chromium merge from https://codereview.chromium.org/151653004

Source/WebCore:

Tests: fast/dom/document-contentType-DOMParser.html

fast/dom/document-contentType-createDocument.html
fast/dom/document-contentType-data-uri.html
fast/xsl/xslt-contentType.html
http/tests/dom/document-contentType-meta.html
http/tests/dom/document-contentType-xhr.html
http/tests/dom/document-contentType.html

  • dom/Document.cpp:

(WebCore::Document::overrideMIMEType):
(WebCore::Document::contentType):
(WebCore::Document::cloneDataFromDocument):

  • dom/Document.h:
  • dom/Document.idl:
  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::currentContentType):

  • loader/DocumentLoader.h:
  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::responseXML):

  • xml/XSLTProcessor.cpp:

(WebCore::XSLTProcessor::createDocumentFromSource):

LayoutTests:

  • fast/dom/Document/clone-node-expected.txt:
  • fast/dom/Document/clone-node.html:
  • fast/dom/HTMLDocument/clone-node-quirks-mode-expected.txt:
  • fast/dom/HTMLDocument/clone-node-quirks-mode.html:
  • fast/dom/document-contentType-DOMParser-expected.txt: Added.
  • fast/dom/document-contentType-DOMParser.html: Added.
  • fast/dom/document-contentType-createDocument-expected.txt: Added.
  • fast/dom/document-contentType-createDocument.html: Added.
  • fast/dom/document-contentType-data-uri-expected.txt: Added.
  • fast/dom/document-contentType-data-uri.html: Added.
  • fast/xsl/xslt-contentType-expected.txt: Added.
  • fast/xsl/xslt-contentType.html: Added.
  • http/tests/dom/document-contentType-expected.txt: Added.
  • http/tests/dom/document-contentType-meta-expected.txt: Added.
  • http/tests/dom/document-contentType-meta.html: Added.
  • http/tests/dom/document-contentType-xhr-expected.txt: Added.
  • http/tests/dom/document-contentType-xhr.html: Added.
  • http/tests/dom/document-contentType.html: Added.
  • http/tests/dom/resources/dummy.css: Added.

(body):

  • http/tests/dom/resources/dummy.html: Added.
  • http/tests/dom/resources/dummy.js: Added.
  • http/tests/dom/resources/dummy.txt: Added.
  • http/tests/dom/resources/dummy.xml: Added.
  • http/tests/dom/resources/send-mime-type.php: Added.
  • http/tests/dom/resources/square20.bmp: Added.
  • http/tests/dom/resources/square20.gif: Added.
  • http/tests/dom/resources/square20.jpg: Added.
  • http/tests/dom/resources/square20.png: Added.
  • resources/js-test.js:

(shouldBeEqualToNumber):

Location:
trunk
Files:
26 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r177364 r177366  
     12014-12-16  Tibor Meszaros  <tmeszaros.u-szeged@partner.samsung.com>
     2
     3        Document.contentType implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=132269
     5
     6        Reviewed by Darin Adler.
     7
     8        Chromium merge from https://codereview.chromium.org/151653004
     9
     10        * fast/dom/Document/clone-node-expected.txt:
     11        * fast/dom/Document/clone-node.html:
     12        * fast/dom/HTMLDocument/clone-node-quirks-mode-expected.txt:
     13        * fast/dom/HTMLDocument/clone-node-quirks-mode.html:
     14        * fast/dom/document-contentType-DOMParser-expected.txt: Added.
     15        * fast/dom/document-contentType-DOMParser.html: Added.
     16        * fast/dom/document-contentType-createDocument-expected.txt: Added.
     17        * fast/dom/document-contentType-createDocument.html: Added.
     18        * fast/dom/document-contentType-data-uri-expected.txt: Added.
     19        * fast/dom/document-contentType-data-uri.html: Added.
     20        * fast/xsl/xslt-contentType-expected.txt: Added.
     21        * fast/xsl/xslt-contentType.html: Added.
     22        * http/tests/dom/document-contentType-expected.txt: Added.
     23        * http/tests/dom/document-contentType-meta-expected.txt: Added.
     24        * http/tests/dom/document-contentType-meta.html: Added.
     25        * http/tests/dom/document-contentType-xhr-expected.txt: Added.
     26        * http/tests/dom/document-contentType-xhr.html: Added.
     27        * http/tests/dom/document-contentType.html: Added.
     28        * http/tests/dom/resources/dummy.css: Added.
     29        (body):
     30        * http/tests/dom/resources/dummy.html: Added.
     31        * http/tests/dom/resources/dummy.js: Added.
     32        * http/tests/dom/resources/dummy.txt: Added.
     33        * http/tests/dom/resources/dummy.xml: Added.
     34        * http/tests/dom/resources/send-mime-type.php: Added.
     35        * http/tests/dom/resources/square20.bmp: Added.
     36        * http/tests/dom/resources/square20.gif: Added.
     37        * http/tests/dom/resources/square20.jpg: Added.
     38        * http/tests/dom/resources/square20.png: Added.
     39        * resources/js-test.js:
     40        (shouldBeEqualToNumber):
     41
    1422014-12-16  Alexey Proskuryakov  <ap@apple.com>
    243
  • trunk/LayoutTests/fast/dom/Document/clone-node-expected.txt

    r160330 r177366  
    77PASS className(doc.cloneNode(false)) is "Document"
    88PASS doc.cloneNode(true).documentElement.localName is "root"
     9PASS doc.cloneNode(true).contentType is "application/xml"
    910PASS document.cloneNode(true).compatMode is "CSS1Compat"
    1011PASS document.cloneNode(false).URL is document.URL
    1112PASS document.cloneNode(false).baseURI is document.baseURI
    1213PASS document.cloneNode(false).characterSet is document.characterSet
     14PASS document.cloneNode(true).contentType is "text/html"
    1315PASS successfullyParsed is true
    1416
  • trunk/LayoutTests/fast/dom/Document/clone-node.html

    r160330 r177366  
    1515shouldBeEqualToString('className(doc.cloneNode(false))', 'Document');
    1616shouldBeEqualToString('doc.cloneNode(true).documentElement.localName', 'root');
     17shouldBeEqualToString('doc.cloneNode(true).contentType', 'application/xml');
    1718shouldBeEqualToString('document.cloneNode(true).compatMode', 'CSS1Compat');
    1819shouldBe('document.cloneNode(false).URL', 'document.URL');
    1920shouldBe('document.cloneNode(false).baseURI', 'document.baseURI');
    2021shouldBe('document.cloneNode(false).characterSet', 'document.characterSet');
     22shouldBeEqualToString('document.cloneNode(true).contentType', 'text/html');
    2123
    2224</script>
  • trunk/LayoutTests/fast/dom/HTMLDocument/clone-node-quirks-mode-expected.txt

    r160330 r177366  
    88PASS document.cloneNode(true).title is document.title
    99PASS document.cloneNode(true).compatMode is "BackCompat"
     10PASS document.cloneNode(true).contentType is "text/html"
    1011PASS doc.cloneNode(false).__proto__ is HTMLDocument.prototype
    1112PASS className(doc.cloneNode(false)) is "HTMLDocument"
    1213PASS doc.cloneNode(true).title is doc.title
    1314PASS doc.cloneNode(true).compatMode is "CSS1Compat"
     15PASS doc.cloneNode(true).contentType is "text/html"
    1416PASS successfullyParsed is true
    1517
  • trunk/LayoutTests/fast/dom/HTMLDocument/clone-node-quirks-mode.html

    r160330 r177366  
    1212shouldBe('document.cloneNode(true).title', 'document.title');
    1313shouldBeEqualToString('document.cloneNode(true).compatMode', 'BackCompat');
     14shouldBeEqualToString('document.cloneNode(true).contentType', 'text/html');
    1415
    1516var doc = document.implementation.createHTMLDocument('title');
     
    1819shouldBe('doc.cloneNode(true).title', 'doc.title');
    1920shouldBeEqualToString('doc.cloneNode(true).compatMode', 'CSS1Compat');
     21shouldBeEqualToString('doc.cloneNode(true).contentType', 'text/html');
    2022
    2123</script>
  • trunk/LayoutTests/resources/js-test.js

    r166668 r177366  
    421421  if (typeof a !== "string" || typeof b !== "string")
    422422    debug("WARN: shouldBeEqualToString() expects string arguments");
     423  var unevaledString = JSON.stringify(b);
     424  shouldBe(a, unevaledString);
     425}
     426
     427function shouldBeEqualToNumber(a, b)
     428{
     429  if (typeof a !== "string" || typeof b !== "number")
     430    debug("WARN: shouldBeEqualToNumber() expects a string and a number arguments");
    423431  var unevaledString = JSON.stringify(b);
    424432  shouldBe(a, unevaledString);
  • trunk/Source/WebCore/ChangeLog

    r177365 r177366  
     12014-12-16  Tibor Meszaros  <tmeszaros.u-szeged@partner.samsung.com>
     2
     3        Document.contentType implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=132269
     5
     6        Reviewed by Darin Adler.
     7
     8        Chromium merge from https://codereview.chromium.org/151653004
     9
     10        Tests: fast/dom/document-contentType-DOMParser.html
     11               fast/dom/document-contentType-createDocument.html
     12               fast/dom/document-contentType-data-uri.html
     13               fast/xsl/xslt-contentType.html
     14               http/tests/dom/document-contentType-meta.html
     15               http/tests/dom/document-contentType-xhr.html
     16               http/tests/dom/document-contentType.html
     17
     18        * dom/Document.cpp:
     19        (WebCore::Document::overrideMIMEType):
     20        (WebCore::Document::contentType):
     21        (WebCore::Document::cloneDataFromDocument):
     22        * dom/Document.h:
     23        * dom/Document.idl:
     24        * loader/DocumentLoader.cpp:
     25        (WebCore::DocumentLoader::currentContentType):
     26        * loader/DocumentLoader.h:
     27        * xml/XMLHttpRequest.cpp:
     28        (WebCore::XMLHttpRequest::responseXML):
     29        * xml/XSLTProcessor.cpp:
     30        (WebCore::XSLTProcessor::createDocumentFromSource):
     31
    1322014-12-16  Anders Carlsson  <andersca@apple.com>
    233
  • trunk/Source/WebCore/dom/Document.cpp

    r177360 r177366  
    13771377}
    13781378
     1379void Document::overrideMIMEType(const String& mimeType)
     1380{
     1381    m_overriddenMIMEType = mimeType;
     1382}
     1383
     1384String Document::contentType() const
     1385{
     1386    if (!m_overriddenMIMEType.isNull())
     1387        return m_overriddenMIMEType;
     1388
     1389    if (DocumentLoader* documentLoader = loader())
     1390        return documentLoader->currentContentType();
     1391
     1392    String mimeType = suggestedMIMEType();
     1393    if (!mimeType.isNull())
     1394        return mimeType;
     1395
     1396    return ASCIILiteral("application/xml");
     1397}
     1398
    13791399Node* Document::nodeFromPoint(const LayoutPoint& clientPoint, LayoutPoint* localPoint)
    13801400{
     
    32173237    setCompatibilityMode(other.m_compatibilityMode);
    32183238    setSecurityOrigin(other.securityOrigin());
     3239    overrideMIMEType(other.contentType());
    32193240    setDecoder(other.decoder());
    32203241}
  • trunk/Source/WebCore/dom/Document.h

    r177314 r177366  
    466466    String suggestedMIMEType() const;
    467467
     468    void overrideMIMEType(const String&);
     469    String contentType() const;
     470
    468471    String contentLanguage() const { return m_contentLanguage; }
    469472    void setContentLanguage(const String&);
     
    14091412    String m_baseTarget;
    14101413
     1414    // MIME type of the document in case it was cloned or created by XHR.
     1415    String m_overriddenMIMEType;
     1416
    14111417    std::unique_ptr<DOMImplementation> m_implementation;
    14121418
  • trunk/Source/WebCore/dom/Document.idl

    r172865 r177366  
    105105    [ObjCLegacyUnnamedParameters] CSSStyleDeclaration getOverrideStyle([Default=Undefined] optional Element element,
    106106                                                        [Default=Undefined] optional DOMString pseudoElement);
     107
     108    readonly attribute DOMString contentType;
    107109
    108110    // DOM Level 3 XPath (XPathEvaluator interface)
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r176459 r177366  
    12841284}
    12851285
     1286const String& DocumentLoader::currentContentType() const
     1287{
     1288    return m_writer.mimeType();
     1289}
     1290
    12861291#if PLATFORM(IOS)
    12871292// FIXME: This method seems to violate the encapsulation of this class.
  • trunk/Source/WebCore/loader/DocumentLoader.h

    r176459 r177366  
    119119        WEBCORE_EXPORT void setResponseMIMEType(const String&);
    120120#endif
    121 
     121        const String& currentContentType() const;
    122122        void replaceRequestURLForSameDocumentNavigation(const URL&);
    123123        bool isStopping() const { return m_isStopping; }
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r175053 r177366  
    207207
    208208    if (!m_createdDocument) {
    209         bool isHTML = equalIgnoringCase(responseMIMEType(), "text/html");
     209        String mimeType = responseMIMEType();
     210        bool isHTML = equalIgnoringCase(mimeType, "text/html");
    210211
    211212        // The W3C spec requires the final MIME type to be some valid XML type, or text/html.
     
    223224            m_responseDocument->setContent(m_responseBuilder.toStringPreserveCapacity());
    224225            m_responseDocument->setSecurityOrigin(securityOrigin());
     226            m_responseDocument->overrideMIMEType(mimeType);
     227
    225228            if (!m_responseDocument->wellFormed())
    226229                m_responseDocument = 0;
  • trunk/Source/WebCore/xml/XSLTProcessor.cpp

    r164254 r177366  
    7777    RefPtr<Document> result;
    7878    if (sourceMIMEType == "text/plain") {
    79         result = Document::create(frame, sourceIsDocument ? ownerDocument->url() : URL());
     79        result = Document::createXHTML(frame, sourceIsDocument ? ownerDocument->url() : URL());
    8080        transformTextStringToXHTMLDocumentString(documentSource);
    8181    } else
Note: See TracChangeset for help on using the changeset viewer.