Changeset 61548 in webkit


Ignore:
Timestamp:
Jun 21, 2010 9:54:52 AM (14 years ago)
Author:
mitz@apple.com
Message:

WebCore: CSS3: Implement the 'hyphens' and 'hyphenate-character' properties
https://bugs.webkit.org/show_bug.cgi?id=10228

Reviewed by Darin Adler.

Tests: fast/text/hyphenate-character.html

fast/text/hyphens.html

Added -webkit-hyphens and -webkit-hyphenate-character as specified in
<http://www.w3.org/TR/2010/WD-css3-gcpm-20100608/#hyphenation>.

  • Android.mk: Added Hyphenation.cpp.
  • CMakeLists.txt: Ditto.
  • GNUmakefile.am: Added Hyphenation.{cpp,h}.
  • WebCore.base.exp: Exported wkGetHyphenationLocationBeforeIndex().
  • WebCore.gypi: Added Hyphenation.{cpp,h}.
  • WebCore.pro: Added Hyphenation.{cpp,h}.
  • WebCore.vcproj/WebCore.vcproj: Added Hyphenation.{cpp,h}.
  • WebCore.xcodeproj/project.pbxproj: Added Hyphenation.{cpp,h}.
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added the -webkit-hyphenate-character
and -webkit-hyphens cases.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue): Validate values for the new properties.

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added. Maps from a Hyphens value to an identifier.
(WebCore::CSSPrimitiveValue::operator Hyphens): Added. Maps from an identifier to a Hyphens value.

  • css/CSSPropertyNames.in: Added -webkit-hyphenate-character and -webkit-hyphens.
  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyProperty): Apply the new properties to the RenderStyle.

  • css/CSSValueKeywords.in:
  • platform/mac/WebCoreSystemInterface.h: Added wkGetHyphenationLocationBeforeIndex.
  • platform/mac/WebCoreSystemInterface.mm: Ditto.
  • platform/text/CharacterNames.h: Added the hyphen character.
  • platform/text/Hyphenation.cpp: Added.

(WebCore::lastHyphenLocation): Added this default implementation for platforms that do not implement
hyphenation yet. It calls notImplemented() and returns 0.

  • platform/text/Hyphenation.h: Added.
  • platform/text/cf/HyphenationCF.cpp: Added.

(WebCore::lastHyphenLocation): Returns the last hyphenation location occurring in the given string before
the given index. Uses the current search locale (which is based on the top language preference of the user)
for hyphenation.

  • platform/text/mac/HyphenationMac.mm: Added.

(WebCore::lastHyphenLocation): Returns the last hyphenation location occurring in the given string before
the given index. Returns 0 if the current search locale is not "en", because the platform only knows how to
hyphenate English.

  • rendering/BidiRun.h:

(WebCore::BidiRun::BidiRun): Added a boolean member, m_hasHyphen, and initialized it to false in the constructor.

  • rendering/InlineBox.h:

(WebCore::InlineBox::InlineBox): Renamed m_hasEllipsisBox to m_hasEllipsisBoxOrHyphen, because this bit is now
shared by two subclass: RootInlineBox uses it for hasEllipsisBox(), while InlineTextBox uses it for hasHyphen().

  • rendering/InlineTextBox.cpp:

(WebCore::adjustCharactersAndLengthForHyphen): Added this helper function to get the hyphen string from the style
and return a UChar* and length for the concatenation of the given text with the hyphen string.
(WebCore::InlineTextBox::selectionRect): If the selected range touches the end and the box has a hyphen,
compute the width of the text with the hyphen string concatenated to it.
(WebCore::InlineTextBox::paint): If the box has a hyphen, draw the text with the hyphen string concatenated to it.
(WebCore::InlineTextBox::paintSelection): Similarly concatenate the hyphen string.

  • rendering/InlineTextBox.h:

(WebCore::InlineTextBox::hasHyphen): Added this accessor.
(WebCore::InlineTextBox::setHasHyphen): Ditto.

  • rendering/RenderBlock.h:
  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::constructLine): Copy the m_hasHyphen flag from the run to its text box.
(WebCore::RenderBlock::computeHorizontalPositionsForLine): Add the width of the hyphen string when computing the
width of a box that has a hyphen.
(WebCore::RenderBlock::layoutInlineChildren): If the line was hyphenated, set the m_hasHyphen flag on the
logically last run.
(WebCore::tryHyphenating): Added this helper function which checks if a piece of text that does not fit on the
line could be hyphenated such that the part before the hyphen, including the hyphen, would fit. Given the amount
of space remaining on the line, it finds the longest prefix that can fit in the remaining space (which leaving room for
the hyphen), and then checks for a hyphenation location within that prefix.
(WebCore::RenderBlock::findNextLineBreak): In the 'hyphens: none' case, prevent line breaks at soft hyphens.
In the 'hyphens: auto' case, try hyphenating when a word will not fit in the remaining space on the line.

  • rendering/RootInlineBox.cpp:

(WebCore::RootInlineBox::detachEllipsisBox): Changed to use hasEllipsisBox() and setHasEllipsisBox().
(WebCore::RootInlineBox::clearTruncation): Ditto.
(WebCore::RootInlineBox::placeEllipsis): Ditto.
(WebCore::RootInlineBox::paintEllipsisBox): Ditto.
(WebCore::RootInlineBox::nodeAtPoint): Ditto.
(WebCore::RootInlineBox::ellipsisBox): Ditto.

  • rendering/RootInlineBox.h:

(WebCore::RootInlineBox::hasEllipsisBox): Added this accessor.
(WebCore::RootInlineBox::setHasEllipsisBox): Ditto.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::diff): Return a layout hint if the hyphens setting or hyphenate-character differs.
(WebCore::RenderStyle::hyphenString): Added. For hyphenate-character: auto, returns the hyphen character.

  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::hyphens): Added this accessor.
(WebCore::InheritedFlags::hyphenateCharacter): Ditto.
(WebCore::InheritedFlags::setHyphens): Ditto.
(WebCore::InheritedFlags::setHyphenateCharacter): Ditto.
(WebCore::InheritedFlags::initialHyphens): Added. Returns HyphensManual.
(WebCore::InheritedFlags::initialHyphenateCharacter): Added. Returns the null string, corresponding to
a value of 'auto'.

  • rendering/style/RenderStyleConstants.h:

Added a Hyphens enum.

  • rendering/style/StyleRareInheritedData.cpp:

(WebCore::StyleRareInheritedData::StyleRareInheritedData): Initialize and copy the new members.
(WebCore::StyleRareInheritedData::operator==): Compare the new members.

  • rendering/style/StyleRareInheritedData.h: Added two new members: hyphens and hyphenateCharacter.

WebKit/mac: WebKit part of implementing the 'hyphens' and 'hyphenate-character' properties
https://bugs.webkit.org/show_bug.cgi?id=10228

