Changeset 121050 in webkit


Ignore:
Timestamp:
Jun 22, 2012 1:06:54 PM (12 years ago)
Author:
mitz@apple.com
Message:

RenderText’s minimum preferred width is incorrect when soft hyphens are used
https://bugs.webkit.org/show_bug.cgi?id=89775

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/text/soft-hyphen-min-preferred-width.html

  • rendering/RenderText.cpp:

(WebCore::hyphenWidth): Added this helper function.
(WebCore::RenderText::computePreferredLogicalWidths): In places where this function tests
for the soft hyphen character, added a check that the 'hyphens' style property is not set
to 'none', because in that case soft hyphens are not break opportunities. Also added an
explicit check to suppress break opportunities from isBreakable() if the occur after a
soft hyphen and 'hyphens' is set to 'none'. Finally, when measuring text up to a potential
line break, added the width of the hyphen string when needed.

LayoutTests:

  • fast/text/soft-hyphen-min-preferred-width-expected.html: Added.
  • fast/text/soft-hyphen-min-preferred-width.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r121046 r121050  
     12012-06-22  Dan Bernstein  <mitz@apple.com>
     2
     3        RenderText’s minimum preferred width is incorrect when soft hyphens are used
     4        https://bugs.webkit.org/show_bug.cgi?id=89775
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/text/soft-hyphen-min-preferred-width-expected.html: Added.
     9        * fast/text/soft-hyphen-min-preferred-width.html: Added.
     10
    1112012-06-22  Jan Keromnes  <janx@linux.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r121048 r121050  
     12012-06-22  Dan Bernstein  <mitz@apple.com>
     2
     3        RenderText’s minimum preferred width is incorrect when soft hyphens are used
     4        https://bugs.webkit.org/show_bug.cgi?id=89775
     5
     6        Reviewed by Simon Fraser.
     7
     8        Test: fast/text/soft-hyphen-min-preferred-width.html
     9
     10        * rendering/RenderText.cpp:
     11        (WebCore::hyphenWidth): Added this helper function.
     12        (WebCore::RenderText::computePreferredLogicalWidths): In places where this function tests
     13        for the soft hyphen character, added a check that the 'hyphens' style property is not set
     14        to 'none', because in that case soft hyphens are not break opportunities. Also added an
     15        explicit check to suppress break opportunities from isBreakable() if the occur after a
     16        soft hyphen and 'hyphens' is set to 'none'. Finally, when measuring text up to a potential
     17        line break, added the width of the hyphen string when needed.
     18
    1192012-06-22  Dean Jackson  <dino@apple.com>
    220
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r120495 r121050  
    883883}
    884884
     885static inline float hyphenWidth(RenderText* renderer, const Font& font)
     886{
     887    RenderStyle* style = renderer->style();
     888    return font.width(RenderBlock::constructTextRun(renderer, font, style->hyphenString().string(), style));
     889}
     890
    885891void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
    886892{
     
    964970            lastWordBoundary++;
    965971            continue;
    966         } else if (c == softHyphen) {
     972        } else if (c == softHyphen && styleToUse->hyphens() != HyphensNone) {
    967973            currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow);
    968974            if (firstGlyphLeftOverflow < 0)
     
    975981        bool betweenWords = true;
    976982        int j = i;
    977         while (c != '\n' && !isSpaceAccordingToStyle(c, styleToUse) && c != '\t' && c != softHyphen) {
     983        while (c != '\n' && !isSpaceAccordingToStyle(c, styleToUse) && c != '\t' && (c != softHyphen || styleToUse->hyphens() == HyphensNone)) {
    978984            j++;
    979985            if (j == len)
    980986                break;
    981987            c = txt[j];
    982             if (isBreakable(breakIterator, j, nextBreakable, breakNBSP))
     988            if (isBreakable(breakIterator, j, nextBreakable, breakNBSP) && txt[j - 1] != softHyphen)
    983989                break;
    984990            if (breakAll) {
     
    9941000            if (wordTrailingSpaceWidth && isSpace)
    9951001                w = widthFromCache(f, i, wordLen + 1, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow) - wordTrailingSpaceWidth;
    996             else
     1002            else {
    9971003                w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow);
     1004                if (c == softHyphen && styleToUse->hyphens() != HyphensNone)
     1005                    currMinWidth += hyphenWidth(this, f);
     1006            }
    9981007
    9991008            if (firstGlyphLeftOverflow < 0)
Note: See TracChangeset for help on using the changeset viewer.