OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2008 David Levin (levin@chromium.org) | 8 * Copyright (C) 2008 David Levin (levin@chromium.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "DocumentType.h" | 46 #include "DocumentType.h" |
47 #include "EditingText.h" | 47 #include "EditingText.h" |
48 #include "Editor.h" | 48 #include "Editor.h" |
49 #include "EntityReference.h" | 49 #include "EntityReference.h" |
50 #include "Event.h" | 50 #include "Event.h" |
51 #include "EventHandler.h" | 51 #include "EventHandler.h" |
52 #include "EventListener.h" | 52 #include "EventListener.h" |
53 #include "EventNames.h" | 53 #include "EventNames.h" |
54 #include "ExceptionCode.h" | 54 #include "ExceptionCode.h" |
55 #include "FocusController.h" | 55 #include "FocusController.h" |
56 #include "FontCache.h" | |
57 #include "Frame.h" | 56 #include "Frame.h" |
58 #include "FrameLoader.h" | 57 #include "FrameLoader.h" |
59 #include "FrameTree.h" | 58 #include "FrameTree.h" |
60 #include "FrameView.h" | 59 #include "FrameView.h" |
61 #include "HTMLAnchorElement.h" | 60 #include "HTMLAnchorElement.h" |
62 #include "HTMLBodyElement.h" | 61 #include "HTMLBodyElement.h" |
63 #include "HTMLCanvasElement.h" | 62 #include "HTMLCanvasElement.h" |
64 #include "HTMLDocument.h" | 63 #include "HTMLDocument.h" |
65 #include "HTMLElementFactory.h" | 64 #include "HTMLElementFactory.h" |
66 #include "HTMLFrameOwnerElement.h" | 65 #include "HTMLFrameOwnerElement.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 #if ENABLE(DASHBOARD_SUPPORT) | 322 #if ENABLE(DASHBOARD_SUPPORT) |
324 , m_hasDashboardRegions(false) | 323 , m_hasDashboardRegions(false) |
325 , m_dashboardRegionsDirty(false) | 324 , m_dashboardRegionsDirty(false) |
326 #endif | 325 #endif |
327 , m_accessKeyMapValid(false) | 326 , m_accessKeyMapValid(false) |
328 , m_createRenderers(true) | 327 , m_createRenderers(true) |
329 , m_inPageCache(false) | 328 , m_inPageCache(false) |
330 , m_useSecureKeyboardEntryWhenActive(false) | 329 , m_useSecureKeyboardEntryWhenActive(false) |
331 , m_isXHTML(isXHTML) | 330 , m_isXHTML(isXHTML) |
332 , m_numNodeListCaches(0) | 331 , m_numNodeListCaches(0) |
333 , m_dominantScript(USCRIPT_INVALID_CODE) | |
334 #if ENABLE(DATABASE) | 332 #if ENABLE(DATABASE) |
335 , m_hasOpenDatabases(false) | 333 , m_hasOpenDatabases(false) |
336 #endif | 334 #endif |
337 , m_usingGeolocation(false) | 335 , m_usingGeolocation(false) |
338 { | 336 { |
339 m_document.resetSkippingRef(this); | 337 m_document.resetSkippingRef(this); |
340 | 338 |
341 m_printing = false; | 339 m_printing = false; |
342 | 340 |
343 m_ignoreAutofocus = false; | 341 m_ignoreAutofocus = false; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 434 |
437 Document::~Document() | 435 Document::~Document() |
438 { | 436 { |
439 ASSERT(!renderer()); | 437 ASSERT(!renderer()); |
440 ASSERT(!m_inPageCache); | 438 ASSERT(!m_inPageCache); |
441 ASSERT(!m_savedRenderer); | 439 ASSERT(!m_savedRenderer); |
442 ASSERT(m_ranges.isEmpty()); | 440 ASSERT(m_ranges.isEmpty()); |
443 | 441 |
444 removeAllEventListeners(); | 442 removeAllEventListeners(); |
445 | 443 |
446 | |
447 #if USE(JSC) | 444 #if USE(JSC) |
448 forgetAllDOMNodesForDocument(this); | 445 forgetAllDOMNodesForDocument(this); |
449 #endif | 446 #endif |
450 | 447 |
451 if (m_docChanged && changedDocuments) | 448 if (m_docChanged && changedDocuments) |
452 changedDocuments->remove(this); | 449 changedDocuments->remove(this); |
453 delete m_tokenizer; | 450 delete m_tokenizer; |
454 m_document.resetSkippingRef(0); | 451 m_document.resetSkippingRef(0); |
455 delete m_styleSelector; | 452 delete m_styleSelector; |
456 delete m_docLoader; | 453 delete m_docLoader; |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 return String(); | 861 return String(); |
865 } | 862 } |
866 | 863 |
867 void Document::setCharset(const String& charset) | 864 void Document::setCharset(const String& charset) |
868 { | 865 { |
869 if (!decoder()) | 866 if (!decoder()) |
870 return; | 867 return; |
871 decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); | 868 decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); |
872 } | 869 } |
873 | 870 |
874 UScriptCode Document::dominantScript() const | |
875 { | |
876 struct EncodingScript { | |
877 const char* encoding; | |
878 UScriptCode script; | |
879 }; | |
880 | |
881 // inputEncoding() always returns a canonical name. We use | |
882 // MIME names and IANA names (if the former is not available). | |
883 static const EncodingScript encodingScriptList[] = { | |
884 { "GB2312", USCRIPT_SIMPLIFIED_HAN }, | |
885 { "GBK", USCRIPT_SIMPLIFIED_HAN }, | |
886 { "GB18030", USCRIPT_SIMPLIFIED_HAN }, | |
887 { "Big5", USCRIPT_TRADITIONAL_HAN }, | |
888 { "Big5-HKSCS", USCRIPT_TRADITIONAL_HAN }, | |
889 { "Shift_JIS", USCRIPT_HIRAGANA}, | |
890 { "EUC-JP", USCRIPT_HIRAGANA }, // Japanese (USCRIPT_JAPANESE) | |
891 { "ISO-2022-KR", USCRIPT_HIRAGANA }, | |
892 { "EUC-KR", USCRIPT_HANGUL }, // Korean (USCRIPT_KOREAN) | |
893 { "TIS-620", USCRIPT_THAI }, | |
894 { "ISO-8859-1", USCRIPT_LATIN }, | |
895 { "ISO-8859-15", USCRIPT_LATIN }, | |
896 { "windows-1252", USCRIPT_LATIN }, | |
897 { "ISO-8859-2", USCRIPT_LATIN }, | |
898 { "windows-1250", USCRIPT_LATIN }, | |
899 { "ISO-8859-3", USCRIPT_LATIN }, | |
900 { "ISO-8859-4", USCRIPT_LATIN }, | |
901 { "ISO-8859-13", USCRIPT_LATIN }, | |
902 { "windows-1257", USCRIPT_LATIN }, | |
903 { "ISO-8859-5", USCRIPT_CYRILLIC }, | |
904 { "windows-1251", USCRIPT_CYRILLIC }, | |
905 { "KOI8-R", USCRIPT_CYRILLIC }, | |
906 { "KOI8-U", USCRIPT_CYRILLIC }, | |
907 { "ISO-8859-6", USCRIPT_ARABIC }, | |
908 { "windows-1256", USCRIPT_ARABIC }, | |
909 { "ISO-8859-7", USCRIPT_GREEK }, | |
910 { "windows-1253", USCRIPT_GREEK }, | |
911 { "ISO-8859-8", USCRIPT_HEBREW }, | |
912 { "windows-1255", USCRIPT_HEBREW }, | |
913 { "ISO-8859-9", USCRIPT_LATIN }, // Turkish | |
914 { "windows-1254", USCRIPT_LATIN }, | |
915 { "ISO-8859-10", USCRIPT_LATIN }, // Nordic | |
916 { "ISO-8859-14", USCRIPT_LATIN }, // Celtic | |
917 { "ISO-8859-16", USCRIPT_LATIN }, // Romanian | |
918 { "windows-1258", USCRIPT_LATIN }, // Vietnamese | |
919 }; | |
920 | |
921 static HashMap<String, UScriptCode> encodingScriptMap; | |
922 | |
923 if (encodingScriptMap.isEmpty()) { | |
924 for (unsigned i = 0; i < sizeof(encodingScriptList) / sizeof(encodingScr
iptList[0]); ++i) | |
925 encodingScriptMap.set(encodingScriptList[i].encoding, | |
926 encodingScriptList[i].script); | |
927 } | |
928 | |
929 if (m_dominantScript != USCRIPT_INVALID_CODE) | |
930 return m_dominantScript; | |
931 String encoding = inputEncoding(); | |
932 if (encoding.isEmpty()) | |
933 return m_dominantScript; | |
934 | |
935 HashMap<String, UScriptCode>::iterator it = encodingScriptMap.find(encoding)
; | |
936 if (it != encodingScriptMap.end()) | |
937 m_dominantScript = it->second; | |
938 else | |
939 // TODO(jungshik) : should return a script corresponding to the locale. | |
940 m_dominantScript = USCRIPT_COMMON; | |
941 return m_dominantScript; | |
942 } | |
943 | |
944 void Document::setXMLVersion(const String& version, ExceptionCode& ec) | 871 void Document::setXMLVersion(const String& version, ExceptionCode& ec) |
945 { | 872 { |
946 if (!implementation()->hasFeature("XML", String())) { | 873 if (!implementation()->hasFeature("XML", String())) { |
947 ec = NOT_SUPPORTED_ERR; | 874 ec = NOT_SUPPORTED_ERR; |
948 return; | 875 return; |
949 } | 876 } |
950 | 877 |
951 // FIXME: Also raise NOT_SUPPORTED_ERR if the version is set to a value that
is not supported by this Document. | 878 // FIXME: Also raise NOT_SUPPORTED_ERR if the version is set to a value that
is not supported by this Document. |
952 | 879 |
953 m_xmlVersion = version; | 880 m_xmlVersion = version; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 m_hasNodesWithPlaceholderStyle = false; | 1131 m_hasNodesWithPlaceholderStyle = false; |
1205 | 1132 |
1206 RefPtr<RenderStyle> documentStyle = RenderStyle::create(); | 1133 RefPtr<RenderStyle> documentStyle = RenderStyle::create(); |
1207 documentStyle->setDisplay(BLOCK); | 1134 documentStyle->setDisplay(BLOCK); |
1208 documentStyle->setVisuallyOrdered(visuallyOrdered); | 1135 documentStyle->setVisuallyOrdered(visuallyOrdered); |
1209 documentStyle->setZoom(frame()->pageZoomFactor()); | 1136 documentStyle->setZoom(frame()->pageZoomFactor()); |
1210 m_styleSelector->setStyle(documentStyle); | 1137 m_styleSelector->setStyle(documentStyle); |
1211 | 1138 |
1212 FontDescription fontDescription; | 1139 FontDescription fontDescription; |
1213 fontDescription.setUsePrinterFont(printing()); | 1140 fontDescription.setUsePrinterFont(printing()); |
1214 // TODO(jungshik): Eventually, we need to derive the dominant script | |
1215 // for the current node based on 'xml:lang' and 'lang' specified for | |
1216 // it or inherited from its parent rather than using the document-wide | |
1217 // value (inferred from charset). Note also that it does not work | |
1218 // for 'script-agnostic' charsets like UTF-8. In that case, Firefox | |
1219 // uses the script corresponding to the application locale. | |
1220 // While a document is loaded, this function is called multiple | |
1221 // times. At the beginning, the document charset is not known and | |
1222 // dominantScript remains invalid. Only when it's determined, we | |
1223 // change the font accordingly. | |
1224 // See http://bugs.webkit.org/show_bug.cgi?id=10874 and | |
1225 // https://bugs.webkit.org/show_bug.cgi?id=18085 | |
1226 UScriptCode script = dominantScript(); | |
1227 if (script != USCRIPT_INVALID_CODE) | |
1228 fontDescription.setDominantScript(script); | |
1229 if (Settings* settings = this->settings()) { | 1141 if (Settings* settings = this->settings()) { |
1230 fontDescription.setRenderingMode(settings->fontRenderingMode()); | 1142 fontDescription.setRenderingMode(settings->fontRenderingMode()); |
1231 if (printing() && !settings->shouldPrintBackgrounds()) | 1143 if (printing() && !settings->shouldPrintBackgrounds()) |
1232 documentStyle->setForceBackgroundsToWhite(true); | 1144 documentStyle->setForceBackgroundsToWhite(true); |
1233 const AtomicString& stdfont = settings->standardFontFamily(); | 1145 const AtomicString& stdfont = settings->standardFontFamily(); |
1234 if (!stdfont.isEmpty()) { | 1146 if (!stdfont.isEmpty()) { |
1235 fontDescription.firstFamily().setFamily(stdfont); | 1147 fontDescription.firstFamily().setFamily(stdfont); |
1236 FontFamily& currFamily = fontDescription.firstFamily(); | 1148 fontDescription.firstFamily().appendFamily(0); |
1237 if (script != USCRIPT_INVALID_CODE) { | |
1238 // TODO(jungshik) : I might as well modify |genericFamily| of | |
1239 // |fontDescription| here, but I'm wary of a potential breakag
e. | |
1240 // For now, just use a temporary variable. | |
1241 FontDescription tmpDescription; | |
1242 tmpDescription.setGenericFamily(FontDescription::StandardFamil
y); | |
1243 AtomicString docFont = FontCache::getGenericFontForScript( | |
1244 script, tmpDescription); | |
1245 if (!docFont.isEmpty()) { | |
1246 RefPtr<SharedFontFamily> newFamily(SharedFontFamily::creat
e()); | |
1247 newFamily->setFamily(docFont); | |
1248 currFamily.appendFamily(newFamily); | |
1249 currFamily = *newFamily; | |
1250 } | |
1251 } | |
1252 currFamily.appendFamily(0); | |
1253 } | 1149 } |
1254 fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1)
; | 1150 fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1)
; |
1255 m_styleSelector->setFontSize(fontDescription, m_styleSelector->fontS
izeForKeyword(CSSValueMedium, inCompatMode(), false)); | 1151 m_styleSelector->setFontSize(fontDescription, m_styleSelector->fontS
izeForKeyword(CSSValueMedium, inCompatMode(), false)); |
1256 } | 1152 } |
1257 | 1153 |
1258 documentStyle->setFontDescription(fontDescription); | 1154 documentStyle->setFontDescription(fontDescription); |
1259 documentStyle->font().update(m_styleSelector->fontSelector()); | 1155 documentStyle->font().update(m_styleSelector->fontSelector()); |
1260 if (inCompatMode()) | 1156 if (inCompatMode()) |
1261 documentStyle->setHtmlHacks(true); // enable html specific rendering
tricks | 1157 documentStyle->setHtmlHacks(true); // enable html specific rendering
tricks |
1262 | 1158 |
(...skipping 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4516 { | 4412 { |
4517 if (m_decoder) | 4413 if (m_decoder) |
4518 return m_decoder->encoding().displayString(str); | 4414 return m_decoder->encoding().displayString(str); |
4519 return str; | 4415 return str; |
4520 } | 4416 } |
4521 | 4417 |
4522 void Document::displayBufferModifiedByEncoding(UChar* buffer, unsigned len) cons
t | 4418 void Document::displayBufferModifiedByEncoding(UChar* buffer, unsigned len) cons
t |
4523 { | 4419 { |
4524 if (m_decoder) | 4420 if (m_decoder) |
4525 m_decoder->encoding().displayBuffer(buffer, len); | 4421 m_decoder->encoding().displayBuffer(buffer, len); |
4526 | |
4527 } | 4422 } |
4528 | 4423 |
4529 } // namespace WebCore | 4424 } // namespace WebCore |
OLD | NEW |