2006-10-19 Anders Carlsson <acarlsson@apple.com>
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2006 16:09:00 +0000 (16:09 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2006 16:09:00 +0000 (16:09 +0000)
        Reviewed by Maciej, Brady.

        Remove "charset" from the ResourceLoader metadata map and use
        a getter function instead. Also, rename charset to encoding in a couple of places.

        * loader/CachedCSSStyleSheet.cpp:
        (WebCore::CachedCSSStyleSheet::setEncoding):
        * loader/CachedCSSStyleSheet.h:
        * loader/CachedResource.h:
        (WebCore::CachedResource::setEncoding):
        * loader/CachedScript.cpp:
        (WebCore::CachedScript::setEncoding):
        * loader/CachedScript.h:
        * loader/CachedXBLDocument.cpp:
        (WebCore::CachedXBLDocument::setEncoding):
        * loader/CachedXBLDocument.h:
        * loader/CachedXSLStyleSheet.cpp:
        (WebCore::CachedXSLStyleSheet::setEncoding):
        * loader/CachedXSLStyleSheet.h:
        * loader/loader.cpp:
        (WebCore::Loader::receivedResponse):
        * platform/ResourceLoader.cpp:
        (WebCore::ResourceLoader::responseEncoding):
        (WebCore::ResourceLoader::queryMetaData):
        * platform/ResourceLoader.h:
        * platform/ResourceLoaderInternal.h:
        (WebCore::ResourceLoaderInternal::ResourceLoaderInternal):
        * platform/mac/ResourceLoaderMac.mm:
        (WebCore::ResourceLoader::retrieveResponseEncoding):
        (WebCore::ResourceLoader::receivedResponse):
        * xml/xmlhttprequest.cpp:
        (WebCore::XMLHttpRequest::receivedData):

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

16 files changed:
WebCore/ChangeLog
WebCore/loader/CachedCSSStyleSheet.cpp
WebCore/loader/CachedCSSStyleSheet.h
WebCore/loader/CachedResource.h
WebCore/loader/CachedScript.cpp
WebCore/loader/CachedScript.h
WebCore/loader/CachedXBLDocument.cpp
WebCore/loader/CachedXBLDocument.h
WebCore/loader/CachedXSLStyleSheet.cpp
WebCore/loader/CachedXSLStyleSheet.h
WebCore/loader/loader.cpp
WebCore/platform/ResourceLoader.cpp
WebCore/platform/ResourceLoader.h
WebCore/platform/ResourceLoaderInternal.h
WebCore/platform/mac/ResourceLoaderMac.mm
WebCore/xml/xmlhttprequest.cpp

index 8885bd8f2dcad370fee83fdd54c12a9af6143765..ee5fbe6b889e20a7f23a0247d0c87b9391887f09 100644 (file)
@@ -1,3 +1,38 @@
+2006-10-19  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej, Brady.
+
+        Remove "charset" from the ResourceLoader metadata map and use 
+        a getter function instead. Also, rename charset to encoding in a couple of places.
+        
+        * loader/CachedCSSStyleSheet.cpp:
+        (WebCore::CachedCSSStyleSheet::setEncoding):
+        * loader/CachedCSSStyleSheet.h:
+        * loader/CachedResource.h:
+        (WebCore::CachedResource::setEncoding):
+        * loader/CachedScript.cpp:
+        (WebCore::CachedScript::setEncoding):
+        * loader/CachedScript.h:
+        * loader/CachedXBLDocument.cpp:
+        (WebCore::CachedXBLDocument::setEncoding):
+        * loader/CachedXBLDocument.h:
+        * loader/CachedXSLStyleSheet.cpp:
+        (WebCore::CachedXSLStyleSheet::setEncoding):
+        * loader/CachedXSLStyleSheet.h:
+        * loader/loader.cpp:
+        (WebCore::Loader::receivedResponse):
+        * platform/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::responseEncoding):
+        (WebCore::ResourceLoader::queryMetaData):
+        * platform/ResourceLoader.h:
+        * platform/ResourceLoaderInternal.h:
+        (WebCore::ResourceLoaderInternal::ResourceLoaderInternal):
+        * platform/mac/ResourceLoaderMac.mm:
+        (WebCore::ResourceLoader::retrieveResponseEncoding):
+        (WebCore::ResourceLoader::receivedResponse):
+        * xml/xmlhttprequest.cpp:
+        (WebCore::XMLHttpRequest::receivedData):
+
 2006-10-19  David Hyatt  <hyatt@apple.com>
 
         Rewrite of the WebCore memory cache.  The following changes have been made (along with many more):
index 1366ffb4205a133b3702cf727228abfa26add08a..ca2d1e34f5cd504336db9faa322d9ad5766c138b 100644 (file)
@@ -63,7 +63,7 @@ void CachedCSSStyleSheet::ref(CachedResourceClient *c)
         c->setCSSStyleSheet(m_url, m_decoder->encoding().name(), m_sheet);
 }
 
