[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jparent at chromium.org jparent at chromium.org
Wed Dec 22 11:55:13 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7f5fa83b64a172239c5e9cccab33f9b83b08daa8
Author: jparent at chromium.org <jparent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 11 10:30:47 2010 +0000

    2010-08-11  Julie Parent  <jparent at chromium.org>
    
            Reviewed by Justin Garcia.
    
            Crash in replaceSelectionCommand with RTL text.
            https://bugs.webkit.org/show_bug.cgi?id=41485
    
            Adds tests for 4 cases: latin text plus space in RTL region and LTR region,
            and hebrew text plus space in RTL region and LTR region.  Currently, the
            latin text in RTL region case crashes.  Added all combinations of test since
            earlier patch crashed with hebrew text in LTR region.
    
            * editing/execCommand/insert-image-on-top-of-directional-text-expected.txt: Added.
            * editing/execCommand/insert-image-on-top-of-directional-text.html: Added.
    2010-08-11  Julie Parent  <jparent at chromium.org>
    
            Reviewed by Justin Garcia.
    
            Crash in replaceSelectionCommand with RTL text.
            https://bugs.webkit.org/show_bug.cgi?id=41485
    
            For text with mixed directionality, sort the text boxes before
            computing gaps, since that code assumes the boxes are in order.
    
            Test: editing/execCommand/insert-image-on-top-of-directional-text.html
    
            * editing/CompositeEditCommand.cpp:
            (WebCore::CompositeEditCommand::deleteInsignificantText): Sort boxes
            like we do in TextIterator before computing gaps.
            * editing/TextIterator.cpp:
            (WebCore::TextIterator::handleTextNode): Use new compareByStart
            rather than compareBoxStart.  No functional change.
            * rendering/InlineTextBox.h:
            (WebCore::InlineTextBox::compareByStart): Moved compareBoxStart
            from TextIterator here so it can be used in multiple places.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65144 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 4d464dd..8f34560 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-08-11  Julie Parent  <jparent at chromium.org>
+
+        Reviewed by Justin Garcia.
+
+        Crash in replaceSelectionCommand with RTL text.
+        https://bugs.webkit.org/show_bug.cgi?id=41485
+
+        Adds tests for 4 cases: latin text plus space in RTL region and LTR region,
+        and hebrew text plus space in RTL region and LTR region.  Currently, the
+        latin text in RTL region case crashes.  Added all combinations of test since
+        earlier patch crashed with hebrew text in LTR region.
+        
+        * editing/execCommand/insert-image-on-top-of-directional-text-expected.txt: Added.
+        * editing/execCommand/insert-image-on-top-of-directional-text.html: Added.
+
 2010-08-11  Alejandro G. Castro  <alex at igalia.com>
 
         Reviewed by Dirk Schulze.
diff --git a/LayoutTests/editing/execCommand/insert-image-on-top-of-directional-text-expected.txt b/LayoutTests/editing/execCommand/insert-image-on-top-of-directional-text-expected.txt
new file mode 100644
index 0000000..4fedc09
--- /dev/null
+++ b/LayoutTests/editing/execCommand/insert-image-on-top-of-directional-text-expected.txt
@@ -0,0 +1,5 @@
+This test uses execCommand('insertImage') to replace the selection in a variety of mixed directionality text. If this doesn't crash, then the test passes.
+ 
+ 
+ 
+ 
diff --git a/LayoutTests/editing/execCommand/insert-image-on-top-of-directional-text.html b/LayoutTests/editing/execCommand/insert-image-on-top-of-directional-text.html
new file mode 100644
index 0000000..887f234
--- /dev/null
+++ b/LayoutTests/editing/execCommand/insert-image-on-top-of-directional-text.html
@@ -0,0 +1,22 @@
+<div>This test uses execCommand('insertImage') to replace the selection in a variety of mixed directionality text.  If this doesn't crash, then the test passes.</div>
+<div dir='rtl' id='rtl1' style='white-space:pre' contentEditable>the </div>
+<div dir='rtl' id='rtl2' style='white-space:pre' contentEditable>אחת </div>
+<div dir='ltr' id='ltr1' style='white-space:pre' contentEditable>the </div>
+<div dir='ltr' id='ltr2' style='white-space:pre' contentEditable>אחת </div>
+<script>
+if (window.layoutTestController)
+     layoutTestController.dumpAsText();
+
+// Select only "the", not the space, LTR text in RTL region.
+document.getSelection().setBaseAndExtent(rtl1.firstChild, 0, rtl1.firstChild, 3);
+document.execCommand('InsertImage', false, "../resources/abe.png");
+// Select only "אחת", not the space, RTL text in RTL region.
+document.getSelection().setBaseAndExtent(rtl2.firstChild, 0, rtl2.firstChild, 3);
+document.execCommand('InsertImage', false, "../resources/abe.png");
+// Select only "the", not the space, LTR text in LTR region.
+document.getSelection().setBaseAndExtent(ltr1.firstChild, 0, ltr1.firstChild, 3);
+document.execCommand('InsertImage', false, "../resources/abe.png");
+// Select only "אחת", not the space, RTL text in LTR region.
+document.getSelection().setBaseAndExtent(ltr2.firstChild, 0, ltr2.firstChild, 3);
+document.execCommand('InsertImage', false, "../resources/abe.png");
+</script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1cf2780..8ebfc35 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-08-11  Julie Parent  <jparent at chromium.org>
+
+        Reviewed by Justin Garcia.
+
+        Crash in replaceSelectionCommand with RTL text.
+        https://bugs.webkit.org/show_bug.cgi?id=41485
+        
+        For text with mixed directionality, sort the text boxes before
+        computing gaps, since that code assumes the boxes are in order.
+
+        Test: editing/execCommand/insert-image-on-top-of-directional-text.html
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::deleteInsignificantText): Sort boxes
+        like we do in TextIterator before computing gaps.
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::handleTextNode): Use new compareByStart
+        rather than compareBoxStart.  No functional change.
+        * rendering/InlineTextBox.h:
+        (WebCore::InlineTextBox::compareByStart): Moved compareBoxStart
+        from TextIterator here so it can be used in multiple places.
+
 2010-08-11  Fumitoshi Ukai  <ukai at chromium.org>
 
         Unreviewed build fix of Leopard Intel Debug (Build)
