Changeset 156657 in webkit


Ignore:
Timestamp:
Sep 30, 2013 9:21:54 AM (11 years ago)
Author:
Antti Koivisto
Message:

Remove FontTranscoder
https://bugs.webkit.org/show_bug.cgi?id=122088

Reviewed by Andreas Kling.

This overly generic class just implements mapping of backslash to yen symbol for some legacy Japanese fonts.

  • CMakeLists.txt:
  • GNUmakefile.am:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.pri:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/Font.cpp:

(WebCore::useBackslashAsYenSignForFamily):

Move the family set to Font.cpp.

(WebCore::Font::Font):
(WebCore::Font::operator=):
(WebCore::Font::update):

Keep the cached boolean up to date.

  • platform/graphics/Font.h:

(WebCore::Font::useBackslashAsYenSymbol):

Use descriptive name instead of talking about "transcoding".

  • platform/text/transcoder: Removed.
  • platform/text/transcoder/FontTranscoder.cpp: Removed.
  • platform/text/transcoder/FontTranscoder.h: Removed.
  • rendering/RenderText.cpp:

(WebCore::RenderText::RenderText):
(WebCore::RenderText::computeUseBackslashAsYenSymbol):

Rename for clarity.
Avoid unnecessary hash lookup, just check the cached bit in Font.

(WebCore::RenderText::styleDidChange):
(WebCore::RenderText::setTextInternal):

"Transcoding" here was just a simple character replacement.

(WebCore::RenderText::textWithoutConvertingBackslashToYenSymbol):

Renamed.

  • rendering/RenderText.h:
