JavaScriptCore:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2007 01:50:54 +0000 (01:50 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2007 01:50:54 +0000 (01:50 +0000)
        Reviewed by Mark.

        - follow-up to previous change

        * kjs/ustring.cpp:
        (KJS::UString::operator=): Make sure to reset the length when
        replacing the buffer contents for a single-owned string.

WebCore:

        Reviewed by Mark.

        - follow-up to previous change to avoid assertion failures in debug

        * xml/XMLHttpRequest.cpp:
        (WebCore::XMLHttpRequest::getResponseText): hold JSLock when needed
        (WebCore::XMLHttpRequest::open): ditto
        (WebCore::XMLHttpRequest::didFinishLoading): ditto
        (WebCore::XMLHttpRequest::didReceiveData): ditto
        * xml/XMLHttpRequest.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24637 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/ustring.cpp
WebCore/ChangeLog
WebCore/xml/XMLHttpRequest.cpp
WebCore/xml/XMLHttpRequest.h

index ca11d41..4b6e28d 100644 (file)
@@ -1,5 +1,15 @@
 2007-07-25  Maciej Stachowiak  <mjs@apple.com>
 
+        Reviewed by Mark.
+
+        - follow-up to previous change
+        
+        * kjs/ustring.cpp:
+        (KJS::UString::operator=): Make sure to reset the length when
+        replacing the buffer contents for a single-owned string.
+
+2007-07-25  Maciej Stachowiak  <mjs@apple.com>
+
         Reviewed by Darin.
         
         - JavaScriptCore part of fix for <rdar://problem/5300291> Optimize GC to reclaim big, temporary objects (like XMLHttpRequest.responseXML) quickly
index 8bb7ec1..e9ca36a 100644 (file)
@@ -841,6 +841,7 @@ UString &UString::operator=(const char *c)
   if (m_rep->rc == 1 && l <= m_rep->capacity && m_rep->baseIsSelf() && m_rep->offset == 0 && m_rep->preCapacity == 0) {
     d = m_rep->buf;
     m_rep->_hash = 0;
+    m_rep->len = l;
   } else {
     d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * l));
     m_rep = Rep::create(d, l);
index fc62088..caf5ee1 100644 (file)
@@ -1,3 +1,16 @@
+2007-07-25  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Mark.
+
+        - follow-up to previous change to avoid assertion failures in debug
+        
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::getResponseText): hold JSLock when needed
+        (WebCore::XMLHttpRequest::open): ditto
+        (WebCore::XMLHttpRequest::didFinishLoading): ditto
+        (WebCore::XMLHttpRequest::didReceiveData): ditto
+        * xml/XMLHttpRequest.h:
+
 2007-07-25  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Darin.
index 178818e..c7c600c 100644 (file)
@@ -145,7 +145,7 @@ XMLHttpRequestState XMLHttpRequest::getReadyState() const
     return m_state;
 }
 
-KJS::UString XMLHttpRequest::getResponseText() const
+const KJS::UString& XMLHttpRequest::getResponseText() const
 {
     return m_responseText;
 }
@@ -325,7 +325,10 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc
     // clear stuff from possible previous load
     m_requestHeaders.clear();
     m_response = ResourceResponse();
-    m_responseText = "";
+    {
+        KJS::JSLock lock;
+        m_responseText = "";
+    }
     m_createdDocument = false;
     m_responseXML = 0;
 
@@ -643,8 +646,11 @@ void XMLHttpRequest::didFinishLoading(SubresourceLoader* loader)
     if (m_state < Sent)
         changeState(Sent);
 
-    if (m_decoder)
-        m_responseText += m_decoder->flush();
+    {
+        KJS::JSLock lock;
+        if (m_decoder)
+            m_responseText += m_decoder->flush();
+    }
 
     bool hadLoader = m_loader;
     m_loader = 0;
@@ -695,7 +701,10 @@ void XMLHttpRequest::didReceiveData(SubresourceLoader*, const char* data, int le
 
     String decoded = m_decoder->decode(data, len);
 
-    m_responseText += decoded;
+    {
+        KJS::JSLock lock;
+        m_responseText += decoded;
+    }
 
     if (!m_aborted) {
         if (m_state != Receiving)
index e8e06ee..8a40b93 100644 (file)
@@ -82,7 +82,7 @@ public:
     void overrideMIMEType(const String& override);
     String getAllResponseHeaders() const;
     String getResponseHeader(const String& name) const;
-    KJS::UString getResponseText() const;
+    const KJS::UString& getResponseText() const;
     Document* getResponseXML() const;
 
     void setOnReadyStateChangeListener(EventListener*);