-void CachedCSSStyleSheet::setCharset(const String& chs)
+void CachedCSSStyleSheet::setEncoding(const String& chs)
 {
     m_decoder->setEncoding(chs, Decoder::EncodingFromHTTPHeader);
 }
index 118ba9d962738640e6cd2133261c3480eb070951..f15bb59eaa351b79a8704508210578d28617c028 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
 
         virtual void ref(CachedResourceClient*);
  
-        virtual void setCharset(const String&);
+        virtual void setEncoding(const String&);
         virtual void data(Vector<char>&, bool allDataReceived);
         virtual void error();
 
index 1e94d26e2c542de6d7b79b94231e271b11e8b497..1deaaa8fbcb6677e8db26b23aaf4065c798883d5 100644 (file)
@@ -69,7 +69,7 @@ public:
     CachedResource(const String& URL, Type type, CachePolicy cachePolicy, time_t expireDate, unsigned size = 0);
     virtual ~CachedResource();
 
-    virtual void setCharset(const String&) { }
+    virtual void setEncoding(const String&) { }
     virtual Vector<char>& bufferData(const char* bytes, int addedSize, Request*);
     virtual void data(Vector<char>&, bool allDataReceived) = 0;
     virtual void error() = 0;
index ed91afaf7aef3a80c86a1cf769353515ba92ef77..dc40cbd26ac1077a7d5047fad599861b74a5b67d 100644 (file)
@@ -64,7 +64,7 @@ void CachedScript::ref(CachedResourceClient* c)
         c->notifyFinished(this);
 }
 
