Changeset 41551 in webkit for trunk/WebCore/loader/CachedScript.h


Ignore:
Timestamp:
Mar 10, 2009, 7:10:56 AM (16 years ago)
Author:
[email protected]
Message:

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=24285
Text resource loading checks for BOM twice

This removes TextDecoder class, since its only purpose was to check for BOM, which is
already done in TextResourceDecoder. Callers that use TextEncoding::decode() won't get
BOM checked, but I didn't find any cases where it would significantly change behavior.

  • GNUmakefile.am:
  • WebCore.pro:
  • WebCore.scons:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • WebCoreSources.bkl: Remove TextDecoder.{h,cpp}.
  • platform/text/TextDecoder.cpp: Removed.
  • platform/text/TextDecoder.h: Removed.
  • loader/TextResourceDecoder.h: Instead of a TextDecoder object, keep TextEncoding and TextCodec separately.
  • loader/TextResourceDecoder.cpp: (WebCore::TextResourceDecoder::TextResourceDecoder): Updated for m_encoding being a member. (WebCore::TextResourceDecoder::setEncoding): Ditto. (WebCore::TextResourceDecoder::checkForBOM): Removed a FIXME saying that a BOM could override even a user-chosen encoding - this is how it already worked due to TextDecoder checking for BOM again. Made this function return the detected BOM length. (WebCore::TextResourceDecoder::decode): Skip the BOM if it was found at the beginning of a text resource. (WebCore::TextResourceDecoder::flush): Reset m_checkedForBOM, so that re-decoding the same resource again (as frequently done by CachedResource subclasses) will skip the BOM correctly.
  • platform/text/TextEncoding.cpp: (WebCore::TextEncoding::decode): Use TextCodec directly without a TextDecoder wrapper. This means that this method no longer checks for BOM, which was a counter-intuitive feature.
  • loader/CachedScript.cpp: (WebCore::CachedScript::CachedScript): (WebCore::CachedScript::setEncoding): (WebCore::CachedScript::encoding): (WebCore::CachedScript::script):
  • loader/CachedScript.h:
  • loader/appcache/ManifestParser.cpp: (WebCore::parseManifest): Use TextResourceDecoder, as TextEncoding::decode() no longer checks for BOM. A side effect of this is that these resources will now be subject to encoding auto-detection.
  • loader/CachedFont.cpp: (WebCore::CachedFont::ensureSVGFontData):
  • page/Page.cpp: (WebCore::Page::userStyleSheet): Be sure to flush TextResourceDecoder, pushing any remaining bytes out, and making the decoder re-usable (for repeated decoding of the same resource).
  • platform/text/TextEncodingRegistry.h: Updated comments for newTextCodec().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/loader/CachedScript.h

    r39556 r41551  
    2828
    2929#include "CachedResource.h"
    30 #include "TextEncoding.h"
    3130#include "Timer.h"
    3231
     
    3433
    3534    class DocLoader;
     35    class TextResourceDecoder;
    3636
    3737    class CachedScript : public CachedResource {
     
    6060
    6161        String m_script;
    62         TextEncoding m_encoding;
     62        RefPtr<TextResourceDecoder> m_decoder;
    6363        Timer<CachedScript> m_decodedDataDeletionTimer;
    6464    };
Note: See TracChangeset for help on using the changeset viewer.