Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Don't hyphenate the last word in a paragraph of text.
https://bugs.webkit.org/show_bug.cgi?id=156803 Reviewed by Simon Fraser. Source/WebCore: Added fast/text/hyphenate-avoid-orphaned-word.html * rendering/RenderText.h: * rendering/line/BreakingContext.h: (WebCore::BreakingContext::handleText): LayoutTests: * fast/text/hyphenate-avoid-orphaned-word.html: Added. * platform/mac/fast/text/hyphenate-avoid-orphaned-word-expected.txt: Added. * platform/mac/fast/text/hyphenate-limit-before-after-expected.txt: Canonical link: https://commits.webkit.org/174953@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
212 additions
and 9 deletions.
- +11 −0 LayoutTests/ChangeLog
- +76 −0 LayoutTests/fast/text/hyphenate-avoid-orphaned-word.html
- +93 −0 LayoutTests/platform/mac/fast/text/hyphenate-avoid-orphaned-word-expected.txt
- +6 −6 LayoutTests/platform/mac/fast/text/hyphenate-limit-before-after-expected.txt
- +13 −0 Source/WebCore/ChangeLog
- +2 −1 Source/WebCore/rendering/RenderText.h
- +11 −2 Source/WebCore/rendering/line/BreakingContext.h
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,76 @@ | ||
<style> | ||
html { | ||
-webkit-locale: "en_US"; | ||
} | ||
|
||
.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.</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. | ||
</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. </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. </div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,93 @@ | ||
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 344x240 | ||
RenderBlock {P} at (0,16) size 344x18 | ||
RenderText {#text} at (0,0) size 208x18 | ||
text run at (0,0) width 208: "The initial value (should be like " | ||
RenderInline {TT} at (0,0) size 33x15 | ||
RenderText {#text} at (207,2) size 33x15 | ||
text run at (207,2) width 33: "auto" | ||
RenderText {#text} at (239,0) size 6x18 | ||
text run at (239,0) width 6: ")" | ||
RenderBlock {DIV} at (0,50) size 344x190 [border: (3px solid #000000)] | ||
RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF] | ||
RenderText {#text} at (7,7) size 330x176 | ||
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" + hyphen string "-" | ||
text run at (7,73) width 209: "ting its body tucked away, " | ||
text run at (215,73) width 37: "com" + hyphen string "-" | ||
text run at (7,95) width 245: "fortably enough, under her arm," | ||
text run at (7,117) width 228: "with its legs hanging down, " | ||
text run at (234,117) width 103: "but generally," | ||
text run at (7,139) width 330: "just as she had got its neck nicely" | ||
text run at (7,161) width 93: "straightened." | ||
RenderBlock (floating) {DIV} at (356,0) size 344x240 | ||
RenderBlock {P} at (0,16) size 344x18 | ||
RenderText {#text} at (0,0) size 83x18 | ||
text run at (0,0) width 83: "The default (" | ||
RenderInline {TT} at (0,0) size 196x15 | ||
RenderText {#text} at (82,2) size 196x15 | ||
text run at (82,2) width 196: "hyphenate-character: auto" | ||
RenderText {#text} at (277,0) size 6x18 | ||
text run at (277,0) width 6: ")" | ||
RenderBlock {DIV} at (0,50) size 344x190 [border: (3px solid #000000)] | ||
RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF] | ||
RenderText {#text} at (7,7) size 330x176 | ||
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" + hyphen string "-" | ||
text run at (7,73) width 209: "ting its body tucked away, " | ||
text run at (215,73) width 37: "com" + hyphen string "-" | ||
text run at (7,95) width 245: "fortably enough, under her arm," | ||
text run at (7,117) width 228: "with its legs hanging down, " | ||
text run at (234,117) width 103: "but generally," | ||
text run at (7,139) width 330: "just as she had got its neck nicely" | ||
text run at (7,161) width 93: "straightened." | ||
RenderBlock (floating) {DIV} at (4,240) size 344x240 | ||
RenderBlock {P} at (0,16) size 344x18 | ||
RenderText {#text} at (0,0) size 49x18 | ||
text run at (0,0) width 49: "Bullet (" | ||
RenderInline {TT} at (0,0) size 219x15 | ||
RenderText {#text} at (48,2) size 219x15 | ||
text run at (48,2) width 219: "hyphenate-character: \"\\2022\"" | ||
RenderText {#text} at (266,0) size 7x18 | ||
text run at (266,0) width 7: ")" | ||
RenderBlock {DIV} at (0,50) size 344x190 [border: (3px solid #000000)] | ||
RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF] | ||
RenderText {#text} at (7,7) size 330x176 | ||
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" + hyphen string "\x{2022}" | ||
text run at (7,73) width 208: "ting its body tucked away, " | ||
text run at (214,73) width 38: "com" + hyphen string "\x{2022}" | ||
text run at (7,95) width 245: "fortably enough, under her arm," | ||
text run at (7,117) width 228: "with its legs hanging down, " | ||
text run at (234,117) width 103: "but generally," | ||
text run at (7,139) width 330: "just as she had got its neck nicely" | ||
text run at (7,161) width 93: "straightened." | ||
RenderBlock (floating) {DIV} at (356,240) size 356x240 | ||
RenderBlock {P} at (0,16) size 356x18 | ||
RenderText {#text} at (0,0) size 140x18 | ||
text run at (0,0) width 140: "Middle dot and tilde (" | ||
RenderInline {TT} at (0,0) size 212x15 | ||
RenderText {#text} at (139,2) size 212x15 | ||
text run at (139,2) width 212: "hyphenate-character: \"\\B7~\"" | ||
RenderText {#text} at (350,0) size 6x18 | ||
text run at (350,0) width 6: ")" | ||
RenderBlock {DIV} at (0,50) size 344x190 [border: (3px solid #000000)] | ||
RenderBlock (floating) {DIV} at (262,7) size 75x90 [bgcolor=#F0F8FF] | ||
RenderText {#text} at (7,7) size 330x176 | ||
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" + hyphen string "\x{B7}~" | ||
text run at (7,73) width 200: "ting its body tucked away, " | ||
text run at (206,73) width 46: "com" + hyphen string "\x{B7}~" | ||
text run at (7,95) width 245: "fortably enough, under her arm," | ||
text run at (7,117) width 228: "with its legs hanging down, " | ||
text run at (234,117) width 103: "but generally," | ||
text run at (7,139) width 330: "just as she had got its neck nicely" | ||
text run at (7,161) width 93: "straightened." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters