Changeset 64677 in webkit


Ignore:
Timestamp:
Aug 4, 2010, 2:22:24 PM (15 years ago)
Author:
mitz@apple.com
Message:

WebCore: Allow the language for hyphenation to be specified
https://bugs.webkit.org/show_bug.cgi?id=43467

Test: fast/text/hyphenate-locale.html

Added a -webkit-hyphenate-locale property whose value can be either auto or a locale identifier
string. The initial value is auto and the property is inherited. When the value is a locale
identifier, hyphenation should follow the rules for the specified locale.

  • WebCore.xcodeproj/project.pbxproj: Added AtomicStringKeyedMRUCache.h.
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Handle -webkit-hyphenate-locale.
Updated for the renaming of RenderStyle::hyphenateCharacter() to hyphenationString().

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue): Parse -webkit-hyphenate-locale.

  • css/CSSPropertyNames.in: Added -webkit-hyphenate-locale.
  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyProperty): Apply the -webkit-hyphenate-locale property to the
RenderStyle. Updated for the renaming of RenderStyle::hyphenateCharacter() to hyphenationString().

  • platform/text/AtomicStringKeyedMRUCache.h: Added.

(WebCore::AtomicStringKeyedMRUCache::get):

  • platform/text/Hyphenation.cpp:

(WebCore::canHyphenate): Added an implementation that returns false.
(WebCore::lastHyphenLocation): Now asserts that it is not called, because it is an error to call
this function if canHyphenate() returned false.

  • platform/text/Hyphenation.h:

Added canHyphenate(). Returns true if hyphenation is possible for the given locale identifier.

  • platform/text/android/HyphenationAndroid.cpp:

(WebCore::canHyphenate): Added an implementation that returns true and a FIXME.
(WebCore::lastHyphenLocation): Added unused localeIdentifier parameter.

  • platform/text/cf/HyphenationCF.cpp:

(WebCore::AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForNullKey): Returns
the CFLocaleRef for the current search locale.
(WebCore::AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForKey): Returns a
CFLocaleRef for the locale identifier.
(WebCore::canHyphenate): Added. Returns true.
(WebCore::lastHyphenLocation): Added localeIdentifier parameter, used to pass a CFLocaleRef to
the hyphenation function.

  • platform/text/mac/HyphenationMac.mm:

(WebCore::AtomicStringKeyedMRUCache<bool>::createValueForNullKey): Returns whether the current
search locale is english.
(WebCore::AtomicStringKeyedMRUCache<bool>::createValueForKey): Returns whether the locale identifier
string identifies locale with the English language.
(WebCore::canHyphenate): Added. Returns true if the locale language is English.
(WebCore::lastHyphenLocation): Added localeIdentifier parameter and an assertion that its language
is English.

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::tryHyphenating): Added a locale identifier parameter, which is passed down to
lastHyphenLocation(). Added 1 to the value passed for the beforeIndex parameter to lastHyphenLocation(),
because the latter only returns values smaller than that index. The Mac implementation could
return a value equal to beforeIndex, but that is fixed in the WebKitSystemInterface part of this patch.
(WebCore::RenderBlock::findNextLineBreak): Only set canHyphenate to true if hyphenation is possible
for the specified hyphenation locale. Pass the hyphenation locale to tryHyphenating().

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::diff): Compare hyphenation locales.
(WebCore::RenderStyle::hyphenString): Updated for the renaming of hyphenateCharacter() to
hyphenationString().

  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::hyphenationString): Renamed hyphenateCharacter() to this.
(WebCore::InheritedFlags::hyphenationLocale): Added this accessor.
(WebCore::InheritedFlags::setHyphenationString): Renamed setHyphenateCharacter() to this.
(WebCore::InheritedFlags::setHyphenationLocale): Added this accessor.
(WebCore::InheritedFlags::initialHyphenationString): Renamed initialHyphenateCharacter() to this.
(WebCore::InheritedFlags::initialHyphenateLocale): Added. Returns the null atom, which represents a
value of auto.

  • rendering/style/StyleRareInheritedData.cpp:

