|
Lines 153-158
a/Source/WebCore/dom/Document.cpp_sec1
|
| 153 |
#include "htmlediting.h" |
153 |
#include "htmlediting.h" |
| 154 |
#include <wtf/CurrentTime.h> |
154 |
#include <wtf/CurrentTime.h> |
| 155 |
#include <wtf/HashFunctions.h> |
155 |
#include <wtf/HashFunctions.h> |
|
|
156 |
#include <wtf/HashMap.h> |
| 156 |
#include <wtf/MainThread.h> |
157 |
#include <wtf/MainThread.h> |
| 157 |
#include <wtf/PassRefPtr.h> |
158 |
#include <wtf/PassRefPtr.h> |
| 158 |
#include <wtf/StdLibExtras.h> |
159 |
#include <wtf/StdLibExtras.h> |
|
Lines 393-398
Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
a/Source/WebCore/dom/Document.cpp_sec2
|
| 393 |
, m_scriptRunner(ScriptRunner::create(this)) |
394 |
, m_scriptRunner(ScriptRunner::create(this)) |
| 394 |
, m_xmlVersion("1.0") |
395 |
, m_xmlVersion("1.0") |
| 395 |
, m_xmlStandalone(false) |
396 |
, m_xmlStandalone(false) |
|
|
397 |
, m_dominantScript(USCRIPT_INVALID_CODE) |
| 396 |
, m_savedRenderer(0) |
398 |
, m_savedRenderer(0) |
| 397 |
, m_designMode(inherit) |
399 |
, m_designMode(inherit) |
| 398 |
#if ENABLE(DASHBOARD_SUPPORT) |
400 |
#if ENABLE(DASHBOARD_SUPPORT) |
|
Lines 1045-1050
void Document::setCharset(const String& charset)
a/Source/WebCore/dom/Document.cpp_sec3
|
| 1045 |
decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); |
1047 |
decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); |
| 1046 |
} |
1048 |
} |
| 1047 |
|
1049 |
|
|
|
1050 |
UScriptCode Document::dominantScript() |
| 1051 |
{ |
| 1052 |
if (m_dominantScript != USCRIPT_INVALID_CODE) |
| 1053 |
return m_dominantScript; |
| 1054 |
String encoding = inputEncoding(); |
| 1055 |
if (encoding.isEmpty()) |
| 1056 |
return m_dominantScript; |
| 1057 |
m_dominantScript = encodingToScriptCode(encoding); |
| 1058 |
return m_dominantScript; |
| 1059 |
} |
| 1060 |
|
| 1061 |
UScriptCode Document::encodingToScriptCode(const String& encoding) |
| 1062 |
{ |
| 1063 |
struct EncodingScript { |
| 1064 |
const char* encoding; |
| 1065 |
UScriptCode script; |
| 1066 |
}; |
| 1067 |
|
| 1068 |
// inputEncoding() always returns a canonical name. We use |
| 1069 |
// MIME names and IANA names (if the former is not available). |
| 1070 |
static const EncodingScript encodingScriptList[] = { |
| 1071 |
{ "GB2312", USCRIPT_SIMPLIFIED_HAN }, |
| 1072 |
{ "GBK", USCRIPT_SIMPLIFIED_HAN }, |
| 1073 |
{ "GB18030", USCRIPT_SIMPLIFIED_HAN }, |
| 1074 |
{ "Big5", USCRIPT_TRADITIONAL_HAN }, |
| 1075 |
{ "Big5-HKSCS", USCRIPT_TRADITIONAL_HAN }, |
| 1076 |
{ "Shift_JIS", USCRIPT_KATAKANA_OR_HIRAGANA }, |
| 1077 |
{ "EUC-JP", USCRIPT_KATAKANA_OR_HIRAGANA }, |
| 1078 |
{ "ISO-2022-JP", USCRIPT_KATAKANA_OR_HIRAGANA }, |
| 1079 |
{ "ISO-2022-KR", USCRIPT_HANGUL }, |
| 1080 |
{ "EUC-KR", USCRIPT_HANGUL }, |
| 1081 |
{ "TIS-620", USCRIPT_THAI }, |
| 1082 |
{ "ISO-8859-1", USCRIPT_LATIN }, |
| 1083 |
{ "ISO-8859-15", USCRIPT_LATIN }, |
| 1084 |
{ "windows-1252", USCRIPT_LATIN }, |
| 1085 |
{ "ISO-8859-2", USCRIPT_LATIN }, |
| 1086 |
{ "windows-1250", USCRIPT_LATIN }, |
| 1087 |
{ "ISO-8859-3", USCRIPT_LATIN }, |
| 1088 |
{ "ISO-8859-4", USCRIPT_LATIN }, |
| 1089 |
{ "ISO-8859-13", USCRIPT_LATIN }, |
| 1090 |
{ "windows-1257", USCRIPT_LATIN }, |
| 1091 |
{ "ISO-8859-5", USCRIPT_CYRILLIC }, |
| 1092 |
{ "windows-1251", USCRIPT_CYRILLIC }, |
| 1093 |
{ "KOI8-R", USCRIPT_CYRILLIC }, |
| 1094 |
{ "KOI8-U", USCRIPT_CYRILLIC }, |
| 1095 |
{ "ISO-8859-6", USCRIPT_ARABIC }, |
| 1096 |
{ "windows-1256", USCRIPT_ARABIC }, |
| 1097 |
{ "ISO-8859-7", USCRIPT_GREEK }, |
| 1098 |
{ "windows-1253", USCRIPT_GREEK }, |
| 1099 |
{ "ISO-8859-8", USCRIPT_HEBREW }, |
| 1100 |
{ "windows-1255", USCRIPT_HEBREW }, |
| 1101 |
{ "ISO-8859-9", USCRIPT_LATIN }, // Turkish |
| 1102 |
{ "windows-1254", USCRIPT_LATIN }, |
| 1103 |
{ "ISO-8859-10", USCRIPT_LATIN }, // Nordic |
| 1104 |
{ "ISO-8859-14", USCRIPT_LATIN }, // Celtic |
| 1105 |
{ "ISO-8859-16", USCRIPT_LATIN }, // Romanian |
| 1106 |
{ "windows-1258", USCRIPT_LATIN }, // Vietnamese |
| 1107 |
}; |
| 1108 |
|
| 1109 |
typedef HashMap<String, UScriptCode> EncodingScriptMap; |
| 1110 |
DEFINE_STATIC_LOCAL(EncodingScriptMap, encodingScriptMap, ()); |
| 1111 |
|
| 1112 |
if (encodingScriptMap.isEmpty()) { |
| 1113 |
for (unsigned i = 0; i < sizeof(encodingScriptList) / sizeof(encodingScriptList[0]); ++i) |
| 1114 |
encodingScriptMap.set(encodingScriptList[i].encoding, |
| 1115 |
encodingScriptList[i].script); |
| 1116 |
} |
| 1117 |
HashMap<String, UScriptCode>::iterator it = encodingScriptMap.find(encoding); |
| 1118 |
UScriptCode dominantScript; |
| 1119 |
if (it != encodingScriptMap.end()) |
| 1120 |
dominantScript = it->second; |
| 1121 |
else |
| 1122 |
// TODO(jungshik) : should return a script corresponding to the locale. |
| 1123 |
dominantScript = USCRIPT_COMMON; |
| 1124 |
return dominantScript; |
| 1125 |
} |
| 1126 |
|
| 1048 |
void Document::setXMLVersion(const String& version, ExceptionCode& ec) |
1127 |
void Document::setXMLVersion(const String& version, ExceptionCode& ec) |
| 1049 |
{ |
1128 |
{ |
| 1050 |
if (!implementation()->hasFeature("XML", String())) { |
1129 |
if (!implementation()->hasFeature("XML", String())) { |