WebCore:
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 May 2009 01:25:11 +0000 (01:25 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 May 2009 01:25:11 +0000 (01:25 +0000)
2009-05-11  Darin Adler  <darin@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/6276843> REGRESSION: TextIterator generates
        an extra newline for ranges that start outside of body

        * editing/TextIterator.cpp:
        (WebCore::TextIterator::shouldRepresentNodeOffsetZero):
        Check startPos for null, not just currPos.

LayoutTests:

2009-05-11  Darin Adler  <darin@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/6276843> REGRESSION: TextIterator generates
        an extra newline for ranges that start outside of body

        * editing/text-iterator/basic-iteration-expected.txt:
        Expect success, not failure.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@43533 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/text-iterator/basic-iteration-expected.txt
WebCore/ChangeLog
WebCore/editing/TextIterator.cpp

index 84aeb76..886d34e 100644 (file)
@@ -1,3 +1,13 @@
+2009-05-11  Darin Adler  <darin@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/6276843> REGRESSION: TextIterator generates
+        an extra newline for ranges that start outside of body
+
+        * editing/text-iterator/basic-iteration-expected.txt:
+        Expect success, not failure.
+
 2009-05-11  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
 
         Enable the new passing test, and skip two new failing tests.
index aa9371c..5f7b524 100644 (file)
@@ -13,8 +13,7 @@ FAIL range.selectNodeContents(testDocument.body); plainText.plainText(range) sho
 
 .
 PASS range.selectNodeContents(testDocument.body); plainText.plainText(range) is "hey"
-FAIL range.setStartBefore(testDocument.body); range.setEndAfter(testDocument.body); plainText.plainText(range) should be hey. Was 
-hey.
+PASS range.setStartBefore(testDocument.body); range.setEndAfter(testDocument.body); plainText.plainText(range) is "hey"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 67ab2a5..7d122a3 100644 (file)
@@ -1,3 +1,14 @@
+2009-05-11  Darin Adler  <darin@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/6276843> REGRESSION: TextIterator generates
+        an extra newline for ranges that start outside of body
+
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::shouldRepresentNodeOffsetZero):
+        Check startPos for null, not just currPos.
+
 2009-05-11  Chris Fleizach  <cfleizach@apple.com>
 
         Reviewed by Darin Adler.
index 34fa54b..b311853 100644 (file)
@@ -613,11 +613,13 @@ bool TextIterator::shouldRepresentNodeOffsetZero()
     if (!m_node->renderer() || m_node->renderer()->style()->visibility() != VISIBLE)
         return false;
     
-    // The currPos.isNotNull() check is needed because positions in non-html content
-    // (like svg) do not have visible positions, and we don't want to emit for them either.
+    // The startPos.isNotNull() check is needed because the start could be before the body,
+    // and in that case we'll get null. We don't want to put in newlines at the start in that case.
+    // The currPos.isNotNull() check is needed because positions in non-HTML content
+    // (like SVG) do not have visible positions, and we don't want to emit for them either.
     VisiblePosition startPos = VisiblePosition(m_startContainer, m_startOffset, DOWNSTREAM);
     VisiblePosition currPos = VisiblePosition(m_node, 0, DOWNSTREAM);
-    return currPos.isNotNull() && !inSameLine(startPos, currPos);
+    return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos, currPos);
 }
 
 bool TextIterator::shouldEmitSpaceBeforeAndAfterNode(Node* node)