(WebCore::StyleRareInheritedData::StyleRareInheritedData): Copy the hyphenation locale. Updated for
rename.
(WebCore::StyleRareInheritedData::operator==): Compare the hyphenation locales. Updated for rename.

  • rendering/style/StyleRareInheritedData.h:

WebKitLibraries: WebKitSystemInterface part of: Allow the language for hyphenation to be specified
https://bugs.webkit.org/show_bug.cgi?id=43467

Reviewed by Darin Adler.

  • WebKitSystemInterface.h:
  • libWebKitSystemInterfaceLeopard.a:
  • libWebKitSystemInterfaceSnowLeopard.a:
  • libWebKitSystemInterfaceTiger.a:

LayoutTests: Allow the language for hyphenation to be specified
https://bugs.webkit.org/show_bug.cgi?id=43467

Reviewed by Simon Fraser.

  • fast/text/hyphenate-locale.html: Added.
  • platform/mac/fast/text/hyphenate-locale-expected.checksum: Added.
  • platform/mac/fast/text/hyphenate-locale-expected.png: Added.
  • platform/mac/fast/text/hyphenate-locale-expected.txt: Added.
Location:
trunk
Files:
5 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r64676 r64677  
     12010-08-04  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Allow the language for hyphenation to be specified
     6        https://bugs.webkit.org/show_bug.cgi?id=43467
     7
     8        * fast/text/hyphenate-locale.html: Added.
     9        * platform/mac/fast/text/hyphenate-locale-expected.checksum: Added.
     10        * platform/mac/fast/text/hyphenate-locale-expected.png: Added.
     11        * platform/mac/fast/text/hyphenate-locale-expected.txt: Added.
     12
    1132010-08-04  Dimitri Glazkov  <dglazkov@chromium.org>
    214
  • trunk/WebCore/ChangeLog

    r64674 r64677  
     12010-08-04  Dan Bernstein  <mitz@apple.com>
     2
     3        Allow the language for hyphenation to be specified
     4        https://bugs.webkit.org/show_bug.cgi?id=43467
     5
     6        Test: fast/text/hyphenate-locale.html
     7
     8        Added a -webkit-hyphenate-locale property whose value can be either auto or a locale identifier
     9        string. The initial value is auto and the property is inherited. When the value is a locale
     10        identifier, hyphenation should follow the rules for the specified locale.
     11
     12        * WebCore.xcodeproj/project.pbxproj: Added AtomicStringKeyedMRUCache.h.
     13        * css/CSSComputedStyleDeclaration.cpp:
     14        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Handle -webkit-hyphenate-locale.
     15        Updated for the renaming of RenderStyle::hyphenateCharacter() to hyphenationString().
     16        * css/CSSParser.cpp:
     17        (WebCore::CSSParser::parseValue): Parse -webkit-hyphenate-locale.
     18        * css/CSSPropertyNames.in: Added -webkit-hyphenate-locale.
     19        * css/CSSStyleSelector.cpp:
     20        (WebCore::CSSStyleSelector::applyProperty): Apply the -webkit-hyphenate-locale property to the
     21        RenderStyle. Updated for the renaming of RenderStyle::hyphenateCharacter() to hyphenationString().
     22        * platform/text/AtomicStringKeyedMRUCache.h: Added.
     23        (WebCore::AtomicStringKeyedMRUCache::get):
     24        * platform/text/Hyphenation.cpp:
     25        (WebCore::canHyphenate): Added an implementation that returns false.
     26        (WebCore::lastHyphenLocation): Now asserts that it is not called, because it is an error to call
     27        this function if canHyphenate() returned false.
     28        * platform/text/Hyphenation.h:
     29        Added canHyphenate(). Returns true if hyphenation is possible for the given locale identifier.
     30        * platform/text/android/HyphenationAndroid.cpp:
     31        (WebCore::canHyphenate): Added an implementation that returns true and a FIXME.
     32        (WebCore::lastHyphenLocation): Added unused localeIdentifier parameter.
     33        * platform/text/cf/HyphenationCF.cpp:
     34        (WebCore::AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForNullKey): Returns
     35        the CFLocaleRef for the current search locale.
     36        (WebCore::AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForKey): Returns a
     37        CFLocaleRef for the locale identifier.
     38        (WebCore::canHyphenate): Added. Returns true.
     39        (WebCore::lastHyphenLocation): Added localeIdentifier parameter, used to pass a CFLocaleRef to
     40        the hyphenation function.
     41        * platform/text/mac/HyphenationMac.mm:
     42        (WebCore::AtomicStringKeyedMRUCache<bool>::createValueForNullKey): Returns whether the current
     43        search locale is english.
     44        (WebCore::AtomicStringKeyedMRUCache<bool>::createValueForKey): Returns whether the locale identifier
     45        string identifies locale with the English language.
     46        (WebCore::canHyphenate): Added. Returns true if the locale language is English.
     47        (WebCore::lastHyphenLocation): Added localeIdentifier parameter and an assertion that its language
     48        is English.
     49        * rendering/RenderBlockLineLayout.cpp:
     50        (WebCore::tryHyphenating): Added a locale identifier parameter, which is passed down to
     51        lastHyphenLocation(). Added 1 to the value passed for the beforeIndex parameter to lastHyphenLocation(),
     52        because the latter only returns values smaller than that index. The Mac implementation could
     53        return a value equal to beforeIndex, but that is fixed in the WebKitSystemInterface part of this patch.
     54        (WebCore::RenderBlock::findNextLineBreak): Only set canHyphenate to true if hyphenation is possible
     55        for the specified hyphenation locale. Pass the hyphenation locale to tryHyphenating().
     56        * rendering/style/RenderStyle.cpp:
     57        (WebCore::RenderStyle::diff): Compare hyphenation locales.
     58        (WebCore::RenderStyle::hyphenString): Updated for the renaming of hyphenateCharacter() to
     59        hyphenationString().
     60        * rendering/style/RenderStyle.h:
     61        (WebCore::InheritedFlags::hyphenationString): Renamed hyphenateCharacter() to this.
     62        (WebCore::InheritedFlags::hyphenationLocale): Added this accessor.
     63        (WebCore::InheritedFlags::setHyphenationString): Renamed setHyphenateCharacter() to this.
     64        (WebCore::InheritedFlags::setHyphenationLocale): Added this accessor.
     65        (WebCore::InheritedFlags::initialHyphenationString): Renamed initialHyphenateCharacter() to this.
     66        (WebCore::InheritedFlags::initialHyphenateLocale): Added. Returns the null atom, which represents a
     67        value of auto.
     68        * rendering/style/StyleRareInheritedData.cpp:
     69        (WebCore::StyleRareInheritedData::StyleRareInheritedData): Copy the hyphenation locale. Updated for
     70        rename.
     71        (WebCore::StyleRareInheritedData::operator==): Compare the hyphenation locales. Updated for rename.
     72        * rendering/style/StyleRareInheritedData.h:
     73
    1742010-08-04  Tony Gentilcore  <tonyg@chromium.org>
    275
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r64642 r64677  
    795795                37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.cpp */; };
    796796                37C28A6810F659CC008C7813 /* TypesettingFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C28A6710F659CC008C7813 /* TypesettingFeatures.h */; settings = {ATTRIBUTES = (Private, ); }; };
     797                37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */; };
    797798                37F818FD0D657606005E1F05 /* WebCoreURLResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
    798799                37F818FE0D657606005E1F05 /* WebCoreURLResponse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */; };
     
    65166517                37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextControllerCoreText.cpp; sourceTree = "<group>"; };
    65176518                37C28A6710F659CC008C7813 /* TypesettingFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypesettingFeatures.h; sourceTree = "<group>"; };
     6519                37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AtomicStringKeyedMRUCache.h; sourceTree = "<group>"; };
    65186520                37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreURLResponse.h; sourceTree = "<group>"; };
    65196521                37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreURLResponse.mm; sourceTree = "<group>"; };
     
    1563615638                                0FC705200EB1815600B90AD8 /* AtomicStringHash.h */,
    1563715639                                B2C3D9EF0D006C1D00EF6F26 /* AtomicStringImpl.h */,
     15640                                37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */,
    1563815641                                B2C3D9F00D006C1D00EF6F26 /* Base64.cpp */,
    1563915642                                B2C3D9F10D006C1D00EF6F26 /* Base64.h */,
     
    1998719990                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
    1998819991                                CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
     19992                                37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */,
    1998919993                        );
    1999019994                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/css/CSSComputedStyleDeclaration.cpp

    r63342 r64677  
    911911            return CSSPrimitiveValue::create(style->hyphens());
    912912        case CSSPropertyWebkitHyphenateCharacter:
    913             if (style->hyphenateCharacter().isNull())
     913            if (style->hyphenationString().isNull())
    914914                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    915             return CSSPrimitiveValue::create(style->hyphenateCharacter(), CSSPrimitiveValue::CSS_STRING);
     915            return CSSPrimitiveValue::create(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
     916        case CSSPropertyWebkitHyphenateLocale:
     917            if (style->hyphenationLocale().isNull())
     918                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     919            return CSSPrimitiveValue::create(style->hyphenationLocale(), CSSPrimitiveValue::CSS_STRING);
    916920        case CSSPropertyWebkitBorderFit:
    917921            if (style->borderFit() == BorderFitBorder)
  • trunk/WebCore/css/CSSParser.cpp

    r64071 r64677  
    15731573
    15741574    case CSSPropertyWebkitHyphenateCharacter:
     1575        if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
     1576            validPrimitive = true;
     1577        break;
     1578
     1579    case CSSPropertyWebkitHyphenateLocale:
    15751580        if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
    15761581            validPrimitive = true;
  • trunk/WebCore/css/CSSPropertyNames.in

    r63342 r64677  
    218218-webkit-highlight
    219219-webkit-hyphenate-character
     220-webkit-hyphenate-locale
    220221-webkit-hyphens
    221222-webkit-line-break
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r64518 r64677  
    52165216    }
    52175217    case CSSPropertyWebkitHyphenateCharacter: {
    5218         HANDLE_INHERIT_AND_INITIAL(hyphenateCharacter, HyphenateCharacter);
     5218        HANDLE_INHERIT_AND_INITIAL(hyphenationString, HyphenationString);
    52195219        if (primitiveValue->getIdent() == CSSValueAuto)
    5220             m_style->setHyphenateCharacter(nullAtom);
     5220            m_style->setHyphenationString(nullAtom);
    52215221        else
    5222             m_style->setHyphenateCharacter(primitiveValue->getStringValue());
     5222            m_style->setHyphenationString(primitiveValue->getStringValue());
     5223        return;
     5224    }
     5225    case CSSPropertyWebkitHyphenateLocale: {
     5226        HANDLE_INHERIT_AND_INITIAL(hyphenationLocale, HyphenationLocale);
     5227        if (primitiveValue->getIdent() == CSSValueAuto)
     5228            m_style->setHyphenationLocale(nullAtom);
     5229        else
     5230            m_style->setHyphenationLocale(primitiveValue->getStringValue());
    52235231        return;
    52245232    }
  • trunk/WebCore/platform/text/Hyphenation.cpp

    r61548 r64677  
    3131namespace WebCore {
    3232
    33 size_t lastHyphenLocation(const UChar* /* characters */, size_t /* length */, size_t /* beforeIndex */)
     33bool canHyphenate(const AtomicString& /* localeIdentifier */)
    3434{
    35     notImplemented();
     35    return false;
     36}
     37
     38size_t lastHyphenLocation(const UChar* /* characters */, size_t /* length */, size_t /* beforeIndex */, const AtomicString& /* localeIdentifier */)
     39{
     40    ASSERT_NOT_REACHED();
    3641    return 0;
    3742}
  • trunk/WebCore/platform/text/Hyphenation.h

    r61548 r64677  
    3131namespace WebCore {
    3232
    33 size_t lastHyphenLocation(const UChar*, size_t length, size_t beforeIndex);
     33class AtomicString;
     34
     35bool canHyphenate(const AtomicString& localeIdentifier);
     36size_t lastHyphenLocation(const UChar*, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier);
    3437
    3538} // namespace WebCore
  • trunk/WebCore/platform/text/android/HyphenationAndroid.cpp

    r64087 r64677  
    5858}
    5959
    60 size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex)
     60bool canHyphenate(const AtomicString& /* localeIdentifier */)
     61{
     62    // FIXME: Check that the locale identifier matches the available dictionary.
     63    return true;
     64}
     65
     66size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& /* localeIdentifier */)
    6167{
    6268    static const size_t minWordLen = 5;
  • trunk/WebCore/platform/text/cf/HyphenationCF.cpp

    r61548 r64677  
    2929#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    3030
     31#include "AtomicString.h"
     32#include "AtomicStringKeyedMRUCache.h"
    3133#include "TextBreakIteratorInternalICU.h"
     34#include <wtf/ListHashSet.h>
    3235#include <wtf/RetainPtr.h>
    3336
    3437namespace WebCore {
    3538
    36 static CFLocaleRef createCurrentSearchLocale()
     39template<>
     40RetainPtr<CFLocaleRef> AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForNullKey()
    3741{
    38     RetainPtr<CFStringRef> localeIdentifier(AdoptCF, CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, (const UInt8*)currentSearchLocaleID(), strlen(currentSearchLocaleID()), kCFStringEncodingASCII, false, kCFAllocatorNull));
    39     return CFLocaleCreate(kCFAllocatorDefault, localeIdentifier.get());
     42    RetainPtr<CFStringRef> cfLocaleIdentifier(AdoptCF, CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(currentSearchLocaleID()), strlen(currentSearchLocaleID()), kCFStringEncodingASCII, false, kCFAllocatorNull));
     43    RetainPtr<CFLocaleRef> locale(AdoptCF, CFLocaleCreate(kCFAllocatorDefault, cfLocaleIdentifier.get()));
     44    return locale;
    4045}
    4146
    42 size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex)
     47template<>
     48RetainPtr<CFLocaleRef> AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForKey(const AtomicString& localeIdentifier)
     49{
     50    RetainPtr<CFStringRef> cfLocaleIdentifier(AdoptCF, localeIdentifier.createCFString());
     51    RetainPtr<CFLocaleRef> locale(AdoptCF, CFLocaleCreate(kCFAllocatorDefault, cfLocaleIdentifier.get()));
     52    return locale;
     53}
     54
     55bool canHyphenate(const AtomicString& /* localeIdentifer */)
     56{
     57    return true;
     58}
     59
     60size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier)
    4361{
    4462    RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters, length, kCFAllocatorNull));
    4563
    46     static CFLocaleRef locale = createCurrentSearchLocale();
     64    DEFINE_STATIC_LOCAL(AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >, cfLocaleCache, ());
     65    RetainPtr<CFLocaleRef> locale = cfLocaleCache.get(localeIdentifier);
    4766
    48     CFIndex result = CFStringGetHyphenationLocationBeforeIndex(string.get(), beforeIndex, CFRangeMake(0, length), 0, locale, 0);
     67    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(string.get(), beforeIndex, CFRangeMake(0, length), 0, locale.get(), 0);
    4968    return result == kCFNotFound ? 0 : result;
    5069}
  • trunk/WebCore/platform/text/mac/HyphenationMac.mm

    r61548 r64677  
    2929#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
    3030
     31#import "AtomicString.h"
     32#import "AtomicStringKeyedMRUCache.h"
    3133#import "TextBreakIteratorInternalICU.h"
    3234#import "WebCoreSystemInterface.h"
     
    3537namespace WebCore {
    3638
    37 size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex)
     39template<>
     40bool AtomicStringKeyedMRUCache<bool>::createValueForNullKey()
    3841{
    39     static bool localeIsEnglish = !strcmp("en", currentSearchLocaleID());
    40     if (!localeIsEnglish)
    41         return 0;
     42    return !strcmp(currentSearchLocaleID(), "en");
     43}
     44
     45template<>
     46bool AtomicStringKeyedMRUCache<bool>::createValueForKey(const AtomicString& localeIdentifier)
     47{
     48    RetainPtr<CFStringRef> cfLocaleIdentifier(AdoptCF, localeIdentifier.createCFString());
     49    RetainPtr<CFDictionaryRef> components(AdoptCF, CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorDefault, cfLocaleIdentifier.get()));
     50    CFStringRef language = reinterpret_cast<CFStringRef>(CFDictionaryGetValue(components.get(), kCFLocaleLanguageCode));
     51    static CFStringRef englishLanguage = CFSTR("en");
     52    return language && CFEqual(language, englishLanguage);
     53}
     54
     55bool canHyphenate(const AtomicString& localeIdentifier)
     56{
     57    DEFINE_STATIC_LOCAL(AtomicStringKeyedMRUCache<bool>, isEnglishCache, ());
     58    return isEnglishCache.get(localeIdentifier);
     59}
     60
     61size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier)
     62{
     63    ASSERT(canHyphenate(localeIdentifier));
    4264
    4365    RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters, length, kCFAllocatorNull));
  • trunk/WebCore/rendering/RenderBlockLineLayout.cpp

    r62510 r64677  
    13231323}
    13241324
    1325 static void tryHyphenating(RenderText* text, const Font& font, int lastSpace, int pos, int xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated)
     1325static void tryHyphenating(RenderText* text, const Font& font, const AtomicString& localeIdentifier, int lastSpace, int pos, int xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated)
    13261326{
    13271327    const AtomicString& hyphenString = text->style()->hyphenString();
     
    13321332        return;
    13331333
    1334     prefixLength = 1 + lastHyphenLocation(text->characters() + lastSpace + 1, pos - lastSpace - 1, prefixLength - 1);
     1334    prefixLength = 1 + lastHyphenLocation(text->characters() + lastSpace + 1, pos - lastSpace - 1, prefixLength, localeIdentifier);
    13351335    if (prefixLength <= 1)
    13361336        return;
     
    15661566            const Font& f = style->font();
    15671567            bool isFixedPitch = f.isFixedPitch();
    1568             bool canHyphenate = style->hyphens() == HyphensAuto;
     1568            bool canHyphenate = style->hyphens() == HyphensAuto && WebCore::canHyphenate(style->hyphenationLocale());
    15691569
    15701570            int lastSpace = pos;
     
    17121712                        if (lineWasTooWide || w + tmpW > width) {
    17131713                            if (canHyphenate && w + tmpW > width) {
    1714                                 tryHyphenating(t, f, lastSpace, pos, w + tmpW - additionalTmpW, width, isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
     1714                                tryHyphenating(t, f, style->hyphenationLocale(), lastSpace, pos, w + tmpW - additionalTmpW, width, isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
    17151715                                if (hyphenated)
    17161716                                    goto end;
     
    18261826
    18271827            if (canHyphenate && w + tmpW > width) {
    1828                 tryHyphenating(t, f, lastSpace, pos, w + tmpW - additionalTmpW, width, isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
     1828                tryHyphenating(t, f, style->hyphenationLocale(), lastSpace, pos, w + tmpW - additionalTmpW, width, isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
    18291829                if (hyphenated)
    18301830                    goto end;
  • trunk/WebCore/rendering/style/RenderStyle.cpp

    r62551 r64677  
    386386            rareInheritedData->textSecurity != other->rareInheritedData->textSecurity ||
    387387            rareInheritedData->hyphens != other->rareInheritedData->hyphens ||
    388             rareInheritedData->hyphenateCharacter != other->rareInheritedData->hyphenateCharacter)
     388            rareInheritedData->hyphenationString != other->rareInheritedData->hyphenationString ||
     389            rareInheritedData->hyphenationLocale != other->rareInheritedData->hyphenationLocale)
    389390            return StyleDifferenceLayout;
    390391
     
    833834    ASSERT(hyphens() == HyphensAuto);
    834835
    835     const AtomicString& hyphenateCharacter = rareInheritedData.get()->hyphenateCharacter;
    836     if (!hyphenateCharacter.isNull())
    837         return hyphenateCharacter;
     836    const AtomicString& hyphenationString = rareInheritedData.get()->hyphenationString;
     837    if (!hyphenationString.isNull())
     838        return hyphenationString;
    838839
    839840    // FIXME: This should depend on locale.
  • trunk/WebCore/rendering/style/RenderStyle.h

    r63653 r64677  
    649649    const AtomicString& highlight() const { return rareInheritedData->highlight; }
    650650    Hyphens hyphens() const { return static_cast<Hyphens>(rareInheritedData->hyphens); }
    651     const AtomicString& hyphenateCharacter() const { return rareInheritedData->hyphenateCharacter; }
     651    const AtomicString& hyphenationString() const { return rareInheritedData->hyphenationString; }
     652    const AtomicString& hyphenationLocale() const { return rareInheritedData->hyphenationLocale; }
    652653    EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
    653654    EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); }
     
    989990    void setHighlight(const AtomicString& h) { SET_VAR(rareInheritedData, highlight, h); }
    990991    void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); }
    991     void setHyphenateCharacter(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenateCharacter, h); }
     992    void setHyphenationString(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationString, h); }
     993    void setHyphenationLocale(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationLocale, h); }
    992994    void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
    993995    void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); }
     
    11981200    static const AtomicString& initialHighlight() { return nullAtom; }
    11991201    static Hyphens initialHyphens() { return HyphensManual; }
    1200     static const AtomicString& initialHyphenateCharacter() { return nullAtom; }
     1202    static const AtomicString& initialHyphenationString() { return nullAtom; }
     1203    static const AtomicString& initialHyphenationLocale() { return nullAtom; }
    12011204    static EBorderFit initialBorderFit() { return BorderFitBorder; }
    12021205    static EResize initialResize() { return RESIZE_NONE; }
  • trunk/WebCore/rendering/style/StyleRareInheritedData.cpp

    r61548 r64677  
    7272    , colorSpace(o.colorSpace)
    7373    , hyphens(o.hyphens)
    74     , hyphenateCharacter(o.hyphenateCharacter)
     74    , hyphenationString(o.hyphenationString)
     75    , hyphenationLocale(o.hyphenationLocale)
    7576{
    7677}
     
    113114        && colorSpace == o.colorSpace
    114115        && hyphens == o.hyphens
    115         && hyphenateCharacter == o.hyphenateCharacter;
     116        && hyphenationString == o.hyphenationString
     117        && hyphenationLocale == o.hyphenationLocale;
    116118}
    117119
  • trunk/WebCore/rendering/style/StyleRareInheritedData.h

    r61548 r64677  
    8080    unsigned hyphens : 2; // Hyphens
    8181
    82     AtomicString hyphenateCharacter;
     82    AtomicString hyphenationString;
     83    AtomicString hyphenationLocale;
    8384
    8485private:
  • trunk/WebKitLibraries/ChangeLog

    r64593 r64677  
     12010-08-04  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        WebKitSystemInterface part of: Allow the language for hyphenation to be specified
     6        https://bugs.webkit.org/show_bug.cgi?id=43467
     7
     8        * WebKitSystemInterface.h:
     9        * libWebKitSystemInterfaceLeopard.a:
     10        * libWebKitSystemInterfaceSnowLeopard.a:
     11        * libWebKitSystemInterfaceTiger.a:
     12
    1132010-08-03  Beth Dakin  <bdakin@apple.com>
    214
  • trunk/WebKitLibraries/WebKitSystemInterface.h

    r62356 r64677  
    11/*     
    22    WebKitSystemInterface.h
    3     Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     3    Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    44
    55    Public header file.
     
    211211    WKMediaUIPartSeekBackButton,
    212212    WKMediaUIPartSeekForwardButton,
    213     WKMediaUIPartSlider,
    214     WKMediaUIPartSliderThumb,
     213    WKMediaUIPartTimelineSlider,
     214    WKMediaUIPartTimelineSliderThumb,
    215215    WKMediaUIPartRewindButton,
    216216    WKMediaUIPartSeekToRealtimeButton,
     
    221221    WKMediaUIPartBackground,
    222222    WKMediaUIPartCurrentTimeDisplay,
    223     WKMediaUIPartTimeRemainingDisplay
     223    WKMediaUIPartTimeRemainingDisplay,
     224    WKMediaUIPartStatusDisplay,
     225    WKMediaUIPartControlsPanel,
     226    WKMediaUIPartVolumeSliderContainer,
     227    WKMediaUIPartVolumeSlider,
     228    WKMediaUIPartVolumeSliderThumb
    224229} WKMediaUIPart;
    225230
     
    252257    WKMediaUIControlVolumeUpButton,
    253258    WKMediaUIControlVolumeDownButton
    254 
    255259} WKMediaUIControlType;
    256260   
Note: See TracChangeset for help on using the changeset viewer.