Reviewed by Darin Adler.

  • WebCoreSupport/WebSystemInterface.mm:

(InitWebCoreSystemInterface): Initialize wkGetHyphenationLocationBeforeIndex.

WebKitLibraries: WebKitSystemInterface part of CSS3: Implement the 'hyphens' and 'hyphenate-character' properties
https://bugs.webkit.org/show_bug.cgi?id=10228

Reviewed by Darin Adler.

  • WebKitSystemInterface.h: Added WKGetHyphenationLocationBeforeIndex().
  • libWebKitSystemInterfaceLeopard.a:
  • libWebKitSystemInterfaceSnowLeopard.a:
  • libWebKitSystemInterfaceTiger.a:

LayoutTests: Added tests for the 'hyphens' and 'hyphenate-character' properties
https://bugs.webkit.org/show_bug.cgi?id=10228

Reviewed by Darin Adler.

  • fast/text/hyphenate-character.html: Added.
  • fast/text/hyphens.html: Added.
  • platform/gtk/Skipped:
  • platform/mac/fast/text/hyphenate-character-expected.checksum: Added.
  • platform/mac/fast/text/hyphenate-character-expected.png: Added.
  • platform/mac/fast/text/hyphenate-character-expected.txt: Added.
  • platform/mac/fast/text/hyphens-expected.checksum: Added.
  • platform/mac/fast/text/hyphens-expected.png: Added.
  • platform/mac/fast/text/hyphens-expected.txt: Added.
  • platform/qt/Skipped:
  • platform/win/Skipped:
