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

Adele adele at opensource.apple.com
Tue Jul 26 14:44:16 PDT 2005


adele       05/07/26 14:44:16

  Modified:    .        Tag: Safari-2-0-branch ChangeLog
               khtml/editing Tag: Safari-2-0-branch visible_text.cpp
                        visible_text.h
               khtml/rendering Tag: Safari-2-0-branch render_text.cpp
                        render_text.h
  Log:
          Merged fix from TOT to Safari-2-0-branch
  
      2005-07-12  Justin Garcia  <justin.garcia at apple.com>
  
          Reviewed by mjs
  
          - Fixes <rdar://problem/4124326> [RTL] Lines in messages with Hebrew text and numbers are truncated by Tiger Mail
  
          Mail sends plaintext when a message doesn't have any formatting, plaintext depends on
          innertext, which depends on TextIterators.  A TextIterator iterates over text boxes
          in render order, but assumes logical order, which was causing the problems.
  
          Test cases added:
          * layout-tests/fast/text/international/bidi-innertext-expected.txt: Added.
          * layout-tests/fast/text/international/bidi-innertext.html: Added.
  
          * khtml/editing/visible_text.cpp:
          (khtml::TextIterator::handleTextNode):
              If the text node contains reversed text, sort the text boxes (m_sortedTextBoxes).
              Not all reversed text will be out of logical order, but this simple check is less expensive
              than doing an exhaustive one.  Most text is LTR and an exhaustive check might hurt performance.
          (khtml::TextIterator::handleTextBox):
              Iterates over sorted text boxes when necessary
          * khtml/editing/visible_text.h:
          * khtml/rendering/render_text.cpp:
          (RenderText::RenderText):
          (RenderText::position):
              If asked to position a text box with reversed text, modify m_containsReversedText
          * khtml/rendering/render_text.h:
          (khtml::InlineTextBox::operator ==): Added to facilitate sorting
          (khtml::InlineTextBox::operator <): Ditto
          (khtml::RenderText::containsReversedText):
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4104.2.75 +35 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4104.2.74
  retrieving revision 1.4104.2.75
  diff -u -r1.4104.2.74 -r1.4104.2.75
  --- ChangeLog	26 Jul 2005 21:14:15 -0000	1.4104.2.74
  +++ ChangeLog	26 Jul 2005 21:44:06 -0000	1.4104.2.75
  @@ -2,6 +2,41 @@
   
           Merged fix from TOT to Safari-2-0-branch
   
  +    2005-07-12  Justin Garcia  <justin.garcia at apple.com>
  +
  +        Reviewed by mjs
  +
  +        - Fixes <rdar://problem/4124326> [RTL] Lines in messages with Hebrew text and numbers are truncated by Tiger Mail 
  +        
  +        Mail sends plaintext when a message doesn't have any formatting, plaintext depends on 
  +        innertext, which depends on TextIterators.  A TextIterator iterates over text boxes 
  +        in render order, but assumes logical order, which was causing the problems.
  +
  +        Test cases added:
  +        * layout-tests/fast/text/international/bidi-innertext-expected.txt: Added.
  +        * layout-tests/fast/text/international/bidi-innertext.html: Added.
  +
  +        * khtml/editing/visible_text.cpp:
  +        (khtml::TextIterator::handleTextNode):
  +            If the text node contains reversed text, sort the text boxes (m_sortedTextBoxes).  
  +            Not all reversed text will be out of logical order, but this simple check is less expensive 
  +            than doing an exhaustive one.  Most text is LTR and an exhaustive check might hurt performance.
  +        (khtml::TextIterator::handleTextBox):
  +            Iterates over sorted text boxes when necessary
  +        * khtml/editing/visible_text.h:
  +        * khtml/rendering/render_text.cpp:
  +        (RenderText::RenderText):
  +        (RenderText::position):
  +            If asked to position a text box with reversed text, modify m_containsReversedText
  +        * khtml/rendering/render_text.h:
  +        (khtml::InlineTextBox::operator ==): Added to facilitate sorting
  +        (khtml::InlineTextBox::operator <): Ditto
  +        (khtml::RenderText::containsReversedText):
  +
  +2005-07-26  Adele Peterson  <adele at apple.com>
  +
  +        Merged fix from TOT to Safari-2-0-branch
  +
       2005-05-26  David Harrison  <harrison at apple.com>
   
           Reviewed by John.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.26.8.1  +19 -5     WebCore/khtml/editing/visible_text.cpp
  
  Index: visible_text.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/visible_text.cpp,v
  retrieving revision 1.26
  retrieving revision 1.26.8.1
  diff -u -r1.26 -r1.26.8.1
  --- visible_text.cpp	24 Mar 2005 01:47:25 -0000	1.26
  +++ visible_text.cpp	26 Jul 2005 21:44:15 -0000	1.26.8.1
  @@ -246,7 +246,16 @@
           return true;
       }
   
  -    m_textBox = renderer->firstTextBox();
  +    // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text)
  +    if (renderer->containsReversedText()) {
  +        m_sortedTextBoxes.clear();
  +        for (InlineTextBox * textBox = renderer->firstTextBox(); textBox; textBox = textBox->nextTextBox()) {
  +            m_sortedTextBoxes.append(textBox);
  +        }
  +        m_sortedTextBoxes.sort(); 
  +    }
  +    
  +    m_textBox = renderer->containsReversedText() ? m_sortedTextBoxes.first() : renderer->firstTextBox();
       handleTextBox();
       return true;
   }
  @@ -257,19 +266,23 @@
       DOMString str = m_node->nodeValue();
       long start = m_offset;
       long end = (m_node == m_endContainer) ? m_endOffset : LONG_MAX;
  -    for (; m_textBox; m_textBox = m_textBox->nextTextBox()) {
  +    while (m_textBox) {
           long textBoxStart = m_textBox->m_start;
           long runStart = kMax(textBoxStart, start);
   
           // Check for collapsed space at the start of this run.
  +        InlineTextBox *firstTextBox = renderer->containsReversedText() ? m_sortedTextBoxes.getFirst() : renderer->firstTextBox();
           bool needSpace = m_lastTextNodeEndedWithCollapsedSpace
  -            || (m_textBox == renderer->firstTextBox() && textBoxStart == runStart && runStart > 0);
  +            || (m_textBox == firstTextBox && textBoxStart == runStart && runStart > 0);
           if (needSpace && !isCollapsibleWhitespace(m_lastCharacter) && !m_lastCharacter.isNull()) {
               emitCharacter(' ', m_node, 0, runStart, runStart);
               return;
           }
           long textBoxEnd = textBoxStart + m_textBox->m_len;
           long runEnd = kMin(textBoxEnd, end);
  +        
  +        // Determine what the next text box will be, but don't advance yet
  +        InlineTextBox *nextTextBox = renderer->containsReversedText() ? m_sortedTextBoxes.next() : m_textBox->nextTextBox();
   
           if (runStart < runEnd) {
               // Handle either a single newline character (which becomes a space),
  @@ -303,8 +316,7 @@
                   return;
               }
   
  -            // Advance to the next text box.
  -            InlineTextBox *nextTextBox = m_textBox->nextTextBox();
  +            // Advance and return
               long nextRunStart = nextTextBox ? nextTextBox->m_start : str.length();
               if (nextRunStart > runEnd) {
                   m_lastTextNodeEndedWithCollapsedSpace = true; // collapsed space between runs or at the end
  @@ -312,6 +324,8 @@
               m_textBox = nextTextBox;
               return;
           }
  +        // Advance and continue
  +        m_textBox = nextTextBox;
       }
   }
   
  
  
  
  1.13.8.1  +5 -0      WebCore/khtml/editing/visible_text.h
  
  Index: visible_text.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/visible_text.h,v
  retrieving revision 1.13
  retrieving revision 1.13.8.1
  diff -u -r1.13 -r1.13.8.1
  --- visible_text.h	23 Mar 2005 19:49:41 -0000	1.13
  +++ visible_text.h	26 Jul 2005 21:44:15 -0000	1.13.8.1
  @@ -27,6 +27,8 @@
   #define KHTML_EDITING_VISIBLE_TEXT_H
   
   #include "dom/dom2_range.h"
  +#include "render_text.h"
  +#include "../kwq/KWQSortedList.h"
   
   namespace khtml {
   
  @@ -112,6 +114,9 @@
       
       // Used for whitespace characters that aren't in the DOM, so we can point at them.
       QChar m_singleCharacterBuffer;
  +    
  +    // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text)
  +    QSortedList<InlineTextBox> m_sortedTextBoxes;
   };
   
   // Iterates through the DOM range, returning all the text, and 0-length boundaries
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.177.8.2 +2 -1      WebCore/khtml/rendering/render_text.cpp
  
  Index: render_text.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_text.cpp,v
  retrieving revision 1.177.8.1
  retrieving revision 1.177.8.2
  diff -u -r1.177.8.1 -r1.177.8.2
  --- render_text.cpp	27 Apr 2005 16:58:40 -0000	1.177.8.1
  +++ render_text.cpp	26 Jul 2005 21:44:15 -0000	1.177.8.2
  @@ -751,7 +751,7 @@
   // -------------------------------------------------------------------------------------
   
   RenderText::RenderText(DOM::NodeImpl* node, DOMStringImpl *_str)
  -    : RenderObject(node), m_linesDirty(false)
  +    : RenderObject(node), m_linesDirty(false), m_containsReversedText(false)
   {
       // init RenderObject attributes
       setRenderText();   // our object inherits from RenderText
  @@ -1647,6 +1647,7 @@
       }
       
       reverse = reverse && !style()->visuallyOrdered();
  +    m_containsReversedText |= reverse;
   
   #ifdef DEBUG_LAYOUT
       QChar *ch = str->s+from;
  
  
  
  1.77.8.1  +7 -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.77
  retrieving revision 1.77.8.1
  diff -u -r1.77 -r1.77.8.1
  --- render_text.h	14 Feb 2005 18:19:18 -0000	1.77
  +++ render_text.h	26 Jul 2005 21:44:15 -0000	1.77.8.1
  @@ -102,6 +102,10 @@
   
       // Overridden to prevent the normal delete from being called.
       void operator delete(void* ptr, size_t sz);
  +    
  +    // Current used only for sorting, == could be made more robust if needed
  +    bool operator ==(const InlineTextBox &b) { return m_start == b.m_start; }
  +    bool operator <(const InlineTextBox &b) { return m_start < b.m_start; }
           
   private:
       // The normal operator new is disallowed.
  @@ -260,6 +264,8 @@
       virtual long previousOffset (long current) const;
       virtual long nextOffset (long current) const;
       
  +    bool containsReversedText() { return m_containsReversedText; }
  +    
   #if APPLE_CHANGES
   public:
   #endif
  @@ -286,6 +292,7 @@
                              // line boxes, and this hint will enable layoutInlineChildren to avoid
                              // just dirtying everything when character data is modified (e.g., appended/inserted
                              // or removed).
  +    bool m_containsReversedText : 1;
   
       // 22 bits left
   #if APPLE_CHANGES
  
  
  



More information about the webkit-changes mailing list