Skip to content

Commit

Permalink
Remove responseIsXML
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=217133

Patch by Rob Buis <rbuis@igalia.com> on 2020-09-30
Reviewed by Darin Adler.

Remove responseIsXML method, it can be inlined and is still readable, also
it in one case this avoids calling the non trivial responseMIMEType.

No new tests. No change in behavior.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createDecoder const):
(WebCore::XMLHttpRequest::responseIsXML const): Deleted.
* xml/XMLHttpRequest.h:

Canonical link: https://commits.webkit.org/229940@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267821 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rwlbuis authored and webkit-commit-queue committed Oct 1, 2020
1 parent b63a0f1 commit 2d6174a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
17 changes: 17 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
2020-09-30 Rob Buis <rbuis@igalia.com>

Remove responseIsXML
https://bugs.webkit.org/show_bug.cgi?id=217133

Reviewed by Darin Adler.

Remove responseIsXML method, it can be inlined and is still readable, also
it in one case this avoids calling the non trivial responseMIMEType.

No new tests. No change in behavior.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createDecoder const):
(WebCore::XMLHttpRequest::responseIsXML const): Deleted.
* xml/XMLHttpRequest.h:

2020-09-30 John Wilander <wilander@apple.com>

Storage Access API: Enable per-page storage access scope and align test cases
Expand Down
10 changes: 3 additions & 7 deletions Source/WebCore/xml/XMLHttpRequest.cpp
Expand Up @@ -172,10 +172,11 @@ ExceptionOr<Document*> XMLHttpRequest::responseXML()

String mimeType = responseMIMEType();
bool isHTML = equalLettersIgnoringASCIICase(mimeType, "text/html");
bool isXML = MIMETypeRegistry::isXMLMIMEType(mimeType);

// The W3C spec requires the final MIME type to be some valid XML type, or text/html.
// If it is text/html, then the responseType of "document" must have been supplied explicitly.
if ((m_response.isInHTTPFamily() && !responseIsXML() && !isHTML)
if ((m_response.isInHTTPFamily() && !isXML && !isHTML)
|| (isHTML && responseType() == ResponseType::EmptyString)) {
m_responseDocument = nullptr;
} else {
Expand Down Expand Up @@ -858,11 +859,6 @@ String XMLHttpRequest::responseMIMEType() const
return mimeType;
}

bool XMLHttpRequest::responseIsXML() const
{
return MIMETypeRegistry::isXMLMIMEType(responseMIMEType());
}

int XMLHttpRequest::status() const
{
if (readyState() == UNSENT || readyState() == OPENED || m_error)
Expand Down Expand Up @@ -996,7 +992,7 @@ Ref<TextResourceDecoder> XMLHttpRequest::createDecoder() const

switch (responseType()) {
case ResponseType::EmptyString:
if (responseIsXML()) {
if (MIMETypeRegistry::isXMLMIMEType(responseMIMEType())) {
auto decoder = TextResourceDecoder::create("application/xml");
// Don't stop on encoding errors, unlike it is done for other kinds of XML resources. This matches the behavior of previous WebKit versions, Firefox and Opera.
decoder->useLenientXMLDecoding();
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/xml/XMLHttpRequest.h
Expand Up @@ -161,8 +161,6 @@ class XMLHttpRequest final : public ActiveDOMObject, public RefCounted<XMLHttpRe
void didFail(const ResourceError&) override;
void notifyIsDone(bool) final;

bool responseIsXML() const;

Optional<ExceptionOr<void>> prepareToSend();
ExceptionOr<void> send(Document&);
ExceptionOr<void> send(const String& = { });
Expand Down

0 comments on commit 2d6174a

Please sign in to comment.