<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[200300] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/200300">200300</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2016-04-30 21:50:10 -0700 (Sat, 30 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update XMLHttpRequest to use enum class instead of string for enumeration
https://bugs.webkit.org/show_bug.cgi?id=157238

Reviewed by Chris Dumez.

* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::response): Rewrite to use responseType function
instead of responseTypeCode function.

* bindings/scripts/CodeGenerator.pm: Removed XMLHttpRequestResponseType
from the list of enumerations that use a string-based implementation.

* bindings/scripts/CodeGeneratorJS.pm:
(GetEnumerationImplementationContent): Use emptyString instead of ASCIILiteral
when the string constant is empty, to avoid the assertion.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::XMLHttpRequest): Move simple scalar data member
initialization to where the data members are defined in the header.
(WebCore::XMLHttpRequest::responseText): Use m_responseType instead of
m_responseTypeCode.
(WebCore::XMLHttpRequest::didCacheResponseJSON): Ditto.
(WebCore::XMLHttpRequest::responseXML): Ditto.
(WebCore::XMLHttpRequest::responseBlob): Ditto.
(WebCore::XMLHttpRequest::responseArrayBuffer): Ditto.
(WebCore::XMLHttpRequest::setResponseType): Ditto.
(WebCore::XMLHttpRequest::responseType): Moved to header now that it's a
trivial function that should be inlined.
(WebCore::XMLHttpRequest::open): Use m_responseType instead of
m_responseTypeCode.
(WebCore::XMLHttpRequest::responseMIMEType): Removed one redundant check.
(WebCore::XMLHttpRequest::status): Ditto.
(WebCore::XMLHttpRequest::statusText): Ditto.
(WebCore::shouldDecodeResponse): Moved here from the header. This is now
a non-member function that gets passed a response type. It uses a switch
now instead of ordering the types so that the binary ones are all at the
end of the list.
(WebCore::XMLHttpRequest::didReceiveData): Use the new shouldDecodeResponse.
Also removed an unnecessary check that non-decoded responses are of type
&quot;arraybuffer&quot; or &quot;blob&quot;; that's the same check that shouldDecodeResponse does.

