[webkit-changes] cvs commit: WebCore/khtml/rendering bidi.cpp

Eric eseidel at opensource.apple.com
Tue Nov 29 18:40:30 PST 2005


eseidel     05/11/29 18:40:30

  Modified:    .        ChangeLog
               khtml/rendering bidi.cpp
  Log:
  Bug #: 4695
  Submitted by: mitz
  Reviewed by: hyatt
          Test: fast/text/span-in-word-space-causes-overflow.html
  
          Fix for: http://bugzilla.opendarwin.org/show_bug.cgi?id=4695
          <span> in word-spaced text breaks width calc, causes overflow
  
          * khtml/rendering/bidi.cpp:
          (khtml::RenderBlock::findNextLineBreak):
  
  Revision  Changes    Path
  1.437     +12 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.436
  retrieving revision 1.437
  diff -u -r1.436 -r1.437
  --- ChangeLog	30 Nov 2005 02:06:27 -0000	1.436
  +++ ChangeLog	30 Nov 2005 02:40:24 -0000	1.437
  @@ -1,3 +1,15 @@
  +2005-11-29  Mitz Pettel  <opendarwin.org at mitzpettel.com>
  +
  +        Reviewed by hyatt.  Committed by eseidel.
  +
  +        Test: fast/text/span-in-word-space-causes-overflow.html
  +
  +        Fix for: http://bugzilla.opendarwin.org/show_bug.cgi?id=4695
  +        <span> in word-spaced text breaks width calc, causes overflow
  +
  +        * khtml/rendering/bidi.cpp:
  +        (khtml::RenderBlock::findNextLineBreak):
  +
   2005-11-29  Andrew Wellington  <proton at wiretapped.net>
   
           Reviewed by darin.  Committed by eseidel.
  
  
  
  1.159     +16 -16    WebCore/khtml/rendering/bidi.cpp
  
  Index: bidi.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/bidi.cpp,v
  retrieving revision 1.158
  retrieving revision 1.159
  diff -u -r1.158 -r1.159
  --- bidi.cpp	28 Nov 2005 04:37:32 -0000	1.158
  +++ bidi.cpp	30 Nov 2005 02:40:29 -0000	1.159
  @@ -2111,6 +2111,7 @@
               // proportional font, needs a bit more work.
               int lastSpace = pos;
               int wordSpacing = o->style()->wordSpacing();
  +            int lastSpaceWordSpacing = 0;
   
               bool appliedStartWidth = pos > 0; // If the span originated on a previous line,
                                                 // then assume the start width has been applied.
  @@ -2144,7 +2145,7 @@
                               addMidpoint(endMid);
                           
                           // Add the width up to but not including the hyphen.
  -                        tmpW += t->width(lastSpace, pos - lastSpace, f, w+tmpW);
  +                        tmpW += t->width(lastSpace, pos - lastSpace, f, w+tmpW) + lastSpaceWordSpacing;
                           
                           // For wrapping text only, include the hyphen.  We need to ensure it will fit
                           // on the line if it shows when we break.
  @@ -2157,6 +2158,7 @@
                       
                       pos++;
                       len--;
  +                    lastSpaceWordSpacing = 0;
                       lastSpace = pos; // Cheesy hack to prevent adding in widths of the run twice.
                       continue;
                   }
  @@ -2179,6 +2181,7 @@
                               // Stop ignoring spaces and begin at this
                               // new point.
                               ignoringSpaces = false;
  +                            lastSpaceWordSpacing = 0;
                               lastSpace = pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
                               BidiIterator startMid ( 0, o, pos );
                               addMidpoint(startMid);
  @@ -2190,14 +2193,13 @@
                           }
                       }
   
  -                    tmpW += t->width(lastSpace, pos - lastSpace, f, w+tmpW);
  +                    tmpW += t->width(lastSpace, pos - lastSpace, f, w+tmpW) + lastSpaceWordSpacing;
                       if (!appliedStartWidth) {
                           tmpW += inlineWidth(o, true, false);
                           appliedStartWidth = true;
                       }
                       
  -                    applyWordSpacing = (wordSpacing && currentCharacterIsSpace && !previousCharacterIsSpace &&
  -                        !t->containsOnlyWhitespace(pos+1, strlen-(pos+1)));
  +                    applyWordSpacing =  wordSpacing && currentCharacterIsSpace && !previousCharacterIsSpace;
   
                       if (o->style()->autoWrap() && w + tmpW > width && w == 0) {
                           int fb = nearestFloatBottom(m_height);
  @@ -2220,7 +2222,8 @@
                       if (o->style()->autoWrap() || breakWords) {
                           // If we break only after white-space, consider the current character
                           // as candidate width for this line.
  -                        int charWidth = o->style()->breakOnlyAfterWhiteSpace() ? t->width(pos, 1, f, w + tmpW) : 0;
  +                        int charWidth = o->style()->breakOnlyAfterWhiteSpace() ?
  +                                            t->width(pos, 1, f, w + tmpW) + (applyWordSpacing ? wordSpacing : 0) : 0;
                           if (w + tmpW + charWidth > width) {
                               if (o->style()->breakOnlyAfterWhiteSpace()) {
                                   // Check if line is too big even without the extra space
  @@ -2253,11 +2256,9 @@
                           lBreak.pos = pos;
                       }
                       
  +                    lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0;
                       lastSpace = pos;
                       
  -                    if (applyWordSpacing)
  -                        w += wordSpacing;
  -                        
                       if (!ignoringSpaces && o->style()->collapseWhiteSpace()) {
                           // If we encounter a newline, or if we encounter a
                           // second space, we need to go ahead and break up this
  @@ -2269,13 +2270,13 @@
                               // spaces. Create a midpoint to terminate the run
                               // before the second space. 
                               addMidpoint(ignoreStart);
  -                            lastSpace = pos;
                           }
                       }
                   } else if (ignoringSpaces) {
                       // Stop ignoring spaces and begin at this
                       // new point.
                       ignoringSpaces = false;
  +                    lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0;
                       lastSpace = pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
                       BidiIterator startMid(0, o, pos);
                       addMidpoint(startMid);
  @@ -2304,7 +2305,7 @@
               
               // IMPORTANT: pos is > length here!
               if (!ignoringSpaces)
  -                tmpW += t->width(lastSpace, pos - lastSpace, f, w+tmpW);
  +                tmpW += t->width(lastSpace, pos - lastSpace, f, w+tmpW) + lastSpaceWordSpacing;
               if (!appliedStartWidth)
                   tmpW += inlineWidth(o, true, false);
               if (!appliedEndWidth)
  @@ -2325,13 +2326,12 @@
                       checkForBreak = false;
                       RenderText* nextText = static_cast<RenderText*>(next);
                       if (nextText->stringLength() != 0) {
  -	                    QChar c = nextText->text()[0];
  +                        QChar c = nextText->text()[0];
                           if (c == ' ' || c == '\t' || (c == '\n' && !next->style()->preserveNewline())) {
  -                        	// If the next item on the line is text, and if we did not end with
  -                        	// a space, then the next text run continues our word (and so it needs to
  -                       	 	// keep adding to |tmpW|.  Just update and continue.
  - 							checkForBreak = true;
  -                        	tmpW += nextText->htmlFont(m_firstLine)->getWordSpacing();
  +                            // If the next item on the line is text, and if we did not end with
  +                            // a space, then the next text run continues our word (and so it needs to
  +                            // keep adding to |tmpW|.  Just update and continue.
  +                            checkForBreak = true;
                           }
                       }
                       bool canPlaceOnLine = (w + tmpW <= width+1) || !autoWrap;
  
  
  



More information about the webkit-changes mailing list