2011-02-05 Patrick Gansterer <paroga@webkit.org>
authorparoga@webkit.org <paroga@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 20:34:19 +0000 (20:34 +0000)
committerparoga@webkit.org <paroga@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 20:34:19 +0000 (20:34 +0000)
        Reviewed by Alexey Proskuryakov.

        Use Document::encoding() instead of DocumentWriter::encoding()
        https://bugs.webkit.org/show_bug.cgi?id=53398

        This change makes the code more readable, when a subresource
        inherits the character encoding of the document.

        * dom/ProcessingInstruction.cpp:
        (WebCore::ProcessingInstruction::checkStyleSheet):
        * dom/ScriptElement.cpp:
        (WebCore::ScriptElement::scriptCharset):
        * html/HTMLLinkElement.cpp:
        (WebCore::HTMLLinkElement::process):
        * loader/cache/CachedResourceLoader.cpp:
        (WebCore::CachedResourceLoader::requestPreload):
        * platform/network/FormDataBuilder.cpp:
        (WebCore::FormDataBuilder::encodingFromAcceptCharset):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/platform/network/FormDataBuilder.cpp

index cfeb9c4e03eb9642c45e2d6dbbd73bb27b621847..853ba5dd36ab94ded979228bb315be621fed99df 100644 (file)
@@ -1,3 +1,24 @@
+2011-02-05  Patrick Gansterer  <paroga@webkit.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Use Document::encoding() instead of DocumentWriter::encoding()
+        https://bugs.webkit.org/show_bug.cgi?id=53398
+
+        This change makes the code more readable, when a subresource
+        inherits the character encoding of the document.
+
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::checkStyleSheet):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::scriptCharset):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::process):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::requestPreload):
+        * platform/network/FormDataBuilder.cpp:
+        (WebCore::FormDataBuilder::encodingFromAcceptCharset):
+
 2011-02-05  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index 544d7898a202ffa04a925038637ad7ac5778ee50..41bbd921d2337e792a5b83bbdccff82f73919552 100644 (file)
@@ -168,7 +168,7 @@ void ProcessingInstruction::checkStyleSheet()
             {
                 String charset = attrs.get("charset");
                 if (charset.isEmpty())
-                    charset = document()->frame()->loader()->writer()->encoding();
+                    charset = document()->charset();
 
                 m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(url, charset);
             }
index 747f7a13b383175d87752257347d0ee4ec658266..1939a080dfc88369f02fff76ce683bc56ba3852b 100644 (file)
@@ -292,10 +292,8 @@ String ScriptElement::scriptCharset() const
     String charset = charsetAttributeValue().stripWhiteSpace();
 
     // If charset has not been declared in script tag, fall back to frame encoding.
-    if (charset.isEmpty()) {
-        if (Frame* frame = m_element->document()->frame())
-            charset = frame->loader()->writer()->encoding();
-    }
+    if (charset.isEmpty())
+        charset = m_element->document()->charset();
 
     return charset;
 }
index fc29d1d056f4e634212f7283f5dd3e5edcf04538..1aa72f6f99d40635cb3b7c9ea5912980948fafb0 100644 (file)
@@ -229,7 +229,7 @@ void HTMLLinkElement::process()
         
         String charset = getAttribute(charsetAttr);
         if (charset.isEmpty() && document()->frame())
-            charset = document()->frame()->loader()->writer()->encoding();
+            charset = document()->charset();
         
         if (m_cachedSheet) {
             removePendingSheet();
index 478c998f779776cee944046abbdefea89d48d6ac..6dffd1ac22efb645b8ecea50a3553749ac89be43 100644 (file)
@@ -618,7 +618,7 @@ void CachedResourceLoader::requestPreload(CachedResource::Type type, const Strin
 {
     String encoding;
     if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet)
-        encoding = charset.isEmpty() ? m_document->frame()->loader()->writer()->encoding() : charset;
+        encoding = charset.isEmpty() ? m_document->charset() : charset;
 
     CachedResource* resource = requestResource(type, url, encoding, ResourceLoadPriorityUnresolved, true);
     if (!resource || (m_preloads && m_preloads->contains(resource)))
index da28fc22a0f73c9c83b0bff62eddee0f314242df..e973f994397978d3fd2038319c151a1e2b877361 100644 (file)
@@ -94,10 +94,7 @@ TextEncoding FormDataBuilder::encodingFromAcceptCharset(const String& acceptChar
             return encoding;
     }
 
-    if (Frame* frame = document->frame())
-        return frame->loader()->writer()->encoding();
-
-    return Latin1Encoding();
+    return document->inputEncoding();
 }
 
 Vector<char> FormDataBuilder::generateUniqueBoundaryString()