-void CachedScript::setCharset(const String& chs)
+void CachedScript::setEncoding(const String& chs)
 {
     TextEncoding encoding(chs);
     if (encoding.isValid())
index 92bac1f55d9d166c0c0de4738065d703389d935d..4f7f7900fa0aaf623d0d2257a1604c6d342b3c97 100644 (file)
@@ -44,7 +44,7 @@ namespace WebCore {
 
         virtual void ref(CachedResourceClient*);
 
-        virtual void setCharset(const String&);
+        virtual void setEncoding(const String&);
         virtual void data(Vector<char>&, bool allDataReceived);
         virtual void error();
 
index 1c540511bf7ad3081003929025aa53b52581af00..a98939bb933f173ce3e7c716a4d1098ea6bac1c4 100644 (file)
@@ -65,7 +65,7 @@ void CachedXBLDocument::ref(CachedResourceClient *c)
         c->setXBLDocument(m_url, m_document);
 }
 
-void CachedXBLDocument::setCharset(const String& chs)
+void CachedXBLDocument::setEncoding(const String& chs)
 {
     m_decoder->setEncoding(chs, Decoder::EncodingFromHTTPHeader);
 }
index cc8e22417f91c0afe3f8027ff5d075cee51ed7be..6c5ac5d6448bea2c2d6d4232307def7c84eb117d 100644 (file)
@@ -48,7 +48,7 @@ namespace WebCore {
         
         virtual void ref(CachedResourceClient*);
         
-        virtual void setCharset(const String&);
+        virtual void setEncoding(const String&);
         virtual void data(Vector<char>&, bool allDataReceived);
         virtual void error();
         
index 7917d2bbbd71c3ab0c981b5c9786cfc228e47c28..e2d81a268f386e04042d9b0fdc71f9db7a19dda0 100644 (file)
@@ -61,7 +61,7 @@ void CachedXSLStyleSheet::ref(CachedResourceClient *c)
         c->setXSLStyleSheet(m_url, m_sheet);
 }
 
-void CachedXSLStyleSheet::setCharset(const String& chs)
+void CachedXSLStyleSheet::setEncoding(const String& chs)
 {
     m_decoder->setEncoding(chs, Decoder::EncodingFromHTTPHeader);
 }
index 7a80fc64a3e41a7f16ef474b0e541abdce7c8ca8..37253b743cb5dce8e685e2bed4fd431ad63362dc 100644 (file)
@@ -45,7 +45,7 @@ namespace WebCore {
         
         virtual void ref(CachedResourceClient*);
         
-        virtual void setCharset(const String&);
+        virtual void setEncoding(const String&);
         virtual void data(Vector<char>&, bool allDataReceived);
         virtual void error();
         
index bb40674650f42713e4ec664107fca7aff000042c..d33ada434b03cb1c6ede86b809c9e4ccf1d05694 100644 (file)
@@ -128,9 +128,9 @@ void Loader::receivedResponse(ResourceLoader* job, PlatformResponse response)
     req->cachedObject()->setResponse(response);
     req->cachedObject()->setExpireDate(CacheObjectExpiresTime(req->docLoader(), response), false);
     
-    DeprecatedString chs = job->queryMetaData("charset").deprecatedString();
-    if (!chs.isNull())
-        req->cachedObject()->setCharset(chs);
+    String encoding = job->responseEncoding();
+    if (!encoding.isNull())
+        req->cachedObject()->setEncoding(encoding);
     
     if (req->isMultipart()) {
         ASSERT(req->cachedObject()->isImage());
index 9009b936f4a13288af99ea843f2f14d9e6b4e436..57fba67e5e2923e210f7368d99fd3d0d28d912da 100644 (file)
@@ -67,6 +67,13 @@ void ResourceLoader::setError(int e)
     d->status = e;
 }
 
+String ResourceLoader::responseEncoding() const
+{
+    retrieveResponseEncoding();
+    
+    return d->m_responseEncoding;
+}
+
 String ResourceLoader::queryMetaData(const String& key) const
 {
     if (key == "HTTP-Headers") {
@@ -74,10 +81,6 @@ String ResourceLoader::queryMetaData(const String& key) const
         return d->responseHeaders;
     } 
 
-    if (key == "charset")
-        // this will put it in the regular metadata dictionary
-        retrieveCharset();
-
     return d->metaData.get(key); 
 }
 
index 4509c124f4864c6e76a98c5aee8ee8a6dd87cfd5..1fd6291dfe4cbb5706a6d3f3e30e91b2f4d16f8f 100644 (file)
@@ -77,6 +77,7 @@ public:
     void setError(int);
     String errorText() const;
     bool isErrorPage() const;
+    String responseEncoding() const;
     String queryMetaData(const String&) const;
     void addMetaData(const String& key, const String& value);
     void addMetaData(const HashMap<String, String>&);
@@ -118,7 +119,7 @@ public:
 
 private:
     void assembleResponseHeaders() const;
-    void retrieveCharset() const;
+    void retrieveResponseEncoding() const;
 
     ResourceLoaderInternal* d;
 };
index b7ddd88ab78bd7e9badbbb3e6684278fa28cb495..18f1a49061ec9531d11fc7ee9cf48bec003a9f37 100644 (file)
@@ -64,7 +64,7 @@ namespace WebCore {
             , URL(u)
             , method(method)
             , assembledResponseHeaders(true)
-            , retrievedCharset(true)
+            , m_retrievedResponseEncoding(true)
             , m_loading(false)
             , m_cancelled(false)
 #if USE(CFNETWORK)
@@ -100,7 +100,7 @@ namespace WebCore {
             , method(method)
             , postData(p)
             , assembledResponseHeaders(true)
-            , retrievedCharset(true)
+            , m_retrievedResponseEncoding(true)
             , m_loading(false)
             , m_cancelled(false)
 #if USE(CFNETWORK)
@@ -139,9 +139,11 @@ namespace WebCore {
         String method;
         FormData postData;
         
-        bool assembledResponseHeaders;
-        bool retrievedCharset;
+        String m_responseEncoding;
         DeprecatedString responseHeaders;
+
+        bool assembledResponseHeaders;
+        bool m_retrievedResponseEncoding;
     
         bool m_loading;
         bool m_cancelled;
index 42010abd2543849b6c8df942c7f5755a076abf67..c6faf4f77e388c74ba1080399beacd7b6c54e335 100644 (file)
@@ -112,13 +112,13 @@ void ResourceLoader::assembleResponseHeaders() const
     }
 }
 
-void ResourceLoader::retrieveCharset() const
+void ResourceLoader::retrieveResponseEncoding() const
 {
-    if (!d->retrievedCharset) {
-        NSString *charset = [d->response textEncodingName];
-        if (charset)
-            d->metaData.set("charset", charset);
-        d->retrievedCharset = true;
+    if (!d->m_retrievedResponseEncoding) {
+        NSString *textEncodingName = [d->response textEncodingName];
+        if (textEncodingName)
+            d->m_responseEncoding = textEncodingName;
+        d->m_retrievedResponseEncoding = true;
     }
 }
 
@@ -132,7 +132,7 @@ void ResourceLoader::setLoader(WebCoreResourceLoaderImp *loader)
 void ResourceLoader::receivedResponse(NSURLResponse* response)
 {
     d->assembledResponseHeaders = false;
-    d->retrievedCharset = false;
+    d->m_retrievedResponseEncoding = false;
     d->response = response;
     HardRetain(d->response);
     if (d->client)
index 5eae50a160f9d97c128fdfccbb711960c32f8042..dc001248c6c91717b416451a694b6886c988bbb4 100644 (file)
@@ -564,7 +564,7 @@ void XMLHttpRequest::receivedData(ResourceLoader*, const char* data, int len)
         if (m_encoding.isEmpty())
             m_encoding = getCharset(getResponseHeader("Content-Type"));
         if (m_encoding.isEmpty() && m_loader)
-            m_encoding = m_loader->queryMetaData("charset");
+            m_encoding = m_loader->responseEncoding();
     
         if (!m_encoding.isEmpty())
             m_decoder = new Decoder("text/plain", m_encoding);