WebCore: CSS3: Implement the 'hyphens' and 'hyphenate-character' properties
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jun 2010 16:54:52 +0000 (16:54 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jun 2010 16:54:52 +0000 (16:54 +0000)
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:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@61548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

54 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/hyphenate-character.html [new file with mode: 0644]
LayoutTests/fast/text/hyphens.html [new file with mode: 0644]
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/fast/text/hyphenate-character-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/hyphenate-character-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/hyphenate-character-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/hyphens-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/hyphens-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/hyphens-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
WebCore/Android.mk
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.base.exp
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSParser.cpp
WebCore/css/CSSPrimitiveValueMappings.h
WebCore/css/CSSPropertyNames.in
WebCore/css/CSSStyleSelector.cpp
WebCore/css/CSSValueKeywords.in
WebCore/platform/mac/WebCoreSystemInterface.h
WebCore/platform/mac/WebCoreSystemInterface.mm
WebCore/platform/text/CharacterNames.h
WebCore/platform/text/Hyphenation.cpp [new file with mode: 0644]
WebCore/platform/text/Hyphenation.h [new file with mode: 0644]
WebCore/platform/text/cf/HyphenationCF.cpp [new file with mode: 0644]
WebCore/platform/text/mac/HyphenationMac.mm [new file with mode: 0644]
WebCore/rendering/BidiRun.h
WebCore/rendering/InlineBox.h
WebCore/rendering/InlineTextBox.cpp
WebCore/rendering/InlineTextBox.h
WebCore/rendering/RenderBlock.h
WebCore/rendering/RenderBlockLineLayout.cpp
WebCore/rendering/RootInlineBox.cpp
WebCore/rendering/RootInlineBox.h
WebCore/rendering/style/RenderStyle.cpp
WebCore/rendering/style/RenderStyle.h
WebCore/rendering/style/RenderStyleConstants.h
WebCore/rendering/style/StyleRareInheritedData.cpp
WebCore/rendering/style/StyleRareInheritedData.h
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebSystemInterface.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a
WebKitLibraries/libWebKitSystemInterfaceTiger.a

index b155ef2fd742b99d640ce8c5425610ffc4b1796f..23ad1fd9bcd819b41a0f8c5807d37aec87936283 100644 (file)
@@ -1,3 +1,22 @@
+2010-06-21  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Added tests for the 'hyphens' and 'hyphenate-character' properties
+        https://bugs.webkit.org/show_bug.cgi?id=10228
+
+        * 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:
+
 2010-06-21  Dumitru Daniliuc  <dumi@chromium.org>
 
         Unreviewed, fixing expectations.
diff --git a/LayoutTests/fast/text/hyphenate-character.html b/LayoutTests/fast/text/hyphenate-character.html
new file mode 100644 (file)
index 0000000..857f4f6
--- /dev/null
@@ -0,0 +1,83 @@
+<style>
+    .text-box {
+        border: solid;
+        padding: 4px;
+        width: 330px;
+        font-size: 18px;
+        text-align: justify;
+        -webkit-hyphens: auto;
+    }
+
+    .float {
+        width: 75px;
+        height: 5em;
+        background-color: aliceblue;
+        float: right;
+        margin-left: 10px;
+    }
+
+    .hyphenate-character-auto {
+        -webkit-hyphenate-character: auto;
+    }
+
+    .hyphenate-character-bullet {
+        -webkit-hyphenate-character: "\2022";
+    }
+
+    .hyphenate-character-tilde-dot {
+        -webkit-hyphenate-character: "\B7~";
+    }
+
+    .test {
+        float: left;
+        margin: 0 4px;
+    }
+</style>
+<div class="test">
+    <p>The initial value (should be like <tt>auto</tt>)</p>
+    <div class="text-box">
+        <div class="float"></div>
+        The chief difficulty Alice found at first was in managing her
+        flamingo: she succeeded in getting its body tucked away,
+        comfortably enough, under her arm, with its legs hanging down,
+        but generally, just as she had got its neck nicely straightened
+        out, and was going to give the hedgehog a blow with its head, it
+        would twist itself round and look up in her face&#x2026;
+    </div>
+</div>
+<div class="test">
+    <p>The default (<tt>hyphenate-character: auto</tt>)</p>
+    <div class="text-box hyphenate-character-auto">
+        <div class="float"></div>
+        The chief difficulty Alice found at first was in managing her
+        flamingo: she succeeded in getting its body tucked away,
+        comfortably enough, under her arm, with its legs hanging down,
+        but generally, just as she had got its neck nicely straightened
+        out, and was going to give the hedgehog a blow with its head, it
+        would twist itself round and look up in her face&#x2026;
+    </div>
+</div>
+<div class="test">
+    <p>Bullet (<tt>hyphenate-character: "\2022"</tt>)</p>
+    <div class="text-box hyphenate-character-bullet">
+        <div class="float"></div>
+        The chief difficulty Alice found at first was in managing her
+        flamingo: she succeeded in getting its body tucked away,
+        comfortably enough, under her arm, with its legs hanging down,
+        but generally, just as she had got its neck nicely straightened
+        out, and was going to give the hedgehog a blow with its head, it
+        would twist itself round and look up in her face&#x2026;
+    </div>
+</div>
+<div class="test">
+    <p>Middle dot and tilde (<tt>hyphenate-character: "\B7~"</tt>)</p>
+    <div class="text-box hyphenate-character-tilde-dot">
+        <div class="float"></div>
+        The chief difficulty Alice found at first was in managing her
+        flamingo: she succeeded in getting its body tucked away,
+        comfortably enough, under her arm, with its legs hanging down,
+        but generally, just as she had got its neck nicely straightened
+        out, and was going to give the hedgehog a blow with its head, it
+        would twist itself round and look up in her face&#x2026;
+    </div>
+</div>
diff --git a/LayoutTests/fast/text/hyphens.html b/LayoutTests/fast/text/hyphens.html
new file mode 100644 (file)
index 0000000..e14e1f4
--- /dev/null
@@ -0,0 +1,77 @@
+<style>
+    .text-box {
+        border: solid;
+        padding: 4px;
+        width: 330px;
+        font-size: 18px;
+        text-align: justify;
+    }
+
+    .float {
+        width: 75px;
+        height: 5em;
+        background-color: aliceblue;
+        float: right;
+        margin-left: 10px;
+    }
+
+    .hyphens-auto {
+        -webkit-hyphens: auto;
+    }
+
+    .hyphens-none {
+        -webkit-hyphens: none;
+    }
+
+    .test {
+        float: left;
+        margin: 0 4px;
+    }
+</style>
+<div class="test">
+    <p><tt>hyphens: manual</tt> without soft hyphens</p>
+    <div class="text-box">
+        <div class="float"></div>
+        The chief difficulty Alice found at first was in managing her
+        flamingo: she succeeded in getting its body tucked away,
+        comfortably enough, under her arm, with its legs hanging down,
+        but generally, just as she had got its neck nicely straightened
+        out, and was going to give the hedgehog a blow with its head, it
+        would twist itself round and look up in her face&#x2026;
+    </div>
+</div>
+<div class="test">
+    <p><tt>hyphens: none</tt> with soft hyphens</p>
+    <div class="text-box hyphens-none">
+        <div class="float"></div>
+        The chief difficulty Alice found at first was in managing her
+        flamingo: she succeeded in get&shy;ting its body tucked away, com&shy;fortably enough, under her arm, with its legs hanging down,
+        but generally, just as she had got its neck nicely straight&shy;ened
+        out, and was going to give the hedge&shy;hog a blow with its head, it
+        would twist itself round and look up in her face&#x2026;
+    </div>
+</div>
+<div class="test">
+    <p><tt>hyphens: manual</tt> with soft hyphens</p>
+    <div class="text-box">
+        <div class="float"></div>
+        The chief difficulty Alice found at first was in managing her
+        flamingo: she succeeded in get&shy;ting its body tucked away,
+        com&shy;fortably enough, under her arm, with its legs hanging down,
+        but generally, just as she had got its neck nicely straight&shy;ened
+        out, and was going to give the hedge&shy;hog a blow with its head, it
+        would twist itself round and look up in her face&#x2026;
+    </div>
+</div>
+<div class="test">
+    <p><tt>hyphens: auto</tt> without soft hyphens</p>
+    <div class="text-box hyphens-auto">
+        <div class="float"></div>
+        The chief difficulty Alice found at first was in managing her
+        flamingo: she succeeded in getting its body tucked away,
+        comfortably enough, under her arm, with its legs hanging down,
+        but generally, just as she had got its neck nicely straightened
+        out, and was going to give the hedgehog a blow with its head, it
+        would twist itself round and look up in her face&#x2026;
+    </div>
+</div>
index f8336c7b42a8b7b46a49a617d8bcb8cd804d71e9..bd2451f746999082e5f4c36f6fbb814683e458db 100644 (file)
@@ -3124,6 +3124,10 @@ fast/text/basic/generic-family-reset.html
 fast/text/firstline/001.html
 fast/text/firstline/002.html
 fast/text/firstline/003.html
+# Hyphenation is not implemented yet.
+fast/text/hyphenate-character.html
+fast/text/hyphens.html
+
 fast/text/international/001.html
 fast/text/international/002.html
 fast/text/international/003.html
diff --git a/LayoutTests/platform/mac/fast/text/hyphenate-character-expected.checksum b/LayoutTests/platform/mac/fast/text/hyphenate-character-expected.checksum
new file mode 100644 (file)
index 0000000..09d2569
--- /dev/null
@@ -0,0 +1 @@
+1f42877e5a7db832962fe26284932bc5
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/text/hyphenate-character-expected.png b/LayoutTests/platform/mac/fast/text/hyphenate-character-expected.png
new file mode 100644 (file)
index 0000000..10af598
Binary files /dev/null and b/LayoutTests/platform/mac/fast/text/hyphenate-character-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/text/hyphenate-character-expected.txt b/LayoutTests/platform/mac/fast/text/hyphenate-character-expected.txt
new file mode 100644 (file)
index 0000000..1171f28
--- /dev/null
@@ -0,0 +1,109 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock (floating) {DIV} at (4,0) size 344x284
+        RenderBlock {P} at (0,16) size 344x18
+          RenderText {#text} at (0,0) size 203x18
+            text run at (0,0) width 203: "The initial value (should be like "
+          RenderInline {TT} at (0,0) size 32x15
+            RenderText {#text} at (203,2) size 32x15
+              text run at (203,2) width 32: "auto"
+          RenderText {#text} at (235,0) size 5x18
+            text run at (235,0) width 5: ")"
+        RenderBlock {DIV} at (0,50) size 344x234 [border: (3px solid #000000)]
+          RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF]
+          RenderText {#text} at (7,7) size 330x220
+            text run at (7,7) width 245: "The chief difficulty Alice found"
+            text run at (7,29) width 245: "at first was in managing her"
+            text run at (7,51) width 245: "flamingo: she succeeded in get"
+            text run at (7,73) width 208: "ting its body tucked away, "
+            text run at (215,73) width 37: "com"
+            text run at (7,95) width 245: "fortably enough, under her arm,"
+            text run at (7,117) width 226: "with its legs hanging down, "
+            text run at (233,117) width 104: "but generally,"
+            text run at (7,139) width 330: "just as she had got its neck nicely straight"
+            text run at (7,161) width 41: "ened "
+            text run at (48,161) width 289: "out, and was going to give the hedge"
+            text run at (7,183) width 204: "hog a blow with its head, it "
+            text run at (211,183) width 126: "would twist itself"
+            text run at (7,205) width 233: "round and look up in her face\x{2026}"
+      RenderBlock (floating) {DIV} at (356,0) size 344x284
+        RenderBlock {P} at (0,16) size 344x18
+          RenderText {#text} at (0,0) size 81x18
+            text run at (0,0) width 81: "The default ("
+          RenderInline {TT} at (0,0) size 200x15
+            RenderText {#text} at (81,2) size 200x15
+              text run at (81,2) width 200: "hyphenate-character: auto"
+          RenderText {#text} at (281,0) size 5x18
+            text run at (281,0) width 5: ")"
+        RenderBlock {DIV} at (0,50) size 344x234 [border: (3px solid #000000)]
+          RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF]
+          RenderText {#text} at (7,7) size 330x220
+            text run at (7,7) width 245: "The chief difficulty Alice found"
+            text run at (7,29) width 245: "at first was in managing her"
+            text run at (7,51) width 245: "flamingo: she succeeded in get"
+            text run at (7,73) width 208: "ting its body tucked away, "
+            text run at (215,73) width 37: "com"
+            text run at (7,95) width 245: "fortably enough, under her arm,"
+            text run at (7,117) width 226: "with its legs hanging down, "
+            text run at (233,117) width 104: "but generally,"
+            text run at (7,139) width 330: "just as she had got its neck nicely straight"
+            text run at (7,161) width 41: "ened "
+            text run at (48,161) width 289: "out, and was going to give the hedge"
+            text run at (7,183) width 204: "hog a blow with its head, it "
+            text run at (211,183) width 126: "would twist itself"
+            text run at (7,205) width 233: "round and look up in her face\x{2026}"
+      RenderBlock (floating) {DIV} at (4,284) size 344x284
+        RenderBlock {P} at (0,16) size 344x18
+          RenderText {#text} at (0,0) size 47x18
+            text run at (0,0) width 47: "Bullet ("
+          RenderInline {TT} at (0,0) size 224x15
+            RenderText {#text} at (47,2) size 224x15
+              text run at (47,2) width 224: "hyphenate-character: \"\\2022\""
+          RenderText {#text} at (271,0) size 5x18
+            text run at (271,0) width 5: ")"
+        RenderBlock {DIV} at (0,50) size 344x234 [border: (3px solid #000000)]
+          RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF]
+          RenderText {#text} at (7,7) size 330x220
+            text run at (7,7) width 245: "The chief difficulty Alice found"
+            text run at (7,29) width 245: "at first was in managing her"
+            text run at (7,51) width 245: "flamingo: she succeeded in get"
+            text run at (7,73) width 208: "ting its body tucked away, "
+            text run at (215,73) width 37: "com"
+            text run at (7,95) width 245: "fortably enough, under her arm,"
+            text run at (7,117) width 226: "with its legs hanging down, "
+            text run at (233,117) width 104: "but generally,"
+            text run at (7,139) width 330: "just as she had got its neck nicely straight"
+            text run at (7,161) width 41: "ened "
+            text run at (48,161) width 289: "out, and was going to give the hedge"
+            text run at (7,183) width 204: "hog a blow with its head, it "
+            text run at (211,183) width 126: "would twist itself"
+            text run at (7,205) width 233: "round and look up in her face\x{2026}"
+      RenderBlock (floating) {DIV} at (356,284) size 357x284
+        RenderBlock {P} at (0,16) size 357x18
+          RenderText {#text} at (0,0) size 136x18
+            text run at (0,0) width 136: "Middle dot and tilde ("
+          RenderInline {TT} at (0,0) size 216x15
+            RenderText {#text} at (136,2) size 216x15
+              text run at (136,2) width 216: "hyphenate-character: \"\\B7~\""
+          RenderText {#text} at (352,0) size 5x18
+            text run at (352,0) width 5: ")"
+        RenderBlock {DIV} at (0,50) size 344x234 [border: (3px solid #000000)]
+          RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF]
+          RenderText {#text} at (7,7) size 330x220
+            text run at (7,7) width 245: "The chief difficulty Alice found"
+            text run at (7,29) width 245: "at first was in managing her"
+            text run at (7,51) width 245: "flamingo: she succeeded in get"
+            text run at (7,73) width 199: "ting its body tucked away, "
+            text run at (206,73) width 46: "com"
+            text run at (7,95) width 245: "fortably enough, under her arm,"
+            text run at (7,117) width 226: "with its legs hanging down, "
+            text run at (233,117) width 104: "but generally,"
+            text run at (7,139) width 330: "just as she had got its neck nicely straight"
+            text run at (7,161) width 40: "ened "
+            text run at (47,161) width 290: "out, and was going to give the hedge"
+            text run at (7,183) width 204: "hog a blow with its head, it "
+            text run at (211,183) width 126: "would twist itself"
+            text run at (7,205) width 233: "round and look up in her face\x{2026}"
diff --git a/LayoutTests/platform/mac/fast/text/hyphens-expected.checksum b/LayoutTests/platform/mac/fast/text/hyphens-expected.checksum
new file mode 100644 (file)
index 0000000..51967db
--- /dev/null
@@ -0,0 +1 @@
+11c391edd6a7a515f6a962cc28f41d38
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/text/hyphens-expected.png b/LayoutTests/platform/mac/fast/text/hyphens-expected.png
new file mode 100644 (file)
index 0000000..4302f67
Binary files /dev/null and b/LayoutTests/platform/mac/fast/text/hyphens-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/text/hyphens-expected.txt b/LayoutTests/platform/mac/fast/text/hyphens-expected.txt
new file mode 100644 (file)
index 0000000..08d344e
--- /dev/null
@@ -0,0 +1,103 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock (floating) {DIV} at (4,0) size 344x284
+        RenderBlock {P} at (0,16) size 344x18
+          RenderInline {TT} at (0,0) size 120x15
+            RenderText {#text} at (0,2) size 120x15
+              text run at (0,2) width 120: "hyphens: manual"
+          RenderText {#text} at (120,0) size 136x18
+            text run at (120,0) width 136: " without soft hyphens"
+        RenderBlock {DIV} at (0,50) size 344x234 [border: (3px solid #000000)]
+          RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF]
+          RenderText {#text} at (7,7) size 330x220
+            text run at (7,7) width 245: "The chief difficulty Alice found"
+            text run at (7,29) width 245: "at first was in managing her"
+            text run at (7,51) width 245: "flamingo: she succeeded in"
+            text run at (7,73) width 245: "getting its body tucked away,"
+            text run at (7,95) width 245: "comfortably enough, under her"
+            text run at (7,117) width 307: "arm, with its legs hanging down, "
+            text run at (314,117) width 23: "but"
+            text run at (7,139) width 330: "generally, just as she had got its neck nicely"
+            text run at (7,161) width 95: "straightened "
+            text run at (102,161) width 235: "out, and was going to give the"
+            text run at (7,183) width 285: "hedgehog a blow with its head, it "
+            text run at (292,183) width 45: "would"
+            text run at (7,205) width 314: "twist itself round and look up in her face\x{2026}"
+      RenderBlock (floating) {DIV} at (356,0) size 344x284
+        RenderBlock {P} at (0,16) size 344x18
+          RenderInline {TT} at (0,0) size 104x15
+            RenderText {#text} at (0,2) size 104x15
+              text run at (0,2) width 104: "hyphens: none"
+          RenderText {#text} at (104,0) size 116x18
+            text run at (104,0) width 116: " with soft hyphens"
+        RenderBlock {DIV} at (0,50) size 344x234 [border: (3px solid #000000)]
+          RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF]
+          RenderText {#text} at (7,7) size 330x220
+            text run at (7,7) width 245: "The chief difficulty Alice found"
+            text run at (7,29) width 245: "at first was in managing her"
+            text run at (7,51) width 245: "flamingo: she succeeded in"
+            text run at (7,73) width 22: "get"
+            text run at (29,73) width 223: "ting its body tucked away,"
+            text run at (7,95) width 31: "com"
+            text run at (38,95) width 214: "fortably enough, under her"
+            text run at (7,117) width 307: "arm, with its legs hanging down, "
+            text run at (314,117) width 23: "but"
+            text run at (7,139) width 330: "generally, just as she had got its neck nicely"
+            text run at (7,161) width 54: "straight"
+            text run at (61,161) width 41: "ened "
+            text run at (102,161) width 235: "out, and was going to give the"
+            text run at (7,183) width 43: "hedge"
+            text run at (50,183) width 242: "hog a blow with its head, it "
+            text run at (292,183) width 45: "would"
+            text run at (7,205) width 314: "twist itself round and look up in her face\x{2026}"
+      RenderBlock (floating) {DIV} at (4,284) size 344x284
+        RenderBlock {P} at (0,16) size 344x18
+          RenderInline {TT} at (0,0) size 120x15
+            RenderText {#text} at (0,2) size 120x15
+              text run at (0,2) width 120: "hyphens: manual"
+          RenderText {#text} at (120,0) size 116x18
+            text run at (120,0) width 116: " with soft hyphens"
+        RenderBlock {DIV} at (0,50) size 344x234 [border: (3px solid #000000)]
+          RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF]
+          RenderText {#text} at (7,7) size 330x220
+            text run at (7,7) width 245: "The chief difficulty Alice found"
+            text run at (7,29) width 245: "at first was in managing her"
+            text run at (7,51) width 245: "flamingo: she succeeded in get\x{AD}"
+            text run at (7,73) width 208: "ting its body tucked away, "
+            text run at (215,73) width 37: "com\x{AD}"
+            text run at (7,95) width 245: "fortably enough, under her arm,"
+            text run at (7,117) width 226: "with its legs hanging down, "
+            text run at (233,117) width 104: "but generally,"
+            text run at (7,139) width 330: "just as she had got its neck nicely straight\x{AD}"
+            text run at (7,161) width 41: "ened "
+            text run at (48,161) width 289: "out, and was going to give the hedge\x{AD}"
+            text run at (7,183) width 204: "hog a blow with its head, it "
+            text run at (211,183) width 126: "would twist itself"
+            text run at (7,205) width 233: "round and look up in her face\x{2026}"
+      RenderBlock (floating) {DIV} at (356,284) size 344x284
+        RenderBlock {P} at (0,16) size 344x18
+          RenderInline {TT} at (0,0) size 104x15
+            RenderText {#text} at (0,2) size 104x15
+              text run at (0,2) width 104: "hyphens: auto"
+          RenderText {#text} at (104,0) size 136x18
+            text run at (104,0) width 136: " without soft hyphens"
+        RenderBlock {DIV} at (0,50) size 344x234 [border: (3px solid #000000)]
+          RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF]
+          RenderText {#text} at (7,7) size 330x220
+            text run at (7,7) width 245: "The chief difficulty Alice found"
+            text run at (7,29) width 245: "at first was in managing her"
+            text run at (7,51) width 245: "flamingo: she succeeded in get"
+            text run at (7,73) width 208: "ting its body tucked away, "
+            text run at (215,73) width 37: "com"
+            text run at (7,95) width 245: "fortably enough, under her arm,"
+            text run at (7,117) width 226: "with its legs hanging down, "
+            text run at (233,117) width 104: "but generally,"
+            text run at (7,139) width 330: "just as she had got its neck nicely straight"
+            text run at (7,161) width 41: "ened "
+            text run at (48,161) width 289: "out, and was going to give the hedge"
+            text run at (7,183) width 204: "hog a blow with its head, it "
+            text run at (211,183) width 126: "would twist itself"
+            text run at (7,205) width 233: "round and look up in her face\x{2026}"
index 66a4129f8109f4caf25b036fd9f62a100b8a3652..92a3e606214b1e34d5904457cc7fcd74aa470a86 100644 (file)
@@ -102,6 +102,9 @@ compositing
 
 fast/loader/subframe-navigate-during-main-frame-load.html
 
+# Hyphenation is not implemented yet.
+fast/text/hyphenate-character.html
+fast/text/hyphens.html
 
 # =========================================================================== #
 #       Failing HTTP tests.                                                   #
index 91a00b925c9c87d4fb847fe7078d8e7c7005d98b..edd87352649d838cc6d5b96751398af142c1fdff 100644 (file)
@@ -898,3 +898,7 @@ fast/dom/Window/window-properties-on-device-orientation.html
 
 # LayoutTestController::pageProperty is not implemented for WIN yet.
 printing/page-rule-selection.html
+
+# Hyphenation is not implemented yet.
+fast/text/hyphenate-character.html
+fast/text/hyphens.html
index 09778a7dfc2f283da18817f4cde21dac6b2b848b..c6bcb49c1e32068eb8c39f30df09d96fa1e4dafa 100644 (file)
@@ -527,6 +527,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
        \
        platform/text/Base64.cpp \
        platform/text/BidiContext.cpp \
+       platform/text/Hyphenation.cpp \
        platform/text/RegularExpression.cpp \
        platform/text/SegmentedString.cpp \
        platform/text/String.cpp \
index 09d36d7670f7d7fa6eb73b11f48cecef599fd1e3..0f566c02134600978a6c2df1542f1adabfc4101d 100644 (file)
@@ -1246,6 +1246,7 @@ SET(WebCore_SOURCES
 
     platform/text/Base64.cpp
     platform/text/BidiContext.cpp
+    platform/text/Hyphenation.cpp
     platform/text/RegularExpression.cpp
     platform/text/SegmentedString.cpp
     platform/text/String.cpp
index d14e104415285e2bfd460db1ab7961b5fd8daa83..ef1c491d5e7d791f1afcc7c66d423e9758b95e43 100644 (file)
@@ -1,3 +1,107 @@
+2010-06-21  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        CSS3: Implement the 'hyphens' and 'hyphenate-character' properties
+        https://bugs.webkit.org/show_bug.cgi?id=10228
+
+        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.
+
 2010-06-03  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Reviewed by Darin Adler.
index faa3f1ee221940b765aa3b26aaf4e46540ca3e52..1cf6a8482b95cbb9ee20d3a72d07867d4a6224d6 100644 (file)
@@ -1807,6 +1807,8 @@ webcore_sources += \
        WebCore/platform/text/BidiContext.h \
        WebCore/platform/text/BidiResolver.h \
        WebCore/platform/text/CharacterNames.h \
+       WebCore/platform/text/Hyphenation.cpp \
+       WebCore/platform/text/Hyphenation.h \
        WebCore/platform/text/ParserUtilities.h \
        WebCore/platform/text/PlatformString.h \
        WebCore/platform/text/RegularExpression.cpp \
index bf5c147a0f1d5c72d01a3f598e3369360938b9ff..995a39afc7c9539a7f862b1acc3cf160a3d4831c 100644 (file)
@@ -1021,6 +1021,7 @@ _wkGetFontInLanguageForCharacter
 _wkGetFontInLanguageForRange
 _wkGetGlyphTransformedAdvances
 _wkGetGlyphsForCharacters
+_wkGetHyphenationLocationBeforeIndex
 _wkGetMIMETypeForExtension
 _wkGetNSURLResponseCalculatedExpiration
 _wkGetNSURLResponseLastModifiedDate
index 915daae5d5921ccbae48dbcfd4cfae151e6b0c82..3a2c1638b921e398fb3ca9e0788e5ad813f1ba36 100644 (file)
             'platform/text/BidiContext.h',
             'platform/text/BidiResolver.h',
             'platform/text/CharacterNames.h',
+            'platform/text/Hyphenation.cpp',
+            'platform/text/Hyphenation.h',
             'platform/text/ParserUtilities.h',
             'platform/text/PlatformString.h',
             'platform/text/RegularExpression.cpp',
index 8dca707fcee8094d0c8d861330cf527d9061596c..48392e1b02a740a4760d76f7c1036217ccd874e5 100644 (file)
@@ -825,6 +825,7 @@ SOURCES += \
     platform/BlobItem.cpp \
     platform/text/Base64.cpp \
     platform/text/BidiContext.cpp \
+    platform/text/Hyphenation.cpp \
     platform/ContentType.cpp \
     platform/ContextMenu.cpp \
     platform/CrossThreadCopier.cpp \
@@ -1672,6 +1673,7 @@ HEADERS += \
     platform/text/AtomicString.h \
     platform/text/Base64.h \
     platform/text/BidiContext.h \
+    platform/text/Hyphenation.h \
     platform/text/qt/TextCodecQt.h \
     platform/text/RegularExpression.h \
     platform/text/SegmentedString.h \
index f21c2c38e6df4931453fb843720d7001e84924aa..62e2639f2cf6a2807127fbf7ed5df4f01f9b88e7 100644 (file)
                                        RelativePath="..\platform\text\CharacterNames.h"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\platform\text\Hyphentation.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\platform\text\Hyphenation.h"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\platform\text\ParserUtilities.h"\r
                                        >\r
index e1d2d25827be1eb2003723da97c5c390b99650ac..2c0de6fac90766b6cd92bf369756b5cd1721054f 100644 (file)
                3390CA580FFC157B00921962 /* NotificationContents.h in Headers */ = {isa = PBXBuildFile; fileRef = 3390CA540FFC157B00921962 /* NotificationContents.h */; };
                33C0CCD4112C5E6200CE057D /* SecureTextInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33C0CCD2112C5E6200CE057D /* SecureTextInput.cpp */; };
                33C0CCD5112C5E6200CE057D /* SecureTextInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 33C0CCD3112C5E6200CE057D /* SecureTextInput.h */; };
+               371A67CB11C6C7DB00047B8B /* HyphenationCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371A67CA11C6C7DB00047B8B /* HyphenationCF.cpp */; };
                371F4F400D25B9AF00ECE0D5 /* FontData.h in Headers */ = {isa = PBXBuildFile; fileRef = 371F4F3E0D25B9AF00ECE0D5 /* FontData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                371F4F410D25B9AF00ECE0D5 /* FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371F4F3F0D25B9AF00ECE0D5 /* FontData.cpp */; };
                371F4FFC0D25E7F300ECE0D5 /* SegmentedFontData.h in Headers */ = {isa = PBXBuildFile; fileRef = 371F4FFA0D25E7F300ECE0D5 /* SegmentedFontData.h */; };
                371F53EA0D2704F900ECE0D5 /* CSSUnicodeRangeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371F53E80D2704F900ECE0D5 /* CSSUnicodeRangeValue.cpp */; };
                37202199106213C600F25C4B /* FontSmoothingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 37202198106213C600F25C4B /* FontSmoothingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                3744570F0DB05FA500AE0992 /* SVGGlyphMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 3744570E0DB05FA500AE0992 /* SVGGlyphMap.h */; };
+               375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
+               375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 375CD239119D44EA00A2A859 /* HyphenationMac.mm */; };
                3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                377C4CDF1014E9F600B9AE42 /* PlaceholderDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */; };
                377C4CE01014E9F600B9AE42 /* PlaceholderDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377C4CDE1014E9F600B9AE42 /* PlaceholderDocument.cpp */; };
                3390CA540FFC157B00921962 /* NotificationContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NotificationContents.h; path = notifications/NotificationContents.h; sourceTree = "<group>"; };
                33C0CCD2112C5E6200CE057D /* SecureTextInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecureTextInput.cpp; sourceTree = "<group>"; };
                33C0CCD3112C5E6200CE057D /* SecureTextInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecureTextInput.h; sourceTree = "<group>"; };
+               371A67CA11C6C7DB00047B8B /* HyphenationCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HyphenationCF.cpp; sourceTree = "<group>"; };
                371F4F3E0D25B9AF00ECE0D5 /* FontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontData.h; sourceTree = "<group>"; };
                371F4F3F0D25B9AF00ECE0D5 /* FontData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontData.cpp; sourceTree = "<group>"; };
                371F4FFA0D25E7F300ECE0D5 /* SegmentedFontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SegmentedFontData.h; sourceTree = "<group>"; };
                371F53E80D2704F900ECE0D5 /* CSSUnicodeRangeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSUnicodeRangeValue.cpp; sourceTree = "<group>"; };
                37202198106213C600F25C4B /* FontSmoothingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSmoothingMode.h; sourceTree = "<group>"; };
                3744570E0DB05FA500AE0992 /* SVGGlyphMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGGlyphMap.h; sourceTree = "<group>"; };
+               375CD231119D43C800A2A859 /* Hyphenation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hyphenation.h; sourceTree = "<group>"; };
+               375CD239119D44EA00A2A859 /* HyphenationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HyphenationMac.mm; sourceTree = "<group>"; };
                3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
                377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderDocument.h; sourceTree = "<group>"; };
                377C4CDE1014E9F600B9AE42 /* PlaceholderDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlaceholderDocument.cpp; sourceTree = "<group>"; };
                                93EEC1EC09C2877700C515D1 /* html */,
                                1C81B94D0E9732D900266E07 /* inspector */,
                                BCB16BFB0979C38700467741 /* loader */,
-                               FABE72EC1059C1EB00D999DD /* mathml */,
                                333F703D0FB49C16008E12A6 /* notifications */,
                                65BF02180974806300C43196 /* page */,
                                BCF1A5BA097832090061A123 /* platform */,
                B2B264590D00A77E000ACC1D /* cf */ = {
                        isa = PBXGroup;
                        children = (
+                               371A67CA11C6C7DB00047B8B /* HyphenationCF.cpp */,
                                B2B2645A0D00A77E000ACC1D /* StringCF.cpp */,
                                B2B2645B0D00A77E000ACC1D /* StringImplCF.cpp */,
                        );
                                B2C3D9F30D006C1D00EF6F26 /* BidiContext.h */,
                                B2C3D9F40D006C1D00EF6F26 /* BidiResolver.h */,
                                B2C3D9F50D006C1D00EF6F26 /* CharacterNames.h */,
+                               375CD231119D43C800A2A859 /* Hyphenation.h */,
                                BC76AC110DD7AD5C00415F34 /* ParserUtilities.h */,
                                B2C3D9FB0D006C1D00EF6F26 /* PlatformString.h */,
                                B2C3D9FC0D006C1D00EF6F26 /* RegularExpression.cpp */,
                        children = (
                                B2AFFC850D00A5DF0030074D /* character-sets.txt */,
                                B2C3D9FA0D006C1D00EF6F26 /* CharsetData.h */,
+                               375CD239119D44EA00A2A859 /* HyphenationMac.mm */,
                                B2AFFC860D00A5DF0030074D /* mac-encodings.txt */,
                                B2AFFC870D00A5DF0030074D /* make-charset-table.pl */,
                                B2AFFC880D00A5DF0030074D /* ShapeArabic.c */,
                BCB16BFB0979C38700467741 /* loader */ = {
                        isa = PBXGroup;
                        children = (
+                               FABE72EC1059C1EB00D999DD /* mathml */,
                                1A8F6BB00DB55CDC001DB794 /* appcache */,
                                512DD8E80D91E691000F89EE /* archive */,
                                5126E6B60A2E3AEF005C29FA /* icon */,
                                FA7EFB031120D25400CF79C7 /* RenderMathMLUnderOver.cpp */,
                                FA7EFB041120D25400CF79C7 /* RenderMathMLUnderOver.h */,
                        );
-                       path = mathml;
+                       name = mathml;
+                       path = ../mathml;
                        sourceTree = "<group>";
                };
 /* End PBXGroup section */
                                BCCD74DC0A4C8D35005FDA6D /* HTMLViewSourceDocument.h in Headers */,
                                514C76710CE923A1007EF3CD /* HTTPHeaderMap.h in Headers */,
                                514C76730CE923A1007EF3CD /* HTTPParsers.h in Headers */,
+                               375CD232119D43C800A2A859 /* Hyphenation.h in Headers */,
                                B275356E0B053814002CE64F /* Icon.h in Headers */,
                                5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */,
                                51E1ECBE0C91C90400DC255B /* IconDatabaseClient.h in Headers */,
                                BCCD74E50A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp in Sources */,
                                0B8C56D40F28627F000502E1 /* HTTPHeaderMap.cpp in Sources */,
                                514C76720CE923A1007EF3CD /* HTTPParsers.cpp in Sources */,
+                               371A67CB11C6C7DB00047B8B /* HyphenationCF.cpp in Sources */,
+                               375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */,
                                5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */,
                                445C8DB710015FC90031531A /* IconDatabaseNone.cpp in Sources */,
                                1A2D753E0DE47FAB00F0A648 /* IconFetcher.cpp in Sources */,
index 05c2e3edd73ba2aa74bcb9a98c503bc446189e9f..62bd5e0c22c198527b0b1b499de0d1238d0f9592 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
  * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
  *
@@ -905,6 +905,12 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             if (style->highlight() == nullAtom)
                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
             return CSSPrimitiveValue::create(style->highlight(), CSSPrimitiveValue::CSS_STRING);
+        case CSSPropertyWebkitHyphens:
+            return CSSPrimitiveValue::create(style->hyphens());
+        case CSSPropertyWebkitHyphenateCharacter:
+            if (style->hyphenateCharacter().isNull())
+                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
+            return CSSPrimitiveValue::create(style->hyphenateCharacter(), CSSPrimitiveValue::CSS_STRING);
         case CSSPropertyWebkitBorderFit:
             if (style->borderFit() == BorderFitBorder)
                 return CSSPrimitiveValue::createIdentifier(CSSValueBorder);
index 6575ba1c09bcf818d791b7f221559ae208b0a74f..4330d09031d33cd26f080e13cdbccc9c57cc6437 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
  * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
@@ -1557,6 +1557,16 @@ bool CSSParser::parseValue(int propId, bool important)
             validPrimitive = true;
         break;
 
+    case CSSPropertyWebkitHyphens:
+        if (id == CSSValueNone || id == CSSValueManual || id == CSSValueAuto)
+            validPrimitive = true;
+        break;
+
+    case CSSPropertyWebkitHyphenateCharacter:
+        if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
+            validPrimitive = true;
+        break;
+
     case CSSPropertyWebkitBorderFit:
         if (id == CSSValueBorder || id == CSSValueLines)
             validPrimitive = true;
index f646b29e4300990656538def7bde9371db7ccc66..dd7b732bb0f58984822938b55436646bf61e292e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>.
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
@@ -2157,6 +2157,38 @@ template<> inline CSSPrimitiveValue::operator ColorSpace() const
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Hyphens hyphens)
+    : m_type(CSS_IDENT)
+    , m_hasCachedCSSText(false)
+{
+    switch (hyphens) {
+    case HyphensNone:
+        m_value.ident = CSSValueNone;
+        break;
+    case HyphensManual:
+        m_value.ident = CSSValueManual;
+        break;
+    case HyphensAuto:
+        m_value.ident = CSSValueAuto;
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator Hyphens() const
+{
+    switch (m_value.ident) {
+    case CSSValueNone:
+        return HyphensNone;
+    case CSSValueManual:
+        return HyphensManual;
+    case CSSValueAuto:
+        return HyphensAuto;
+    default:
+        ASSERT_NOT_REACHED();
+        return HyphensAuto;
+    }
+}
+
 #if ENABLE(SVG)
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e)
index b2174c72b8cd4b43191ca5cf6515bb2bb5c72b47..8f2e79e1d800c585f6ce567a996eec0a71575b30 100644 (file)
@@ -209,6 +209,8 @@ z-index
 -webkit-font-size-delta
 -webkit-font-smoothing
 -webkit-highlight
+-webkit-hyphenate-character
+-webkit-hyphens
 -webkit-line-break
 -webkit-line-clamp
 -webkit-margin-bottom-collapse
index 4f4038ce08a61e012262224ab92733c6ccf63d9c..8634332bc87a54229ba8785f2c90a7054a70a6eb 100644 (file)
@@ -5180,6 +5180,19 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             m_style->setHighlight(primitiveValue->getStringValue());
         return;
     }
+    case CSSPropertyWebkitHyphens: {
+        HANDLE_INHERIT_AND_INITIAL(hyphens, Hyphens);
+        m_style->setHyphens(*primitiveValue);
+        return;
+    }
+    case CSSPropertyWebkitHyphenateCharacter: {
+        HANDLE_INHERIT_AND_INITIAL(hyphenateCharacter, HyphenateCharacter);
+        if (primitiveValue->getIdent() == CSSValueAuto)
+            m_style->setHyphenateCharacter(nullAtom);
+        else
+            m_style->setHyphenateCharacter(primitiveValue->getStringValue());
+        return;
+    }
     case CSSPropertyWebkitBorderFit: {
         HANDLE_INHERIT_AND_INITIAL(borderFit, BorderFit);
         if (primitiveValue->getIdent() == CSSValueBorder)
index 154183b544583fe5bf72623767f7db5fe133d5c3..13dd034d44c57846d0fe0125725231b38a17aa9d 100644 (file)
@@ -730,3 +730,8 @@ fullscreen
 maximized
 minimized
 windowed
+
+# -webkit-hyphens
+# none
+manual
+# auto
index 577b908a717c26d6a7594960ad3fe2d169089841..1f1431189087f97957fcd4d38fe42c95f62f5c13 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -170,8 +170,10 @@ extern BOOL (*wkUseSharedMediaUI)();
 
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
 extern NSMutableArray *(*wkNoteOpenPanelFiles)(NSArray *);
+extern void* wkGetHyphenationLocationBeforeIndex;
 #else
 extern void* wkNoteOpenPanelFiles;
+extern CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
 #endif
 
 }
index bb54ad01368e9cf48153dd4a314bc914e25abde0..2a06f15e0e01109942f76288b3f0d768b731c2db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2007, 2008, 2010 Apple Computer, Inc. All rights reserved.
+ * Copyright 2006, 2007, 2008, 2009, 2010 Apple Computer, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -112,6 +112,8 @@ BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
 
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
 NSMutableArray *(*wkNoteOpenPanelFiles)(NSArray *);
+void* wkGetHyphenationLocationBeforeIndex;
 #else
 void* wkNoteOpenPanelFiles;
+CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
 #endif
index 687bfb4aa2e29ab4fbb577efbb4d65a218bab532..f06246c84665a4660f47efbee605d4b48b2111ca 100644 (file)
@@ -42,6 +42,7 @@ const UChar ethiopicPrefaceColon = 0x1366;
 const UChar hebrewPunctuationGeresh = 0x05F3;
 const UChar hebrewPunctuationGershayim = 0x05F4;
 const UChar horizontalEllipsis = 0x2026;
+const UChar hyphen = 0x2010;
 const UChar hyphenMinus = 0x002D;
 const UChar ideographicComma = 0x3001;
 const UChar ideographicFullStop = 0x3002;
diff --git a/WebCore/platform/text/Hyphenation.cpp b/WebCore/platform/text/Hyphenation.cpp
new file mode 100644 (file)
index 0000000..8ef5a25
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Hyphenation.h"
+
+#include "NotImplemented.h"
+
+namespace WebCore {
+
+size_t lastHyphenLocation(const UChar* /* characters */, size_t /* length */, size_t /* beforeIndex */)
+{
+    notImplemented();
+    return 0;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/text/Hyphenation.h b/WebCore/platform/text/Hyphenation.h
new file mode 100644 (file)
index 0000000..dbcbe69
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Hyphenation_h
+#define Hyphenation_h
+
+#include <wtf/unicode/Unicode.h>
+
+namespace WebCore {
+
+size_t lastHyphenLocation(const UChar*, size_t length, size_t beforeIndex);
+
+} // namespace WebCore
+
+#endif // Hyphenation_h
diff --git a/WebCore/platform/text/cf/HyphenationCF.cpp b/WebCore/platform/text/cf/HyphenationCF.cpp
new file mode 100644 (file)
index 0000000..50ba4c8
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Hyphenation.h"
+
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+
+#include "TextBreakIteratorInternalICU.h"
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+static CFLocaleRef createCurrentSearchLocale()
+{
+    RetainPtr<CFStringRef> localeIdentifier(AdoptCF, CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, (const UInt8*)currentSearchLocaleID(), strlen(currentSearchLocaleID()), kCFStringEncodingASCII, false, kCFAllocatorNull));
+    return CFLocaleCreate(kCFAllocatorDefault, localeIdentifier.get());
+}
+
+size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex)
+{
+    RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters, length, kCFAllocatorNull));
+
+    static CFLocaleRef locale = createCurrentSearchLocale();
+
+    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(string.get(), beforeIndex, CFRangeMake(0, length), 0, locale, 0);
+    return result == kCFNotFound ? 0 : result;
+}
+
+} // namespace WebCore
+
+#endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
diff --git a/WebCore/platform/text/mac/HyphenationMac.mm b/WebCore/platform/text/mac/HyphenationMac.mm
new file mode 100644 (file)
index 0000000..e64477f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "Hyphenation.h"
+
+#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
+
+#import "TextBreakIteratorInternalICU.h"
+#import "WebCoreSystemInterface.h"
+#import <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex)
+{
+    static bool localeIsEnglish = !strcmp("en", currentSearchLocaleID());
+    if (!localeIsEnglish)
+        return 0;
+
+    RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters, length, kCFAllocatorNull));
+    return wkGetHyphenationLocationBeforeIndex(string.get(), beforeIndex);
+}
+
+} // namespace WebCore
+
+#endif // defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
index 542081a720c421f481b7affcf8dff94c66afaecd..5dbb07b3c4257b2804465fc7d5e253741e9bc2c2 100644 (file)
@@ -38,6 +38,7 @@ struct BidiRun : BidiCharacterRun {
         : BidiCharacterRun(start, stop, context, dir)
         , m_object(object)
         , m_box(0)
+        , m_hasHyphen(false)
     {
     }
 
@@ -58,6 +59,7 @@ private:
 public:
     RenderObject* m_object;
     InlineBox* m_box;
+    bool m_hasHyphen;
 };
 
 }
index c59808edbfbf5e2030b171f527d38e60eaf65430..0b6b0e2e1e08daba600c156b8e88a89e423e11bc 100644 (file)
@@ -53,7 +53,7 @@ public:
 #endif
         , m_endsWithBreak(false)
         , m_hasSelectedChildren(false)
-        , m_hasEllipsisBox(false)
+        , m_hasEllipsisBoxOrHyphen(false)
         , m_dirOverride(false)
         , m_isText(false)
         , m_determinedIfNextOnLineExists(false)
@@ -86,7 +86,7 @@ public:
 #endif
         , m_endsWithBreak(false)
         , m_hasSelectedChildren(false)   
-        , m_hasEllipsisBox(false)
+        , m_hasEllipsisBoxOrHyphen(false)
         , m_dirOverride(false)
         , m_isText(false)
         , m_determinedIfNextOnLineExists(false)
@@ -284,7 +284,7 @@ protected:
     // for RootInlineBox
     bool m_endsWithBreak : 1;  // Whether the line ends with a <br>.
     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).
-    bool m_hasEllipsisBox : 1; 
+    bool m_hasEllipsisBoxOrHyphen : 1; 
 
     // for InlineTextBox
 public:
index f94ba9428e2887bb48daec1b1abe852c3d1a5ef7..c63ee1e44c4b018bfc8568cf0d5585c41489395e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * (C) 1999 Lars Knoll (knoll@kde.org)
  * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -103,6 +103,18 @@ RenderObject::SelectionState InlineTextBox::selectionState()
     return state;
 }
 
+typedef Vector<UChar, 256> BufferForAppendingHyphen;
+
+static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, RenderStyle* style, const UChar*& characters, int& length)
+{
+    const AtomicString& hyphenString = style->hyphenString();
+    charactersWithHyphen.reserveCapacity(length + hyphenString.length());
+    charactersWithHyphen.append(characters, length);
+    charactersWithHyphen.append(hyphenString.characters(), hyphenString.length());
+    characters = charactersWithHyphen.data();
+    length += hyphenString.length();
+}
+
 IntRect InlineTextBox::selectionRect(int tx, int ty, int startPos, int endPos)
 {
     int sPos = max(startPos - m_start, 0);
@@ -114,9 +126,18 @@ IntRect InlineTextBox::selectionRect(int tx, int ty, int startPos, int endPos)
     RenderText* textObj = textRenderer();
     int selTop = selectionTop();
     int selHeight = selectionHeight();
-    const Font& f = textObj->style(m_firstLine)->font();
+    RenderStyle* styleToUse = textObj->style(m_firstLine);
+    const Font& f = styleToUse->font();
+
+    const UChar* characters = textObj->text()->characters() + m_start;
+    int len = m_len;
+    BufferForAppendingHyphen charactersWithHyphen;
+    if (ePos == len && hasHyphen()) {
+        adjustCharactersAndLengthForHyphen(charactersWithHyphen, styleToUse, characters, len);
+        ePos = len;
+    }
 
-    IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(textObj->text()->characters() + m_start, m_len, textObj->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride),
+    IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(characters, len, textObj->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride),
                                                         IntPoint(tx + m_x, ty + selTop), selHeight, sPos, ePos));
     if (r.x() > tx + m_x + m_width)
         r.setWidth(0);
@@ -464,16 +485,21 @@ void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
         }
     }
 
+    const UChar* characters = textRenderer()->text()->characters() + m_start;
+    int length = m_len;
+    BufferForAppendingHyphen charactersWithHyphen;
+    if (hasHyphen())
+        adjustCharactersAndLengthForHyphen(charactersWithHyphen, styleToUse, characters, length);
+
     int baseline = renderer()->style(m_firstLine)->font().ascent();
     IntPoint textOrigin(m_x + tx, m_y + ty + baseline);
-    TextRun textRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride || styleToUse->visuallyOrdered());
+    TextRun textRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride || styleToUse->visuallyOrdered());
 
     int sPos = 0;
     int ePos = 0;
     if (paintSelectedTextOnly || paintSelectedTextSeparately)
         selectionStartEnd(sPos, ePos);
 
-    int length = m_len;
     if (m_truncation != cNoTruncation) {
         sPos = min<int>(sPos, m_truncation);
         ePos = min<int>(ePos, m_truncation);
@@ -588,8 +614,16 @@ void InlineTextBox::paintSelection(GraphicsContext* context, int tx, int ty, Ren
     // If the text is truncated, let the thing being painted in the truncation
     // draw its own highlight.
     int length = m_truncation != cNoTruncation ? m_truncation : m_len;
+    const UChar* characters = textRenderer()->text()->characters() + m_start;
+
+    BufferForAppendingHyphen charactersWithHyphen;
+    if (ePos == length && hasHyphen()) {
+        adjustCharactersAndLengthForHyphen(charactersWithHyphen, style, characters, length);
+        ePos = length;
+    }
+
     context->clip(IntRect(m_x + tx, y + ty, m_width, h));
-    context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, length, textRenderer()->allowTabs(), textPos(), m_toAdd, 
+    context->drawHighlightForText(font, TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd, 
                                   direction() == RTL, m_dirOverride || style->visuallyOrdered()),
                                   IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
     context->restore();
index 14d95b0031ede248ada8d3e3cc06111369ae7fb1..a5bfd5f0ed088b0499aa1d222ba6250140b914f8 100644 (file)
@@ -65,6 +65,9 @@ public:
 
     unsigned short truncation() { return m_truncation; }
 
+    bool hasHyphen() const { return m_hasEllipsisBoxOrHyphen; }
+    void setHasHyphen(bool hasHyphen) { m_hasEllipsisBoxOrHyphen = hasHyphen; }
+
 private:
     virtual int selectionTop();
     virtual int selectionHeight();
index 574a83904954ac0b8f261272391898ed24cf3069..e3a11c80c12ad7ea54c53d53ebdf7af201a4b357 100644 (file)
@@ -307,7 +307,7 @@ private:
     void skipTrailingWhitespace(InlineIterator&, bool isLineEmpty, bool previousLineBrokeCleanly);
     int skipLeadingWhitespace(InlineBidiResolver&, bool firstLine, bool isLineEmpty, bool previousLineBrokeCleanly);
     void fitBelowFloats(int widthToFit, bool firstLine, int& availableWidth);
-    InlineIterator findNextLineBreak(InlineBidiResolver&, bool firstLine, bool& isLineEmpty, bool& previousLineBrokeCleanly, EClear* clear = 0);
+    InlineIterator findNextLineBreak(InlineBidiResolver&, bool firstLine, bool& isLineEmpty, bool& previousLineBrokeCleanly, bool& hyphenated, EClear* = 0);
     RootInlineBox* constructLine(unsigned runCount, BidiRun* firstRun, BidiRun* lastRun, bool firstLine, bool lastLine, RenderObject* endObject);
     InlineFlowBox* createLineBoxes(RenderObject*, bool firstLine);
     void computeHorizontalPositionsForLine(RootInlineBox*, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&);
index b9afe5b5396780119b09590208c0c7805fab0852..35fef86737369466a2c075f4f6dafe2f1d7f3d5f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "BidiResolver.h"
 #include "CharacterNames.h"
+#include "Hyphenation.h"
 #include "InlineIterator.h"
 #include "InlineTextBox.h"
 #include "Logging.h"
@@ -295,6 +296,8 @@ RootInlineBox* RenderBlock::constructLine(unsigned runCount, BidiRun* firstRun,
             text->setStart(r->m_start);
             text->setLen(r->m_stop - r->m_start);
             text->m_dirOverride = r->dirOverride(visuallyOrdered);
+            if (r->m_hasHyphen)
+                text->setHasHyphen(true);
         }
     }
 
@@ -349,6 +352,12 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool
             HashSet<const SimpleFontData*> fallbackFonts;
             GlyphOverflow glyphOverflow;
             r->m_box->setWidth(rt->width(r->m_start, r->m_stop - r->m_start, totWidth, firstLine, &fallbackFonts, &glyphOverflow));
+            int hyphenWidth = 0;
+            if (static_cast<InlineTextBox*>(r->m_box)->hasHyphen()) {
+                const AtomicString& hyphenString = rt->style()->hyphenString();
+                hyphenWidth = rt->style(firstLine)->font().width(TextRun(hyphenString.characters(), hyphenString.length()));
+            }
+            r->m_box->setWidth(rt->width(r->m_start, r->m_stop - r->m_start, totWidth, firstLine, &fallbackFonts, &glyphOverflow) + hyphenWidth);
             if (!fallbackFonts.isEmpty()) {
                 ASSERT(r->m_box->isText());
                 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(static_cast<InlineTextBox*>(r->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
@@ -668,7 +677,8 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
             isLineEmpty = true;
             
             EClear clear = CNONE;
-            end = findNextLineBreak(resolver, firstLine, isLineEmpty, previousLineBrokeCleanly, &clear);
+            bool hyphenated;
+            end = findNextLineBreak(resolver, firstLine, isLineEmpty, previousLineBrokeCleanly, hyphenated, &clear);
             if (resolver.position().atEnd()) {
                 resolver.deleteRuns();
                 checkForFloatsFromLastLine = true;
@@ -734,6 +744,8 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
 
                 RootInlineBox* lineBox = 0;
                 if (resolver.runCount()) {
+                    if (hyphenated)
+                        resolver.logicallyLastRun()->m_hasHyphen = true;
                     lineBox = constructLine(resolver.runCount(), resolver.firstRun(), resolver.lastRun(), firstLine, !end.obj, end.obj && !end.pos ? end.obj : 0);
                     if (lineBox) {
                         lineBox->setEndsWithBreak(previousLineBrokeCleanly);
@@ -1317,8 +1329,32 @@ static inline unsigned textWidth(RenderText* text, unsigned from, unsigned len,
     return font.width(TextRun(text->characters() + from, len, !collapseWhiteSpace, xPos));
 }
 
+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)
+{
+    const AtomicString& hyphenString = text->style()->hyphenString();
+    int hyphenWidth = font.width(TextRun(hyphenString.characters(), hyphenString.length()));
+
+    unsigned prefixLength = font.offsetForPosition(TextRun(text->characters() + lastSpace, pos - lastSpace, !collapseWhiteSpace, xPos + lastSpaceWordSpacing), availableWidth - xPos - hyphenWidth - lastSpaceWordSpacing, false);
+    if (!prefixLength)
+        return;
+
+    prefixLength = 1 + lastHyphenLocation(text->characters() + lastSpace + 1, pos - lastSpace - 1, prefixLength - 1);
+    if (prefixLength <= 1)
+        return;
+
+#if !ASSERT_DISABLED
+    int prefixWidth = hyphenWidth + textWidth(text, lastSpace, prefixLength, font, xPos, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
+    ASSERT(xPos + prefixWidth <= availableWidth);
+#endif
+
+    lineBreak.obj = text;
+    lineBreak.pos = lastSpace + prefixLength;
+    lineBreak.nextBreakablePosition = nextBreakable;
+    hyphenated = true;
+}
+
 InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool firstLine,  bool& isLineEmpty, bool& previousLineBrokeCleanly, 
-                                              EClear* clear)
+                                              bool& hyphenated, EClear* clear)
 {
     ASSERT(resolver.position().block == this);
 
@@ -1356,6 +1392,8 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
     bool prevLineBrokeCleanly = previousLineBrokeCleanly;
     previousLineBrokeCleanly = false;
 
+    hyphenated = false;
+
     bool autoWrapWasEverTrueOnLine = false;
     bool floatsFitOnLine = true;
     
@@ -1529,8 +1567,10 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
             int len = strlen - pos;
             const UChar* str = t->characters();
 
-            const Font& f = t->style(firstLine)->font();
+            RenderStyle* style = t->style(firstLine);
+            const Font& f = style->font();
             bool isFixedPitch = f.isFixedPitch();
+            bool canHyphenate = style->hyphens() == HyphensAuto;
 
             int lastSpace = pos;
             int wordSpacing = o->style()->wordSpacing();
@@ -1600,6 +1640,11 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
                     len--;
                     lastSpaceWordSpacing = 0;
                     lastSpace = pos; // Cheesy hack to prevent adding in widths of the run twice.
+                    if (style->hyphens() == HyphensNone) {
+                        // Prevent a line break at the soft hyphen by ensuring that betweenWords is false
+                        // in the next iteration.
+                        atStart = true;
+                    }
                     continue;
                 }
                 
@@ -1669,6 +1714,11 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
                                 skipTrailingWhitespace(lBreak, isLineEmpty, previousLineBrokeCleanly);
                             }
                         }
+                        if (canHyphenate && w + tmpW > width) {
+                            tryHyphenating(t, f, lastSpace, pos, w + tmpW - additionalTmpW, width, isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
+                            if (hyphenated)
+                                goto end;
+                        }
                         if (lineWasTooWide || w + tmpW > width) {
                             if (lBreak.obj && shouldPreserveNewline(lBreak.obj) && lBreak.obj->isText() && toRenderText(lBreak.obj)->textLength() && !toRenderText(lBreak.obj)->isWordBreak() && toRenderText(lBreak.obj)->characters()[lBreak.pos] == '\n') {
                                 if (!stoppedIgnoringSpaces && pos > 0) {
@@ -1775,9 +1825,15 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
             }
 
             // IMPORTANT: pos is > length here!
-            if (!ignoringSpaces)
-                tmpW += textWidth(t, lastSpace, pos - lastSpace, f, w + tmpW, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
+            int additionalTmpW = ignoringSpaces ? 0 : textWidth(t, lastSpace, pos - lastSpace, f, w + tmpW, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
+            tmpW += additionalTmpW;
             tmpW += inlineWidth(o, !appliedStartWidth, true);
+
+            if (canHyphenate && w + tmpW > width) {
+                tryHyphenating(t, f, lastSpace, pos, w + tmpW - additionalTmpW, width, isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
+                if (hyphenated)
+                    goto end;
+            }
         } else
             ASSERT_NOT_REACHED();
 
index 69a0f2121305f7f4379cf8f432818e2ea7e8cb40..3a8a4f5df848b87d942586248719829c1f20a908 100644 (file)
@@ -47,11 +47,11 @@ void RootInlineBox::destroy(RenderArena* arena)
 
 void RootInlineBox::detachEllipsisBox(RenderArena* arena)
 {
-    if (m_hasEllipsisBox) {
+    if (hasEllipsisBox()) {
         EllipsisBox* box = gEllipsisBoxMap->take(this);
         box->setParent(0);
         box->destroy(arena);
-        m_hasEllipsisBox = false;
+        setHasEllipsisBox(false);
     }
 }
 
@@ -62,7 +62,7 @@ RenderLineBoxList* RootInlineBox::rendererLineBoxes() const
 
 void RootInlineBox::clearTruncation()
 {
-    if (m_hasEllipsisBox) {
+    if (hasEllipsisBox()) {
         detachEllipsisBox(renderer()->renderArena());
         InlineFlowBox::clearTruncation();
     }
@@ -92,7 +92,7 @@ void RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr,  bool ltr, in
     if (!gEllipsisBoxMap)
         gEllipsisBoxMap = new EllipsisBoxMap();
     gEllipsisBoxMap->add(this, ellipsisBox);
-    m_hasEllipsisBox = true;
+    setHasEllipsisBox(true);
 
     // FIXME: Do we need an RTL version of this?
     if (ltr && (x() + width() + ellipsisWidth) <= blockRightEdge) {
@@ -117,8 +117,8 @@ int RootInlineBox::placeEllipsisBox(bool ltr, int blockLeftEdge, int blockRightE
 
 void RootInlineBox::paintEllipsisBox(RenderObject::PaintInfo& paintInfo, int tx, int ty) const
 {
-    if (m_hasEllipsisBox && renderer()->shouldPaintWithinRoot(paintInfo) && renderer()->style()->visibility() == VISIBLE &&
-            paintInfo.phase == PaintPhaseForeground)
+    if (hasEllipsisBox() && renderer()->shouldPaintWithinRoot(paintInfo) && renderer()->style()->visibility() == VISIBLE
+            && paintInfo.phase == PaintPhaseForeground)
         ellipsisBox()->paint(paintInfo, tx, ty);
 }
 
@@ -174,7 +174,7 @@ void RootInlineBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
 
 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty)
 {
-    if (m_hasEllipsisBox && visibleToHitTesting()) {
+    if (hasEllipsisBox() && visibleToHitTesting()) {
         if (ellipsisBox()->nodeAtPoint(request, result, x, y, tx, ty)) {
             renderer()->updateHitTestResult(result, IntPoint(x - tx, y - ty));
             return true;
@@ -416,7 +416,7 @@ void RootInlineBox::setLineBreakInfo(RenderObject* obj, unsigned breakPos, const
 
 EllipsisBox* RootInlineBox::ellipsisBox() const
 {
-    if (!m_hasEllipsisBox)
+    if (!hasEllipsisBox())
         return 0;
     return gEllipsisBoxMap->get(this);
 }
index 4b765e91009f0afc2dd2265b4f877836ae1227a9..fa2510acae59d18eaa55f8e24a948202fe48d798 100644 (file)
@@ -128,7 +128,10 @@ public:
     virtual void attachLineBoxToRenderObject();
     virtual void removeLineBoxFromRenderObject();
 
-protected:
+private:
+    bool hasEllipsisBox() const { return m_hasEllipsisBoxOrHyphen; }
+    void setHasEllipsisBox(bool hasEllipsisBox) { m_hasEllipsisBoxOrHyphen = hasEllipsisBox; }
+
     // Where this line ended.  The exact object and the position within that object are stored so that
     // we can create an InlineIterator beginning just after the end of this line.
     RenderObject* m_lineBreakObj;
index af4e0551c29a04194468173175c00cc84f44230e..40f7a277912d86252751464e78446fee114f0a70 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -386,7 +386,9 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
             rareInheritedData->wordWrap != other->rareInheritedData->wordWrap ||
             rareInheritedData->nbspMode != other->rareInheritedData->nbspMode ||
             rareInheritedData->khtmlLineBreak != other->rareInheritedData->khtmlLineBreak ||
-            rareInheritedData->textSecurity != other->rareInheritedData->textSecurity)
+            rareInheritedData->textSecurity != other->rareInheritedData->textSecurity ||
+            rareInheritedData->hyphens != other->rareInheritedData->hyphens ||
+            rareInheritedData->hyphenateCharacter != other->rareInheritedData->hyphenateCharacter)
             return StyleDifferenceLayout;
 
         if (!rareInheritedData->shadowDataEquivalent(*other->rareInheritedData.get()))
@@ -802,6 +804,19 @@ CounterDirectiveMap& RenderStyle::accessCounterDirectives()
     return *map.get();
 }
 
+const AtomicString& RenderStyle::hyphenString() const
+{
+    ASSERT(hyphens() == HyphensAuto);
+
+    const AtomicString& hyphenateCharacter = rareInheritedData.get()->hyphenateCharacter;
+    if (!hyphenateCharacter.isNull())
+        return hyphenateCharacter;
+
+    // FIXME: This should depend on locale.
+    DEFINE_STATIC_LOCAL(AtomicString, hyphenMinusString, (&hyphen, 1));
+    return hyphenMinusString;
+}
+
 #if ENABLE(DASHBOARD_SUPPORT)
 const Vector<StyleDashboardRegion>& RenderStyle::initialDashboardRegions()
 {
index eac59c6c11c590eb94e884f1b7938d45695c8909..44e5b88807f5c3c3c2ee8365da6cd01cb76165db 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
  *           (C) 2000 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
  *
  * This library is free software; you can redistribute it and/or
@@ -647,6 +647,8 @@ public:
     EKHTMLLineBreak khtmlLineBreak() const { return static_cast<EKHTMLLineBreak>(rareInheritedData->khtmlLineBreak); }
     EMatchNearestMailBlockquoteColor matchNearestMailBlockquoteColor() const { return static_cast<EMatchNearestMailBlockquoteColor>(rareNonInheritedData->matchNearestMailBlockquoteColor); }
     const AtomicString& highlight() const { return rareInheritedData->highlight; }
+    Hyphens hyphens() const { return static_cast<Hyphens>(rareInheritedData->hyphens); }
+    const AtomicString& hyphenateCharacter() const { return rareInheritedData->hyphenateCharacter; }
     EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
     EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); }
     float columnWidth() const { return rareNonInheritedData->m_multiCol->m_width; }
@@ -979,6 +981,8 @@ public:
     void setKHTMLLineBreak(EKHTMLLineBreak b) { SET_VAR(rareInheritedData, khtmlLineBreak, b); }
     void setMatchNearestMailBlockquoteColor(EMatchNearestMailBlockquoteColor c) { SET_VAR(rareNonInheritedData, matchNearestMailBlockquoteColor, c); }
     void setHighlight(const AtomicString& h) { SET_VAR(rareInheritedData, highlight, h); }
+    void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); }
+    void setHyphenateCharacter(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenateCharacter, h); }
     void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
     void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); }
     void setColumnWidth(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, f); }
@@ -1058,6 +1062,8 @@ public:
     const CounterDirectiveMap* counterDirectives() const;
     CounterDirectiveMap& accessCounterDirectives();
 
+    const AtomicString& hyphenString() const;
+
     bool inheritedNotEqual(const RenderStyle*) const;
 
     StyleDifference diff(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
@@ -1181,6 +1187,8 @@ public:
     static EKHTMLLineBreak initialKHTMLLineBreak() { return LBNORMAL; }
     static EMatchNearestMailBlockquoteColor initialMatchNearestMailBlockquoteColor() { return BCNORMAL; }
     static const AtomicString& initialHighlight() { return nullAtom; }
+    static Hyphens initialHyphens() { return HyphensManual; }
+    static const AtomicString& initialHyphenateCharacter() { return nullAtom; }
     static EBorderFit initialBorderFit() { return BorderFitBorder; }
     static EResize initialResize() { return RESIZE_NONE; }
     static ControlPart initialAppearance() { return NoControlPart; }
index 0858ec22487c7093c2e62b442ec64662b0b387b5..ebd6f3a650a4a0951064ac13c358c2c61b345a46 100644 (file)
@@ -406,6 +406,8 @@ enum EBackfaceVisibility {
     
 enum ELineClampType { LineClampLineCount, LineClampPercentage };
 
+enum Hyphens { HyphensNone, HyphensManual, HyphensAuto };
+
 } // namespace WebCore
 
 #endif // RenderStyleConstants_h
index 8f0925890e403a1f7b6f313b6c155b893decb412..d8f8efb4cf4260e83229b9bb0a1c7aec19e029a2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -44,6 +44,7 @@ StyleRareInheritedData::StyleRareInheritedData()
     , resize(RenderStyle::initialResize())
     , userSelect(RenderStyle::initialUserSelect())
     , colorSpace(DeviceColorSpace)
+    , hyphens(HyphensManual)
 {
 }
 
@@ -69,6 +70,8 @@ StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
     , resize(o.resize)
     , userSelect(o.userSelect)
     , colorSpace(o.colorSpace)
+    , hyphens(o.hyphens)
+    , hyphenateCharacter(o.hyphenateCharacter)
 {
 }
 
@@ -107,7 +110,9 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
         && textSizeAdjust == o.textSizeAdjust
         && resize == o.resize
         && userSelect == o.userSelect
-        && colorSpace == o.colorSpace;
+        && colorSpace == o.colorSpace
+        && hyphens == o.hyphens
+        && hyphenateCharacter == o.hyphenateCharacter;
 }
 
 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
index 9fecfad2c9e80aa81bf44c1a9a56ceb127dc5e99..70ef374e8654dff4c223207542e5427204203f78 100644 (file)
@@ -77,7 +77,10 @@ public:
     unsigned resize : 2; // EResize
     unsigned userSelect : 1;  // EUserSelect
     unsigned colorSpace : 1; // ColorSpace
-    
+    unsigned hyphens : 2; // Hyphens
+
+    AtomicString hyphenateCharacter;
+
 private:
     StyleRareInheritedData();
     StyleRareInheritedData(const StyleRareInheritedData&);
index 062f39f82ddc6960c49cf4d809346d2911087c69..2c5aeb10547521296339bad5abf3a0cc31c12f6e 100644 (file)
@@ -1,3 +1,13 @@
+2010-06-21  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        WebKit part of implementing the 'hyphens' and 'hyphenate-character' properties
+        https://bugs.webkit.org/show_bug.cgi?id=10228
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Initialize wkGetHyphenationLocationBeforeIndex.
+
 2010-06-21  Satish Sampath  <satish@chromium.org>
 
         Reviewed by Steve Block.
index b792707573a8cc4efe2ac0cb6a491cb2ee11cf8d..1dfd23f1a8cfc839fdff144730be88c5d1d05522 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -115,5 +115,7 @@ void InitWebCoreSystemInterface(void)
     INIT(NoteOpenPanelFiles);
 #endif
 
+    INIT(GetHyphenationLocationBeforeIndex);
+
     didInit = true;
 }
index 2ef17a0ff8184756eea8fffc1b44fbbf9d49266e..7fed09e46e455dfe306380203bd358659d569861 100644 (file)
@@ -1,3 +1,15 @@
+2010-06-21  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        WebKitSystemInterface part of CSS3: Implement the 'hyphens' and 'hyphenate-character' properties
+        https://bugs.webkit.org/show_bug.cgi?id=10228
+
+        * WebKitSystemInterface.h: Added WKGetHyphenationLocationBeforeIndex().
+        * libWebKitSystemInterfaceLeopard.a:
+        * libWebKitSystemInterfaceSnowLeopard.a:
+        * libWebKitSystemInterfaceTiger.a:
+
 2010-06-21  Satish Sampath  <satish@chromium.org>
 
         Reviewed by Steve Block.
index 48defe009c126474409a80545b7fb1b35bd816d9..2d1c60b138be32c65f6bd848486b0aa641016f4d 100644 (file)
@@ -300,6 +300,8 @@ NSMutableArray *WKNoteOpenPanelFiles(NSArray *paths);
 void WKSyncSurfaceToView(NSView *view);
 #endif
 
+CFIndex WKGetHyphenationLocationBeforeIndex(CFStringRef string, CFIndex index);
+
 #ifdef __cplusplus
 }
 #endif
index d99cf6869757b61124a8d5421446a1ae5d0260e9..56ec220fd31aa8dfed4d708633ba3eb63c129a65 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index ef9d3467a135e1033cbe0b6c06dcc713225dfd1d..3255029eb6cf113313bfa00b81d51dca1812f4c2 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ
index 65f874d41162cc36fb912907a9b2f9409efc7235..2657e6d6be19cf7bda1de5b58a9876b0b103e685 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceTiger.a and b/WebKitLibraries/libWebKitSystemInterfaceTiger.a differ