Caret is drawn in the wrong place in multi-column blocks
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Oct 2011 05:52:52 +0000 (05:52 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Oct 2011 05:52:52 +0000 (05:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70662

Reviewed by Gavin Barraclough.

* manual-tests/caret-in-columns.html: Added.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintCaret): Removed the call to offsetForContents(). That function takes
a point in local coordinates, whereas this function was applying it to a point in painting root
coordinates. The desired effect was only to undo the scroll adjustment done by the caller,
paintObject().
(WebCore::RenderBlock::paintObject): Pass the original, rather than scroll-adjusted, paint offset
to paintCaret().

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

Source/WebCore/ChangeLog
Source/WebCore/manual-tests/caret-in-columns.html [new file with mode: 0644]
Source/WebCore/rendering/RenderBlock.cpp

index ac2525ce25a7fd5cade91da32db8e889d65a4645..84d25e57f26b8da1eebbc6f53ab2f0e09e63657f 100755 (executable)
@@ -1,3 +1,19 @@
+2011-10-21  Dan Bernstein  <mitz@apple.com>
+
+        Caret is drawn in the wrong place in multi-column blocks
+        https://bugs.webkit.org/show_bug.cgi?id=70662
+
+        Reviewed by Gavin Barraclough.
+
+        * manual-tests/caret-in-columns.html: Added.
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintCaret): Removed the call to offsetForContents(). That function takes
+        a point in local coordinates, whereas this function was applying it to a point in painting root
+        coordinates. The desired effect was only to undo the scroll adjustment done by the caller,
+        paintObject().
+        (WebCore::RenderBlock::paintObject): Pass the original, rather than scroll-adjusted, paint offset
+        to paintCaret().
+
 2011-10-21  Nat Duca  <nduca@chromium.org>
 
         [chromium] Make setVisibility extension- and thread-correct
diff --git a/Source/WebCore/manual-tests/caret-in-columns.html b/Source/WebCore/manual-tests/caret-in-columns.html
new file mode 100644 (file)
index 0000000..3941508
--- /dev/null
@@ -0,0 +1,21 @@
+<div id="target" style="
+    margin: 100px;
+    -webkit-columns: 3;
+    width: 300px;
+    height: 100px;
+    -webkit-user-modify: read-write;
+    outline: none;
+">
+    <br>
+    <br>
+    <br>
+    <br>
+    <br>
+    <br>
+    The blinking insertion point should be here &rarr;
+</div>
+<script>
+    var target = document.getElementById("target");
+    target.focus();
+    getSelection().modify("move", "forward", "documentboundary");
+</script>
index 0262b396d523922f2e45df9069253e711793fb22..50ddc2321347521af6817d1f15981e95ae7d9a4f 100644 (file)
@@ -2549,15 +2549,10 @@ void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffse
     }
 
     if (caretPainter == this && (isContentEditable || caretBrowsing)) {
-        // Convert the painting offset into the local coordinate system of this renderer,
-        // to match the localCaretRect computed by the FrameSelection
-        LayoutPoint adjustedPaintOffset = paintOffset;
-        offsetForContents(adjustedPaintOffset);
-
         if (type == CursorCaret)
-            frame()->selection()->paintCaret(paintInfo.context, adjustedPaintOffset, paintInfo.rect);
+            frame()->selection()->paintCaret(paintInfo.context, paintOffset, paintInfo.rect);
         else
-            frame()->page()->dragCaretController()->paintDragCaret(frame(), paintInfo.context, adjustedPaintOffset, paintInfo.rect);
+            frame()->page()->dragCaretController()->paintDragCaret(frame(), paintInfo.context, paintOffset, paintInfo.rect);
     }
 }
 
@@ -2640,8 +2635,8 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
     // If the caret's node's render object's containing block is this block, and the paint action is PaintPhaseForeground,
     // then paint the caret.
     if (paintPhase == PaintPhaseForeground) {        
-        paintCaret(paintInfo, scrolledOffset, CursorCaret);
-        paintCaret(paintInfo, scrolledOffset, DragCaret);
+        paintCaret(paintInfo, paintOffset, CursorCaret);
+        paintCaret(paintInfo, paintOffset, DragCaret);
     }
 }