Changeset 66074 in webkit


Ignore:
Timestamp:
Aug 25, 2010 7:54:04 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-08-25 Michael Nordman <Michael Nordman>

Reviewed by David Levin.

https://bugs.webkit.org/show_bug.cgi?id=44133
IDL bindings for XmlHttpRequest.responseBlob support, doesn't do anything yet.
Adds two new attributes, asBlob and responseBlob.
Runtime disabled by default, also behind a new ENABLE_XHR_RESPONSE_BLOB compile time guard.

No new tests, just adding some stubs.

  • bindings/generic/RuntimeEnabledFeatures.cpp:
  • bindings/generic/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setResponseBlobEnabled): (WebCore::RuntimeEnabledFeatures::responseBlobEnabled): (WebCore::RuntimeEnabledFeatures::asBlobEnabled):
  • bindings/js/JSXMLHttpRequestCustom.cpp: (WebCore::JSXMLHttpRequest::responseText): Changed to allow an exceptional return path.
  • bindings/v8/custom/V8XMLHttpRequestCustom.cpp: (WebCore::V8XMLHttpRequest::responseTextAccessorGetter): Changed to allow an exceptional return path.
  • xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::responseText): Changed to raise an exception when accessed with asBlob set to true. (WebCore::XMLHttpRequest::responseXML): Changed to raise an exception when accessed with asBlob set to true. (WebCore::XMLHttpRequest::responseBlob): Added stub method, returns 0 for now. (WebCore::XMLHttpRequest::setAsBlob): Sets the asBlob attribute, raises exception if called at an inappropriate time. (WebCore::XMLHttpRequest::open): Resets asBlob to false, the default value. (WebCore::XMLHttpRequest::abort): Clears m_responseBlob. (WebCore::XMLHttpRequest::clearResponse): Clears m_responseBlob. (WebCore::XMLHttpRequest::didFinishLoading): Added a FIXME to populate m_responseBlob.
  • xml/XMLHttpRequest.h: (WebCore::XMLHttpRequest::asBlob):
  • xml/XMLHttpRequest.idl:

2010-08-25 Michael Nordman <Michael Nordman>

Reviewed by David Levin.