Location:
trunk/Source/WebCore
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r156615 r156657  
    7575    "${WEBCORE_DIR}/platform/sql"
    7676    "${WEBCORE_DIR}/platform/text"
    77     "${WEBCORE_DIR}/platform/text/transcoder"
    7877    "${WEBCORE_DIR}/plugins"
    7978    "${WEBCORE_DIR}/rendering"
     
    20962095    platform/text/UnicodeRange.cpp
    20972096
    2098     platform/text/transcoder/FontTranscoder.cpp
    2099 
    21002097    plugins/DOMMimeType.cpp
    21012098    plugins/DOMMimeTypeArray.cpp
  • trunk/Source/WebCore/ChangeLog

    r156656 r156657  
     12013-09-30  Antti Koivisto  <antti@apple.com>
     2
     3        Remove FontTranscoder
     4        https://bugs.webkit.org/show_bug.cgi?id=122088
     5
     6        Reviewed by Andreas Kling.
     7
     8        This overly generic class just implements mapping of backslash to yen symbol for some legacy Japanese fonts.
     9
     10        * CMakeLists.txt:
     11        * GNUmakefile.am:
     12        * GNUmakefile.list.am:
     13        * Target.pri:
     14        * WebCore.pri:
     15        * WebCore.vcxproj/WebCore.vcxproj:
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * platform/graphics/Font.cpp:
     18        (WebCore::useBackslashAsYenSignForFamily):
     19       
     20            Move the family set to Font.cpp.
     21
     22        (WebCore::Font::Font):
     23        (WebCore::Font::operator=):
     24        (WebCore::Font::update):
     25       
     26            Keep the cached boolean up to date.
     27
     28        * platform/graphics/Font.h:
     29        (WebCore::Font::useBackslashAsYenSymbol):
     30       
     31            Use descriptive name instead of talking about "transcoding".
     32
     33        * platform/text/transcoder: Removed.
     34        * platform/text/transcoder/FontTranscoder.cpp: Removed.
     35        * platform/text/transcoder/FontTranscoder.h: Removed.
     36        * rendering/RenderText.cpp:
     37        (WebCore::RenderText::RenderText):
     38        (WebCore::RenderText::computeUseBackslashAsYenSymbol):
     39       
     40            Rename for clarity.
     41            Avoid unnecessary hash lookup, just check the cached bit in Font.
     42
     43        (WebCore::RenderText::styleDidChange):
     44        (WebCore::RenderText::setTextInternal):
     45       
     46            "Transcoding" here was just a simple character replacement.
     47
     48        (WebCore::RenderText::textWithoutConvertingBackslashToYenSymbol):
     49       
     50            Renamed.
     51
     52        * rendering/RenderText.h:
     53
    1542013-09-27  Jer Noble  <jer.noble@apple.com>
    255
  • trunk/Source/WebCore/GNUmakefile.am

    r156406 r156657  
    8787        -I$(srcdir)/Source/WebCore/platform/sql \
    8888        -I$(srcdir)/Source/WebCore/platform/text \
    89         -I$(srcdir)/Source/WebCore/platform/text/transcoder \
    9089        -I$(srcdir)/Source/WebCore/platform/win \
    9190        -I$(srcdir)/Source/WebCore/plugins \
  • trunk/Source/WebCore/GNUmakefile.list.am

    r156615 r156657  
    59585958        Source/WebCore/platform/text/enchant/TextCheckerEnchant.h \
    59595959        Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp \
    5960         Source/WebCore/platform/text/transcoder/FontTranscoder.cpp \
    5961         Source/WebCore/platform/text/transcoder/FontTranscoder.h \
    59625960        Source/WebCore/platform/text/BidiContext.cpp \
    59635961        Source/WebCore/platform/text/BidiContext.h \
  • trunk/Source/WebCore/Target.pri

    r156615 r156657  
    11041104    platform/Timer.cpp \
    11051105    platform/text/UnicodeRange.cpp \
    1106     platform/text/transcoder/FontTranscoder.cpp \
    11071106    platform/UUID.cpp \
    11081107    platform/Widget.cpp \
     
    23432342    platform/text/TextStream.h \
    23442343    platform/text/UnicodeRange.h \
    2345     platform/text/transcoder/FontTranscoder.h \
    23462344    platform/ThreadGlobalData.h \
    23472345    platform/ThreadTimers.h \
  • trunk/Source/WebCore/WebCore.pri

    r155697 r156657  
    8282    $$SOURCE_DIR/platform/sql \
    8383    $$SOURCE_DIR/platform/text \
    84     $$SOURCE_DIR/platform/text/transcoder \
    8584    $$SOURCE_DIR/plugins \
    8685    $$SOURCE_DIR/rendering \
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r156615 r156657  
    85048504    <ClCompile Include="..\platform\text\cf\StringImplCF.cpp" />
    85058505    <ClCompile Include="..\platform\text\win\TextBreakIteratorInternalICUWin.cpp" />
    8506     <ClCompile Include="..\platform\text\transcoder\FontTranscoder.cpp" />
    85078506    <ClCompile Include="..\platform\image-decoders\ImageDecoder.cpp">
    85088507      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
     
    1954319542    <ClInclude Include="..\platform\graphics\WidthIterator.h" />
    1954419543    <ClInclude Include="..\platform\text\WritingMode.h" />
    19545     <ClInclude Include="..\platform\text\transcoder\FontTranscoder.h" />
    1954619544    <ClInclude Include="..\platform\image-decoders\ImageDecoder.h">
    1954719545      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r156652 r156657  
    46854685                B6D9D27C14EAC0860090D75E /* JSFocusEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D9D27A14EAC0860090D75E /* JSFocusEvent.cpp */; };
    46864686                B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */ = {isa = PBXBuildFile; fileRef = B776D43A1104525D00BEB0EC /* PrintContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    4687                 B734B181119B9911006587BD /* FontTranscoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B734B180119B9911006587BD /* FontTranscoder.cpp */; };
    4688                 B734B183119B991D006587BD /* FontTranscoder.h in Headers */ = {isa = PBXBuildFile; fileRef = B734B182119B991D006587BD /* FontTranscoder.h */; };
    46894687                B776D43D1104527500BEB0EC /* PrintContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B776D43C1104527500BEB0EC /* PrintContext.cpp */; };
    46904688                B885E8D411E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B885E8D211E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp */; };
     
    1156411562                B6D9D27914EAC0860090D75E /* JSFocusEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFocusEvent.h; sourceTree = "<group>"; };
    1156511563                B6D9D27A14EAC0860090D75E /* JSFocusEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFocusEvent.cpp; sourceTree = "<group>"; };
    11566                 B734B180119B9911006587BD /* FontTranscoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FontTranscoder.cpp; path = transcoder/FontTranscoder.cpp; sourceTree = "<group>"; };
    11567                 B734B182119B991D006587BD /* FontTranscoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FontTranscoder.h; path = transcoder/FontTranscoder.h; sourceTree = "<group>"; };
    1156811564                B776D43A1104525D00BEB0EC /* PrintContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintContext.h; sourceTree = "<group>"; };
    1156911565                B776D43C1104527500BEB0EC /* PrintContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintContext.cpp; sourceTree = "<group>"; };
     
    1910519101                                B2B264590D00A77E000ACC1D /* cf */,
    1910619102                                B2C3D9F90D006C1D00EF6F26 /* mac */,
    19107                                 B734B17F119B98DB006587BD /* transcoder */,
    1910819103                                37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */,
    1910919104                                B2C3D9F20D006C1D00EF6F26 /* BidiContext.cpp */,
     
    1923519230                        );
    1923619231                        name = generic;
    19237                         sourceTree = "<group>";
    19238                 };
    19239                 B734B17F119B98DB006587BD /* transcoder */ = {
    19240                         isa = PBXGroup;
    19241                         children = (
    19242                                 B734B180119B9911006587BD /* FontTranscoder.cpp */,
    19243                                 B734B182119B991D006587BD /* FontTranscoder.h */,
    19244                         );
    19245                         name = transcoder;
    1924619232                        sourceTree = "<group>";
    1924719233                };
     
    2254522531                                37202199106213C600F25C4B /* FontSmoothingMode.h in Headers */,
    2254622532                                3784C34B0E11AA34007D8D48 /* FontTraitsMask.h in Headers */,
    22547                                 B734B183119B991D006587BD /* FontTranscoder.h in Headers */,
    2254822533                                A80E6CED0A1989CA007FB8C5 /* FontValue.h in Headers */,
    2254922534                                BCE4413612F7490B009B84B8 /* FontWidthVariant.h in Headers */,
     
    2582225807                                84B62685133138F90095A489 /* FontPlatformData.cpp in Sources */,
    2582325808                                B5320D6C122A24E9002D1440 /* FontPlatformDataCocoa.mm in Sources */,
    25824                                 B734B181119B9911006587BD /* FontTranscoder.cpp in Sources */,
    2582525809                                A80E6CF10A1989CA007FB8C5 /* FontValue.cpp in Sources */,
    2582625810                                4A0DA2FE129B241900AB61E1 /* FormAssociatedElement.cpp in Sources */,
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r156622 r156657  
    33733373
    33743374    // Return the text that is actually being rendered in the input field.
    3375     return static_cast<RenderText*>(renderer)->textWithoutTranscoding();
     3375    return static_cast<RenderText*>(renderer)->textWithoutConvertingBackslashToYenSymbol();
    33763376#else
    33773377    // It seems only GTK is interested in this at the moment.
  • trunk/Source/WebCore/editing/TextIterator.cpp

    r156285 r156657  
    10331033{
    10341034    RenderText* renderer = toRenderText(renderObject);
    1035     m_text = m_emitsOriginalText ? renderer->originalText() : (m_emitsTextWithoutTranscoding ? renderer->textWithoutTranscoding() : renderer->text());
     1035    m_text = m_emitsOriginalText ? renderer->originalText() : (m_emitsTextWithoutTranscoding ? renderer->textWithoutConvertingBackslashToYenSymbol() : renderer->text());
    10361036    ASSERT(!m_text.isEmpty());
    10371037    ASSERT(0 <= textStartOffset && textStartOffset < static_cast<int>(m_text.length()));
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r156142 r156657  
    2727#include "FloatRect.h"
    2828#include "FontCache.h"
    29 #include "FontTranscoder.h"
    3029#include "IntPoint.h"
    3130#include "GlyphBuffer.h"
     
    3433#include <wtf/MainThread.h>
    3534#include <wtf/MathExtras.h>
     35#include <wtf/text/AtomicStringHash.h>
    3636#include <wtf/text/StringBuilder.h>
    3737
     
    6262};
    6363
     64static bool useBackslashAsYenSignForFamily(const AtomicString& family)
     65{
     66    if (family.isEmpty())
     67        return false;
     68    static HashSet<AtomicString>* set;
     69    if (!set) {
     70        set = new HashSet<AtomicString>;
     71        set->add("MS PGothic");
     72        UChar unicodeNameMSPGothic[] = {0xFF2D, 0xFF33, 0x0020, 0xFF30, 0x30B4, 0x30B7, 0x30C3, 0x30AF};
     73        set->add(AtomicString(unicodeNameMSPGothic, WTF_ARRAY_LENGTH(unicodeNameMSPGothic)));
     74
     75        set->add("MS PMincho");
     76        UChar unicodeNameMSPMincho[] = {0xFF2D, 0xFF33, 0x0020, 0xFF30, 0x660E, 0x671D};
     77        set->add(AtomicString(unicodeNameMSPMincho, WTF_ARRAY_LENGTH(unicodeNameMSPMincho)));
     78
     79        set->add("MS Gothic");
     80        UChar unicodeNameMSGothic[] = {0xFF2D, 0xFF33, 0x0020, 0x30B4, 0x30B7, 0x30C3, 0x30AF};
     81        set->add(AtomicString(unicodeNameMSGothic, WTF_ARRAY_LENGTH(unicodeNameMSGothic)));
     82
     83        set->add("MS Mincho");
     84        UChar unicodeNameMSMincho[] = {0xFF2D, 0xFF33, 0x0020, 0x660E, 0x671D};
     85        set->add(AtomicString(unicodeNameMSMincho, WTF_ARRAY_LENGTH(unicodeNameMSMincho)));
     86
     87        set->add("Meiryo");
     88        UChar unicodeNameMeiryo[] = {0x30E1, 0x30A4, 0x30EA, 0x30AA};
     89        set->add(AtomicString(unicodeNameMeiryo, WTF_ARRAY_LENGTH(unicodeNameMeiryo)));
     90    }
     91    return set->contains(family);
     92}
     93
    6494Font::CodePath Font::s_codePath = Auto;
    6595
     
    73103    : m_letterSpacing(0)
    74104    , m_wordSpacing(0)
    75     , m_needsTranscoding(false)
     105    , m_useBackslashAsYenSymbol(false)
    76106    , m_typesettingFeatures(0)
    77107{
     
    82112    , m_letterSpacing(letterSpacing)
    83113    , m_wordSpacing(wordSpacing)
    84     , m_needsTranscoding(fontTranscoder().needsTranscoding(fd))
     114    , m_useBackslashAsYenSymbol(useBackslashAsYenSignForFamily(fd.firstFamily()))
    85115    , m_typesettingFeatures(computeTypesettingFeatures())
    86116{
     
    91121    , m_letterSpacing(0)
    92122    , m_wordSpacing(0)
     123    , m_useBackslashAsYenSymbol(false)
    93124    , m_typesettingFeatures(computeTypesettingFeatures())
    94125{
    95126    m_fontDescription.setUsePrinterFont(isPrinterFont);
    96127    m_fontDescription.setFontSmoothing(fontSmoothingMode);
    97     m_needsTranscoding = fontTranscoder().needsTranscoding(fontDescription());
    98128}
    99129
     
    103133    , m_letterSpacing(other.m_letterSpacing)
    104134    , m_wordSpacing(other.m_wordSpacing)
    105     , m_needsTranscoding(other.m_needsTranscoding)
     135    , m_useBackslashAsYenSymbol(other.m_useBackslashAsYenSymbol)
    106136    , m_typesettingFeatures(computeTypesettingFeatures())
    107137{
     
    114144    m_letterSpacing = other.m_letterSpacing;
    115145    m_wordSpacing = other.m_wordSpacing;
    116     m_needsTranscoding = other.m_needsTranscoding;
     146    m_useBackslashAsYenSymbol = other.m_useBackslashAsYenSymbol;
    117147    m_typesettingFeatures = other.m_typesettingFeatures;
    118148    return *this;
     
    259289{
    260290    m_glyphs = retrieveOrAddCachedFontGlyphs(m_fontDescription, fontSelector.get());
     291    m_useBackslashAsYenSymbol = useBackslashAsYenSignForFamily(firstFamily());
    261292    m_typesettingFeatures = computeTypesettingFeatures();
    262293}
  • trunk/Source/WebCore/platform/graphics/Font.h

    r155496 r156657  
    258258    static String normalizeSpaces(const UChar*, unsigned length);
    259259
    260     bool needsTranscoding() const { return m_needsTranscoding; }
     260    bool useBackslashAsYenSymbol() const { return m_useBackslashAsYenSymbol; }
    261261    FontGlyphs* glyphs() const { return m_glyphs.get(); }
    262262
     
    319319    short m_letterSpacing;
    320320    short m_wordSpacing;
    321     bool m_needsTranscoding;
     321    mutable bool m_useBackslashAsYenSymbol;
    322322    mutable unsigned m_typesettingFeatures : 2; // (TypesettingFeatures) Caches values computed from m_fontDescription.
    323323};
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r156613 r156657  
    2929#include "EllipsisBox.h"
    3030#include "FloatQuad.h"
    31 #include "FontTranscoder.h"
    3231#include "Frame.h"
    3332#include "FrameView.h"
     
    146145    , m_isAllASCII(text.containsOnlyASCII())
    147146    , m_knownToHaveNoOverflowAndNoFallbackFonts(false)
    148     , m_needsTranscoding(false)
     147    , m_useBackslashAsYenSymbol(false)
    149148#if ENABLE(IOS_TEXT_AUTOSIZING)
    150149    , m_candidateComputedTextSize(0)
     
    201200}
    202201
    203 void RenderText::updateNeedsTranscoding()
    204 {
     202bool RenderText::computeUseBackslashAsYenSymbol() const
     203{
     204    const FontDescription& fontDescription = style()->font().fontDescription();
     205    if (style()->font().useBackslashAsYenSymbol())
     206        return true;
     207    if (fontDescription.isSpecifiedFont())
     208        return false;
    205209    const TextEncoding* encoding = document().decoder() ? &document().decoder()->encoding() : 0;
    206     m_needsTranscoding = fontTranscoder().needsTranscoding(style()->font().fontDescription(), encoding);
     210    if (encoding && encoding->backslashAsCurrencySymbol() != '\\')
     211        return true;
     212    return false;
    207213}
    208214
     
    221227    bool needsResetText = false;
    222228    if (!oldStyle) {
    223         updateNeedsTranscoding();
    224         needsResetText = m_needsTranscoding;
    225     } else if (oldStyle->font().needsTranscoding() != newStyle->font().needsTranscoding() || (newStyle->font().needsTranscoding() && oldStyle->font().firstFamily() != newStyle->font().firstFamily())) {
    226         updateNeedsTranscoding();
     229        m_useBackslashAsYenSymbol = computeUseBackslashAsYenSymbol();
     230        needsResetText = m_useBackslashAsYenSymbol;
     231    } else if (oldStyle->font().useBackslashAsYenSymbol() != newStyle->font().useBackslashAsYenSymbol()) {
     232        m_useBackslashAsYenSymbol = computeUseBackslashAsYenSymbol();
    227233        needsResetText = true;
    228234    }
     
    13381344    ASSERT(!text.isNull());
    13391345    m_text = text;
    1340     if (m_needsTranscoding) {
    1341         const TextEncoding* encoding = document().decoder() ? &document().decoder()->encoding() : 0;
    1342         fontTranscoder().convert(m_text, style()->font().fontDescription(), encoding);
    1343     }
     1346
     1347    if (m_useBackslashAsYenSymbol)
     1348        m_text.replace('\\', yenSign);
     1349
    13441350    ASSERT(m_text);
    13451351
     
    14061412}
    14071413
    1408 String RenderText::textWithoutTranscoding() const
    1409 {
    1410     // If m_text isn't transcoded or is secure, we can just return the modified text.
    1411     if (!m_needsTranscoding || style()->textSecurity() != TSNONE)
     1414String RenderText::textWithoutConvertingBackslashToYenSymbol() const
     1415{
     1416    if (!m_useBackslashAsYenSymbol || style()->textSecurity() != TSNONE)
    14121417        return text();
    14131418
    1414     // Otherwise, we should use original text. If text-transform is
    1415     // specified, we should transform the text on the fly.
    14161419    String text = originalText();
    14171420    applyTextTransform(style(), text, previousCharacter());
  • trunk/Source/WebCore/rendering/RenderText.h

    r156608 r156657  
    5757
    5858    StringImpl* text() const { return m_text.impl(); }
    59     String textWithoutTranscoding() const;
     59    String textWithoutConvertingBackslashToYenSymbol() const;
    6060
    6161    InlineTextBox* createInlineTextBox();
     
    180180    float widthFromCache(const Font&, int start, int len, float xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const;
    181181    bool isAllASCII() const { return m_isAllASCII; }
    182     void updateNeedsTranscoding();
     182    bool computeUseBackslashAsYenSymbol() const;
    183183
    184184    void secureText(UChar mask);
     
    200200    bool m_canUseSimpleFontCodePath : 1;
    201201    mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1;
    202     bool m_needsTranscoding : 1;
     202    bool m_useBackslashAsYenSymbol : 1;
    203203   
    204204#if ENABLE(IOS_TEXT_AUTOSIZING)
Note: See TracChangeset for help on using the changeset viewer.