Changeset 69688 in webkit


Ignore:
Timestamp:
Oct 13, 2010 1:10:37 PM (14 years ago)
Author:
barraclough@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=43987
Switch XMLHttpRequest, FileReader, and FileReaderSync to use a Stringbuilder
to construct their internal result string. Remove ScriptString (this is now
redundant).

Reviewed by Oliver Hunt.

WebCore:

  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSDOMBinding.cpp:

(WebCore::jsOwnedStringOrNull):

  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSXMLHttpRequestCustom.cpp:

(WebCore::JSXMLHttpRequest::responseText):

  • bindings/js/ScriptCallFrame.cpp:

(WebCore::ScriptCallFrame::ScriptCallFrame):

  • bindings/js/ScriptCallFrame.h:

(WebCore::ScriptCallFrame::functionName):

  • bindings/js/ScriptCallStack.h:
  • bindings/js/ScriptFunctionCall.cpp:
  • bindings/js/ScriptFunctionCall.h:
  • bindings/js/ScriptString.h: Removed.
  • dom/ScriptExecutionContext.h:
  • fileapi/FileReader.cpp:

(WebCore::FileReader::FileReader):
(WebCore::FileReader::abort):
(WebCore::FileReader::didReceiveData):
(WebCore::FileReader::result):
(WebCore::FileReader::convertToText):
(WebCore::FileReader::convertToDataURL):

  • fileapi/FileReader.h:
  • fileapi/FileReaderSync.cpp:

(WebCore::FileReaderSyncLoader::FileReaderSyncLoader):
(WebCore::FileReaderSyncLoader::didReceiveData):
(WebCore::FileReaderSync::readAsBinaryString):
(WebCore::FileReaderSync::readAsText):
(WebCore::FileReaderSync::readAsDataURL):
(WebCore::FileReaderSync::read):
(WebCore::FileReaderSync::convertToText):

  • fileapi/FileReaderSync.h:

(WebCore::FileReaderSync::readAsText):
(WebCore::FileReaderSync::FileReaderSync):

  • inspector/InspectorController.cpp:

(WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
(WebCore::InspectorController::scriptImported):

  • inspector/InspectorController.h:
  • inspector/InspectorResource.cpp:

(WebCore::InspectorResource::setOverrideContent):

  • inspector/InspectorResource.h:
  • loader/FrameLoader.cpp:
  • loader/FrameLoader.h:
  • loader/FrameLoaderClient.h:
  • loader/ResourceLoadNotifier.h:
  • workers/WorkerScriptLoader.h:
  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::XMLHttpRequest):
(WebCore::XMLHttpRequest::responseText):
(WebCore::XMLHttpRequest::responseXML):
(WebCore::XMLHttpRequest::abort):
(WebCore::XMLHttpRequest::clearResponse):
(WebCore::XMLHttpRequest::dropProtection):
(WebCore::XMLHttpRequest::didFinishLoading):
(WebCore::XMLHttpRequest::didReceiveData):

  • xml/XMLHttpRequest.h:

WebKit/efl:

  • WebCoreSupport/FrameLoaderClientEfl.cpp:

(WebCore::FrameLoaderClientEfl::dispatchDidLoadResourceByXMLHttpRequest):

  • WebCoreSupport/FrameLoaderClientEfl.h:

WebKit/mac:

  • WebCoreSupport/WebFrameLoaderClient.mm:

WebKit/qt:

  • WebCoreSupport/FrameLoaderClientQt.cpp:

WebKit/win:

  • WebCoreSupport/WebFrameLoaderClient.cpp:

WebKit/wx:

  • WebKitSupport/FrameLoaderClientWx.cpp:

