2009-03-26 Jungshik Shin <jshin@chromium.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2009 00:01:58 +0000 (00:01 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2009 00:01:58 +0000 (00:01 +0000)
commit3c07247dead3192667b23043dd014df1fe8128e5
treefba882caa2bd91440d4bb9fc665079e6fbc871e3
parent20d1868426b9b0fe253f232112ad9b6c3413185b
2009-03-26  Jungshik Shin  <jshin@chromium.org>

        Reviewed by Alexey Proskuryakov.

        Add an encoding detector 'hook' to TextResourceDecoder.
         - add |usesEncodingDetector| to Settings. It's off by default.
         - add a new encoding source type |EncodingFromParent|
           to distinguish cases when the encoding is inherited from
           the parent frame from cases when it's actually auto-detected.
         - add TextEncodingDetector* to platform/text. Currently,
           the only implementation uses ICU. Stub is added for
           ports that do not use ICU and a build on Tiger. Mac OS
           Tiger comes with ICU 3.2 that does not support encoding detector.
         - add ucsdet.h to icu/unicode for ports using ICU.

        Layout tests will be added once bug 20534 is fixed and a WebPreference
        can be controlled in test_shell. With UsesEncodingDetector off, there
        is no change to test.

        http://bugs.webkit.org/show_bug.cgi?id=16482

        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCore/GNUmakefile.am
        * WebCore/WebCore.pro
        * WebCore/WebCore.scons
        * WebCore/WebCoreSources.bkl
        * WebCore.base.exp
        * icu/unicode/ucsdet.h
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::write): turn on/off encoding detector depending on Settings and set hintEncoding of TextResourceDecoder to the parent frame encoding if necessary and the security policy allows refering to the parent frame encoding.
        * loader/TextResourceDecoder.cpp:
        (WebCore::TextResourceDecoder::TextResourceDecoder):
        (WebCore::TextResourceDecoder::checkForCSSCharset): add check for EncodingFromParentFrame
        (WebCore::TextResourceDecoder::checkForHeadCharset): ditto
        (WebCore::TextResourceDecoder::shouldAutoDetect):
        (WebCore::TextResourceDecoder::decode): call encoding detector if shouldAutoDetect returns true.
        (WebCore::TextResourceDecoder::flush): if encoding is not determined by now, call encoding detector if shouldAutoDetect returns true.
        * loader/TextResourceDecoder.h:
        (WebCore::TextResourceDecoder::):
        (WebCore::TextResourceDecoder::create):
        (WebCore::TextResourceDecoder::setHintEncoding):
        (WebCore::TextResourceDecoder::source):
        * page/Settings.cpp: add m_usesEncodingDetector
        (WebCore::Settings::Settings):
        (WebCore::Settings::setUsesEncodingDetector):
        * page/Settings.h:
        (WebCore::Settings::usesEncodingDetector):
        * platform/text/TextEncodingDetector.h: Added.
        * platform/text/TextEncodingDetectorICU.cpp: Added.
        (WebCore::detectTextEncoding):
        * platform/text/TextEncodingDetectorNone.cpp: Added.
        (WebCore::detectTextEncoding):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@42022 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.base.exp
WebCore/WebCore.pro
WebCore/WebCore.scons
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/loader/FrameLoader.cpp
WebCore/loader/TextResourceDecoder.cpp
WebCore/loader/TextResourceDecoder.h
WebCore/page/Settings.cpp
WebCore/page/Settings.h
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebPreferenceKeysPrivate.h
WebKit/mac/WebView/WebPreferences.mm
WebKit/mac/WebView/WebPreferencesPrivate.h
WebKit/mac/WebView/WebView.mm