Location:
trunk
Files:
12 added
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r61532 r61548  
     12010-06-21  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Added tests for the 'hyphens' and 'hyphenate-character' properties
     6        https://bugs.webkit.org/show_bug.cgi?id=10228
     7
     8        * fast/text/hyphenate-character.html: Added.
     9        * fast/text/hyphens.html: Added.
     10        * platform/gtk/Skipped:
     11        * platform/mac/fast/text/hyphenate-character-expected.checksum: Added.
     12        * platform/mac/fast/text/hyphenate-character-expected.png: Added.
     13        * platform/mac/fast/text/hyphenate-character-expected.txt: Added.
     14        * platform/mac/fast/text/hyphens-expected.checksum: Added.
     15        * platform/mac/fast/text/hyphens-expected.png: Added.
     16        * platform/mac/fast/text/hyphens-expected.txt: Added.
     17        * platform/qt/Skipped:
     18        * platform/win/Skipped:
     19
    1202010-06-21  Dumitru Daniliuc  <dumi@chromium.org>
    221
  • trunk/LayoutTests/platform/gtk/Skipped

    r61440 r61548  
    31253125fast/text/firstline/002.html
    31263126fast/text/firstline/003.html
     3127# Hyphenation is not implemented yet.
     3128fast/text/hyphenate-character.html
     3129fast/text/hyphens.html
     3130
    31273131fast/text/international/001.html
    31283132fast/text/international/002.html
  • trunk/LayoutTests/platform/qt/Skipped

    r61505 r61548  
    103103fast/loader/subframe-navigate-during-main-frame-load.html
    104104
     105# Hyphenation is not implemented yet.
     106fast/text/hyphenate-character.html
     107fast/text/hyphens.html
    105108
    106109# =========================================================================== #
  • trunk/LayoutTests/platform/win/Skipped

    r61376 r61548  
    899899# LayoutTestController::pageProperty is not implemented for WIN yet.
    900900printing/page-rule-selection.html
     901
     902# Hyphenation is not implemented yet.
     903fast/text/hyphenate-character.html
     904fast/text/hyphens.html
  • trunk/WebCore/Android.mk

    r61511 r61548  
    528528        platform/text/Base64.cpp \
    529529        platform/text/BidiContext.cpp \
     530        platform/text/Hyphenation.cpp \
    530531        platform/text/RegularExpression.cpp \
    531532        platform/text/SegmentedString.cpp \
  • trunk/WebCore/CMakeLists.txt

    r61531 r61548  
    12471247    platform/text/Base64.cpp
    12481248    platform/text/BidiContext.cpp
     1249    platform/text/Hyphenation.cpp
    12491250    platform/text/RegularExpression.cpp
    12501251    platform/text/SegmentedString.cpp
  • trunk/WebCore/ChangeLog

    r61546 r61548  
     12010-06-21  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        CSS3: Implement the 'hyphens' and 'hyphenate-character' properties
     6        https://bugs.webkit.org/show_bug.cgi?id=10228
     7
     8        Tests: fast/text/hyphenate-character.html
     9               fast/text/hyphens.html
     10
     11        Added -webkit-hyphens and -webkit-hyphenate-character as specified in
     12        <http://www.w3.org/TR/2010/WD-css3-gcpm-20100608/#hyphenation>.
     13
     14        * Android.mk: Added Hyphenation.cpp.
     15        * CMakeLists.txt: Ditto.
     16        * GNUmakefile.am: Added Hyphenation.{cpp,h}.
     17        * WebCore.base.exp: Exported wkGetHyphenationLocationBeforeIndex().
     18        * WebCore.gypi: Added Hyphenation.{cpp,h}.
     19        * WebCore.pro: Added Hyphenation.{cpp,h}.
     20        * WebCore.vcproj/WebCore.vcproj: Added Hyphenation.{cpp,h}.
     21        * WebCore.xcodeproj/project.pbxproj: Added Hyphenation.{cpp,h}.
     22        * css/CSSComputedStyleDeclaration.cpp:
     23        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added the -webkit-hyphenate-character
     24        and -webkit-hyphens cases.
     25        * css/CSSParser.cpp:
     26        (WebCore::CSSParser::parseValue): Validate values for the new properties.
     27        * css/CSSPrimitiveValueMappings.h:
     28        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added. Maps from a Hyphens value to an identifier.
     29        (WebCore::CSSPrimitiveValue::operator Hyphens): Added. Maps from an identifier to a Hyphens value.
     30        * css/CSSPropertyNames.in: Added -webkit-hyphenate-character and -webkit-hyphens.
     31        * css/CSSStyleSelector.cpp:
     32        (WebCore::CSSStyleSelector::applyProperty): Apply the new properties to the RenderStyle.
     33        * css/CSSValueKeywords.in:
     34        * platform/mac/WebCoreSystemInterface.h: Added wkGetHyphenationLocationBeforeIndex.
     35        * platform/mac/WebCoreSystemInterface.mm: Ditto.
     36        * platform/text/CharacterNames.h: Added the hyphen character.
     37        * platform/text/Hyphenation.cpp: Added.
     38        (WebCore::lastHyphenLocation): Added this default implementation for platforms that do not implement
     39        hyphenation yet. It calls notImplemented() and returns 0.
     40        * platform/text/Hyphenation.h: Added.
     41        * platform/text/cf/HyphenationCF.cpp: Added.
     42        (WebCore::lastHyphenLocation): Returns the last hyphenation location occurring in the given string before
     43        the given index. Uses the current search locale (which is based on the top language preference of the user)
     44        for hyphenation.
     45        * platform/text/mac/HyphenationMac.mm: Added.
     46        (WebCore::lastHyphenLocation): Returns the last hyphenation location occurring in the given string before
     47        the given index. Returns 0 if the current search locale is not "en", because the platform only knows how to
     48        hyphenate English.
     49        * rendering/BidiRun.h:
     50        (WebCore::BidiRun::BidiRun): Added a boolean member, m_hasHyphen, and initialized it to false in the constructor.
     51        * rendering/InlineBox.h:
     52        (WebCore::InlineBox::InlineBox): Renamed m_hasEllipsisBox to m_hasEllipsisBoxOrHyphen, because this bit is now
     53        shared by two subclass: RootInlineBox uses it for hasEllipsisBox(), while InlineTextBox uses it for hasHyphen().
     54        * rendering/InlineTextBox.cpp:
     55        (WebCore::adjustCharactersAndLengthForHyphen): Added this helper function to get the hyphen string from the style
     56        and return a UChar* and length for the concatenation of the given text with the hyphen string.
     57        (WebCore::InlineTextBox::selectionRect): If the selected range touches the end and the box has a hyphen,
     58        compute the width of the text with the hyphen string concatenated to it.
     59        (WebCore::InlineTextBox::paint): If the box has a hyphen, draw the text with the hyphen string concatenated to it.
     60        (WebCore::InlineTextBox::paintSelection): Similarly concatenate the hyphen string.
     61        * rendering/InlineTextBox.h:
     62        (WebCore::InlineTextBox::hasHyphen): Added this accessor.
     63        (WebCore::InlineTextBox::setHasHyphen): Ditto.
     64        * rendering/RenderBlock.h:
     65        * rendering/RenderBlockLineLayout.cpp:
     66        (WebCore::RenderBlock::constructLine): Copy the m_hasHyphen flag from the run to its text box.
     67        (WebCore::RenderBlock::computeHorizontalPositionsForLine): Add the width of the hyphen string when computing the
     68        width of a box that has a hyphen.
     69        (WebCore::RenderBlock::layoutInlineChildren): If the line was hyphenated, set the m_hasHyphen flag on the
     70        logically last run.
     71        (WebCore::tryHyphenating): Added this helper function which checks if a piece of text that does not fit on the
     72        line could be hyphenated such that the part before the hyphen, including the hyphen, would fit. Given the amount
     73        of space remaining on the line, it finds the longest prefix that can fit in the remaining space (which leaving room for
     74        the hyphen), and then checks for a hyphenation location within that prefix.
     75        (WebCore::RenderBlock::findNextLineBreak): In the 'hyphens: none' case, prevent line breaks at soft hyphens.
     76        In the 'hyphens: auto' case, try hyphenating when a word will not fit in the remaining space on the line.
     77        * rendering/RootInlineBox.cpp:
     78        (WebCore::RootInlineBox::detachEllipsisBox): Changed to use hasEllipsisBox() and setHasEllipsisBox().
     79        (WebCore::RootInlineBox::clearTruncation): Ditto.
     80        (WebCore::RootInlineBox::placeEllipsis): Ditto.
     81        (WebCore::RootInlineBox::paintEllipsisBox): Ditto.
     82        (WebCore::RootInlineBox::nodeAtPoint): Ditto.
     83        (WebCore::RootInlineBox::ellipsisBox): Ditto.
     84        * rendering/RootInlineBox.h:
     85        (WebCore::RootInlineBox::hasEllipsisBox): Added this accessor.
     86        (WebCore::RootInlineBox::setHasEllipsisBox): Ditto.
     87        * rendering/style/RenderStyle.cpp:
     88        (WebCore::RenderStyle::diff): Return a layout hint if the hyphens setting or hyphenate-character differs.
     89        (WebCore::RenderStyle::hyphenString): Added. For hyphenate-character: auto, returns the hyphen character.
     90        * rendering/style/RenderStyle.h:
     91        (WebCore::InheritedFlags::hyphens): Added this accessor.
     92        (WebCore::InheritedFlags::hyphenateCharacter): Ditto.
     93        (WebCore::InheritedFlags::setHyphens): Ditto.
     94        (WebCore::InheritedFlags::setHyphenateCharacter): Ditto.
     95        (WebCore::InheritedFlags::initialHyphens): Added. Returns HyphensManual.
     96        (WebCore::InheritedFlags::initialHyphenateCharacter): Added. Returns the null string, corresponding to
     97        a value of 'auto'.
     98        * rendering/style/RenderStyleConstants.h:
     99        Added a Hyphens enum.
     100        * rendering/style/StyleRareInheritedData.cpp:
     101        (WebCore::StyleRareInheritedData::StyleRareInheritedData): Initialize and copy the new members.
     102        (WebCore::StyleRareInheritedData::operator==): Compare the new members.
     103        * rendering/style/StyleRareInheritedData.h: Added two new members: hyphens and hyphenateCharacter.
     104
    11052010-06-03  Dimitri Glazkov  <dglazkov@chromium.org>
    2106
  • trunk/WebCore/GNUmakefile.am

    r61545 r61548  
    18081808        WebCore/platform/text/BidiResolver.h \
    18091809        WebCore/platform/text/CharacterNames.h \
     1810        WebCore/platform/text/Hyphenation.cpp \
     1811        WebCore/platform/text/Hyphenation.h \
    18101812        WebCore/platform/text/ParserUtilities.h \
    18111813        WebCore/platform/text/PlatformString.h \
  • trunk/WebCore/WebCore.base.exp

    r61438 r61548  
    10221022_wkGetGlyphTransformedAdvances
    10231023_wkGetGlyphsForCharacters
     1024_wkGetHyphenationLocationBeforeIndex
    10241025_wkGetMIMETypeForExtension
    10251026_wkGetNSURLResponseCalculatedExpiration
  • trunk/WebCore/WebCore.gypi

    r61531 r61548  
    27632763            'platform/text/BidiResolver.h',
    27642764            'platform/text/CharacterNames.h',
     2765            'platform/text/Hyphenation.cpp',
     2766            'platform/text/Hyphenation.h',
    27652767            'platform/text/ParserUtilities.h',
    27662768            'platform/text/PlatformString.h',
  • trunk/WebCore/WebCore.pro

    r61511 r61548  
    826826    platform/text/Base64.cpp \
    827827    platform/text/BidiContext.cpp \
     828    platform/text/Hyphenation.cpp \
    828829    platform/ContentType.cpp \
    829830    platform/ContextMenu.cpp \
     
    16731674    platform/text/Base64.h \
    16741675    platform/text/BidiContext.h \
     1676    platform/text/Hyphenation.h \
    16751677    platform/text/qt/TextCodecQt.h \
    16761678    platform/text/RegularExpression.h \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r61531 r61548  
    2624126241                                </File>
    2624226242                                <File
     26243                                        RelativePath="..\platform\text\Hyphentation.cpp"
     26244                                        >
     26245                                </File>
     26246                                <File
     26247                                        RelativePath="..\platform\text\Hyphenation.h"
     26248                                        >
     26249                                </File>
     26250                                <File
    2624326251                                        RelativePath="..\platform\text\ParserUtilities.h"
    2624426252                                        >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r61531 r61548  
    737737                33C0CCD4112C5E6200CE057D /* SecureTextInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33C0CCD2112C5E6200CE057D /* SecureTextInput.cpp */; };
    738738                33C0CCD5112C5E6200CE057D /* SecureTextInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 33C0CCD3112C5E6200CE057D /* SecureTextInput.h */; };
     739                371A67CB11C6C7DB00047B8B /* HyphenationCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371A67CA11C6C7DB00047B8B /* HyphenationCF.cpp */; };
    739740                371F4F400D25B9AF00ECE0D5 /* FontData.h in Headers */ = {isa = PBXBuildFile; fileRef = 371F4F3E0D25B9AF00ECE0D5 /* FontData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    740741                371F4F410D25B9AF00ECE0D5 /* FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371F4F3F0D25B9AF00ECE0D5 /* FontData.cpp */; };
     
    747748                37202199106213C600F25C4B /* FontSmoothingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 37202198106213C600F25C4B /* FontSmoothingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    748749                3744570F0DB05FA500AE0992 /* SVGGlyphMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 3744570E0DB05FA500AE0992 /* SVGGlyphMap.h */; };
     750                375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
     751                375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 375CD239119D44EA00A2A859 /* HyphenationMac.mm */; };
    749752                3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    750753                377C4CDF1014E9F600B9AE42 /* PlaceholderDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */; };
     
    63166319                33C0CCD2112C5E6200CE057D /* SecureTextInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecureTextInput.cpp; sourceTree = "<group>"; };
    63176320                33C0CCD3112C5E6200CE057D /* SecureTextInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecureTextInput.h; sourceTree = "<group>"; };
     6321                371A67CA11C6C7DB00047B8B /* HyphenationCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HyphenationCF.cpp; sourceTree = "<group>"; };
    63186322                371F4F3E0D25B9AF00ECE0D5 /* FontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontData.h; sourceTree = "<group>"; };
    63196323                371F4F3F0D25B9AF00ECE0D5 /* FontData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontData.cpp; sourceTree = "<group>"; };
     
    63266330                37202198106213C600F25C4B /* FontSmoothingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSmoothingMode.h; sourceTree = "<group>"; };
    63276331                3744570E0DB05FA500AE0992 /* SVGGlyphMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGGlyphMap.h; sourceTree = "<group>"; };
     6332                375CD231119D43C800A2A859 /* Hyphenation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hyphenation.h; sourceTree = "<group>"; };
     6333                375CD239119D44EA00A2A859 /* HyphenationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HyphenationMac.mm; sourceTree = "<group>"; };
    63286334                3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
    63296335                377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderDocument.h; sourceTree = "<group>"; };
     
    1077810784                                1C81B94D0E9732D900266E07 /* inspector */,
    1077910785                                BCB16BFB0979C38700467741 /* loader */,
    10780                                 FABE72EC1059C1EB00D999DD /* mathml */,
    1078110786                                333F703D0FB49C16008E12A6 /* notifications */,
    1078210787                                65BF02180974806300C43196 /* page */,
     
    1523515240                        isa = PBXGroup;
    1523615241                        children = (
     15242                                371A67CA11C6C7DB00047B8B /* HyphenationCF.cpp */,
    1523715243                                B2B2645A0D00A77E000ACC1D /* StringCF.cpp */,
    1523815244                                B2B2645B0D00A77E000ACC1D /* StringImplCF.cpp */,
     
    1525615262                                B2C3D9F40D006C1D00EF6F26 /* BidiResolver.h */,
    1525715263                                B2C3D9F50D006C1D00EF6F26 /* CharacterNames.h */,
     15264                                375CD231119D43C800A2A859 /* Hyphenation.h */,
    1525815265                                BC76AC110DD7AD5C00415F34 /* ParserUtilities.h */,
    1525915266                                B2C3D9FB0D006C1D00EF6F26 /* PlatformString.h */,
     
    1530315310                                B2AFFC850D00A5DF0030074D /* character-sets.txt */,
    1530415311                                B2C3D9FA0D006C1D00EF6F26 /* CharsetData.h */,
     15312                                375CD239119D44EA00A2A859 /* HyphenationMac.mm */,
    1530515313                                B2AFFC860D00A5DF0030074D /* mac-encodings.txt */,
    1530615314                                B2AFFC870D00A5DF0030074D /* make-charset-table.pl */,
     
    1571615724                        isa = PBXGroup;
    1571715725                        children = (
     15726                                FABE72EC1059C1EB00D999DD /* mathml */,
    1571815727                                1A8F6BB00DB55CDC001DB794 /* appcache */,
    1571915728                                512DD8E80D91E691000F89EE /* archive */,
     
    1686116870                                FA7EFB041120D25400CF79C7 /* RenderMathMLUnderOver.h */,
    1686216871                        );
    16863                         path = mathml;
     16872                        name = mathml;
     16873                        path = ../mathml;
    1686416874                        sourceTree = "<group>";
    1686516875                };
     
    1810518115                                514C76710CE923A1007EF3CD /* HTTPHeaderMap.h in Headers */,
    1810618116                                514C76730CE923A1007EF3CD /* HTTPParsers.h in Headers */,
     18117                                375CD232119D43C800A2A859 /* Hyphenation.h in Headers */,
    1810718118                                B275356E0B053814002CE64F /* Icon.h in Headers */,
    1810818119                                5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */,
     
    2043720448                                0B8C56D40F28627F000502E1 /* HTTPHeaderMap.cpp in Sources */,
    2043820449                                514C76720CE923A1007EF3CD /* HTTPParsers.cpp in Sources */,
     20450                                371A67CB11C6C7DB00047B8B /* HyphenationCF.cpp in Sources */,
     20451                                375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */,
    2043920452                                5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */,
    2044020453                                445C8DB710015FC90031531A /* IconDatabaseNone.cpp in Sources */,
  • trunk/WebCore/css/CSSComputedStyleDeclaration.cpp

    r60885 r61548  
    11/*
    22 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
    3  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    44 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
    55 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
     
    906906                return CSSPrimitiveValue::createIdentifier(CSSValueNone);
    907907            return CSSPrimitiveValue::create(style->highlight(), CSSPrimitiveValue::CSS_STRING);
     908        case CSSPropertyWebkitHyphens:
     909            return CSSPrimitiveValue::create(style->hyphens());
     910        case CSSPropertyWebkitHyphenateCharacter:
     911            if (style->hyphenateCharacter().isNull())
     912                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     913            return CSSPrimitiveValue::create(style->hyphenateCharacter(), CSSPrimitiveValue::CSS_STRING);
    908914        case CSSPropertyWebkitBorderFit:
    909915            if (style->borderFit() == BorderFitBorder)
  • trunk/WebCore/css/CSSParser.cpp

    r61383 r61548  
    22 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
    33 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
    4  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    55 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
    66 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
     
    15551555    case CSSPropertyWebkitHighlight:
    15561556        if (id == CSSValueNone || value->unit == CSSPrimitiveValue::CSS_STRING)
     1557            validPrimitive = true;
     1558        break;
     1559
     1560    case CSSPropertyWebkitHyphens:
     1561        if (id == CSSValueNone || id == CSSValueManual || id == CSSValueAuto)
     1562            validPrimitive = true;
     1563        break;
     1564
     1565    case CSSPropertyWebkitHyphenateCharacter:
     1566        if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
    15571567            validPrimitive = true;
    15581568        break;
  • trunk/WebCore/css/CSSPrimitiveValueMappings.h

    r60885 r61548  
    11/*
    22 * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>.
    3  * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
     3 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
    44 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
    55 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
     
    21582158}
    21592159
     2160template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Hyphens hyphens)
     2161    : m_type(CSS_IDENT)
     2162    , m_hasCachedCSSText(false)
     2163{
     2164    switch (hyphens) {
     2165    case HyphensNone:
     2166        m_value.ident = CSSValueNone;
     2167        break;
     2168    case HyphensManual:
     2169        m_value.ident = CSSValueManual;
     2170        break;
     2171    case HyphensAuto:
     2172        m_value.ident = CSSValueAuto;
     2173        break;
     2174    }
     2175}
     2176
     2177template<> inline CSSPrimitiveValue::operator Hyphens() const
     2178{
     2179    switch (m_value.ident) {
     2180    case CSSValueNone:
     2181        return HyphensNone;
     2182    case CSSValueManual:
     2183        return HyphensManual;
     2184    case CSSValueAuto:
     2185        return HyphensAuto;
     2186    default:
     2187        ASSERT_NOT_REACHED();
     2188        return HyphensAuto;
     2189    }
     2190}
     2191
    21602192#if ENABLE(SVG)
    21612193
  • trunk/WebCore/css/CSSPropertyNames.in

    r59968 r61548  
    210210-webkit-font-smoothing
    211211-webkit-highlight
     212-webkit-hyphenate-character
     213-webkit-hyphens
    212214-webkit-line-break
    213215-webkit-line-clamp
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r61383 r61548  
    51795179        else
    51805180            m_style->setHighlight(primitiveValue->getStringValue());
     5181        return;
     5182    }
     5183    case CSSPropertyWebkitHyphens: {
     5184        HANDLE_INHERIT_AND_INITIAL(hyphens, Hyphens);
     5185        m_style->setHyphens(*primitiveValue);
     5186        return;
     5187    }
     5188    case CSSPropertyWebkitHyphenateCharacter: {
     5189        HANDLE_INHERIT_AND_INITIAL(hyphenateCharacter, HyphenateCharacter);
     5190        if (primitiveValue->getIdent() == CSSValueAuto)
     5191            m_style->setHyphenateCharacter(nullAtom);
     5192        else
     5193            m_style->setHyphenateCharacter(primitiveValue->getStringValue());
    51815194        return;
    51825195    }
  • trunk/WebCore/css/CSSValueKeywords.in

    r60822 r61548  
    731731minimized
    732732windowed
     733
     734# -webkit-hyphens
     735# none
     736manual
     737# auto
  • trunk/WebCore/platform/mac/WebCoreSystemInterface.h

    r61453 r61548  
    11/*
    2  * Copyright 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
     2 * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    171171#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    172172extern NSMutableArray *(*wkNoteOpenPanelFiles)(NSArray *);
     173extern void* wkGetHyphenationLocationBeforeIndex;
    173174#else
    174175extern void* wkNoteOpenPanelFiles;
     176extern CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
    175177#endif
    176178
  • trunk/WebCore/platform/mac/WebCoreSystemInterface.mm

    r60974 r61548  
    11/*
    2  * Copyright 2006, 2007, 2008, 2010 Apple Computer, Inc. All rights reserved.
     2 * Copyright 2006, 2007, 2008, 2009, 2010 Apple Computer, Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    113113#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    114114NSMutableArray *(*wkNoteOpenPanelFiles)(NSArray *);
     115void* wkGetHyphenationLocationBeforeIndex;
    115116#else
    116117void* wkNoteOpenPanelFiles;
     118CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
    117119#endif
  • trunk/WebCore/platform/text/CharacterNames.h

    r60063 r61548  
    4343const UChar hebrewPunctuationGershayim = 0x05F4;
    4444const UChar horizontalEllipsis = 0x2026;
     45const UChar hyphen = 0x2010;
    4546const UChar hyphenMinus = 0x002D;
    4647const UChar ideographicComma = 0x3001;
  • trunk/WebCore/rendering/BidiRun.h

    r54665 r61548  
    3939        , m_object(object)
    4040        , m_box(0)
     41        , m_hasHyphen(false)
    4142    {
    4243    }
     
    5960    RenderObject* m_object;
    6061    InlineBox* m_box;
     62    bool m_hasHyphen;
    6163};
    6264
  • trunk/WebCore/rendering/InlineBox.h

    r61393 r61548  
    5454        , m_endsWithBreak(false)
    5555        , m_hasSelectedChildren(false)
    56         , m_hasEllipsisBox(false)
     56        , m_hasEllipsisBoxOrHyphen(false)
    5757        , m_dirOverride(false)
    5858        , m_isText(false)
     
    8787        , m_endsWithBreak(false)
    8888        , m_hasSelectedChildren(false)   
    89         , m_hasEllipsisBox(false)
     89        , m_hasEllipsisBoxOrHyphen(false)
    9090        , m_dirOverride(false)
    9191        , m_isText(false)
     
    285285    bool m_endsWithBreak : 1;  // Whether the line ends with a <br>.
    286286    bool m_hasSelectedChildren : 1; // Whether we have any children selected (this bit will also be set if the <br> that terminates our line is selected).
    287     bool m_hasEllipsisBox : 1;
     287    bool m_hasEllipsisBoxOrHyphen : 1;
    288288
    289289    // for InlineTextBox
  • trunk/WebCore/rendering/InlineTextBox.cpp

    r60753 r61548  
    22 * (C) 1999 Lars Knoll (knoll@kde.org)
    33 * (C) 2000 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    104104}
    105105
     106typedef Vector<UChar, 256> BufferForAppendingHyphen;
     107
     108static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, RenderStyle* style, const UChar*& characters, int& length)
     109{
     110    const AtomicString& hyphenString = style->hyphenString();
     111    charactersWithHyphen.reserveCapacity(length + hyphenString.length());
     112    charactersWithHyphen.append(characters, length);
     113    charactersWithHyphen.append(hyphenString.characters(), hyphenString.length());
     114    characters = charactersWithHyphen.data();
     115    length += hyphenString.length();
     116}
     117
    106118IntRect InlineTextBox::selectionRect(int tx, int ty, int startPos, int endPos)
    107119{
     
    115127    int selTop = selectionTop();
    116128    int selHeight = selectionHeight();
    117     const Font& f = textObj->style(m_firstLine)->font();
    118 
    119     IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(textObj->text()->characters() + m_start, m_len, textObj->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride),
     129    RenderStyle* styleToUse = textObj->style(m_firstLine);
     130    const Font& f = styleToUse->font();
     131
     132    const UChar* characters = textObj->text()->characters() + m_start;
     133    int len = m_len;
     134    BufferForAppendingHyphen charactersWithHyphen;
     135    if (ePos == len && hasHyphen()) {
     136        adjustCharactersAndLengthForHyphen(charactersWithHyphen, styleToUse, characters, len);
     137        ePos = len;
     138    }
     139
     140    IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(characters, len, textObj->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride),
    120141                                                        IntPoint(tx + m_x, ty + selTop), selHeight, sPos, ePos));
    121142    if (r.x() > tx + m_x + m_width)
     
    465486    }
    466487
     488    const UChar* characters = textRenderer()->text()->characters() + m_start;
     489    int length = m_len;
     490    BufferForAppendingHyphen charactersWithHyphen;
     491    if (hasHyphen())
     492        adjustCharactersAndLengthForHyphen(charactersWithHyphen, styleToUse, characters, length);
     493
    467494    int baseline = renderer()->style(m_firstLine)->font().ascent();
    468495    IntPoint textOrigin(m_x + tx, m_y + ty + baseline);
    469     TextRun textRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride || styleToUse->visuallyOrdered());
     496    TextRun textRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride || styleToUse->visuallyOrdered());
    470497
    471498    int sPos = 0;
     
    474501        selectionStartEnd(sPos, ePos);
    475502
    476     int length = m_len;
    477503    if (m_truncation != cNoTruncation) {
    478504        sPos = min<int>(sPos, m_truncation);
     
    589615    // draw its own highlight.
    590616    int length = m_truncation != cNoTruncation ? m_truncation : m_len;
     617    const UChar* characters = textRenderer()->text()->characters() + m_start;
     618
     619    BufferForAppendingHyphen charactersWithHyphen;
     620    if (ePos == length && hasHyphen()) {
     621        adjustCharactersAndLengthForHyphen(charactersWithHyphen, style, characters, length);
     622        ePos = length;
     623    }
     624
    591625    context->clip(IntRect(m_x + tx, y + ty, m_width, h));
    592     context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, length, textRenderer()->allowTabs(), textPos(), m_toAdd,
     626    context->drawHighlightForText(font, TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd,
    593627                                  direction() == RTL, m_dirOverride || style->visuallyOrdered()),
    594628                                  IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
  • trunk/WebCore/rendering/InlineTextBox.h

    r61393 r61548  
    6565
    6666    unsigned short truncation() { return m_truncation; }
     67
     68    bool hasHyphen() const { return m_hasEllipsisBoxOrHyphen; }
     69    void setHasHyphen(bool hasHyphen) { m_hasEllipsisBoxOrHyphen = hasHyphen; }
    6770
    6871private:
  • trunk/WebCore/rendering/RenderBlock.h

    r61393 r61548  
    308308    int skipLeadingWhitespace(InlineBidiResolver&, bool firstLine, bool isLineEmpty, bool previousLineBrokeCleanly);
    309309    void fitBelowFloats(int widthToFit, bool firstLine, int& availableWidth);
    310     InlineIterator findNextLineBreak(InlineBidiResolver&, bool firstLine, bool& isLineEmpty, bool& previousLineBrokeCleanly, EClear* clear = 0);
     310    InlineIterator findNextLineBreak(InlineBidiResolver&, bool firstLine, bool& isLineEmpty, bool& previousLineBrokeCleanly, bool& hyphenated, EClear* = 0);
    311311    RootInlineBox* constructLine(unsigned runCount, BidiRun* firstRun, BidiRun* lastRun, bool firstLine, bool lastLine, RenderObject* endObject);
    312312    InlineFlowBox* createLineBoxes(RenderObject*, bool firstLine);
  • trunk/WebCore/rendering/RenderBlockLineLayout.cpp

    r61393 r61548  
    2525#include "BidiResolver.h"
    2626#include "CharacterNames.h"
     27#include "Hyphenation.h"
    2728#include "InlineIterator.h"
    2829#include "InlineTextBox.h"
     
    296297            text->setLen(r->m_stop - r->m_start);
    297298            text->m_dirOverride = r->dirOverride(visuallyOrdered);
     299            if (r->m_hasHyphen)
     300                text->setHasHyphen(true);
    298301        }
    299302    }
     
    350353            GlyphOverflow glyphOverflow;
    351354            r->m_box->setWidth(rt->width(r->m_start, r->m_stop - r->m_start, totWidth, firstLine, &fallbackFonts, &glyphOverflow));
     355            int hyphenWidth = 0;
     356            if (static_cast<InlineTextBox*>(r->m_box)->hasHyphen()) {
     357                const AtomicString& hyphenString = rt->style()->hyphenString();
     358                hyphenWidth = rt->style(firstLine)->font().width(TextRun(hyphenString.characters(), hyphenString.length()));
     359            }
     360            r->m_box->setWidth(rt->width(r->m_start, r->m_stop - r->m_start, totWidth, firstLine, &fallbackFonts, &glyphOverflow) + hyphenWidth);
    352361            if (!fallbackFonts.isEmpty()) {
    353362                ASSERT(r->m_box->isText());
     
    669678           
    670679            EClear clear = CNONE;
    671             end = findNextLineBreak(resolver, firstLine, isLineEmpty, previousLineBrokeCleanly, &clear);
     680            bool hyphenated;
     681            end = findNextLineBreak(resolver, firstLine, isLineEmpty, previousLineBrokeCleanly, hyphenated, &clear);
    672682            if (resolver.position().atEnd()) {
    673683                resolver.deleteRuns();
     
    735745                RootInlineBox* lineBox = 0;
    736746                if (resolver.runCount()) {
     747                    if (hyphenated)
     748                        resolver.logicallyLastRun()->m_hasHyphen = true;
    737749                    lineBox = constructLine(resolver.runCount(), resolver.firstRun(), resolver.lastRun(), firstLine, !end.obj, end.obj && !end.pos ? end.obj : 0);
    738750                    if (lineBox) {
     
    13181330}
    13191331
     1332static 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)
     1333{
     1334    const AtomicString& hyphenString = text->style()->hyphenString();
     1335    int hyphenWidth = font.width(TextRun(hyphenString.characters(), hyphenString.length()));
     1336
     1337    unsigned prefixLength = font.offsetForPosition(TextRun(text->characters() + lastSpace, pos - lastSpace, !collapseWhiteSpace, xPos + lastSpaceWordSpacing), availableWidth - xPos - hyphenWidth - lastSpaceWordSpacing, false);
     1338    if (!prefixLength)
     1339        return;
     1340
     1341    prefixLength = 1 + lastHyphenLocation(text->characters() + lastSpace + 1, pos - lastSpace - 1, prefixLength - 1);
     1342    if (prefixLength <= 1)
     1343        return;
     1344
     1345#if !ASSERT_DISABLED
     1346    int prefixWidth = hyphenWidth + textWidth(text, lastSpace, prefixLength, font, xPos, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
     1347    ASSERT(xPos + prefixWidth <= availableWidth);
     1348#endif
     1349
     1350    lineBreak.obj = text;
     1351    lineBreak.pos = lastSpace + prefixLength;
     1352    lineBreak.nextBreakablePosition = nextBreakable;
     1353    hyphenated = true;
     1354}
     1355
    13201356InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool firstLine,  bool& isLineEmpty, bool& previousLineBrokeCleanly,
    1321                                               EClear* clear)
     1357                                              bool& hyphenated, EClear* clear)
    13221358{
    13231359    ASSERT(resolver.position().block == this);
     
    13561392    bool prevLineBrokeCleanly = previousLineBrokeCleanly;
    13571393    previousLineBrokeCleanly = false;
     1394
     1395    hyphenated = false;
    13581396
    13591397    bool autoWrapWasEverTrueOnLine = false;
     
    15301568            const UChar* str = t->characters();
    15311569
    1532             const Font& f = t->style(firstLine)->font();
     1570            RenderStyle* style = t->style(firstLine);
     1571            const Font& f = style->font();
    15331572            bool isFixedPitch = f.isFixedPitch();
     1573            bool canHyphenate = style->hyphens() == HyphensAuto;
    15341574
    15351575            int lastSpace = pos;
     
    16011641                    lastSpaceWordSpacing = 0;
    16021642                    lastSpace = pos; // Cheesy hack to prevent adding in widths of the run twice.
     1643                    if (style->hyphens() == HyphensNone) {
     1644                        // Prevent a line break at the soft hyphen by ensuring that betweenWords is false
     1645                        // in the next iteration.
     1646                        atStart = true;
     1647                    }
    16031648                    continue;
    16041649                }
     
    16701715                            }
    16711716                        }
     1717                        if (canHyphenate && w + tmpW > width) {
     1718                            tryHyphenating(t, f, lastSpace, pos, w + tmpW - additionalTmpW, width, isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
     1719                            if (hyphenated)
     1720                                goto end;
     1721                        }
    16721722                        if (lineWasTooWide || w + tmpW > width) {
    16731723                            if (lBreak.obj && shouldPreserveNewline(lBreak.obj) && lBreak.obj->isText() && toRenderText(lBreak.obj)->textLength() && !toRenderText(lBreak.obj)->isWordBreak() && toRenderText(lBreak.obj)->characters()[lBreak.pos] == '\n') {
     
    17761826
    17771827            // IMPORTANT: pos is > length here!
    1778             if (!ignoringSpaces)
    1779                 tmpW += textWidth(t, lastSpace, pos - lastSpace, f, w + tmpW, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
     1828            int additionalTmpW = ignoringSpaces ? 0 : textWidth(t, lastSpace, pos - lastSpace, f, w + tmpW, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
     1829            tmpW += additionalTmpW;
    17801830            tmpW += inlineWidth(o, !appliedStartWidth, true);
     1831
     1832            if (canHyphenate && w + tmpW > width) {
     1833                tryHyphenating(t, f, lastSpace, pos, w + tmpW - additionalTmpW, width, isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
     1834                if (hyphenated)
     1835                    goto end;
     1836            }
    17811837        } else
    17821838            ASSERT_NOT_REACHED();
  • trunk/WebCore/rendering/RootInlineBox.cpp

    r61393 r61548  
    4848void RootInlineBox::detachEllipsisBox(RenderArena* arena)
    4949{
    50     if (m_hasEllipsisBox) {
     50    if (hasEllipsisBox()) {
    5151        EllipsisBox* box = gEllipsisBoxMap->take(this);
    5252        box->setParent(0);
    5353        box->destroy(arena);
    54         m_hasEllipsisBox = false;
     54        setHasEllipsisBox(false);
    5555    }
    5656}
     
    6363void RootInlineBox::clearTruncation()
    6464{
    65     if (m_hasEllipsisBox) {
     65    if (hasEllipsisBox()) {
    6666        detachEllipsisBox(renderer()->renderArena());
    6767        InlineFlowBox::clearTruncation();
     
    9393        gEllipsisBoxMap = new EllipsisBoxMap();
    9494    gEllipsisBoxMap->add(this, ellipsisBox);
    95     m_hasEllipsisBox = true;
     95    setHasEllipsisBox(true);
    9696
    9797    // FIXME: Do we need an RTL version of this?
     
    118118void RootInlineBox::paintEllipsisBox(RenderObject::PaintInfo& paintInfo, int tx, int ty) const
    119119{
    120     if (m_hasEllipsisBox && renderer()->shouldPaintWithinRoot(paintInfo) && renderer()->style()->visibility() == VISIBLE &&
    121             paintInfo.phase == PaintPhaseForeground)
     120    if (hasEllipsisBox() && renderer()->shouldPaintWithinRoot(paintInfo) && renderer()->style()->visibility() == VISIBLE
     121            && paintInfo.phase == PaintPhaseForeground)
    122122        ellipsisBox()->paint(paintInfo, tx, ty);
    123123}
     
    175175bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty)
    176176{
    177     if (m_hasEllipsisBox && visibleToHitTesting()) {
     177    if (hasEllipsisBox() && visibleToHitTesting()) {
    178178        if (ellipsisBox()->nodeAtPoint(request, result, x, y, tx, ty)) {
    179179            renderer()->updateHitTestResult(result, IntPoint(x - tx, y - ty));
     
    417417EllipsisBox* RootInlineBox::ellipsisBox() const
    418418{
    419     if (!m_hasEllipsisBox)
     419    if (!hasEllipsisBox())
    420420        return 0;
    421421    return gEllipsisBoxMap->get(this);
  • trunk/WebCore/rendering/RootInlineBox.h

    r61393 r61548  
    129129    virtual void removeLineBoxFromRenderObject();
    130130
    131 protected:
     131private:
     132    bool hasEllipsisBox() const { return m_hasEllipsisBoxOrHyphen; }
     133    void setHasEllipsisBox(bool hasEllipsisBox) { m_hasEllipsisBoxOrHyphen = hasEllipsisBox; }
     134
    132135    // Where this line ended.  The exact object and the position within that object are stored so that
    133136    // we can create an InlineIterator beginning just after the end of this line.
  • trunk/WebCore/rendering/style/RenderStyle.cpp

    r61099 r61548  
    11/*
    22 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
    3  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    387387            rareInheritedData->nbspMode != other->rareInheritedData->nbspMode ||
    388388            rareInheritedData->khtmlLineBreak != other->rareInheritedData->khtmlLineBreak ||
    389             rareInheritedData->textSecurity != other->rareInheritedData->textSecurity)
     389            rareInheritedData->textSecurity != other->rareInheritedData->textSecurity ||
     390            rareInheritedData->hyphens != other->rareInheritedData->hyphens ||
     391            rareInheritedData->hyphenateCharacter != other->rareInheritedData->hyphenateCharacter)
    390392            return StyleDifferenceLayout;
    391393
     
    803805}
    804806
     807const AtomicString& RenderStyle::hyphenString() const
     808{
     809    ASSERT(hyphens() == HyphensAuto);
     810
     811    const AtomicString& hyphenateCharacter = rareInheritedData.get()->hyphenateCharacter;
     812    if (!hyphenateCharacter.isNull())
     813        return hyphenateCharacter;
     814
     815    // FIXME: This should depend on locale.
     816    DEFINE_STATIC_LOCAL(AtomicString, hyphenMinusString, (&hyphen, 1));
     817    return hyphenMinusString;
     818}
     819
    805820#if ENABLE(DASHBOARD_SUPPORT)
    806821const Vector<StyleDashboardRegion>& RenderStyle::initialDashboardRegions()
  • trunk/WebCore/rendering/style/RenderStyle.h

    r61295 r61548  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    77 *
     
    648648    EMatchNearestMailBlockquoteColor matchNearestMailBlockquoteColor() const { return static_cast<EMatchNearestMailBlockquoteColor>(rareNonInheritedData->matchNearestMailBlockquoteColor); }
    649649    const AtomicString& highlight() const { return rareInheritedData->highlight; }
     650    Hyphens hyphens() const { return static_cast<Hyphens>(rareInheritedData->hyphens); }
     651    const AtomicString& hyphenateCharacter() const { return rareInheritedData->hyphenateCharacter; }
    650652    EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
    651653    EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); }
     
    980982    void setMatchNearestMailBlockquoteColor(EMatchNearestMailBlockquoteColor c) { SET_VAR(rareNonInheritedData, matchNearestMailBlockquoteColor, c); }
    981983    void setHighlight(const AtomicString& h) { SET_VAR(rareInheritedData, highlight, h); }
     984    void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); }
     985    void setHyphenateCharacter(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenateCharacter, h); }
    982986    void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
    983987    void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); }
     
    10581062    const CounterDirectiveMap* counterDirectives() const;
    10591063    CounterDirectiveMap& accessCounterDirectives();
     1064
     1065    const AtomicString& hyphenString() const;
    10601066
    10611067    bool inheritedNotEqual(const RenderStyle*) const;
     
    11821188    static EMatchNearestMailBlockquoteColor initialMatchNearestMailBlockquoteColor() { return BCNORMAL; }
    11831189    static const AtomicString& initialHighlight() { return nullAtom; }
     1190    static Hyphens initialHyphens() { return HyphensManual; }
     1191    static const AtomicString& initialHyphenateCharacter() { return nullAtom; }
    11841192    static EBorderFit initialBorderFit() { return BorderFitBorder; }
    11851193    static EResize initialResize() { return RESIZE_NONE; }
  • trunk/WebCore/rendering/style/RenderStyleConstants.h

    r61376 r61548  
    407407enum ELineClampType { LineClampLineCount, LineClampPercentage };
    408408
     409enum Hyphens { HyphensNone, HyphensManual, HyphensAuto };
     410
    409411} // namespace WebCore
    410412
  • trunk/WebCore/rendering/style/StyleRareInheritedData.cpp

    r59629 r61548  
    11/*
    22 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
    3  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    4545    , userSelect(RenderStyle::initialUserSelect())
    4646    , colorSpace(DeviceColorSpace)
     47    , hyphens(HyphensManual)
    4748{
    4849}
     
    7071    , userSelect(o.userSelect)
    7172    , colorSpace(o.colorSpace)
     73    , hyphens(o.hyphens)
     74    , hyphenateCharacter(o.hyphenateCharacter)
    7275{
    7376}
     
    108111        && resize == o.resize
    109112        && userSelect == o.userSelect
    110         && colorSpace == o.colorSpace;
     113        && colorSpace == o.colorSpace
     114        && hyphens == o.hyphens
     115        && hyphenateCharacter == o.hyphenateCharacter;
    111116}
    112117
  • trunk/WebCore/rendering/style/StyleRareInheritedData.h

    r59629 r61548  
    7878    unsigned userSelect : 1;  // EUserSelect
    7979    unsigned colorSpace : 1; // ColorSpace
    80    
     80    unsigned hyphens : 2; // Hyphens
     81
     82    AtomicString hyphenateCharacter;
     83
    8184private:
    8285    StyleRareInheritedData();
  • trunk/WebKit/mac/ChangeLog

    r61545 r61548  
     12010-06-21  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        WebKit part of implementing the 'hyphens' and 'hyphenate-character' properties
     6        https://bugs.webkit.org/show_bug.cgi?id=10228
     7
     8        * WebCoreSupport/WebSystemInterface.mm:
     9        (InitWebCoreSystemInterface): Initialize wkGetHyphenationLocationBeforeIndex.
     10
    1112010-06-21  Satish Sampath  <satish@chromium.org>
    212
  • trunk/WebKit/mac/WebCoreSupport/WebSystemInterface.mm

    r61453 r61548  
    11/*
    2  * Copyright 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     2 * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    116116#endif
    117117
     118    INIT(GetHyphenationLocationBeforeIndex);
     119
    118120    didInit = true;
    119121}
  • trunk/WebKitLibraries/ChangeLog

    r61545 r61548  
     12010-06-21  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        WebKitSystemInterface part of CSS3: Implement the 'hyphens' and 'hyphenate-character' properties
     6        https://bugs.webkit.org/show_bug.cgi?id=10228
     7
     8        * WebKitSystemInterface.h: Added WKGetHyphenationLocationBeforeIndex().
     9        * libWebKitSystemInterfaceLeopard.a:
     10        * libWebKitSystemInterfaceSnowLeopard.a:
     11        * libWebKitSystemInterfaceTiger.a:
     12
    1132010-06-21  Satish Sampath  <satish@chromium.org>
    214
  • trunk/WebKitLibraries/WebKitSystemInterface.h

    r60978 r61548  
    301301#endif
    302302
     303CFIndex WKGetHyphenationLocationBeforeIndex(CFStringRef string, CFIndex index);
     304
    303305#ifdef __cplusplus
    304306}
Note: See TracChangeset for help on using the changeset viewer.