* xml/XMLHttpRequest.h: Removed some unneeded includes and forward declarations.
Removed a comment about the State values needing to be stable numbers; for one
thing the bindings already check that these values have no changed. It's not a
valuable comment. Removed ResponseTypeCode, responseTypeCode, and
m_responseTypeCode. Changed the type of the result of responseType and the
argument to setResponseType from a string to XMLHttpRequestResponseType.
Removed shouldDecodeResponse. Added the initial values for lots of data members
that are simple scalars, matching what was set in the constructor before.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSXMLHttpRequestCustomcpp">trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorpm">trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorexmlXMLHttpRequestcpp">trunk/Source/WebCore/xml/XMLHttpRequest.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXMLHttpRequesth">trunk/Source/WebCore/xml/XMLHttpRequest.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200299 => 200300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-01 04:17:54 UTC (rev 200299)
+++ trunk/Source/WebCore/ChangeLog        2016-05-01 04:50:10 UTC (rev 200300)
</span><span class="lines">@@ -1,5 +1,57 @@
</span><span class="cx"> 2016-04-30  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Update XMLHttpRequest to use enum class instead of string for enumeration
+        https://bugs.webkit.org/show_bug.cgi?id=157238
+
+        Reviewed by Chris Dumez.
+
+        * bindings/js/JSXMLHttpRequestCustom.cpp:
+        (WebCore::JSXMLHttpRequest::response): Rewrite to use responseType function
+        instead of responseTypeCode function.
+
+        * bindings/scripts/CodeGenerator.pm: Removed XMLHttpRequestResponseType
+        from the list of enumerations that use a string-based implementation.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GetEnumerationImplementationContent): Use emptyString instead of ASCIILiteral
+        when the string constant is empty, to avoid the assertion.
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::XMLHttpRequest): Move simple scalar data member
+        initialization to where the data members are defined in the header.
+        (WebCore::XMLHttpRequest::responseText): Use m_responseType instead of
+        m_responseTypeCode.
+        (WebCore::XMLHttpRequest::didCacheResponseJSON): Ditto.
+        (WebCore::XMLHttpRequest::responseXML): Ditto.
+        (WebCore::XMLHttpRequest::responseBlob): Ditto.
+        (WebCore::XMLHttpRequest::responseArrayBuffer): Ditto.
+        (WebCore::XMLHttpRequest::setResponseType): Ditto.
+        (WebCore::XMLHttpRequest::responseType): Moved to header now that it's a
+        trivial function that should be inlined.
+        (WebCore::XMLHttpRequest::open): Use m_responseType instead of
+        m_responseTypeCode.
+        (WebCore::XMLHttpRequest::responseMIMEType): Removed one redundant check.
+        (WebCore::XMLHttpRequest::status): Ditto.
+        (WebCore::XMLHttpRequest::statusText): Ditto.
+        (WebCore::shouldDecodeResponse): Moved here from the header. This is now
+        a non-member function that gets passed a response type. It uses a switch
+        now instead of ordering the types so that the binary ones are all at the
+        end of the list.
+        (WebCore::XMLHttpRequest::didReceiveData): Use the new shouldDecodeResponse.
+        Also removed an unnecessary check that non-decoded responses are of type
+        &quot;arraybuffer&quot; or &quot;blob&quot;; that's the same check that shouldDecodeResponse does.
+
+        * xml/XMLHttpRequest.h: Removed some unneeded includes and forward declarations.
+        Removed a comment about the State values needing to be stable numbers; for one
+        thing the bindings already check that these values have no changed. It's not a
+        valuable comment. Removed ResponseTypeCode, responseTypeCode, and
+        m_responseTypeCode. Changed the type of the result of responseType and the
+        argument to setResponseType from a string to XMLHttpRequestResponseType.
+        Removed shouldDecodeResponse. Added the initial values for lots of data members
+        that are simple scalars, matching what was set in the constructor before.
+
+2016-04-30  Darin Adler  &lt;darin@apple.com&gt;
+
</ins><span class="cx">         Streamline and remove unused bindings generation code
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=157237
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSXMLHttpRequestCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp (200299 => 200300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp        2016-05-01 04:17:54 UTC (rev 200299)
+++ trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp        2016-05-01 04:50:10 UTC (rev 200300)
</span><span class="lines">@@ -186,27 +186,36 @@
</span><span class="cx">     if (m_response &amp;&amp; wrapped().responseCacheIsValid())
</span><span class="cx">         return m_response.get();
</span><span class="cx"> 
</span><del>-    if (!wrapped().doneWithoutErrors() &amp;&amp; wrapped().responseTypeCode() &gt; XMLHttpRequest::ResponseTypeText)
-        return jsNull();
</del><ins>+    auto type = wrapped().responseType();
</ins><span class="cx"> 
</span><del>-    switch (wrapped().responseTypeCode()) {
-    case XMLHttpRequest::ResponseTypeDefault:
-    case XMLHttpRequest::ResponseTypeText:
</del><ins>+    switch (type) {
+    case XMLHttpRequestResponseType::EmptyString:
+    case XMLHttpRequestResponseType::Text:
</ins><span class="cx">         return responseText(state);
</span><ins>+    default:
+        break;
+    }
</ins><span class="cx"> 
</span><del>-    case XMLHttpRequest::ResponseTypeJSON:
</del><ins>+    if (!wrapped().doneWithoutErrors())
+        return jsNull();
+
+    switch (type) {
+    case XMLHttpRequestResponseType::EmptyString:
+    case XMLHttpRequestResponseType::Text:
+        ASSERT_NOT_REACHED();
+        break;
+
+    case XMLHttpRequestResponseType::Json:
</ins><span class="cx">         {
</span><span class="cx">             JSValue value = JSONParse(&amp;state, wrapped().responseTextIgnoringResponseType());
</span><span class="cx">             if (!value)
</span><span class="cx">                 value = jsNull();
</span><span class="cx">             m_response.set(state.vm(), this, value);
</span><del>-
</del><span class="cx">             wrapped().didCacheResponseJSON();
</span><del>-
</del><span class="cx">             return value;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-    case XMLHttpRequest::ResponseTypeDocument:
</del><ins>+    case XMLHttpRequestResponseType::Document:
</ins><span class="cx">         {
</span><span class="cx">             ExceptionCode ec = 0;
</span><span class="cx">             Document* document = wrapped().responseXML(ec);
</span><span class="lines">@@ -217,13 +226,14 @@
</span><span class="cx">             return toJS(&amp;state, globalObject(), document);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-    case XMLHttpRequest::ResponseTypeBlob:
</del><ins>+    case XMLHttpRequestResponseType::Blob:
</ins><span class="cx">         return toJS(&amp;state, globalObject(), wrapped().responseBlob());
</span><span class="cx"> 
</span><del>-    case XMLHttpRequest::ResponseTypeArrayBuffer:
</del><ins>+    case XMLHttpRequestResponseType::Arraybuffer:
</ins><span class="cx">         return toJS(&amp;state, globalObject(), wrapped().responseArrayBuffer());
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    ASSERT_NOT_REACHED();
</ins><span class="cx">     return jsUndefined();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (200299 => 200300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm        2016-05-01 04:17:54 UTC (rev 200299)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm        2016-05-01 04:50:10 UTC (rev 200300)
</span><span class="lines">@@ -144,7 +144,6 @@
</span><span class="cx">     &quot;RequestType&quot; =&gt; 1,
</span><span class="cx">     &quot;TextTrackKind&quot; =&gt; 1,
</span><span class="cx">     &quot;TextTrackMode&quot; =&gt; 1,
</span><del>-    &quot;XMLHttpRequestResponseType&quot; =&gt; 1,
</del><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> # Cache of IDL file pathnames.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (200299 => 200300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-05-01 04:17:54 UTC (rev 200299)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-05-01 04:50:10 UTC (rev 200300)
</span><span class="lines">@@ -862,7 +862,11 @@
</span><span class="cx">         # FIXME: Might be nice to make the entire array be NeverDestroyed instead of each value, but not sure the syntax for that.
</span><span class="cx">         $result .= &quot;    static NeverDestroyed&lt;const String&gt; values[] = {\n&quot;;
</span><span class="cx">         foreach my $value (@{$enumeration-&gt;values}) {
</span><del>-            $result .= &quot;        ASCIILiteral(\&quot;$value\&quot;),\n&quot;;
</del><ins>+            if ($value eq &quot;&quot;) {
+                $result .= &quot;        emptyString(),\n&quot;;
+            } else {
+                $result .= &quot;        ASCIILiteral(\&quot;$value\&quot;),\n&quot;;
+            }
</ins><span class="cx">         }
</span><span class="cx">         $result .= &quot;    };\n&quot;;
</span><span class="cx">         my $index = 0;
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLHttpRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (200299 => 200300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2016-05-01 04:17:54 UTC (rev 200299)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2016-05-01 04:50:10 UTC (rev 200300)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx"> 
</span><span class="cx"> static void replaceCharsetInMediaType(String&amp; mediaType, const String&amp; charsetValue)
</span><span class="cx"> {
</span><del>-    unsigned int pos = 0, len = 0;
</del><ins>+    unsigned pos = 0, len = 0;
</ins><span class="cx"> 
</span><span class="cx">     findCharsetInMediaType(mediaType, pos, len);
</span><span class="cx"> 
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">     // Found at least one existing charset, replace all occurrences with new charset.
</span><span class="cx">     while (len) {
</span><span class="cx">         mediaType.replace(pos, len, charsetValue);
</span><del>-        unsigned int start = pos + charsetValue.length();
</del><ins>+        unsigned start = pos + charsetValue.length();
</ins><span class="cx">         findCharsetInMediaType(mediaType, pos, len, start);
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -109,30 +109,15 @@
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;XMLHttpRequest&gt; XMLHttpRequest::create(ScriptExecutionContext&amp; context)
</span><span class="cx"> {
</span><del>-    Ref&lt;XMLHttpRequest&gt; xmlHttpRequest = adoptRef(*new XMLHttpRequest(context));
</del><ins>+    auto xmlHttpRequest = adoptRef(*new XMLHttpRequest(context));
</ins><span class="cx">     xmlHttpRequest-&gt;suspendIfNeeded();
</span><span class="cx">     return xmlHttpRequest;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> XMLHttpRequest::XMLHttpRequest(ScriptExecutionContext&amp; context)
</span><span class="cx">     : ActiveDOMObject(&amp;context)
</span><del>-    , m_async(true)
-    , m_includeCredentials(false)
-    , m_state(UNSENT)
-    , m_createdDocument(false)
-    , m_error(false)
-    , m_uploadEventsAllowed(true)
-    , m_uploadComplete(false)
-    , m_sameOriginRequest(true)
-    , m_receivedLength(0)
-    , m_lastSendLineNumber(0)
-    , m_lastSendColumnNumber(0)
-    , m_exceptionCode(0)
</del><span class="cx">     , m_progressEventThrottle(this)
</span><del>-    , m_responseTypeCode(ResponseTypeDefault)
-    , m_responseCacheIsValid(false)
</del><span class="cx">     , m_resumeTimer(*this, &amp;XMLHttpRequest::resumeTimerFired)
</span><del>-    , m_dispatchErrorOnResuming(false)
</del><span class="cx">     , m_networkErrorTimer(*this, &amp;XMLHttpRequest::networkErrorTimerFired)
</span><span class="cx">     , m_timeoutTimer(*this, &amp;XMLHttpRequest::didReachTimeout)
</span><span class="cx"> {
</span><span class="lines">@@ -160,6 +145,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(DASHBOARD_SUPPORT)
</span><ins>+
</ins><span class="cx"> bool XMLHttpRequest::usesDashboardBackwardCompatibilityMode() const
</span><span class="cx"> {
</span><span class="cx">     if (scriptExecutionContext()-&gt;isWorkerGlobalScope())
</span><span class="lines">@@ -167,6 +153,7 @@
</span><span class="cx">     Settings* settings = document()-&gt;settings();
</span><span class="cx">     return settings &amp;&amp; settings-&gt;usesDashboardBackwardCompatibilityMode();
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> XMLHttpRequest::State XMLHttpRequest::readyState() const
</span><span class="lines">@@ -176,16 +163,16 @@
</span><span class="cx"> 
</span><span class="cx"> String XMLHttpRequest::responseText(ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><del>-    if (m_responseTypeCode != ResponseTypeDefault &amp;&amp; m_responseTypeCode != ResponseTypeText) {
</del><ins>+    if (m_responseType != XMLHttpRequestResponseType::EmptyString &amp;&amp; m_responseType != XMLHttpRequestResponseType::Text) {
</ins><span class="cx">         ec = INVALID_STATE_ERR;
</span><del>-        return &quot;&quot;;
</del><ins>+        return { };
</ins><span class="cx">     }
</span><span class="cx">     return responseTextIgnoringResponseType();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void XMLHttpRequest::didCacheResponseJSON()
</span><span class="cx"> {
</span><del>-    ASSERT(m_responseTypeCode == ResponseTypeJSON);
</del><ins>+    ASSERT(m_responseType == XMLHttpRequestResponseType::Json);
</ins><span class="cx">     ASSERT(doneWithoutErrors());
</span><span class="cx">     m_responseCacheIsValid = true;
</span><span class="cx">     m_responseBuilder.clear();
</span><span class="lines">@@ -193,7 +180,7 @@
</span><span class="cx"> 
</span><span class="cx"> Document* XMLHttpRequest::responseXML(ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><del>-    if (m_responseTypeCode != ResponseTypeDefault &amp;&amp; m_responseTypeCode != ResponseTypeDocument) {
</del><ins>+    if (m_responseType != XMLHttpRequestResponseType::EmptyString &amp;&amp; m_responseType != XMLHttpRequestResponseType::Document) {
</ins><span class="cx">         ec = INVALID_STATE_ERR;
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="lines">@@ -208,7 +195,7 @@
</span><span class="cx">         // The W3C spec requires the final MIME type to be some valid XML type, or text/html.
</span><span class="cx">         // If it is text/html, then the responseType of &quot;document&quot; must have been supplied explicitly.
</span><span class="cx">         if ((m_response.isHTTP() &amp;&amp; !responseIsXML() &amp;&amp; !isHTML)
</span><del>-            || (isHTML &amp;&amp; m_responseTypeCode == ResponseTypeDefault)
</del><ins>+            || (isHTML &amp;&amp; m_responseType == XMLHttpRequestResponseType::EmptyString)
</ins><span class="cx">             || scriptExecutionContext()-&gt;isWorkerGlobalScope()) {
</span><span class="cx">             m_responseDocument = nullptr;
</span><span class="cx">         } else {
</span><span class="lines">@@ -232,7 +219,7 @@
</span><span class="cx"> 
</span><span class="cx"> Blob* XMLHttpRequest::responseBlob()
</span><span class="cx"> {
</span><del>-    ASSERT(m_responseTypeCode == ResponseTypeBlob);
</del><ins>+    ASSERT(m_responseType == XMLHttpRequestResponseType::Blob);
</ins><span class="cx">     ASSERT(doneWithoutErrors());
</span><span class="cx"> 
</span><span class="cx">     if (!m_responseBlob) {
</span><span class="lines">@@ -254,7 +241,7 @@
</span><span class="cx"> 
</span><span class="cx"> ArrayBuffer* XMLHttpRequest::responseArrayBuffer()
</span><span class="cx"> {
</span><del>-    ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer);
</del><ins>+    ASSERT(m_responseType == XMLHttpRequestResponseType::Arraybuffer);
</ins><span class="cx">     ASSERT(doneWithoutErrors());
</span><span class="cx"> 
</span><span class="cx">     if (!m_responseArrayBuffer) {
</span><span class="lines">@@ -286,7 +273,7 @@
</span><span class="cx">     m_timeoutTimer.startOneShot(std::max(0.0, interval.count()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void XMLHttpRequest::setResponseType(const String&amp; responseType, ExceptionCode&amp; ec)
</del><ins>+void XMLHttpRequest::setResponseType(XMLHttpRequestResponseType type, ExceptionCode&amp; ec)
</ins><span class="cx"> {
</span><span class="cx">     if (m_state &gt;= LOADING) {
</span><span class="cx">         ec = INVALID_STATE_ERR;
</span><span class="lines">@@ -303,41 +290,9 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (responseType == &quot;&quot;)
-        m_responseTypeCode = ResponseTypeDefault;
-    else if (responseType == &quot;text&quot;)
-        m_responseTypeCode = ResponseTypeText;
-    else if (responseType == &quot;json&quot;)
-        m_responseTypeCode = ResponseTypeJSON;
-    else if (responseType == &quot;document&quot;)
-        m_responseTypeCode = ResponseTypeDocument;
-    else if (responseType == &quot;blob&quot;)
-        m_responseTypeCode = ResponseTypeBlob;
-    else if (responseType == &quot;arraybuffer&quot;)
-        m_responseTypeCode = ResponseTypeArrayBuffer;
-    else
-        ASSERT_NOT_REACHED();
</del><ins>+    m_responseType = type;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-String XMLHttpRequest::responseType()
-{
-    switch (m_responseTypeCode) {
-    case ResponseTypeDefault:
-        return &quot;&quot;;
-    case ResponseTypeText:
-        return &quot;text&quot;;
-    case ResponseTypeJSON:
-        return &quot;json&quot;;
-    case ResponseTypeDocument:
-        return &quot;document&quot;;
-    case ResponseTypeBlob:
-        return &quot;blob&quot;;
-    case ResponseTypeArrayBuffer:
-        return &quot;arraybuffer&quot;;
-    }
-    return &quot;&quot;;
-}
-
</del><span class="cx"> String XMLHttpRequest::responseURL() const
</span><span class="cx"> {
</span><span class="cx">     URL responseURL(m_response.url());
</span><span class="lines">@@ -508,7 +463,7 @@
</span><span class="cx">         // attempt to discourage synchronous XHR use. responseType is one such piece of functionality.
</span><span class="cx">         // We'll only disable this functionality for HTTP(S) requests since sync requests for local protocols
</span><span class="cx">         // such as file: and data: still make sense to allow.
</span><del>-        if (url.protocolIsInHTTPFamily() &amp;&amp; m_responseTypeCode != ResponseTypeDefault) {
</del><ins>+        if (url.protocolIsInHTTPFamily() &amp;&amp; m_responseType != XMLHttpRequestResponseType::EmptyString) {
</ins><span class="cx">             logConsoleError(scriptExecutionContext(), &quot;Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set.&quot;);
</span><span class="cx">             ec = INVALID_ACCESS_ERR;
</span><span class="cx">             return;
</span><span class="lines">@@ -1025,10 +980,9 @@
</span><span class="cx">             mimeType = extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType));
</span><span class="cx">         else
</span><span class="cx">             mimeType = m_response.mimeType();
</span><ins>+        if (mimeType.isEmpty())
+            mimeType = ASCIILiteral(&quot;text/xml&quot;);
</ins><span class="cx">     }
</span><del>-    if (mimeType.isEmpty())
-        mimeType = &quot;text/xml&quot;;
-
</del><span class="cx">     return mimeType;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1042,10 +996,7 @@
</span><span class="cx">     if (m_state == UNSENT || m_state == OPENED || m_error)
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    if (m_response.httpStatusCode())
-        return m_response.httpStatusCode();
-
-    return 0;
</del><ins>+    return m_response.httpStatusCode();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String XMLHttpRequest::statusText() const
</span><span class="lines">@@ -1053,10 +1004,7 @@
</span><span class="cx">     if (m_state == UNSENT || m_state == OPENED || m_error)
</span><span class="cx">         return String();
</span><span class="cx"> 
</span><del>-    if (!m_response.httpStatusText().isNull())
-        return m_response.httpStatusText();
-
-    return String();
</del><ins>+    return m_response.httpStatusText();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void XMLHttpRequest::didFail(const ResourceError&amp; error)
</span><span class="lines">@@ -1147,6 +1095,22 @@
</span><span class="cx">         m_response.setHTTPHeaderField(HTTPHeaderName::ContentType, m_mimeTypeOverride);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline bool shouldDecodeResponse(XMLHttpRequestResponseType type)
+{
+    switch (type) {
+    case XMLHttpRequestResponseType::EmptyString:
+    case XMLHttpRequestResponseType::Document:
+    case XMLHttpRequestResponseType::Json:
+    case XMLHttpRequestResponseType::Text:
+        return true;
+    case XMLHttpRequestResponseType::Arraybuffer:
+    case XMLHttpRequestResponseType::Blob:
+        return false;
+    }
+    ASSERT_NOT_REACHED();
+    return true;
+}
+
</ins><span class="cx"> void XMLHttpRequest::didReceiveData(const char* data, int len)
</span><span class="cx"> {
</span><span class="cx">     if (m_error)
</span><span class="lines">@@ -1161,7 +1125,7 @@
</span><span class="cx">     if (m_responseEncoding.isEmpty())
</span><span class="cx">         m_responseEncoding = m_response.textEncodingName();
</span><span class="cx"> 
</span><del>-    bool useDecoder = shouldDecodeResponse();
</del><ins>+    bool useDecoder = shouldDecodeResponse(m_responseType);
</ins><span class="cx"> 
</span><span class="cx">     if (useDecoder &amp;&amp; !m_decoder) {
</span><span class="cx">         if (!m_responseEncoding.isEmpty())
</span><span class="lines">@@ -1185,7 +1149,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (useDecoder)
</span><span class="cx">         m_responseBuilder.append(m_decoder-&gt;decode(data, len));
</span><del>-    else if (m_responseTypeCode == ResponseTypeArrayBuffer || m_responseTypeCode == ResponseTypeBlob) {
</del><ins>+    else {
</ins><span class="cx">         // Buffer binary data.
</span><span class="cx">         if (!m_binaryResponseBuilder)
</span><span class="cx">             m_binaryResponseBuilder = SharedBuffer::create();
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLHttpRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLHttpRequest.h (200299 => 200300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLHttpRequest.h        2016-05-01 04:17:54 UTC (rev 200299)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.h        2016-05-01 04:50:10 UTC (rev 200300)
</span><span class="lines">@@ -19,18 +19,14 @@
</span><span class="cx">  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef XMLHttpRequest_h
-#define XMLHttpRequest_h
</del><ins>+#pragma once
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;ActiveDOMObject.h&quot;
</span><del>-#include &quot;EventListener.h&quot;
</del><span class="cx"> #include &quot;FormData.h&quot;
</span><span class="cx"> #include &quot;ResourceResponse.h&quot;
</span><del>-#include &quot;ScriptWrappable.h&quot;
</del><span class="cx"> #include &quot;ThreadableLoaderClient.h&quot;
</span><span class="cx"> #include &quot;XMLHttpRequestEventTarget.h&quot;
</span><span class="cx"> #include &quot;XMLHttpRequestProgressEventThrottle.h&quot;
</span><del>-#include &lt;wtf/text/AtomicStringHash.h&gt;
</del><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="lines">@@ -43,19 +39,19 @@
</span><span class="cx"> class Blob;
</span><span class="cx"> class Document;
</span><span class="cx"> class DOMFormData;
</span><del>-class ResourceRequest;
</del><span class="cx"> class SecurityOrigin;
</span><span class="cx"> class SharedBuffer;
</span><span class="cx"> class TextResourceDecoder;
</span><span class="cx"> class ThreadableLoader;
</span><span class="cx"> 
</span><ins>+enum class XMLHttpRequestResponseType { EmptyString, Arraybuffer, Blob, Document, Json, Text };
+
</ins><span class="cx"> class XMLHttpRequest final : public RefCounted&lt;XMLHttpRequest&gt;, public XMLHttpRequestEventTarget, private ThreadableLoaderClient, public ActiveDOMObject {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;XMLHttpRequest&gt; create(ScriptExecutionContext&amp;);
</span><span class="cx">     WEBCORE_EXPORT ~XMLHttpRequest();
</span><span class="cx"> 
</span><del>-    // These exact numeric values are important because JS expects them.
</del><span class="cx">     enum State {
</span><span class="cx">         UNSENT = 0,
</span><span class="cx">         OPENED = 1,
</span><span class="lines">@@ -64,18 +60,6 @@
</span><span class="cx">         DONE = 4
</span><span class="cx">     };
</span><span class="cx">     
</span><del>-    enum ResponseTypeCode {
-        ResponseTypeDefault,
-        ResponseTypeText,
-        ResponseTypeJSON,
-        ResponseTypeDocument,
-
-        // Binary format
-        ResponseTypeBlob,
-        ResponseTypeArrayBuffer
-    };
-    static const ResponseTypeCode FirstBinaryResponseType = ResponseTypeBlob;
-
</del><span class="cx">     virtual void didReachTimeout();
</span><span class="cx"> 
</span><span class="cx">     EventTargetInterface eventTargetInterface() const override { return XMLHttpRequestEventTargetInterfaceType; }
</span><span class="lines">@@ -122,9 +106,8 @@
</span><span class="cx">     static String uppercaseKnownHTTPMethod(const String&amp;);
</span><span class="cx">     static bool isAllowedHTTPHeader(const String&amp;);
</span><span class="cx"> 
</span><del>-    void setResponseType(const String&amp;, ExceptionCode&amp;);
-    String responseType();
-    ResponseTypeCode responseTypeCode() const { return m_responseTypeCode; }
</del><ins>+    void setResponseType(XMLHttpRequestResponseType, ExceptionCode&amp;);
+    XMLHttpRequestResponseType responseType() const;
</ins><span class="cx"> 
</span><span class="cx">     String responseURL() const;
</span><span class="cx"> 
</span><span class="lines">@@ -194,8 +177,6 @@
</span><span class="cx">     void networkError();
</span><span class="cx">     void abortError();
</span><span class="cx"> 
</span><del>-    bool shouldDecodeResponse() const { return m_responseTypeCode &lt; FirstBinaryResponseType; }
-
</del><span class="cx">     void dispatchErrorEvents(const AtomicString&amp;);
</span><span class="cx"> 
</span><span class="cx">     void resumeTimerFired();
</span><span class="lines">@@ -207,12 +188,12 @@
</span><span class="cx">     HTTPHeaderMap m_requestHeaders;
</span><span class="cx">     RefPtr&lt;FormData&gt; m_requestEntityBody;
</span><span class="cx">     String m_mimeTypeOverride;
</span><del>-    bool m_async;
-    bool m_includeCredentials;
</del><ins>+    bool m_async { true };
+    bool m_includeCredentials { false };
</ins><span class="cx">     RefPtr&lt;Blob&gt; m_responseBlob;
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;ThreadableLoader&gt; m_loader;
</span><del>-    State m_state;
</del><ins>+    State m_state { UNSENT };
</ins><span class="cx">     bool m_sendFlag { false };
</span><span class="cx"> 
</span><span class="cx">     ResourceResponse m_response;
</span><span class="lines">@@ -221,35 +202,34 @@
</span><span class="cx">     RefPtr&lt;TextResourceDecoder&gt; m_decoder;
</span><span class="cx"> 
</span><span class="cx">     StringBuilder m_responseBuilder;
</span><del>-    bool m_createdDocument;
</del><ins>+    bool m_createdDocument { false };
</ins><span class="cx">     RefPtr&lt;Document&gt; m_responseDocument;
</span><span class="cx">     
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; m_binaryResponseBuilder;
</span><span class="cx">     RefPtr&lt;JSC::ArrayBuffer&gt; m_responseArrayBuffer;
</span><span class="cx"> 
</span><del>-    bool m_error;
</del><ins>+    bool m_error { false };
</ins><span class="cx"> 
</span><del>-    bool m_uploadEventsAllowed;
-    bool m_uploadComplete;
</del><ins>+    bool m_uploadEventsAllowed { true };
+    bool m_uploadComplete { false };
</ins><span class="cx"> 
</span><del>-    bool m_sameOriginRequest;
</del><ins>+    bool m_sameOriginRequest { true };
</ins><span class="cx"> 
</span><del>-    // Used for onprogress tracking
-    long long m_receivedLength;
</del><ins>+    // Used for progress event tracking.
+    long long m_receivedLength { 0 };
</ins><span class="cx"> 
</span><del>-    unsigned m_lastSendLineNumber;
-    unsigned m_lastSendColumnNumber;
</del><ins>+    unsigned m_lastSendLineNumber { 0 };
+    unsigned m_lastSendColumnNumber { 0 };
</ins><span class="cx">     String m_lastSendURL;
</span><del>-    ExceptionCode m_exceptionCode;
</del><ins>+    ExceptionCode m_exceptionCode { 0 };
</ins><span class="cx"> 
</span><span class="cx">     XMLHttpRequestProgressEventThrottle m_progressEventThrottle;
</span><span class="cx"> 
</span><del>-    // An enum corresponding to the allowed string values for the responseType attribute.
-    ResponseTypeCode m_responseTypeCode;
-    bool m_responseCacheIsValid;
</del><ins>+    XMLHttpRequestResponseType m_responseType { XMLHttpRequestResponseType::EmptyString };
+    bool m_responseCacheIsValid { false };
</ins><span class="cx"> 
</span><span class="cx">     Timer m_resumeTimer;
</span><del>-    bool m_dispatchErrorOnResuming;
</del><ins>+    bool m_dispatchErrorOnResuming { false };
</ins><span class="cx"> 
</span><span class="cx">     Timer m_networkErrorTimer;
</span><span class="cx">     void networkErrorTimerFired();
</span><span class="lines">@@ -259,6 +239,9 @@
</span><span class="cx">     Timer m_timeoutTimer;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-} // namespace WebCore
</del><ins>+inline XMLHttpRequestResponseType XMLHttpRequest::responseType() const
+{
+    return m_responseType;
+}
</ins><span class="cx"> 
</span><del>-#endif // XMLHttpRequest_h
</del><ins>+} // namespace WebCore
</ins></span></pre>
</div>
</div>

</body>
</html>