Source/WebCore: RenderBlock::offsetForContents() is wrong in flipped blocks writing...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jul 2012 04:59:30 +0000 (04:59 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jul 2012 04:59:30 +0000 (04:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=92588

Reviewed by Sam Weinig.

Tests: fast/multicol/hit-test-block-axis-flipped.html
       fast/writing-mode/flipped-blocks-hit-test-overflow-scroll.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::offsetForContents): Flip the point, which puts it back in unflipped
coordinates, before adding the scroll offset and adjusting for columns, then flip it back.
(WebCore::RenderBlock::adjustPointToColumnContents): Changed the inline-axis cases to
work with an unflipped point.

LayoutTests: Hit test results are wrong in flipped blocks writing modes with block column axis
https://bugs.webkit.org/show_bug.cgi?id=92588

Reviewed by Sam Weinig.

* fast/multicol/hit-test-block-axis-flipped-expected.txt: Added.
* fast/multicol/hit-test-block-axis-flipped.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/multicol/hit-test-block-axis-flipped-expected.txt [new file with mode: 0644]
LayoutTests/fast/multicol/hit-test-block-axis-flipped.html [new file with mode: 0644]
LayoutTests/fast/writing-mode/flipped-blocks-hit-test-overflow-scroll-expected.txt [new file with mode: 0644]
LayoutTests/fast/writing-mode/flipped-blocks-hit-test-overflow-scroll.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp

index 17535da..b5d29e5 100644 (file)
@@ -1,3 +1,13 @@
+2012-07-28  Dan Bernstein  <mitz@apple.com>
+
+        Hit test results are wrong in flipped blocks writing modes with block column axis
+        https://bugs.webkit.org/show_bug.cgi?id=92588
+
+        Reviewed by Sam Weinig.
+
+        * fast/multicol/hit-test-block-axis-flipped-expected.txt: Added.
+        * fast/multicol/hit-test-block-axis-flipped.html: Added.
+
 2012-07-28  Peter Kasting  <pkasting@google.com>
 
         [Chromium] New baselines and test expectations update.
diff --git a/LayoutTests/fast/multicol/hit-test-block-axis-flipped-expected.txt b/LayoutTests/fast/multicol/hit-test-block-axis-flipped-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/fast/multicol/hit-test-block-axis-flipped.html b/LayoutTests/fast/multicol/hit-test-block-axis-flipped.html
new file mode 100644 (file)
index 0000000..e3511f7
--- /dev/null
@@ -0,0 +1,24 @@
+<div style="-webkit-writing-mode: horizontal-bt;">
+    <div style="
+        margin-top: 300px;
+        outline: dashed lightblue;
+        height: 100px;
+        width: 100px;
+        border-bottom: 25px solid;
+        -webkit-column-axis: vertical;
+        -webkit-column-gap: 50px;
+    ">
+        <div style="height: 100px; background-color: silver;"></div>
+        <div id="target" style="height: 100px; background-color: silver;"></div>
+        <div style="height: 100px; background-color: silver;"></div>
+    </div>
+</div>
+<p id="result">FAIL: Test did not run.</p>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    var hitContainer = document.caretRangeFromPoint(208, 208).startContainer;
+    var target = document.getElementById("target");
+    document.getElementById("result").innerText = hitContainer === target ? "PASS" : "FAIL";
+</script>
diff --git a/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-overflow-scroll-expected.txt b/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-overflow-scroll-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-overflow-scroll.html b/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-overflow-scroll.html
new file mode 100644 (file)
index 0000000..764c518
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<div style="-webkit-writing-mode: horizontal-bt;">
+    <div id="scrollable" style="height: 100px; overflow: hidden;">
+        <div style="height: 100px; width: 100px; background-color: silver;"></div>
+        <div id="target" style="height: 100px; width: 100px; background-color: blue;"></div>
+    </div>
+</div>
+<p id="result">
+    FAIL: Test did not run.
+</p>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    var scrollable = document.getElementById("scrollable");
+    scrollable.scrollTop = 40;
+    var target = document.getElementById("target");
+    var hitContainer = document.caretRangeFromPoint(208, 58).startContainer;
+    document.getElementById("result").innerText = hitContainer === target ? "PASS" : "FAIL";
+</script>
index 28b3eae..abac6b6 100644 (file)
@@ -1,5 +1,21 @@
 2012-07-28  Dan Bernstein  <mitz@apple.com>
 
+        RenderBlock::offsetForContents() is wrong in flipped blocks writing modes
+        https://bugs.webkit.org/show_bug.cgi?id=92588
+
+        Reviewed by Sam Weinig.
+
+        Tests: fast/multicol/hit-test-block-axis-flipped.html
+               fast/writing-mode/flipped-blocks-hit-test-overflow-scroll.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::offsetForContents): Flip the point, which puts it back in unflipped
+        coordinates, before adding the scroll offset and adjusting for columns, then flip it back.
+        (WebCore::RenderBlock::adjustPointToColumnContents): Changed the inline-axis cases to
+        work with an unflipped point.
+
+2012-07-28  Dan Bernstein  <mitz@apple.com>
+
         In flipped lines writing modes, hit testing at the beginning of a column may return a result from the previous column
         https://bugs.webkit.org/show_bug.cgi?id=92566
 
index 3470154..3f1d3b3 100755 (executable)
@@ -5042,11 +5042,15 @@ VisiblePosition RenderBlock::positionForPoint(const LayoutPoint& point)
 
 void RenderBlock::offsetForContents(LayoutPoint& offset) const
 {
+    offset = flipForWritingMode(offset);
+
     if (hasOverflowClip())
         offset += scrolledContentOffset();
 
     if (hasColumns())
         adjustPointToColumnContents(offset);
+
+    offset = flipForWritingMode(offset);
 }
 
 LayoutUnit RenderBlock::availableLogicalWidth() const
@@ -5282,12 +5286,12 @@ void RenderBlock::adjustPointToColumnContents(LayoutPoint& point) const
 
                 // We're inside the column.  Translate the x and y into our column coordinate space.
                 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis)
-                    point.move(columnPoint.x() - colRect.x(), logicalOffset);
+                    point.move(columnPoint.x() - colRect.x(), (!style()->isFlippedBlocksWritingMode() ? logicalOffset : -logicalOffset));
                 else
                     point.move((!style()->isFlippedBlocksWritingMode() ? logicalOffset : -logicalOffset) - colRect.x() + borderLeft() + paddingLeft(), 0);
                 return;
             }
-            
+
             // Move to the next position.
             logicalOffset += colInfo->progressionAxis() == ColumnInfo::InlineAxis ? colRect.height() : colRect.width();
         } else {
@@ -5314,12 +5318,12 @@ void RenderBlock::adjustPointToColumnContents(LayoutPoint& point) const
 
                 // We're inside the column.  Translate the x and y into our column coordinate space.
                 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis)
-                    point.move(logicalOffset, columnPoint.y() - colRect.y());
+                    point.move((!style()->isFlippedBlocksWritingMode() ? logicalOffset : -logicalOffset), columnPoint.y() - colRect.y());
                 else
                     point.move(0, (!style()->isFlippedBlocksWritingMode() ? logicalOffset : -logicalOffset) - colRect.y() + borderTop() + paddingTop());
                 return;
             }
-            
+
             // Move to the next position.
             logicalOffset += colInfo->progressionAxis() == ColumnInfo::InlineAxis ? colRect.width() : colRect.height();
         }