diff --git a/WebCore/editing/CompositeEditCommand.cpp b/WebCore/editing/CompositeEditCommand.cpp
index 5ec87d6..4216452 100644
--- a/WebCore/editing/CompositeEditCommand.cpp
+++ b/WebCore/editing/CompositeEditCommand.cpp
@@ -489,7 +489,18 @@ void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un
     if (!textRenderer)
         return;
 
-    InlineTextBox* box = textRenderer->firstTextBox();
+    Vector<InlineTextBox*> sortedTextBoxes;
+    size_t sortedTextBoxesPosition = 0;
+   
+    for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox = textBox->nextTextBox())
+        sortedTextBoxes.append(textBox);
+    
+    // If there is mixed directionality text, the boxes can be out of order,
+    // (like Arabic with embedded LTR), so sort them first. 
+    if (textRenderer->containsReversedText())    
+        std::sort(sortedTextBoxes.begin(), sortedTextBoxes.end(), InlineTextBox::compareByStart);
+    InlineTextBox* box = sortedTextBoxes.isEmpty() ? 0 : sortedTextBoxes[sortedTextBoxesPosition];
+
     if (!box) {
         // whole text node is empty
         removeNode(textNode);
@@ -526,8 +537,12 @@ void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un
         }
         
         prevBox = box;
-        if (box)
-            box = box->nextTextBox();
+        if (box) {
+            if (++sortedTextBoxesPosition < sortedTextBoxes.size())
+                box = sortedTextBoxes[sortedTextBoxesPosition];
+            else
+                box = 0;
+        }
     }
 
     if (!str.isNull()) {
diff --git a/WebCore/editing/TextIterator.cpp b/WebCore/editing/TextIterator.cpp
index 9589bff..7226eba 100644
--- a/WebCore/editing/TextIterator.cpp
+++ b/WebCore/editing/TextIterator.cpp
@@ -442,11 +442,6 @@ void TextIterator::advance()
     }
 }
 
-static inline bool compareBoxStart(const InlineTextBox* first, const InlineTextBox* second)
-{
-    return first->start() < second->start();
-}
-
 bool TextIterator::handleTextNode()
 {
     if (m_fullyClippedStack.top())
@@ -507,7 +502,7 @@ bool TextIterator::handleTextNode()
         for (InlineTextBox* textBox = renderer->firstTextBox(); textBox; textBox = textBox->nextTextBox()) {
             m_sortedTextBoxes.append(textBox);
         }
-        std::sort(m_sortedTextBoxes.begin(), m_sortedTextBoxes.end(), compareBoxStart); 
+        std::sort(m_sortedTextBoxes.begin(), m_sortedTextBoxes.end(), InlineTextBox::compareByStart); 
         m_sortedTextBoxesPosition = 0;
     }
     
diff --git a/WebCore/rendering/InlineTextBox.h b/WebCore/rendering/InlineTextBox.h
index fcbf23a..7d828f3 100644
--- a/WebCore/rendering/InlineTextBox.h
+++ b/WebCore/rendering/InlineTextBox.h
@@ -67,6 +67,7 @@ public:
 
     bool hasHyphen() const { return m_hasEllipsisBoxOrHyphen; }
     void setHasHyphen(bool hasHyphen) { m_hasEllipsisBoxOrHyphen = hasHyphen; }
+    static inline bool compareByStart(const InlineTextBox* first, const InlineTextBox* second) { return first->start() < second->start(); }
 
 private:
     virtual int selectionTop();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list