Changeset 26846 in webkit


Ignore:
Timestamp:
Oct 21, 2007 12:10:55 AM (17 years ago)
Author:
mitz
Message:

WebCore:

Reviewed by Dave Hyatt.

Test: fast/text/word-space.html

  • rendering/RenderBlock.cpp: (WebCore::stripTrailingSpace): Added word-spacing to the width of the space being stripped out.
  • rendering/RenderText.cpp: (WebCore::RenderText::trimmedPrefWidths): Changed handling of leading space. Since Font::width includes leading space width but not leading word spacing, this method needs to either remove the width of a space character or add word spacing, depending on stripFrontSpaces. (WebCore::RenderText::calcPrefWidths): Corrected the check for adding trailing word spacing so that it would work in the case where the last space is ignored.
  • rendering/bidi.cpp: (WebCore::RenderBlock::computeHorizontalPositionsForLine): Changed to actually add word spacing to the total width.

LayoutTests:

Reviewed by Dave Hyatt.

  • fast/text/word-space.html: Added.
  • platform/mac/fast/css/word-space-extra-expected.txt: Updated result.
  • platform/mac/fast/text/word-space-expected.checksum: Added.
  • platform/mac/fast/text/word-space-expected.png: Added.
  • platform/mac/fast/text/word-space-expected.txt: Added.
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r26840 r26846  
     12007-10-21  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - test for http://bugs.webkit.org/show_bug.cgi?id=15259
     6          <rdar://problem/5499902> REGRESSION: Text overflows when using word spacing and centering (affects myspace.com music videos page)
     7
     8        * fast/text/word-space.html: Added.
     9        * platform/mac/fast/css/word-space-extra-expected.txt: Updated result.
     10        * platform/mac/fast/text/word-space-expected.checksum: Added.
     11        * platform/mac/fast/text/word-space-expected.png: Added.
     12        * platform/mac/fast/text/word-space-expected.txt: Added.
     13
    1142007-10-20  Dan Bernstein  <mitz@apple.com>
    215
  • trunk/LayoutTests/platform/mac/fast/css/word-space-extra-expected.txt

    r25970 r26846  
    77        RenderText {#text} at (0,0) size 138x28
    88          text run at (0,0) width 138: "word-spacing"
    9       RenderBlock (floating) {PRE} at (0,60) size 1164x167
    10         RenderBlock {H3} at (0,15) size 1164x17
     9      RenderBlock (floating) {PRE} at (0,60) size 1224x167
     10        RenderBlock {H3} at (0,15) size 1224x17
    1111          RenderText {#text} at (0,0) size 204x17
    1212            text run at (0,0) width 204: "In a floated pre"
    13         RenderBlock (anonymous) at (0,47) size 1164x120
     13        RenderBlock (anonymous) at (0,47) size 1224x120
    1414          RenderText {#text} at (0,0) size 220x30
    1515            text run at (0,0) width 0: " "
     
    146146            text run at (1068,105) width 0: " "
    147147      RenderBlock (anonymous) at (0,47) size 769x193
    148         RenderBR {BR} at (1164,0) size 0x18
     148        RenderBR {BR} at (1224,0) size 0x18
    149149      RenderBlock {PRE} at (0,255) size 769x152
    150150        RenderBlock {H3} at (0,0) size 769x17
     
    894894        RenderText {#text} at (0,0) size 131x28
    895895          text run at (0,0) width 131: "both-spacing"
    896       RenderBlock (floating) {PRE} at (0,1599) size 1918x167
    897         RenderBlock {H3} at (0,15) size 1918x17
     896      RenderBlock (floating) {PRE} at (0,1599) size 1978x167
     897        RenderBlock {H3} at (0,15) size 1978x17
    898898          RenderText {#text} at (0,0) size 284x17
    899899            text run at (0,0) width 284: "In a floated pre"
    900         RenderBlock (anonymous) at (0,47) size 1918x120
     900        RenderBlock (anonymous) at (0,47) size 1978x120
    901901          RenderText {#text} at (0,0) size 503x30
    902902            text run at (0,0) width 0: " "
     
    10331033            text run at (1731,105) width 0: " "
    10341034      RenderBlock (anonymous) at (0,1586) size 769x193
    1035         RenderBR {BR} at (1918,0) size 0x18
     1035        RenderBR {BR} at (1978,0) size 0x18
    10361036      RenderBlock {PRE} at (0,1794) size 769x152
    10371037        RenderBlock {H3} at (0,0) size 769x17
  • trunk/WebCore/ChangeLog

    r26843 r26846  
     12007-10-21  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=15259
     6          <rdar://problem/5499902> REGRESSION: Text overflows when using word spacing and centering (affects myspace.com music videos page)
     7
     8        Test: fast/text/word-space.html
     9
     10        * rendering/RenderBlock.cpp:
     11        (WebCore::stripTrailingSpace): Added word-spacing to the width of the
     12        space being stripped out.
     13        * rendering/RenderText.cpp:
     14        (WebCore::RenderText::trimmedPrefWidths): Changed handling of
     15        leading space. Since Font::width includes leading space width but not
     16        leading word spacing, this method needs to either remove the width of a
     17        space character or add word spacing,
     18        depending on stripFrontSpaces.
     19        (WebCore::RenderText::calcPrefWidths): Corrected the check for adding
     20        trailing word spacing so that it would work in the case where the last
     21        space is ignored.
     22        * rendering/bidi.cpp:
     23        (WebCore::RenderBlock::computeHorizontalPositionsForLine): Changed to
     24        actually add word spacing to the total width.
     25
    1262007-10-20  David Hyatt  <hyatt@apple.com>
    227
  • trunk/WebCore/rendering/RenderBlock.cpp

    r25754 r26846  
    35273527        RenderText* t = static_cast<RenderText*>(trailingSpaceChild);
    35283528        const UChar space = ' ';
    3529         int spaceWidth = t->style()->font().width(TextRun(&space, 1)); // FIXME: This ignores first-line.
    3530         inlineMax -= spaceWidth;
     3529        const Font& font = t->style()->font(); // FIXME: This ignores first-line.
     3530        int spaceWidth = font.width(TextRun(&space, 1));
     3531        inlineMax -= spaceWidth + font.wordSpacing();
    35313532        if (inlineMin > inlineMax)
    35323533            inlineMin = inlineMax;
  • trunk/WebCore/rendering/RenderText.cpp

    r26746 r26846  
    448448    hasBreak = m_hasBreak;
    449449
    450     if (stripFrontSpaces && ((*m_text)[0] == ' ' || ((*m_text)[0] == '\n' && !style()->preserveNewline()) || (*m_text)[0] == '\t')) {
     450    if ((*m_text)[0] == ' ' || ((*m_text)[0] == '\n' && !style()->preserveNewline()) || (*m_text)[0] == '\t') {
    451451        const Font& f = style()->font(); // FIXME: This ignores first-line.
    452         const UChar space = ' ';
    453         int spaceWidth = f.width(TextRun(&space, 1));
    454         maxW -= spaceWidth + f.wordSpacing();
     452        if (stripFrontSpaces) {
     453            const UChar space = ' ';
     454            int spaceWidth = f.width(TextRun(&space, 1));
     455            maxW -= spaceWidth;
     456        } else
     457            maxW += f.wordSpacing();
    455458    }
    456459
     
    677680    }
    678681
    679     if (needsWordSpacing && len > 1)
     682    if (needsWordSpacing && len > 1 || ignoringSpaces && !firstWord)
    680683        currMaxWidth += wordSpacing;
    681684
  • trunk/WebCore/rendering/bidi.cpp

    r26434 r26846  
    646646            RenderText* rt = static_cast<RenderText*>(r->obj);
    647647            int textWidth = rt->width(r->m_start, r->m_stop - r->m_start, totWidth, m_firstLine);
    648             int effectiveWidth = textWidth;
    649648            int rtLength = rt->textLength();
    650649            if (rtLength != 0) {
    651                 if (!r->m_start && needsWordSpacing && DeprecatedChar(rt->characters()[r->m_start]).isSpace())
    652                     effectiveWidth += rt->style(m_firstLine)->font().wordSpacing();
     650                if (!r->compact && !r->m_start && needsWordSpacing && DeprecatedChar(rt->characters()[r->m_start]).isSpace())
     651                    totWidth += rt->style(m_firstLine)->font().wordSpacing();
    653652                needsWordSpacing = !DeprecatedChar(rt->characters()[r->m_stop - 1]).isSpace() && r->m_stop == rtLength;         
    654653            }
Note: See TracChangeset for help on using the changeset viewer.