Commit fa13fccd authored by mitz@apple.com's avatar mitz@apple.com
Browse files

<rdar://problem/7488126> With text-rendering: optimizelegibility, sometimes lines run too long

https://bugs.webkit.org/show_bug.cgi?id=32794

Reviewed by Sam Weinig.

WebCore: 

Test: platform/mac/fast/text/line-breaking-with-kerning.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::findNextLineBreak): When kerning is enabled, include
the trailing space when measuring a word, then subtract its width. This
accounts for kerning between the last glyph of the word and the following space.

LayoutTests: 

* platform/mac/fast/text/line-breaking-with-kerning-expected.checksum: Added.
* platform/mac/fast/text/line-breaking-with-kerning-expected.png: Added.
* platform/mac/fast/text/line-breaking-with-kerning-expected.txt: Added.
* platform/mac/fast/text/line-breaking-with-kerning.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52889 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 64f6212d
2010-01-06 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
<rdar://problem/7488126> With text-rendering: optimizelegibility, sometimes lines run too long
https://bugs.webkit.org/show_bug.cgi?id=32794
* platform/mac/fast/text/line-breaking-with-kerning-expected.checksum: Added.
* platform/mac/fast/text/line-breaking-with-kerning-expected.png: Added.
* platform/mac/fast/text/line-breaking-with-kerning-expected.txt: Added.
* platform/mac/fast/text/line-breaking-with-kerning.html: Added.
2010-01-06 Eric Seidel <eric@webkit.org>
 
No review.
7280887d18297aeb59691625fd6bad2a
\ No newline at end of file
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 784x582
RenderBlock {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 53x18
text run at (0,0) width 53: "Test for "
RenderInline {I} at (0,0) size 759x36
RenderInline {A} at (0,0) size 307x18 [color=#0000EE]
RenderText {#text} at (53,0) size 307x18
text run at (53,0) width 307: "https://bugs.webkit.org/show_bug.cgi?id=32794"
RenderText {#text} at (360,0) size 759x36
text run at (360,0) width 4: " "
text run at (364,0) width 395: "With text-rendering: optimizelegibility, sometimes lines run too"
text run at (0,18) width 28: "long"
RenderText {#text} at (28,18) size 4x18
text run at (28,18) width 4: "."
RenderBlock {P} at (0,52) size 784x18
RenderText {#text} at (0,0) size 572x18
text run at (0,0) width 422: "Text should not overflow any of these boxes. The terminal of the f "
text run at (422,0) width 150: "may overlap the border."
RenderBlock {DIV} at (0,86) size 251x42 [border: (3px solid #0000FF)]
RenderText {#text} at (3,3) size 245x36
text run at (3,3) width 245: "maintenance of the balance of power"
text run at (3,21) width 13: "in"
RenderBlock {DIV} at (0,138) size 251x42 [border: (3px solid #FF0000)]
RenderText {#text} at (3,3) size 245x36
text run at (3,3) width 245: "maintenance of the balance of"
text run at (3,21) width 57: "power in"
RenderBlock {DIV} at (0,190) size 251x42 [border: (3px solid #0000FF)]
RenderText {#text} at (3,3) size 242x36
text run at (3,3) width 242: "maintenance of the balance of power"
text run at (3,21) width 13: "in"
RenderBlock {DIV} at (0,242) size 251x42 [border: (3px solid #FF0000)]
RenderText {#text} at (3,3) size 201x36
text run at (3,3) width 201: "maintenance of the balance of"
text run at (3,21) width 57: "power in"
RenderBlock {DIV} at (0,294) size 251x24 [border: (3px solid #0000FF)]
RenderText {#text} at (3,3) size 244x18
text run at (3,3) width 244: "f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f"
RenderBlock {DIV} at (0,328) size 251x42 [border: (3px solid #FF0000)]
RenderText {#text} at (3,3) size 235x36
text run at (3,3) width 235: "f f f f f f f f f f f f f f f f f f f f f f"
text run at (3,21) width 92: "f f f f f f f f f"
<style>
div {
font-family: baskerville;
width: 245px;
border: solid blue;
margin: 10px 0;
}
div.optimizelegibility {
text-rendering: optimizelegibility;
border-color: red;
}
</style>
<p>
Test for <i><a href="https://bugs.webkit.org/show_bug.cgi?id=32794">https://bugs.webkit.org/show_bug.cgi?id=32794</a>
With text-rendering: optimizelegibility, sometimes lines run too long</i>.
</p>
<p>
Text should not overflow any of these boxes. The terminal of the f
may overlap the border.
</p>
<div style="text-align: justify;">maintenance of the balance of power in</div>
<div class="optimizelegibility" style="text-align: justify;">maintenance of the balance of power in</div>
<div>maintenance of the balance of power in</div>
<div class="optimizelegibility">maintenance of the balance of power in</div>
<div>f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f</div>
<div class="optimizelegibility">f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f</div>
2010-01-06 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
<rdar://problem/7488126> With text-rendering: optimizelegibility, sometimes lines run too long
https://bugs.webkit.org/show_bug.cgi?id=32794
Test: platform/mac/fast/text/line-breaking-with-kerning.html
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::findNextLineBreak): When kerning is enabled, include
the trailing space when measuring a word, then subtract its width. This
accounts for kerning between the last glyph of the word and the following space.
2010-01-06 Kevin Decker <kdecker@apple.com>
 
Reviewed by Simon Fraser
......@@ -1804,6 +1804,11 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
int wordSpacing = o->style()->wordSpacing();
int lastSpaceWordSpacing = 0;
TextRenderingMode textRenderingMode = f.fontDescription().textRenderingMode();
// Non-zero only when kerning is enabled, in which case we measure words with their trailing
// space, then subtract its width.
int wordTrailingSpaceWidth = textRenderingMode == OptimizeLegibility || textRenderingMode == GeometricPrecision ? f.spaceWidth() + wordSpacing : 0;
int wrapW = tmpW + inlineWidth(o, !appliedStartWidth, true);
int charWidth = 0;
bool breakNBSP = autoWrap && o->style()->nbspMode() == SPACE;
......@@ -1898,7 +1903,11 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
}
}
int additionalTmpW = textWidth(t, lastSpace, pos - lastSpace, f, w + tmpW, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
int additionalTmpW;
if (wordTrailingSpaceWidth && currentCharacterIsSpace)
additionalTmpW = textWidth(t, lastSpace, pos + 1 - lastSpace, f, w + tmpW, isFixedPitch, collapseWhiteSpace) - wordTrailingSpaceWidth + lastSpaceWordSpacing;
else
additionalTmpW = textWidth(t, lastSpace, pos - lastSpace, f, w + tmpW, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
tmpW += additionalTmpW;
if (!appliedStartWidth) {
tmpW += inlineWidth(o, true, false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment