Further fix for 4053515.
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Mar 2005 01:47:25 +0000 (01:47 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Mar 2005 01:47:25 +0000 (01:47 +0000)
Covered cases where text position doesn't lie inside a
text node.

        Reviewed by Richard.

        * khtml/editing/visible_text.cpp:
        (khtml::TextIterator::setRangeFromLocationAndLength):

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/visible_text.cpp

index 5081ec34fd6f90e5ee2b8cf91e488ef610481598..b5a6551f818eaa1a7286df46dc4dc4941f86d2d1 100644 (file)
@@ -1,3 +1,15 @@
+2005-03-23  Darin Adler   <darin@apple.com>
+
+       Further fix for 4053515.
+
+       Covered cases where text position doesn't lie inside a
+       text node.      
+
+        Reviewed by Richard.
+
+        * khtml/editing/visible_text.cpp:
+        (khtml::TextIterator::setRangeFromLocationAndLength):
+
 2005-03-23  Richard Williamson   <rjw@apple.com>
 
        Fixed <rdar://problem/4053515> REGRESSION (Mail): Kotoeri input method reconversion does not work in WebViews
index 4817e526f2622ef8ada43a849b6bf8fa99dbd3da..be8a1a6bad28be6314c532824b8d78c77da42046 100644 (file)
@@ -995,12 +995,32 @@ void TextIterator::setRangeFromLocationAndLength (const Range &range, Range &res
 
     for (TextIterator it(range); !it.atEnd(); it.advance()) {
         long len = it.length();
-        if (rangeLocation >= docTextPosition && rangeLocation < docTextPosition + len) {
-            resultRange.setStart(it.m_node, rangeLocation - docTextPosition);
+        if (rangeLocation >= docTextPosition && rangeLocation <= docTextPosition + len) {
+            Range textRunRange = it.range();
+            if (textRunRange.startContainer().handle()->isTextNode()) {
+                long offset = rangeLocation - docTextPosition;
+                resultRange.setStart(textRunRange.startContainer(), offset + textRunRange.startOffset());
+            } else {
+                if (rangeLocation == docTextPosition) {
+                    resultRange.setStart(textRunRange.startContainer(), textRunRange.startOffset());
+                } else {
+                    resultRange.setStart(textRunRange.endContainer(), textRunRange.endOffset());
+                }
+            }
         }
         if (rangeEnd >= docTextPosition && rangeEnd <= docTextPosition + len) {
+            Range textRunRange = it.range();
+            if (textRunRange.startContainer().handle()->isTextNode()) {
+                long offset = rangeEnd - docTextPosition;
+                resultRange.setEnd(textRunRange.startContainer(), offset + textRunRange.startOffset());
+            } else {
+                if (rangeEnd == docTextPosition) {
+                    resultRange.setEnd(textRunRange.startContainer(), textRunRange.startOffset());
+                } else {
+                    resultRange.setEnd(textRunRange.endContainer(), textRunRange.endOffset());
+                }
+            }
             if ( !(rangeLength == 0 && rangeEnd == docTextPosition + len) ) {
-                resultRange.setEnd(it.m_node, rangeEnd - docTextPosition);
                 break;
             }
         }