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

David harrison at opensource.apple.com
Mon Nov 7 16:49:10 PST 2005


harrison    05/11/07 16:49:09

  Modified:    .        ChangeLog
               khtml/rendering render_text.cpp render_text.h
  Log:
          Reviewed by Justin and Hyatt.
  
          http://bugzilla.opendarwin.org/show_bug.cgi?id=3739
          Unreproducible - Assertion failure in isEqualIgnoringAffinity on double-click
  
          Test case added:
          * editing/inserting/doubleclick-crash.html
  
          * khtml/rendering/render_text.cpp:
          (RenderText::atLineWrap):
          New utility function.
          (RenderText::caretRect):
          Use atLineWrap.  Remove dead code.
          (RenderText::inlineBox):
          Use atLineWrap.
          * khtml/rendering/render_text.h:
          Add atLineWrap.
  
  Revision  Changes    Path
  1.345     +20 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.344
  retrieving revision 1.345
  diff -u -r1.344 -r1.345
  --- ChangeLog	7 Nov 2005 23:24:15 -0000	1.344
  +++ ChangeLog	8 Nov 2005 00:49:06 -0000	1.345
  @@ -1,3 +1,23 @@
  +2005-11-07  David Harrison  <harrison at apple.com>
  +
  +        Reviewed by Justin and Hyatt.
  +
  +        http://bugzilla.opendarwin.org/show_bug.cgi?id=3739
  +        Unreproducible - Assertion failure in isEqualIgnoringAffinity on double-click
  +
  +        Test case added:
  +        * editing/inserting/doubleclick-crash.html
  +        
  +        * khtml/rendering/render_text.cpp:
  +        (RenderText::atLineWrap):
  +        New utility function.
  +        (RenderText::caretRect):
  +        Use atLineWrap.  Remove dead code.
  +        (RenderText::inlineBox):
  +        Use atLineWrap.
  +        * khtml/rendering/render_text.h:
  +        Add atLineWrap.
  +
   2005-11-07  David Hyatt  <hyatt at apple.com>
   
   	Fix for sluggish loading of large pages due to excessive
  
  
  
  1.207     +23 -29    WebCore/khtml/rendering/render_text.cpp
  
  Index: render_text.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_text.cpp,v
  retrieving revision 1.206
  retrieving revision 1.207
  diff -u -r1.206 -r1.207
  --- render_text.cpp	4 Nov 2005 21:02:46 -0000	1.206
  +++ render_text.cpp	8 Nov 2005 00:49:09 -0000	1.207
  @@ -985,6 +985,7 @@
       return VisiblePosition(element(), 0, DOWNSTREAM);
   }
   
  +static RenderObject *firstRendererOnNextLine(InlineBox *box) __attribute__ ((unused));
   static RenderObject *firstRendererOnNextLine(InlineBox *box)
   {
       if (!box)
  @@ -1031,31 +1032,33 @@
       return lastChild->object();
   }
   
  +bool RenderText::atLineWrap(InlineTextBox *box, int offset)
  +{
  +    if (box->nextTextBox() && !box->nextOnLine() && offset == box->m_start + box->m_len) {
  +        // Take special care because in preformatted text, the newlines
  +        // are in between the text boxes (i.e. not in any box's m_start
  +        // thru m_start+m_len-1), even though they are rendered.
  +        if (!style()->preserveNewline() || str->s[offset] != '\n')
  +            return true;
  +    }
  +    
  +    return false;
  +}
  +
   QRect RenderText::caretRect(int offset, EAffinity affinity, int *extraWidthToEndOfLine)
   {
  -    if (!firstTextBox() || stringLength() == 0) {
  +    if (!firstTextBox() || stringLength() == 0)
           return QRect();
  -    }
   
       // Find the text box for the given offset
       InlineTextBox *box = 0;
       for (box = firstTextBox(); box; box = box->nextTextBox()) {
           if ((offset >= box->m_start) && (offset <= box->m_start + box->m_len)) {
               // Check if downstream affinity would make us move to the next line.
  -            InlineTextBox *nextBox = box->nextTextBox();
  -            if (offset == box->m_start + box->m_len && affinity == DOWNSTREAM  && nextBox &&  !box->nextOnLine()) {
  -                // We're at the end of a line broken on a word boundary and affinity is downstream.
  -                // Try to jump down to the next line.
  -                if (nextBox) {
  -                    // Use the next text box
  -                    box = nextBox;
  -                    offset = box->m_start;
  -                } else {
  -                    // Look on the next line
  -                    RenderObject *object = firstRendererOnNextLine(box);
  -                    if (object)
  -                        return object->caretRect(0, affinity);
  -                }
  +            if (affinity == DOWNSTREAM && atLineWrap(box, offset)) {
  +                // Use the next text box
  +                box = box->nextTextBox();
  +                offset = box->m_start;
               } else {
                   InlineTextBox *prevBox = box->prevTextBox();
                   if (offset == box->m_start && affinity == UPSTREAM && prevBox && !box->prevOnLine()) {
  @@ -1812,21 +1815,12 @@
   {
       for (InlineTextBox *box = firstTextBox(); box; box = box->nextTextBox()) {
           if (offset >= box->m_start && offset <= box->m_start + box->m_len) {
  -            if (affinity == DOWNSTREAM) {
  -                // Take special care because in white-space:pre, the newline
  -                // characters are in between the text boxes (i.e. not in any
  -                // box's m_start thru m_start+m_len-1).  So, check that the
  -                // offset really is in the next text box, vs checking that it
  -                // is simply "past" the current box.
  -                InlineTextBox *nextBox = box->nextTextBox();
  -                if (nextBox && offset >= nextBox->m_start) {
  -                    assert(offset < nextBox->m_start + nextBox->m_len);
  -                    return box->nextTextBox();
  -                }
  -            }
  +            if (affinity == DOWNSTREAM && atLineWrap(box, offset))
  +                return box->nextTextBox();
               return box;
           }
  -        else if (offset < box->m_start) {
  +        
  +        if (offset < box->m_start) {
               // The offset we're looking for is before this node
               // this means the offset must be in content that is
               // not rendered.
  
  
  
  1.92      +1 -0      WebCore/khtml/rendering/render_text.h
  
  Index: render_text.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_text.h,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- render_text.h	6 Oct 2005 00:53:59 -0000	1.91
  +++ render_text.h	8 Nov 2005 00:49:09 -0000	1.92
  @@ -274,6 +274,7 @@
       virtual int previousOffset (int current) const;
       virtual int nextOffset (int current) const;
       
  +    bool atLineWrap(InlineTextBox *box, int offset);
       bool containsReversedText() { return m_containsReversedText; }
       
   #if APPLE_CHANGES
  
  
  



More information about the webkit-changes mailing list