https://bugs.webkit.org/show_bug.cgi?id=44133
WebKitAPI to allow runtime enablement of XmlHttpRequest.responseBlob.

  • features.gypi: Define ENABLE_XHR_RESPONSE_BLOB.
  • public/WebRuntimeFeatures.h:
  • src/WebRuntimeFeatures.cpp: (WebKit::WebRuntimeFeatures::enableXHRResponseBlob): (WebKit::WebRuntimeFeatures::isXHRResponseBlobEnabled):
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66071 r66074  
     12010-08-25  Michael Nordman  <michaeln@google.com>
     2
     3        Reviewed by David Levin.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=44133
     6        IDL bindings for XmlHttpRequest.responseBlob support, doesn't do anything yet.
     7        Adds two new attributes, asBlob and responseBlob.
     8        Runtime disabled by default, also behind a new ENABLE_XHR_RESPONSE_BLOB compile time guard.
     9       
     10        No new tests, just adding some stubs.
     11
     12        * bindings/generic/RuntimeEnabledFeatures.cpp:
     13        * bindings/generic/RuntimeEnabledFeatures.h:
     14        (WebCore::RuntimeEnabledFeatures::setResponseBlobEnabled):
     15        (WebCore::RuntimeEnabledFeatures::responseBlobEnabled):
     16        (WebCore::RuntimeEnabledFeatures::asBlobEnabled):
     17        * bindings/js/JSXMLHttpRequestCustom.cpp:
     18        (WebCore::JSXMLHttpRequest::responseText): Changed to allow an exceptional return path.
     19        * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
     20        (WebCore::V8XMLHttpRequest::responseTextAccessorGetter): Changed to allow an exceptional return path.
     21        * xml/XMLHttpRequest.cpp:
     22        (WebCore::XMLHttpRequest::responseText): Changed to raise an exception when accessed with asBlob set to true.
     23        (WebCore::XMLHttpRequest::responseXML): Changed to raise an exception when accessed with asBlob set to true.
     24        (WebCore::XMLHttpRequest::responseBlob): Added stub method, returns 0 for now.
     25        (WebCore::XMLHttpRequest::setAsBlob): Sets the asBlob attribute, raises exception if called at an inappropriate time.
     26        (WebCore::XMLHttpRequest::open): Resets asBlob to false, the default value.
     27        (WebCore::XMLHttpRequest::abort): Clears m_responseBlob.
     28        (WebCore::XMLHttpRequest::clearResponse): Clears m_responseBlob.
     29        (WebCore::XMLHttpRequest::didFinishLoading): Added a FIXME to populate m_responseBlob.
     30        * xml/XMLHttpRequest.h:
     31        (WebCore::XMLHttpRequest::asBlob):
     32        * xml/XMLHttpRequest.idl:
     33
    1342010-08-24  Victoria Kirst  <vrk@google.com>
    235
  • trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp

    r64845 r66074  
    5151bool RuntimeEnabledFeatures::isDeviceOrientationEnabled = true;
    5252bool RuntimeEnabledFeatures::isSpeechInputEnabled = true;
     53
     54#if ENABLE(XHR_RESPONSE_BLOB)
     55bool RuntimeEnabledFeatures::isXHRResponseBlobEnabled = false;
     56#endif
    5357
    5458#if ENABLE(VIDEO)
  • trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.h

    r64845 r66074  
    129129    static bool speechEnabled() { return isSpeechInputEnabled; }
    130130
     131#if ENABLE(XHR_RESPONSE_BLOB)
     132    static bool xhrResponseBlobEnabled() { return isXHRResponseBlobEnabled; }
     133    static void setXHRResponseBlobEnabled(bool isEnabled) { isXHRResponseBlobEnabled = isEnabled; }
     134    static bool responseBlobEnabled() { return isXHRResponseBlobEnabled; }
     135    static bool asBlobEnabled()  { return isXHRResponseBlobEnabled; }
     136#endif
     137
    131138private:
    132139    // Never instantiate.
     
    145152    static bool isDeviceOrientationEnabled;
    146153    static bool isSpeechInputEnabled;
     154    static bool isXHRResponseBlobEnabled;
    147155};
    148156
  • trunk/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp

    r61100 r66074  
    125125JSValue JSXMLHttpRequest::responseText(ExecState* exec) const
    126126{
    127     return jsOwnedStringOrNull(exec, impl()->responseText());
     127    ExceptionCode ec = 0;
     128    const ScriptString& text = impl()->responseText(ec);
     129    if (ec) {
     130        setDOMException(exec, ec);
     131        return jsUndefined();
     132    }
     133    return jsOwnedStringOrNull(exec, text);
    128134}
    129135
  • trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp

    r59559 r66074  
    5050    INC_STATS("DOM.XMLHttpRequest.responsetext._get");
    5151    XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
    52     return xmlHttpRequest->responseText().v8StringOrNull();
     52    ExceptionCode ec = 0;
     53    const ScriptString& text = xmlHttpRequest->responseText(ec);
     54    if (ec)
     55        return throwError(ec);
     56    return text.v8StringOrNull();
    5357}
    5458
  • trunk/WebCore/xml/XMLHttpRequest.cpp

    r63680 r66074  
    4949#include <wtf/StdLibExtras.h>
    5050#include <wtf/RefCountedLeakCounter.h>
     51#include <wtf/UnusedParam.h>
    5152
    5253#if USE(JSC)
     
    226227}
    227228
    228 const ScriptString& XMLHttpRequest::responseText() const
    229 {
     229const ScriptString& XMLHttpRequest::responseText(ExceptionCode& ec) const
     230{
     231#if ENABLE(XHR_RESPONSE_BLOB)
     232    if (m_asBlob)
     233        ec = INVALID_STATE_ERR;
     234#else
     235    UNUSED_PARAM(ec);
     236#endif
    230237    return m_responseText;
    231238}
    232239
    233 Document* XMLHttpRequest::responseXML() const
    234 {
     240Document* XMLHttpRequest::responseXML(ExceptionCode& ec) const
     241{
     242#if ENABLE(XHR_RESPONSE_BLOB)
     243    if (m_asBlob) {
     244        ec = INVALID_STATE_ERR;
     245        return 0;
     246    }
     247#else
     248    UNUSED_PARAM(ec);
     249#endif
     250
    235251    if (m_state != DONE)
    236252        return 0;
     
    257273}
    258274
     275#if ENABLE(XHR_RESPONSE_BLOB)
     276Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) const
     277{
     278    if (!m_asBlob) {
     279        ec = INVALID_STATE_ERR;
     280        return 0;
     281    }
     282    return m_responseBlob.get();
     283}
     284#endif
     285
    259286XMLHttpRequestUpload* XMLHttpRequest::upload()
    260287{
     
    319346}
    320347
     348#if ENABLE(XHR_RESPONSE_BLOB)
     349void XMLHttpRequest::setAsBlob(bool value, ExceptionCode& ec)
     350{
     351    if (m_state != OPENED || m_loader) {
     352        ec = INVALID_STATE_ERR;
     353        return;
     354    }
     355
     356    m_asBlob = value;
     357}
     358#endif
     359
    321360void XMLHttpRequest::open(const String& method, const KURL& url, ExceptionCode& ec)
    322361{
     
    330369    m_state = UNSENT;
    331370    m_error = false;
    332 
     371#if ENABLE(XHR_RESPONSE_BLOB)
     372    m_asBlob = false;
     373#endif
    333374    m_uploadComplete = false;
    334375
     
    595636    m_createdDocument = false;
    596637    m_responseXML = 0;
     638#if ENABLE(XHR_RESPONSE_BLOB)
     639    m_responseBlob = 0;
     640#endif
    597641
    598642    // Clear headers as required by the spec
     
    641685    m_createdDocument = false;
    642686    m_responseXML = 0;
     687#if ENABLE(XHR_RESPONSE_BLOB)
     688    m_responseBlob = 0;
     689#endif
    643690}
    644691
     
    902949    if (m_decoder)
    903950        m_responseText += m_decoder->flush();
     951
     952#if ENABLE(XHR_RESPONSE_BLOB)
     953    // FIXME: Set m_responseBlob to something here in the m_asBlob case.
     954#endif
    904955
    905956#if ENABLE(INSPECTOR)
  • trunk/WebCore/xml/XMLHttpRequest.h

    r65077 r66074  
    7171    bool withCredentials() const { return m_includeCredentials; }
    7272    void setWithCredentials(bool, ExceptionCode&);
     73#if ENABLE(XHR_RESPONSE_BLOB)
     74    bool asBlob() const { return m_asBlob; }
     75    void setAsBlob(bool, ExceptionCode&);
     76#endif
    7377    void open(const String& method, const KURL&, ExceptionCode&);
    7478    void open(const String& method, const KURL&, bool async, ExceptionCode&);
     
    8589    String getAllResponseHeaders(ExceptionCode&) const;
    8690    String getResponseHeader(const AtomicString& name, ExceptionCode&) const;
    87     const ScriptString& responseText() const;
    88     Document* responseXML() const;
     91    const ScriptString& responseText(ExceptionCode&) const;
     92    Document* responseXML(ExceptionCode&) const;
     93#if ENABLE(XHR_RESPONSE_BLOB)
     94    Blob* responseBlob(ExceptionCode&) const;
     95#endif
    8996    void setLastSendLineNumber(unsigned lineNumber) { m_lastSendLineNumber = lineNumber; }
    9097    void setLastSendURL(const String& url) { m_lastSendURL = url; }
     
    156163    bool m_async;
    157164    bool m_includeCredentials;
     165#if ENABLE(XHR_RESPONSE_BLOB)
     166    bool m_asBlob;
     167    RefPtr<Blob> m_responseBlob;
     168#endif
    158169
    159170    RefPtr<ThreadableLoader> m_loader;
  • trunk/WebCore/xml/XMLHttpRequest.idl

    r61101 r66074  
    5858
    5959        // request
     60#if defined(ENABLE_XHR_RESPONSE_BLOB) && ENABLE_XHR_RESPONSE_BLOB
     61        attribute [EnabledAtRuntime] boolean asBlob
     62            setter raises(DOMException);
     63#endif
     64
    6065        attribute boolean withCredentials
    6166            setter raises(DOMException);
     
    8388        [RequiresAllArguments=Raise, ConvertNullStringTo=Null] DOMString getResponseHeader(in DOMString header)
    8489            raises(DOMException);
    85         readonly attribute [CustomGetter] DOMString responseText; // The custom getter implements ConvertNullStringTo=Null
    86         readonly attribute Document responseXML;
     90        readonly attribute [CustomGetter] DOMString responseText // The custom getter implements ConvertNullStringTo=Null
     91            getter raises(DOMException);
     92        readonly attribute Document responseXML
     93            getter raises(DOMException);
     94#if defined(ENABLE_XHR_RESPONSE_BLOB) && ENABLE_XHR_RESPONSE_BLOB
     95        readonly attribute [EnabledAtRuntime] Blob responseBlob
     96            getter raises(DOMException);
     97#endif
    8798        readonly attribute unsigned short status
    8899            getter raises(DOMException);
  • trunk/WebKit/chromium/ChangeLog

    r66071 r66074  
     12010-08-25  Michael Nordman  <michaeln@google.com>
     2
     3        Reviewed by David Levin.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=44133
     6        WebKitAPI to allow runtime enablement of XmlHttpRequest.responseBlob.
     7
     8        * features.gypi: Define ENABLE_XHR_RESPONSE_BLOB.
     9        * public/WebRuntimeFeatures.h:
     10        * src/WebRuntimeFeatures.cpp:
     11        (WebKit::WebRuntimeFeatures::enableXHRResponseBlob):
     12        (WebKit::WebRuntimeFeatures::isXHRResponseBlobEnabled):
     13
    1142010-08-24  Victoria Kirst  <vrk@google.com>
    215
  • trunk/WebKit/chromium/features.gypi

    r65766 r66074  
    8282        'ENABLE_WEB_TIMING=1',
    8383        'ENABLE_WORKERS=1',
     84        'ENABLE_XHR_RESPONSE_BLOB=1',
    8485        'ENABLE_XPATH=1',
    8586        'ENABLE_XSLT=1',
  • trunk/WebKit/chromium/public/WebRuntimeFeatures.h

    r64851 r66074  
    8787    WEBKIT_API static bool isSpeechInputEnabled();
    8888
     89    WEBKIT_API static void enableXHRResponseBlob(bool);
     90    WEBKIT_API static bool isXHRResponseBlobEnabled();
     91
    8992private:
    9093    WebRuntimeFeatures();
  • trunk/WebKit/chromium/src/WebRuntimeFeatures.cpp

    r64972 r66074  
    257257}
    258258
     259void WebRuntimeFeatures::enableXHRResponseBlob(bool enable)
     260{
     261#if ENABLE(XHR_RESPONSE_BLOB)
     262    RuntimeEnabledFeatures::setXHRResponseBlobEnabled(enable);
     263#endif
     264}
     265
     266bool WebRuntimeFeatures::isXHRResponseBlobEnabled()
     267{
     268#if ENABLE(XHR_RESPONSE_BLOB)
     269    return RuntimeEnabledFeatures::xhrResponseBlobEnabled();
     270#else
     271    return false;
     272#endif
     273}
     274
    259275} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.