WebKit2:

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest):

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
Location:
trunk
Files:
1 deleted
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69683 r69688  
     12010-10-13  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=43987
     6        Switch XMLHttpRequest, FileReader, and FileReaderSync to use a Stringbuilder
     7        to construct their internal result string.  Remove ScriptString (this is now
     8        redundant).
     9
     10        * WebCore.xcodeproj/project.pbxproj:
     11        * bindings/js/JSDOMBinding.cpp:
     12        (WebCore::jsOwnedStringOrNull):
     13        * bindings/js/JSDOMBinding.h:
     14        * bindings/js/JSXMLHttpRequestCustom.cpp:
     15        (WebCore::JSXMLHttpRequest::responseText):
     16        * bindings/js/ScriptCallFrame.cpp:
     17        (WebCore::ScriptCallFrame::ScriptCallFrame):
     18        * bindings/js/ScriptCallFrame.h:
     19        (WebCore::ScriptCallFrame::functionName):
     20        * bindings/js/ScriptCallStack.h:
     21        * bindings/js/ScriptFunctionCall.cpp:
     22        * bindings/js/ScriptFunctionCall.h:
     23        * bindings/js/ScriptString.h: Removed.
     24        * dom/ScriptExecutionContext.h:
     25        * fileapi/FileReader.cpp:
     26        (WebCore::FileReader::FileReader):
     27        (WebCore::FileReader::abort):
     28        (WebCore::FileReader::didReceiveData):
     29        (WebCore::FileReader::result):
     30        (WebCore::FileReader::convertToText):
     31        (WebCore::FileReader::convertToDataURL):
     32        * fileapi/FileReader.h:
     33        * fileapi/FileReaderSync.cpp:
     34        (WebCore::FileReaderSyncLoader::FileReaderSyncLoader):
     35        (WebCore::FileReaderSyncLoader::didReceiveData):
     36        (WebCore::FileReaderSync::readAsBinaryString):
     37        (WebCore::FileReaderSync::readAsText):
     38        (WebCore::FileReaderSync::readAsDataURL):
     39        (WebCore::FileReaderSync::read):
     40        (WebCore::FileReaderSync::convertToText):
     41        * fileapi/FileReaderSync.h:
     42        (WebCore::FileReaderSync::readAsText):
     43        (WebCore::FileReaderSync::FileReaderSync):
     44        * inspector/InspectorController.cpp:
     45        (WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
     46        (WebCore::InspectorController::scriptImported):
     47        * inspector/InspectorController.h:
     48        * inspector/InspectorResource.cpp:
     49        (WebCore::InspectorResource::setOverrideContent):
     50        * inspector/InspectorResource.h:
     51        * loader/FrameLoader.cpp:
     52        * loader/FrameLoader.h:
     53        * loader/FrameLoaderClient.h:
     54        * loader/ResourceLoadNotifier.h:
     55        * workers/WorkerScriptLoader.h:
     56        * xml/XMLHttpRequest.cpp:
     57        (WebCore::XMLHttpRequest::XMLHttpRequest):
     58        (WebCore::XMLHttpRequest::responseText):
     59        (WebCore::XMLHttpRequest::responseXML):
     60        (WebCore::XMLHttpRequest::abort):
     61        (WebCore::XMLHttpRequest::clearResponse):
     62        (WebCore::XMLHttpRequest::dropProtection):
     63        (WebCore::XMLHttpRequest::didFinishLoading):
     64        (WebCore::XMLHttpRequest::didReceiveData):
     65        * xml/XMLHttpRequest.h:
     66
    1672010-10-13  Gavin Barraclough  <barraclough@apple.com>
    268
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r69660 r69688  
    877877                416E75CB0EDF90C700360E1D /* ScriptCallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 416E75C90EDF90C700360E1D /* ScriptCallFrame.h */; };
    878878                416E75CC0EDF90C700360E1D /* ScriptCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */; };
    879                 416F45F00ED7B311008215B6 /* ScriptString.h in Headers */ = {isa = PBXBuildFile; fileRef = 416F45EF0ED7B311008215B6 /* ScriptString.h */; settings = {ATTRIBUTES = (Private, ); }; };
    880879                41885B9311B6FDA6003383BB /* FormSubmission.h in Headers */ = {isa = PBXBuildFile; fileRef = 41885B9111B6FDA6003383BB /* FormSubmission.h */; settings = {ATTRIBUTES = (Private, ); }; };
    881880                41885B9411B6FDA6003383BB /* FormSubmission.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41885B9211B6FDA6003383BB /* FormSubmission.cpp */; };
     
    69006899                416E75C90EDF90C700360E1D /* ScriptCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallFrame.h; sourceTree = "<group>"; };
    69016900                416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallFrame.cpp; sourceTree = "<group>"; };
    6902                 416F45EF0ED7B311008215B6 /* ScriptString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptString.h; sourceTree = "<group>"; };
    69036901                41885B9111B6FDA6003383BB /* FormSubmission.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormSubmission.h; sourceTree = "<group>"; };
    69046902                41885B9211B6FDA6003383BB /* FormSubmission.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormSubmission.cpp; sourceTree = "<group>"; };
     
    1674916747                                4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */,
    1675016748                                41C760B00EDE03D300C1655F /* ScriptState.h */,
    16751                                 416F45EF0ED7B311008215B6 /* ScriptString.h */,
    1675216749                                934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */,
    1675316750                                934CC0E00ED39D6F00A658F2 /* ScriptValue.h */,
     
    2052420521                                CE54FD381016D9A6008B44C8 /* ScriptSourceProvider.h in Headers */,
    2052520522                                41C760B10EDE03D300C1655F /* ScriptState.h in Headers */,
    20526                                 416F45F00ED7B311008215B6 /* ScriptString.h in Headers */,
    2052720523                                934CC0E20ED39D6F00A658F2 /* ScriptValue.h in Headers */,
    2052820524                                228C284510D82500009D0D0E /* ScriptWrappable.h in Headers */,
  • trunk/WebCore/bindings/js/JSDOMBinding.cpp

    r68854 r69688  
    453453}
    454454
     455JSValue jsOwnedStringOrNull(ExecState* exec, const String& s)
     456{
     457    if (s.isNull())
     458        return jsNull();
     459    return jsOwnedString(exec, stringToUString(s));
     460}
     461
    455462JSValue jsOwnedStringOrNull(ExecState* exec, const UString& s)
    456463{
  • trunk/WebCore/bindings/js/JSDOMBinding.h

    r67825 r69688  
    255255    // See JavaScriptCore for explanation: Should be used for any UString that is already owned by another
    256256    // object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
     257    JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const String&);
    257258    JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const JSC::UString&);
    258259
  • trunk/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp

    r69283 r69688  
    129129{
    130130    ExceptionCode ec = 0;
    131     const ScriptString& text = impl()->responseText(ec);
     131    String text = impl()->responseText(ec);
    132132    if (ec) {
    133133        setDOMException(exec, ec);
  • trunk/WebCore/bindings/js/ScriptCallFrame.cpp

    r69662 r69688  
    4040
    4141ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount)
    42     : m_functionName(functionName)
     42    : m_functionName(ustringToString(functionName))
    4343    , m_sourceURL(ustringToString(urlString))
    4444    , m_lineNumber(lineNumber)
  • trunk/WebCore/bindings/js/ScriptCallFrame.h

    r69662 r69688  
    3333
    3434#include <runtime/ArgList.h>
    35 #include "ScriptString.h"
    3635#include "ScriptValue.h"
    3736#include <wtf/Vector.h>
     
    5352        ~ScriptCallFrame();
    5453
    55         const ScriptString& functionName() const { return m_functionName; }
     54        const String& functionName() const { return m_functionName; }
    5655        const String& sourceURL() const { return m_sourceURL; }
    5756        unsigned lineNumber() const { return m_lineNumber; }
     
    6261
    6362    private:
    64         ScriptString m_functionName;
     63        String m_functionName;
    6564        String m_sourceURL;
    6665        unsigned m_lineNumber;
  • trunk/WebCore/bindings/js/ScriptCallStack.h

    r64735 r69688  
    3434#include "ScriptCallFrame.h"
    3535#include "ScriptState.h"
    36 #include "ScriptString.h"
    3736#include <wtf/Noncopyable.h>
    3837#include <wtf/RefPtr.h>
  • trunk/WebCore/bindings/js/ScriptFunctionCall.cpp

    r68146 r69688  
    3434#include "JSDOMBinding.h"
    3535#include "JSMainThreadExecState.h"
    36 #include "ScriptString.h"
    3736#include "ScriptValue.h"
    3837
     
    5150    }
    5251    m_arguments.append(argument.jsObject());
    53 }
    54 
    55 void ScriptCallArgumentHandler::appendArgument(const ScriptString& argument)
    56 {
    57     m_arguments.append(jsString(m_exec, argument.ustring()));
    5852}
    5953
  • trunk/WebCore/bindings/js/ScriptFunctionCall.h

    r68074 r69688  
    4545namespace WebCore {
    4646    class ScriptValue;
    47     class ScriptString;
    4847
    4948    class ScriptCallArgumentHandler {
     
    5251
    5352        void appendArgument(const ScriptObject&);
    54         void appendArgument(const ScriptString&);
    5553        void appendArgument(const ScriptValue&);
    5654        void appendArgument(const String&);
  • trunk/WebCore/dom/ScriptExecutionContext.h

    r67614 r69688  
    5858    class MessagePort;
    5959    class SecurityOrigin;
    60     class ScriptString;
    6160#if ENABLE(INSPECTOR)
    6261    class InspectorController;
  • trunk/WebCore/fileapi/FileReader.cpp

    r67208 r69688  
    4444#include "ResourceError.h"
    4545#include "ResourceRequest.h"
     46#include "ResourceResponse.h"
    4647#include "ScriptExecutionContext.h"
    4748#include "TextResourceDecoder.h"
     
    5859    , m_state(None)
    5960    , m_readType(ReadFileAsBinaryString)
    60     , m_result("")
    6161    , m_isRawDataConverted(false)
    6262    , m_bytesLoaded(0)
     
    145145    terminate();
    146146
    147     m_result = "";
     147    m_builder.clear();
    148148    m_error = FileError::create(ABORT_ERR);
    149149
     
    213213    switch (m_readType) {
    214214    case ReadFileAsBinaryString:
    215         m_result += String(data, static_cast<unsigned>(lengthReceived));
     215        m_builder.append(data, static_cast<unsigned>(lengthReceived));
    216216        break;
    217217    case ReadFileAsText:
     
    297297}
    298298
    299 const ScriptString& FileReader::result()
     299String FileReader::result()
    300300{
    301301    // If reading as binary string, we can return the result immediately.
    302302    if (m_readType == ReadFileAsBinaryString)
    303         return m_result;
     303        return m_builder.toString();
    304304
    305305    // If we already convert the raw data received so far, we can return the result now.
    306306    if (m_isRawDataConverted)
    307         return m_result;
     307        return m_builder.toString();
    308308    m_isRawDataConverted = true;
    309309
     
    312312    // For data URL, we only do the coversion until we receive all the raw data.
    313313    else if (m_readType == ReadFileAsDataURL && m_state == Completed)
    314         convertToDataURL(m_rawData, m_fileType, m_result);
    315 
    316     return m_result;
     314        convertToDataURL(m_rawData, m_fileType, m_builder);
     315
     316    return m_builder.toString();
    317317}
    318318
     
    320320{
    321321    if (!m_rawData.size()) {
    322         m_result = "";
     322        m_builder.clear();
    323323        return;
    324324    }
     
    331331    if (!m_decoder)
    332332        m_decoder = TextResourceDecoder::create("text/plain", m_encoding.isValid() ? m_encoding : UTF8Encoding());
    333     m_result = m_decoder->decode(&m_rawData.at(0), m_rawData.size());
     333    m_builder.clear();
     334    m_builder.append(m_decoder->decode(&m_rawData.at(0), m_rawData.size()));
    334335
    335336    if (m_state == Completed && !m_error)
    336         m_result += m_decoder->flush();
    337 }
    338 
    339 void FileReader::convertToDataURL(const Vector<char>& rawData, const String& fileType, ScriptString& result)
    340 {
    341     result = "data:";
     337        m_builder.append(m_decoder->flush());
     338}
     339
     340void FileReader::convertToDataURL(const Vector<char>& rawData, const String& fileType, StringBuilder& builder)
     341{
     342    builder.clear();
     343    builder.append("data:");
    342344
    343345    if (!rawData.size())
    344346        return;
    345347
    346     result += fileType;
    347     if (!fileType.isEmpty())
    348         result += ";";
    349     result += "base64,";
     348    if (!fileType.isEmpty()) {
     349        builder.append(fileType);
     350        builder.append(";base64,");
     351    } else
     352        builder.append("base64,");
    350353
    351354    Vector<char> out;
    352355    base64Encode(rawData, out);
    353356    out.append('\0');
    354     result += out.data();
     357    builder.append(out.data());
    355358}
    356359
  • trunk/WebCore/fileapi/FileReader.h

    r67208 r69688  
    3838#include "FileError.h"
    3939#include "KURL.h"
    40 #include "PlatformString.h"
    41 #include "ScriptString.h"
    4240#include "TextEncoding.h"
    4341#include "ThreadableLoaderClient.h"
     
    4644#include <wtf/RefPtr.h>
    4745#include <wtf/Vector.h>
     46#include <wtf/text/StringBuilder.h>
     47#include <wtf/text/WTFString.h>
    4848
    4949namespace WebCore {
     
    7878    ReadyState readyState() const;
    7979    PassRefPtr<FileError> error() { return m_error; }
    80     const ScriptString& result();
     80    String result();
    8181
    8282    // Helper methods, also used by FileReaderSync.
    8383    static ExceptionCode httpStatusCodeToExceptionCode(int httpStatusCode);
    84     static void convertToDataURL(const Vector<char>& rawData, const String& fileType, ScriptString& result);
     84    static void convertToDataURL(const Vector<char>& rawData, const String& fileType, StringBuilder&);
    8585
    8686    // ActiveDOMObject
     
    148148    TextEncoding m_encoding;
    149149
    150     // Like XMLHttpRequest.m_responseText, we keep this as a ScriptString, not a WTF::String.
    151     // That's because these strings can easily get huge (they are filled from the file) and
    152     // because JS can easily observe many intermediate states, so it's very useful to be
    153     // able to share the buffer with JavaScript versions of the whole or partial string.
    154     // In contrast, this string doesn't interact much with the rest of the engine so it's not that
    155     // big a cost that it isn't a String.
    156     ScriptString m_result;
     150    StringBuilder m_builder;
    157151
    158152    // The raw data. We have to keep track of all the raw data for it to be converted to text or data URL data.
  • trunk/WebCore/fileapi/FileReaderSync.cpp

    r67208 r69688  
    4040#include "FileReader.h"
    4141#include "ResourceRequest.h"
     42#include "ResourceResponse.h"
    4243#include "ScriptExecutionContext.h"
    4344#include "TextEncoding.h"
     
    5152public:
    5253    // If the output result is provided, use it. Otherwise, save it as the raw data.
    53     FileReaderSyncLoader(ScriptString* result);
     54    FileReaderSyncLoader(StringBuilder*);
    5455
    5556    // Returns the http status code.
     
    6667private:
    6768    // The output result. The caller provides this in order to load the binary data directly.
    68     ScriptString* m_result;
     69    StringBuilder* m_builder;
    6970
    7071    // The raw data. The caller does not provide the above output result and we need to save it here.
     
    7475};
    7576
    76 FileReaderSyncLoader::FileReaderSyncLoader(ScriptString* result)
    77     : m_result(result)
     77FileReaderSyncLoader::FileReaderSyncLoader(StringBuilder* builder)
     78    : m_builder(builder)
    7879    , m_httpStatusCode(0)
    7980{
     
    101102void FileReaderSyncLoader::didReceiveData(const char* data, int lengthReceived)
    102103{
    103     if (m_result)
    104         *m_result += String(data, static_cast<unsigned>(lengthReceived));
     104    if (m_builder)
     105        m_builder->append(data, static_cast<unsigned>(lengthReceived));
    105106    else
    106107        m_rawData.append(data, static_cast<unsigned>(lengthReceived));
     
    117118}
    118119
    119 FileReaderSync::FileReaderSync()
    120     : m_result("")
     120String FileReaderSync::readAsBinaryString(ScriptExecutionContext* scriptExecutionContext, Blob* blob, ExceptionCode& ec)
    121121{
     122    if (!blob)
     123        return m_builder.toString();
     124
     125    read(scriptExecutionContext, blob, ReadAsBinaryString, ec);
     126    return m_builder.toString();
    122127}
    123128
    124 const ScriptString& FileReaderSync::readAsBinaryString(ScriptExecutionContext* scriptExecutionContext, Blob* blob, ExceptionCode& ec)
     129String FileReaderSync::readAsText(ScriptExecutionContext* scriptExecutionContext, Blob* blob, const String& encoding, ExceptionCode& ec)
    125130{
    126131    if (!blob)
    127         return m_result;
    128 
    129     read(scriptExecutionContext, blob, ReadAsBinaryString, ec);
    130     return m_result;
    131 }
    132 
    133 const ScriptString& FileReaderSync::readAsText(ScriptExecutionContext* scriptExecutionContext, Blob* blob, const String& encoding, ExceptionCode& ec)
    134 {
    135     if (!blob)
    136         return m_result;
     132        return m_builder.toString();
    137133
    138134    m_encoding = encoding;
    139135    read(scriptExecutionContext, blob, ReadAsText, ec);
    140     return m_result;
     136    return m_builder.toString();
    141137}
    142138
    143 const ScriptString& FileReaderSync::readAsDataURL(ScriptExecutionContext* scriptExecutionContext, Blob* blob, ExceptionCode& ec)
     139String FileReaderSync::readAsDataURL(ScriptExecutionContext* scriptExecutionContext, Blob* blob, ExceptionCode& ec)
    144140{
    145141    if (!blob)
    146         return m_result;
     142        return m_builder.toString();
    147143
    148144    read(scriptExecutionContext, blob, ReadAsDataURL, ec);
    149     return m_result;
     145    return m_builder.toString();
    150146}
    151147
     
    159155    request.setHTTPMethod("GET");
    160156
    161     FileReaderSyncLoader loader((readType == ReadAsBinaryString) ? &m_result : 0);
     157    FileReaderSyncLoader loader((readType == ReadAsBinaryString) ? &m_builder : 0);
    162158    loader.start(scriptExecutionContext, request, ec);
    163159    ThreadableBlobRegistry::unregisterBlobURL(urlForReading);
     
    170166        return;
    171167    case ReadAsText:
    172         convertToText(loader.rawData().data(), loader.rawData().size(), m_result);
     168        convertToText(loader.rawData().data(), loader.rawData().size(), m_builder);
    173169        return;
    174170    case ReadAsDataURL:
    175         FileReader::convertToDataURL(loader.rawData(), blob->type(), m_result);
     171        FileReader::convertToDataURL(loader.rawData(), blob->type(), m_builder);
    176172        return;
    177173    }
     
    180176}
    181177
    182 void FileReaderSync::convertToText(const char* data, int size, ScriptString& result)
     178void FileReaderSync::convertToText(const char* data, int size, StringBuilder& builder)
    183179{
    184180    if (!size)
     
    191187    // FIXME: consider supporting incremental decoding to improve the perf.
    192188    RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("text/plain", m_encoding.isEmpty() ? UTF8Encoding() : TextEncoding(m_encoding));
    193     result = decoder->decode(data, size);
    194     result += decoder->flush();
     189    builder.clear();
     190    builder.append(decoder->decode(data, size));
     191    builder.append(decoder->flush());
    195192}
    196193
  • trunk/WebCore/fileapi/FileReaderSync.h

    r66461 r69688  
    3535
    3636#include "ExceptionCode.h"
    37 #include "ScriptString.h"
    3837#include <wtf/PassRefPtr.h>
    3938#include <wtf/RefCounted.h>
     39#include <wtf/text/StringBuilder.h>
    4040
    4141namespace WebCore {
     
    5353    virtual ~FileReaderSync() { }
    5454
    55     const ScriptString& readAsBinaryString(ScriptExecutionContext*, Blob*, ExceptionCode&);
    56     const ScriptString& readAsText(ScriptExecutionContext* scriptExecutionContext, Blob* blob, ExceptionCode& ec)
     55    String readAsBinaryString(ScriptExecutionContext*, Blob*, ExceptionCode&);
     56    String readAsText(ScriptExecutionContext* scriptExecutionContext, Blob* blob, ExceptionCode& ec)
    5757    {
    5858        return readAsText(scriptExecutionContext, blob, "", ec);
    5959    }
    60     const ScriptString& readAsText(ScriptExecutionContext*, Blob*, const String& encoding, ExceptionCode&);
    61     const ScriptString& readAsDataURL(ScriptExecutionContext*, Blob*, ExceptionCode&);
     60    String readAsText(ScriptExecutionContext*, Blob*, const String& encoding, ExceptionCode&);
     61    String readAsDataURL(ScriptExecutionContext*, Blob*, ExceptionCode&);
    6262
    6363private:
     
    6868    };
    6969
    70     FileReaderSync();
    71    
     70    FileReaderSync() { }
     71
    7272    void read(ScriptExecutionContext*, Blob*, ReadType, ExceptionCode&);
    73     void convertToText(const char* data, int size, ScriptString& result);
     73    void convertToText(const char* data, int size, StringBuilder&);
    7474
    75     // Like XMLHttpRequest.m_responseText, we keep this as a ScriptString, not a WTF::String.
    76     // That's because these strings can easily get huge (they are filled from the file) and
    77     // because JS can easily observe many intermediate states, so it's very useful to be
    78     // able to share the buffer with JavaScript versions of the whole or partial string.
    79     // In contrast, this string doesn't interact much with the rest of the engine so it's not that
    80     // big a cost that it isn't a String.
    81     ScriptString m_result;
     75    StringBuilder m_builder;
    8276
    8377    String m_encoding;
  • trunk/WebCore/inspector/InspectorController.cpp

    r69567 r69688  
    8787#include "ScriptProfiler.h"
    8888#include "ScriptSourceCode.h"
    89 #include "ScriptString.h"
    9089#include "SecurityOrigin.h"
    9190#include "Settings.h"
     
    11331132}
    11341133
    1135 void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
     1134void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
    11361135{
    11371136    if (!enabled())
     
    11631162        return;
    11641163
    1165     resource->setOverrideContent(ScriptString(sourceString), InspectorResource::Script);
     1164    resource->setOverrideContent(sourceString, InspectorResource::Script);
    11661165
    11671166    if (m_frontend)
  • trunk/WebCore/inspector/InspectorController.h

    r69567 r69688  
    8383class ScriptCallStack;
    8484class ScriptProfile;
    85 class ScriptString;
    8685class SharedBuffer;
    8786class Storage;
     
    174173    void didFinishLoading(unsigned long identifier, double finishTime);
    175174    void didFailLoading(unsigned long identifier, const ResourceError&);
    176     void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
     175    void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
    177176    void scriptImported(unsigned long identifier, const String& sourceString);
    178177
  • trunk/WebCore/inspector/InspectorResource.cpp

    r69594 r69688  
    412412}
    413413
    414 void InspectorResource::setOverrideContent(const ScriptString& data, Type type)
     414void InspectorResource::setOverrideContent(const String& data, Type type)
    415415{
    416416    m_overrideContent = data;
  • trunk/WebCore/inspector/InspectorResource.h

    r69185 r69688  
    3434#include "HTTPHeaderMap.h"
    3535#include "KURL.h"
    36 #include "ScriptString.h"
    3736#include "WebSocketHandshakeRequest.h"
    3837#include "WebSocketHandshakeResponse.h"
     
    9998#endif
    10099
    101         void setOverrideContent(const ScriptString& data, Type);
     100        void setOverrideContent(const String& data, Type);
    102101
    103102        String sourceString() const;
     
    195194        bool m_connectionReused;
    196195        RefPtr<ResourceLoadTiming> m_loadTiming;
    197         ScriptString m_overrideContent;
     196        String m_overrideContent;
    198197        Type m_overrideContentType;
    199198        Changes m_changes;
  • trunk/WebCore/loader/FrameLoader.cpp

    r69432 r69688  
    9191#include "ScriptController.h"
    9292#include "ScriptSourceCode.h"
    93 #include "ScriptString.h"
    9493#include "SecurityOrigin.h"
    9594#include "SegmentedString.h"
  • trunk/WebCore/loader/FrameLoader.h

    r69039 r69688  
    7474class ResourceResponse;
    7575class ScriptSourceCode;
    76 class ScriptString;
    7776class ScriptValue;
    7877class SecurityOrigin;
  • trunk/WebCore/loader/FrameLoaderClient.h

    r68576 r69688  
    7474    class ResourceRequest;
    7575    class ResourceResponse;
    76     class ScriptString;
    7776    class SecurityOrigin;
    7877    class SharedBuffer;
  • trunk/WebCore/loader/ResourceLoadNotifier.h

    r67553 r69688  
    4141class ResourceLoader;
    4242class ResourceResponse;
    43 class ScriptString;
    4443class ResourceRequest;
    4544
  • trunk/WebCore/workers/WorkerScriptLoader.h

    r58647 r69688  
    3434#include "ResourceRequest.h"
    3535#include "ResourceResponse.h"
    36 #include "ScriptString.h"
    3736#include "TextResourceDecoder.h"
    3837#include "ThreadableLoader.h"
  • trunk/WebCore/xml/XMLHttpRequest.cpp

    r69406 r69688  
    174174#endif
    175175    , m_state(UNSENT)
    176     , m_responseText("")
    177176    , m_createdDocument(false)
    178177    , m_error(false)
     
    227226}
    228227
    229 const ScriptString& XMLHttpRequest::responseText(ExceptionCode& ec) const
     228String XMLHttpRequest::responseText(ExceptionCode& ec)
    230229{
    231230#if ENABLE(XHR_RESPONSE_BLOB)
     
    235234    UNUSED_PARAM(ec);
    236235#endif
    237     return m_responseText;
    238 }
    239 
    240 Document* XMLHttpRequest::responseXML(ExceptionCode& ec) const
     236    return m_responseBuilder.toStringPreserveCapacity();
     237}
     238
     239Document* XMLHttpRequest::responseXML(ExceptionCode& ec)
    241240{
    242241#if ENABLE(XHR_RESPONSE_BLOB)
     
    260259            m_responseXML->open();
    261260            // FIXME: Set Last-Modified.
    262             m_responseXML->write(String(m_responseText));
     261            m_responseXML->write(m_responseBuilder.toStringPreserveCapacity());
    263262            m_responseXML->finishParsing();
    264263            m_responseXML->close();
     
    628627    internalAbort();
    629628
    630     m_responseText = "";
     629    m_responseBuilder.clear();
    631630    m_createdDocument = false;
    632631    m_responseXML = 0;
     
    677676{
    678677    m_response = ResourceResponse();
    679     m_responseText = "";
     678    m_responseBuilder.clear();
    680679    m_createdDocument = false;
    681680    m_responseXML = 0;
     
    734733    JSC::JSGlobalData* globalData = scriptExecutionContext()->globalData();
    735734    if (hasCachedDOMObjectWrapper(globalData, this))
    736         globalData->heap.reportExtraMemoryCost(m_responseText.size() * 2);
     735        globalData->heap.reportExtraMemoryCost(m_responseBuilder.length() * 2);
    737736#endif
    738737
     
    943942
    944943    if (m_decoder)
    945         m_responseText += m_decoder->flush();
     944        m_responseBuilder.append(m_decoder->flush());
     945
     946    m_responseBuilder.shrinkToFit();
    946947
    947948#if ENABLE(XHR_RESPONSE_BLOB)
     
    951952#if ENABLE(INSPECTOR)
    952953    if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
    953         inspector->resourceRetrievedByXMLHttpRequest(identifier, m_responseText, m_url, m_lastSendURL, m_lastSendLineNumber);
     954        inspector->resourceRetrievedByXMLHttpRequest(identifier, m_responseBuilder.toStringPreserveCapacity(), m_url, m_lastSendURL, m_lastSendLineNumber);
    954955#endif
    955956
     
    10201021        len = strlen(data);
    10211022
    1022     m_responseText += m_decoder->decode(data, len);
     1023    m_responseBuilder.append(m_decoder->decode(data, len));
    10231024
    10241025    if (!m_error) {
  • trunk/WebCore/xml/XMLHttpRequest.h

    r68049 r69688  
    2727#include "FormData.h"
    2828#include "ResourceResponse.h"
    29 #include "ScriptString.h"
    3029#include "ThreadableLoaderClient.h"
    3130#include "XMLHttpRequestProgressEventThrottle.h"
    3231#include <wtf/OwnPtr.h>
    3332#include <wtf/text/AtomicStringHash.h>
     33#include <wtf/text/StringBuilder.h>
    3434
    3535namespace WebCore {
     
    9090    String getAllResponseHeaders(ExceptionCode&) const;
    9191    String getResponseHeader(const AtomicString& name, ExceptionCode&) const;
    92     const ScriptString& responseText(ExceptionCode&) const;
    93     Document* responseXML(ExceptionCode&) const;
     92    String responseText(ExceptionCode&);
     93    Document* responseXML(ExceptionCode&);
    9494#if ENABLE(XHR_RESPONSE_BLOB)
    9595    Blob* responseBlob(ExceptionCode&) const;
     
    177177    RefPtr<TextResourceDecoder> m_decoder;
    178178
    179     // Unlike most strings in the DOM, we keep this as a ScriptString, not a WTF::String.
    180     // That's because these strings can easily get huge (they are filled from the network with
    181     // no parsing) and because JS can easily observe many intermediate states, so it's very useful
    182     // to be able to share the buffer with JavaScript versions of the whole or partial string.
    183     // In contrast, this string doesn't interact much with the rest of the engine so it's not that
    184     // big a cost that it isn't a String.
    185     ScriptString m_responseText;
     179    StringBuilder m_responseBuilder;
    186180    mutable bool m_createdDocument;
    187181    mutable RefPtr<Document> m_responseXML;
  • trunk/WebKit/efl/ChangeLog

    r69650 r69688  
     12010-10-13  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=43987
     6        Switch XMLHttpRequest, FileReader, and FileReaderSync to use a Stringbuilder
     7        to construct their internal result string.  Remove ScriptString (this is now
     8        redundant).
     9
     10        * WebCoreSupport/FrameLoaderClientEfl.cpp:
     11        (WebCore::FrameLoaderClientEfl::dispatchDidLoadResourceByXMLHttpRequest):
     12        * WebCoreSupport/FrameLoaderClientEfl.h:
     13
    1142010-10-13  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    215
  • trunk/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp

    r69650 r69688  
    760760}
    761761
    762 void FrameLoaderClientEfl::dispatchDidLoadResourceByXMLHttpRequest(unsigned long, const ScriptString&)
     762void FrameLoaderClientEfl::dispatchDidLoadResourceByXMLHttpRequest(unsigned long, const String&)
    763763{
    764764    notImplemented();
  • trunk/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h

    r69061 r69688  
    9292    virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long  identifier, const ResourceError&);
    9393    virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length);
    94     virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString& sourceString);
     94    virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::String& sourceString);
    9595
    9696    virtual void dispatchDidHandleOnloadEvents();
  • trunk/WebKit/mac/ChangeLog

    r69623 r69688  
     12010-10-13  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=43987
     6        Switch XMLHttpRequest, FileReader, and FileReaderSync to use a Stringbuilder
     7        to construct their internal result string.  Remove ScriptString (this is now
     8        redundant).
     9
     10        * WebCoreSupport/WebFrameLoaderClient.mm:
     11
    1122010-10-12  Andy Estes  <aestes@apple.com>
    213
  • trunk/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r68854 r69688  
    112112#import <WebCore/ResourceRequest.h>
    113113#import <WebCore/ScriptController.h>
    114 #import <WebCore/ScriptString.h>
    115114#import <WebCore/SharedBuffer.h>
    116115#import <WebCore/WebCoreObjCExtras.h>
  • trunk/WebKit/qt/ChangeLog

    r69648 r69688  
     12010-10-13  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=43987
     6        Switch XMLHttpRequest, FileReader, and FileReaderSync to use a Stringbuilder
     7        to construct their internal result string.  Remove ScriptString (this is now
     8        redundant).
     9
     10        * WebCoreSupport/FrameLoaderClientQt.cpp:
     11
    1122010-10-13  Dinu Jacob  <dinu.jacob@nokia.com>
    213
  • trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp

    r69396 r69688  
    6565#include "ResourceHandle.h"
    6666#include "ScriptController.h"
    67 #include "ScriptString.h"
    6867#include "Settings.h"
    6968#include "QWebPageClient.h"
  • trunk/WebKit/win/ChangeLog

    r69656 r69688  
     12010-10-13  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=43987
     6        Switch XMLHttpRequest, FileReader, and FileReaderSync to use a Stringbuilder
     7        to construct their internal result string.  Remove ScriptString (this is now
     8        redundant).
     9
     10        * WebCoreSupport/WebFrameLoaderClient.cpp:
     11
    1122010-10-12  Adam Roben  <aroben@apple.com>
    213
  • trunk/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp

    r68854 r69688  
    6868#include <WebCore/RenderPart.h>
    6969#include <WebCore/ResourceHandle.h>
    70 #include <WebCore/ScriptString.h>
    7170#pragma warning(pop)
    7271
  • trunk/WebKit/wx/ChangeLog

    r68576 r69688  
     12010-10-13  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=43987
     6        Switch XMLHttpRequest, FileReader, and FileReaderSync to use a Stringbuilder
     7        to construct their internal result string.  Remove ScriptString (this is now
     8        redundant).
     9
     10        * WebKitSupport/FrameLoaderClientWx.cpp:
     11
    1122010-09-28  Jenn Braithwaite  <jennb@chromium.org>
    213
  • trunk/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp

    r68576 r69688  
    5050#include "ResourceResponse.h"
    5151#include "ScriptController.h"
    52 #include "ScriptString.h"
    5352#include <wtf/PassRefPtr.h>
    5453#include <wtf/RefPtr.h>
  • trunk/WebKit2/ChangeLog

    r69687 r69688  
     12010-10-13  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=43987
     6        Switch XMLHttpRequest, FileReader, and FileReaderSync to use a Stringbuilder
     7        to construct their internal result string.  Remove ScriptString (this is now
     8        redundant).
     9
     10        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     11        (WebKit::WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest):
     12        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
     13
    1142010-10-13  Anders Carlsson  <andersca@apple.com>
    215
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r69329 r69688  
    197197}
    198198
    199 void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString&)
     199void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const String&)
    200200{
    201201    notImplemented();
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

    r68576 r69688  
    7070    virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&);
    7171    virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length);
    72     virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString&);
     72    virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WTF::String&);
    7373   
    7474    virtual void dispatchDidHandleOnloadEvents();
Note: See TracChangeset for help on using the changeset viewer.