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

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 16:34:16 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2f6625ba384c9e488d7800386e4c8ef39c828fc9
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 26 00:36:49 2010 +0000

    2010-11-24  Ryosuke Niwa  <rniwa at webkit.org>
    
            Crash when moving caret around a word with a first-letter rule and whitespace is not collapsible.
            https://bugs.webkit.org/show_bug.cgi?id=49652
    
            Fixed the crash by giving the correct end offset to emitText in handleTextNode.
    
            This patch does not fix a bug in TextIterator that incorrectly calculates
            the end offset of a word with a first-letter rule as demonstrated in the layout test
            because fixing the bug requires an overhaul of TextIterator and new behavior is consistent
            with the case when whitespace is collapsible.
    
            Test: editing/text-iterator/first-letter-word-boundary.html
    
            * editing/TextIterator.cpp:
            (WebCore::TextIterator::handleTextNode):
    2010-11-24  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Kent Tamura.
    
            Added a test to ensure WebKit does not crash when moving carets around a word
            with a first-letter rule.  While WebKit no longer crashes, the test demonstrates a bug
            that the position offset at the end of word is incorrect.
    
            * editing/text-iterator/first-letter-word-boundary-expected.txt: Added.
            * editing/text-iterator/first-letter-word-boundary.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72748 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 560cc8e..a067f96 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-11-24  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Kent Tamura.
+
+        Added a test to ensure WebKit does not crash when moving carets around a word
+        with a first-letter rule.  While WebKit no longer crashes, the test demonstrates a bug
+        that the position offset at the end of word is incorrect.
+
+        * editing/text-iterator/first-letter-word-boundary-expected.txt: Added.
+        * editing/text-iterator/first-letter-word-boundary.html: Added.
+
 2010-11-25  Ilya Tikhonovsky  <loislo at chromium.org>
 
         Unreviewed. Enable test for Win Release chromuim.
diff --git a/LayoutTests/editing/text-iterator/first-letter-word-boundary-expected.txt b/LayoutTests/editing/text-iterator/first-letter-word-boundary-expected.txt
new file mode 100644
index 0000000..1ee0ba4
--- /dev/null
+++ b/LayoutTests/editing/text-iterator/first-letter-word-boundary-expected.txt
@@ -0,0 +1,10 @@
+This tests moving caret around a word with a first-letter rule. WebKit should not crash. This test also demonstrates a bug that word position is incorrectly reported.
+
+ hello world'
+white-space: normal;
+FAIL: moving forward by word put caret at offset 4 but expected 6
+PASS: moving backward by word put caret at offset 0
+white-space: pre;
+FAIL: moving forward by word put caret at offset 4 but expected 6
+PASS: moving backward by word put caret at offset 0
+
diff --git a/LayoutTests/editing/text-iterator/first-letter-word-boundary.html b/LayoutTests/editing/text-iterator/first-letter-word-boundary.html
new file mode 100644
index 0000000..fbcbc00
--- /dev/null
+++ b/LayoutTests/editing/text-iterator/first-letter-word-boundary.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+
+#test:first-letter {
+    color: red;
+}
+
+</style>
+</head>
+<body>
+<p>This tests moving caret around a word with a first-letter rule. WebKit should not crash.
+This test also demonstrates a bug that word position is incorrectly reported.</p>
+<div id="test" contenteditable> hello world'</div>
+<pre id="console"></pre>
+<script>
+
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function runTest(actor, expectedOffset) {
+    var action = actor() + ' put caret at offset ';
+    var startOffset = window.getSelection().getRangeAt(0).startOffset;
+    action += startOffset;
+    if (startOffset == expectedOffset)
+        console.innerHTML += 'PASS: ' + action + '\n';
+    else
+        console.innerHTML += 'FAIL: ' + action + ' but expected ' + expectedOffset + '\n';
+}
+
+var test = document.getElementById('test');
+var console = document.getElementById('console');
+window.getSelection().setPosition(test, 0);
+
+console.innerHTML += 'white-space: normal;\n';
+runTest(function () {window.getSelection().modify('move', 'forward', 'word'); return 'moving forward by word';}, 6);
+runTest(function () {window.getSelection().modify('move', 'backward', 'word'); return 'moving backward by word';}, 0);
+
+console.innerHTML += 'white-space: pre;\n';
+test.style.whiteSpace = 'pre';
+runTest(function () {window.getSelection().modify('move', 'forward', 'word'); return 'moving forward by word';}, 6);
+runTest(function () {window.getSelection().modify('move', 'backward', 'word'); return 'moving backward by word';}, 0);
+
+</script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3fe6a9c..aaa5b8d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-11-24  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Crash when moving caret around a word with a first-letter rule and whitespace is not collapsible.
+        https://bugs.webkit.org/show_bug.cgi?id=49652
+
+        Fixed the crash by giving the correct end offset to emitText in handleTextNode.
+
+        This patch does not fix a bug in TextIterator that incorrectly calculates
+        the end offset of a word with a first-letter rule as demonstrated in the layout test
+        because fixing the bug requires an overhaul of TextIterator and new behavior is consistent
+        with the case when whitespace is collapsible.
+
+        Test: editing/text-iterator/first-letter-word-boundary.html
+
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::handleTextNode):
+
 2010-11-25  Mike Lawther  <mikelawther at chromium.org>
 
         Reviewed by Kent Tamura.
diff --git a/WebCore/editing/TextIterator.cpp b/WebCore/editing/TextIterator.cpp
index a96268d..2ea16fb 100644
--- a/WebCore/editing/TextIterator.cpp
+++ b/WebCore/editing/TextIterator.cpp
@@ -473,7 +473,7 @@ bool TextIterator::handleTextNode()
             handleTextNodeFirstLetter(static_cast<RenderTextFragment*>(renderer));
             if (m_firstLetterText) {
                 String firstLetter = m_firstLetterText->text();
-                emitText(m_node, m_firstLetterText, m_offset, firstLetter.length());
+                emitText(m_node, m_firstLetterText, m_offset, m_offset + firstLetter.length());
                 m_firstLetterText = 0;
                 m_textBox = 0;
                 return false;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list