Reviewed by Justin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jan 2006 20:34:00 +0000 (20:34 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jan 2006 20:34:00 +0000 (20:34 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5401
          [WebCoreBridge firstRectForDOMRange:] works incorrectly for the first character after a line wrap

        Test: editing/input/wrapped-line-char-rect.html

        * bridge/mac/WebCoreFrameBridge.mm: (-[WebCoreFrameBridge firstRectForDOMRange:]):
         Use DOWNSTREAM affinity for the range start

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

LayoutTests/ChangeLog
LayoutTests/editing/input/wrapped-line-char-rect-expected.txt [new file with mode: 0644]
LayoutTests/editing/input/wrapped-line-char-rect.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bridge/mac/WebCoreFrameBridge.mm

index 54feac9c073cd03f28eae6bd8258cd1b8a397cb3..cee0889bec2e862cf289412509c7be1d3f2ae627 100644 (file)
@@ -1,3 +1,13 @@
+2006-01-16  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Justin.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5401
+          [WebCoreBridge firstRectForDOMRange:] works incorrectly for the first character after a line wrap
+
+        * editing/input/wrapped-line-char-rect.html: Added.
+        * editing/input/wrapped-line-char-rect-expected.txt: Added.
+
 2006-01-16  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by darin
diff --git a/LayoutTests/editing/input/wrapped-line-char-rect-expected.txt b/LayoutTests/editing/input/wrapped-line-char-rect-expected.txt
new file mode 100644 (file)
index 0000000..86d6fbd
--- /dev/null
@@ -0,0 +1,8 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of P > BODY > HTML > #document to 0 of P > BODY > HTML > #document toDOMRange:range from 0 of #text > P > BODY > HTML > #document to 20 of #text > P > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+aaaaaaaaaa–aaaaaaaaa
+
+Success.
diff --git a/LayoutTests/editing/input/wrapped-line-char-rect.html b/LayoutTests/editing/input/wrapped-line-char-rect.html
new file mode 100644 (file)
index 0000000..8500202
--- /dev/null
@@ -0,0 +1,37 @@
+<html>
+<head>
+<style>
+body { margin: 0; padding: 0 }
+</style>
+</head>
+<body>
+<p contenteditable id='test' STYLE="width: 100px;"></p>
+<script type="text/javascript">
+
+    if (window.layoutTestController) {
+        
+        try {
+        
+            layoutTestController.dumpAsText();
+            window.getSelection().setPosition(document.getElementById("test"), 0);
+            
+            // currently, firstRectForCharacterRange only works with marked or selected text because of bug 4682
+            textInputController.setMarkedText("aaaaaaaaaa–aaaaaaaaa", 0, 0);
+        
+            var rect = textInputController.firstRectForCharacterRange(11, 1);
+            
+            // should be the first character in a line
+            if (rect[0] == 0 && rect[2] > 5)
+               document.write("Success.");
+            else
+               document.write("Failure. Rect: " + rect);
+
+               } catch (ex) {
+                       document.write("Exception: " + ex.description);
+               }
+       } else {
+               document.write("(cannot run interactively)");
+       }
+</script>
+</body>
+</html>
index 7466768940bc653118fc963c58edeab1896d72f4..538c83bd2bbc699db6a3830afb8dd9cd91ec80d9 100644 (file)
@@ -1,3 +1,15 @@
+2006-01-16  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Justin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5401
+          [WebCoreBridge firstRectForDOMRange:] works incorrectly for the first character after a line wrap
+
+        Test: editing/input/wrapped-line-char-rect.html
+
+        * bridge/mac/WebCoreFrameBridge.mm: (-[WebCoreFrameBridge firstRectForDOMRange:]):
+         Use DOWNSTREAM affinity for the range start
+
 2006-01-16  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by darin
index 101b7af848d7309000e371f5002b54f8829d3b34..57609baa6c9d40d09c54a5ae3cd3e07ef19b867b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Alexey Proskuryakov (ap@nypop.com)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1558,7 +1559,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
 - (NSRect)firstRectForDOMRange:(DOMRange *)range
 {
     int extraWidthToEndOfLine = 0;
-    IntRect startCaretRect = [[range startContainer] _nodeImpl]->renderer()->caretRect([range startOffset], UPSTREAM, &extraWidthToEndOfLine);
+    IntRect startCaretRect = [[range startContainer] _nodeImpl]->renderer()->caretRect([range startOffset], DOWNSTREAM, &extraWidthToEndOfLine);
     IntRect endCaretRect = [[range endContainer] _nodeImpl]->renderer()->caretRect([range endOffset], UPSTREAM);
 
     if (startCaretRect.y() == endCaretRect.y()) {