|
Lines 50-55
WebCore/dom/Document.cpp_sec1
|
| 50 |
#include "EventNames.h" |
50 |
#include "EventNames.h" |
| 51 |
#include "ExceptionCode.h" |
51 |
#include "ExceptionCode.h" |
| 52 |
#include "FocusController.h" |
52 |
#include "FocusController.h" |
|
|
53 |
#include "FontCache.h" |
| 53 |
#include "Frame.h" |
54 |
#include "Frame.h" |
| 54 |
#include "FrameLoader.h" |
55 |
#include "FrameLoader.h" |
| 55 |
#include "FrameTree.h" |
56 |
#include "FrameTree.h" |
|
Lines 275-280
Document::Document(Frame* frame, bool is
WebCore/dom/Document.cpp_sec2
|
| 275 |
#if ENABLE(XBL) |
276 |
#if ENABLE(XBL) |
| 276 |
, m_bindingManager(new XBLBindingManager(this)) |
277 |
, m_bindingManager(new XBLBindingManager(this)) |
| 277 |
#endif |
278 |
#endif |
|
|
279 |
, m_dominantScript(USCRIPT_INVALID_CODE) |
| 278 |
, m_savedRenderer(0) |
280 |
, m_savedRenderer(0) |
| 279 |
, m_secureForms(0) |
281 |
, m_secureForms(0) |
| 280 |
, m_designMode(inherit) |
282 |
, m_designMode(inherit) |
|
Lines 843-848
void Document::setCharset(const String&
WebCore/dom/Document.cpp_sec3
|
| 843 |
decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); |
845 |
decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); |
| 844 |
} |
846 |
} |
| 845 |
|
847 |
|
|
|
848 |
UScriptCode Document::dominantScript() const |
| 849 |
{ |
| 850 |
struct EncodingScript { |
| 851 |
const char* encoding; |
| 852 |
UScriptCode script; |
| 853 |
}; |
| 854 |
|
| 855 |
// inputEncoding() always returns a canonical name. We use |
| 856 |
// MIME names and IANA names (if the former is not available). |
| 857 |
static const EncodingScript encodingScriptList[] = { |
| 858 |
{ "GB2312", USCRIPT_SIMPLIFIED_HAN }, |
| 859 |
{ "GBK", USCRIPT_SIMPLIFIED_HAN }, |
| 860 |
{ "GB18030", USCRIPT_SIMPLIFIED_HAN }, |
| 861 |
{ "Big5", USCRIPT_TRADITIONAL_HAN }, |
| 862 |
{ "Big5-HKSCS", USCRIPT_TRADITIONAL_HAN }, |
| 863 |
{ "Shift_JIS", USCRIPT_HIRAGANA}, |
| 864 |
{ "EUC-JP", USCRIPT_HIRAGANA }, // Japanese (USCRIPT_JAPANESE) |
| 865 |
{ "ISO-2022-KR", USCRIPT_HIRAGANA }, |
| 866 |
{ "EUC-KR", USCRIPT_HANGUL }, // Korean (USCRIPT_KOREAN) |
| 867 |
{ "TIS-620", USCRIPT_THAI }, |
| 868 |
{ "ISO-8859-1", USCRIPT_LATIN }, |
| 869 |
{ "ISO-8859-15", USCRIPT_LATIN }, |
| 870 |
{ "windows-1252", USCRIPT_LATIN }, |
| 871 |
{ "ISO-8859-2", USCRIPT_LATIN }, |
| 872 |
{ "windows-1250", USCRIPT_LATIN }, |
| 873 |
{ "ISO-8859-3", USCRIPT_LATIN }, |
| 874 |
{ "ISO-8859-4", USCRIPT_LATIN }, |
| 875 |
{ "ISO-8859-13", USCRIPT_LATIN }, |
| 876 |
{ "windows-1257", USCRIPT_LATIN }, |
| 877 |
{ "ISO-8859-5", USCRIPT_CYRILLIC }, |
| 878 |
{ "windows-1251", USCRIPT_CYRILLIC }, |
| 879 |
{ "KOI8-R", USCRIPT_CYRILLIC }, |
| 880 |
{ "KOI8-U", USCRIPT_CYRILLIC }, |
| 881 |
{ "ISO-8859-6", USCRIPT_ARABIC }, |
| 882 |
{ "windows-1256", USCRIPT_ARABIC }, |
| 883 |
{ "ISO-8859-7", USCRIPT_GREEK }, |
| 884 |
{ "windows-1253", USCRIPT_GREEK }, |
| 885 |
{ "ISO-8859-8", USCRIPT_HEBREW }, |
| 886 |
{ "windows-1255", USCRIPT_HEBREW }, |
| 887 |
{ "ISO-8859-9", USCRIPT_LATIN }, // Turkish |
| 888 |
{ "windows-1254", USCRIPT_LATIN }, |
| 889 |
{ "ISO-8859-10", USCRIPT_LATIN }, // Nordic |
| 890 |
{ "ISO-8859-14", USCRIPT_LATIN }, // Celtic |
| 891 |
{ "ISO-8859-16", USCRIPT_LATIN }, // Romanian |
| 892 |
{ "windows-1258", USCRIPT_LATIN }, // Vietnamese |
| 893 |
}; |
| 894 |
|
| 895 |
static HashMap<String, UScriptCode> encodingScriptMap; |
| 896 |
|
| 897 |
if (encodingScriptMap.isEmpty()) { |
| 898 |
for (unsigned i = 0; i < sizeof(encodingScriptList) / sizeof(encodingScriptList[0]); ++i) |
| 899 |
encodingScriptMap.set(encodingScriptList[i].encoding, |
| 900 |
encodingScriptList[i].script); |
| 901 |
} |
| 902 |
|
| 903 |
if (m_dominantScript != USCRIPT_INVALID_CODE) |
| 904 |
return m_dominantScript; |
| 905 |
String encoding = inputEncoding(); |
| 906 |
if (encoding.isEmpty()) |
| 907 |
return m_dominantScript; |
| 908 |
|
| 909 |
HashMap<String, UScriptCode>::iterator it = encodingScriptMap.find(encoding); |
| 910 |
if (it != encodingScriptMap.end()) |
| 911 |
m_dominantScript = it->second; |
| 912 |
else |
| 913 |
// TODO(jungshik) : should return a script corresponding to the locale. |
| 914 |
m_dominantScript = USCRIPT_COMMON; |
| 915 |
return m_dominantScript; |
| 916 |
} |
| 917 |
|
| 846 |
void Document::setXMLVersion(const String& version, ExceptionCode& ec) |
918 |
void Document::setXMLVersion(const String& version, ExceptionCode& ec) |
| 847 |
{ |
919 |
{ |
| 848 |
if (!implementation()->hasFeature("XML", String())) { |
920 |
if (!implementation()->hasFeature("XML", String())) { |
|
Lines 1112-1117
void Document::recalcStyle(StyleChange c
WebCore/dom/Document.cpp_sec4
|
| 1112 |
|
1184 |
|
| 1113 |
FontDescription fontDescription; |
1185 |
FontDescription fontDescription; |
| 1114 |
fontDescription.setUsePrinterFont(printing()); |
1186 |
fontDescription.setUsePrinterFont(printing()); |
|
|
1187 |
// TODO(jungshik): Eventually, we need to derive the dominant script |
| 1188 |
// for the current node based on 'xml:lang' and 'lang' specified for |
| 1189 |
// it or inherited from its parent rather than using the document-wide |
| 1190 |
// value (inferred from charset). Note also that it does not work |
| 1191 |
// for 'script-agnostic' charsets like UTF-8. In that case, Firefox |
| 1192 |
// uses the script corresponding to the application locale. |
| 1193 |
// While a document is loaded, this function is called multiple |
| 1194 |
// times. At the beginning, the document charset is not known and |
| 1195 |
// dominantScript remains invalid. Only when it's determined, we |
| 1196 |
// change the font accordingly. |
| 1197 |
// See http://bugs.webkit.org/show_bug.cgi?id=10874 and |
| 1198 |
// https://bugs.webkit.org/show_bug.cgi?id=18085 |
| 1199 |
UScriptCode script = dominantScript(); |
| 1200 |
if (script != USCRIPT_INVALID_CODE) |
| 1201 |
fontDescription.setDominantScript(script); |
| 1115 |
if (Settings* settings = this->settings()) { |
1202 |
if (Settings* settings = this->settings()) { |
| 1116 |
fontDescription.setRenderingMode(settings->fontRenderingMode()); |
1203 |
fontDescription.setRenderingMode(settings->fontRenderingMode()); |
| 1117 |
if (printing() && !settings->shouldPrintBackgrounds()) |
1204 |
if (printing() && !settings->shouldPrintBackgrounds()) |
|
Lines 1119-1125
void Document::recalcStyle(StyleChange c
WebCore/dom/Document.cpp_sec5
|
| 1119 |
const AtomicString& stdfont = settings->standardFontFamily(); |
1206 |
const AtomicString& stdfont = settings->standardFontFamily(); |
| 1120 |
if (!stdfont.isEmpty()) { |
1207 |
if (!stdfont.isEmpty()) { |
| 1121 |
fontDescription.firstFamily().setFamily(stdfont); |
1208 |
fontDescription.firstFamily().setFamily(stdfont); |
| 1122 |
fontDescription.firstFamily().appendFamily(0); |
1209 |
FontFamily& currFamily = fontDescription.firstFamily(); |
|
|
1210 |
if (script != USCRIPT_INVALID_CODE) { |
| 1211 |
// TODO(jungshik) : I might as well modify |genericFamily| of |
| 1212 |
// |fontDescription| here, but I'm wary of a potential breakage. |
| 1213 |
// For now, just use a temporary variable. |
| 1214 |
FontDescription tmpDescription; |
| 1215 |
tmpDescription.setGenericFamily(FontDescription::StandardFamily); |
| 1216 |
AtomicString docFont = FontCache::getGenericFontForScript( |
| 1217 |
script, tmpDescription); |
| 1218 |
if (!docFont.isEmpty()) { |
| 1219 |
RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create(); |
| 1220 |
newFamily->setFamily(docFont); |
| 1221 |
currFamily.appendFamily(newFamily); |
| 1222 |
currFamily = *newFamily; |
| 1223 |
} |
| 1224 |
} |
| 1225 |
currFamily.appendFamily(0); |
| 1123 |
} |
1226 |
} |
| 1124 |
fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); |
1227 |
fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); |
| 1125 |
m_styleSelector->setFontSize(fontDescription, m_styleSelector->fontSizeForKeyword(CSSValueMedium, inCompatMode(), false)); |
1228 |
m_styleSelector->setFontSize(fontDescription, m_styleSelector->fontSizeForKeyword(CSSValueMedium, inCompatMode(), false)); |