Polish code for r189579.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Sep 2015 02:13:03 +0000 (02:13 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Sep 2015 02:13:03 +0000 (02:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149131

Reviewed by Chris Dumez.

Use more self-explaining function name "characterSetWithUTF8Fallback" instead of
"characterSetForBindings". Optimize the way to get text encoding.

* dom/Document.cpp:
(WebCore::Document::characterSetWithUTF8Fallback):
(WebCore::Document::encoding): Deleted.
(WebCore::Document::characterSetForBindings): Deleted.
* dom/Document.h:
(WebCore::Document::encoding):
(WebCore::Document::textEncoding):
* dom/Document.idl:
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::createDecoderIfNeeded):
* loader/FormSubmission.cpp:
(WebCore::encodingFromAcceptCharset):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Document.idl
Source/WebCore/loader/DocumentWriter.cpp
Source/WebCore/loader/FormSubmission.cpp

index 4f8d4bc..1ed1d25 100644 (file)
@@ -1,3 +1,26 @@
+2015-09-14  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Polish code for r189579.
+        https://bugs.webkit.org/show_bug.cgi?id=149131
+
+        Reviewed by Chris Dumez.
+
+        Use more self-explaining function name "characterSetWithUTF8Fallback" instead of
+        "characterSetForBindings". Optimize the way to get text encoding.
+
+        * dom/Document.cpp:
+        (WebCore::Document::characterSetWithUTF8Fallback):
+        (WebCore::Document::encoding): Deleted.
+        (WebCore::Document::characterSetForBindings): Deleted.
+        * dom/Document.h:
+        (WebCore::Document::encoding):
+        (WebCore::Document::textEncoding):
+        * dom/Document.idl:
+        * loader/DocumentWriter.cpp:
+        (WebCore::DocumentWriter::createDecoderIfNeeded):
+        * loader/FormSubmission.cpp:
+        (WebCore::encodingFromAcceptCharset):
+
 2015-09-14  Chris Dumez  <cdumez@apple.com>
 
         Drop non-standard [IsIndex] WebKit IDL extended attribute
index be326f0..9192147 100644 (file)
 #include "StyleSheetList.h"
 #include "SubresourceLoader.h"
 #include "TextNodeTraversal.h"
-#include "TextResourceDecoder.h"
 #include "TransformSource.h"
 #include "TreeWalker.h"
 #include "VisitedLinkState.h"
@@ -1248,14 +1247,7 @@ void Document::setVisualUpdatesAllowedByClient(bool visualUpdatesAllowedByClient
         setVisualUpdatesAllowed(true);
 }
 
-AtomicString Document::encoding() const
-{
-    if (TextResourceDecoder* d = decoder())
-        return d->encoding().domName();
-    return nullAtom;
-}
-
-String Document::characterSetForBindings() const
+String Document::characterSetWithUTF8Fallback() const
 {
     AtomicString name = encoding();
     if (!name.isNull())
index 88d3466..74ceaa9 100644 (file)
@@ -47,6 +47,7 @@
 #include "ScriptExecutionContext.h"
 #include "StringWithDirection.h"
 #include "StyleResolveTree.h"
+#include "TextResourceDecoder.h"
 #include "Timer.h"
 #include "TreeScope.h"
 #include "UserActionElementSet.h"
@@ -401,9 +402,10 @@ public:
     String defaultCharset() const;
 
     String charset() const { return Document::encoding(); }
-    String characterSetForBindings() const;
+    String characterSetWithUTF8Fallback() const;
+    TextEncoding textEncoding() const;
 
-    AtomicString encoding() const;
+    AtomicString encoding() const { return textEncoding().domName(); }
 
     void setCharset(const String&);
 
@@ -1750,6 +1752,13 @@ inline void Document::notifyRemovePendingSheetIfNeeded()
         didRemoveAllPendingStylesheet();
 }
 
+inline TextEncoding Document::textEncoding() const
+{
+    if (auto* decoder = this->decoder())
+        return decoder->encoding();
+    return TextEncoding();
+}
+
 #if ENABLE(TEMPLATE_ELEMENT)
 inline const Document* Document::templateDocument() const
 {
index 391c983..f326477 100644 (file)
@@ -64,7 +64,7 @@
 
     // DOM Level 3 Core
 
-    [ImplementedAs=characterSetForBindings] readonly attribute DOMString inputEncoding;
+    [ImplementedAs=characterSetWithUTF8Fallback] readonly attribute DOMString inputEncoding;
 
     [TreatReturnedNullStringAs=Null] readonly attribute DOMString xmlEncoding;
     [TreatReturnedNullStringAs=Null, TreatNullAs=NullString, SetterRaisesException] attribute DOMString xmlVersion;
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
     DOMSelection       getSelection();
 #endif
-    [ImplementedAs=characterSetForBindings] readonly attribute DOMString characterSet;
+    [ImplementedAs=characterSetWithUTF8Fallback] readonly attribute DOMString characterSet;
 
     // WebKit extensions
 
index 0e155e5..a296799 100644 (file)
@@ -189,7 +189,7 @@ TextResourceDecoder* DocumentWriter::createDecoderIfNeeded()
             m_decoder->setHintEncoding(parentFrame->document()->decoder());
         if (m_encoding.isEmpty()) {
             if (canReferToParentFrameEncoding(m_frame, parentFrame))
-                m_decoder->setEncoding(TextEncoding(parentFrame->document()->encoding()), TextResourceDecoder::EncodingFromParentFrame);
+                m_decoder->setEncoding(parentFrame->document()->textEncoding(), TextResourceDecoder::EncodingFromParentFrame);
         } else {
             m_decoder->setEncoding(m_encoding,
                 m_encodingWasChosenByUser ? TextResourceDecoder::UserChosenEncoding : TextResourceDecoder::EncodingFromHTTPHeader);
index 43435d5..7a83ef3 100644 (file)
@@ -151,7 +151,7 @@ static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Docum
             return encoding;
     }
 
-    return TextEncoding(document.encoding());
+    return document.textEncoding();
 }
 
 Ref<FormSubmission> FormSubmission::create(HTMLFormElement* form, const Attributes& attributes, PassRefPtr<Event> event, LockHistory lockHistory, FormSubmissionTrigger trigger)