Caret can be positioned or repainted incorrectly in flipped-blocks multi-column blocks
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 22:45:48 +0000 (22:45 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 22:45:48 +0000 (22:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70851

Reviewed by Dave Hyatt.

* manual-tests/caret-in-columns-flipped.html: Added.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::adjustForColumns): Removed flipped-blocks writing mode considerations
from this function, since not all callers were expecting it to account for flippedness. This makes
it similar to adjustRectForColumns() in not adjusting for flippedness.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::offsetFromContainer): In the columns case, account for flipped-blocks modes
by first mapping the point and the offset to non-flipped, non-columns space, then adjusting for
columns, then flipping.

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

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

index ec8c3c6badea1c21d593b54734c80c6408fa5b1d..3be103a143a36bc6b111c3ecbc77c147d261e38f 100644 (file)
@@ -1,3 +1,20 @@
+2011-10-25  Dan Bernstein  <mitz@apple.com>
+
+        Caret can be positioned or repainted incorrectly in flipped-blocks multi-column blocks
+        https://bugs.webkit.org/show_bug.cgi?id=70851
+
+        Reviewed by Dave Hyatt.
+
+        * manual-tests/caret-in-columns-flipped.html: Added.
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::adjustForColumns): Removed flipped-blocks writing mode considerations
+        from this function, since not all callers were expecting it to account for flippedness. This makes
+        it similar to adjustRectForColumns() in not adjusting for flippedness.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::offsetFromContainer): In the columns case, account for flipped-blocks modes
+        by first mapping the point and the offset to non-flipped, non-columns space, then adjusting for
+        columns, then flipping.
+
 2011-10-25  Michal Mocny  <mmocny@google.com>
 
         LayerRendererChromium::setVisible called needlessly without a visibility change
 2011-10-25  Michal Mocny  <mmocny@google.com>
 
         LayerRendererChromium::setVisible called needlessly without a visibility change
diff --git a/Source/WebCore/manual-tests/caret-in-columns-flipped.html b/Source/WebCore/manual-tests/caret-in-columns-flipped.html
new file mode 100644 (file)
index 0000000..b2be4f2
--- /dev/null
@@ -0,0 +1,25 @@
+<p>
+    (Read from bottom to top)
+</p>
+<div id="target" style="
+    margin: 100px;
+    -webkit-columns: 3;
+    width: 300px;
+    height: 100px;
+    -webkit-user-modify: read-write;
+    -webkit-writing-mode: horizontal-bt;
+    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 50ddc2321347521af6817d1f15981e95ae7d9a4f..86b9dc30cf83335905a435c493aee9aae93f59e5 100644 (file)
@@ -4757,10 +4757,7 @@ void RenderBlock::adjustForColumns(LayoutSize& offset, const LayoutPoint& point)
         if (!isHorizontalWritingMode())
             sliceRect = sliceRect.transposedRect();
         
         if (!isHorizontalWritingMode())
             sliceRect = sliceRect.transposedRect();
         
-        // If we have a flipped blocks writing mode, then convert the column so that it's coming from the after edge (either top or left edge).
-        adjustStartEdgeForWritingModeIncludingColumns(sliceRect);
-        
-        LayoutUnit logicalOffset = style()->isFlippedBlocksWritingMode() ? (colCount - 1 - i) * colLogicalHeight : i * colLogicalHeight;
+        LayoutUnit logicalOffset = i * colLogicalHeight;
 
         // Now we're in the same coordinate space as the point.  See if it is inside the rectangle.
         if (isHorizontalWritingMode()) {
 
         // Now we're in the same coordinate space as the point.  See if it is inside the rectangle.
         if (isHorizontalWritingMode()) {
index a34d40c91fe7bfdf00f381c21ddc09f80ab667bb..996293386b8e01ec5021fc3672718e5b4649c26f 100644 (file)
@@ -1422,15 +1422,15 @@ LayoutSize RenderBox::offsetFromContainer(RenderObject* o, const LayoutPoint& po
         offset += relativePositionOffset();
 
     if (!isInline() || isReplaced()) {
         offset += relativePositionOffset();
 
     if (!isInline() || isReplaced()) {
-        if (style()->position() != AbsolutePosition && style()->position() != FixedPosition) {
-            if (o->hasColumns()) {
-                LayoutRect columnRect(frameRect());
-                toRenderBlock(o)->adjustStartEdgeForWritingModeIncludingColumns(columnRect);
-                offset += LayoutSize(columnRect.location().x(), columnRect.location().y());
-                columnRect.moveBy(point);
-                o->adjustForColumns(offset, columnRect.location());
-            } else
-                offset += topLeftLocationOffset();
+        if (style()->position() != AbsolutePosition && style()->position() != FixedPosition && o->hasColumns()) {
+            RenderBlock* block = toRenderBlock(o);
+            LayoutRect columnRect(frameRect());
+            block->adjustStartEdgeForWritingModeIncludingColumns(columnRect);
+            offset += toSize(columnRect.location());
+            IntPoint columnPoint = block->flipForWritingModeIncludingColumns(point + offset);
+            offset = toSize(block->flipForWritingModeIncludingColumns(LayoutPoint(offset)));
+            o->adjustForColumns(offset, columnPoint);
+            offset = block->flipForWritingMode(offset);
         } else
             offset += topLeftLocationOffset();
     }
         } else
             offset += topLeftLocationOffset();
     }