Title: [123904] trunk
Revision
123904
Author
[email protected]
Date
2012-07-27 12:25:43 -0700 (Fri, 27 Jul 2012)

Log Message

Hit testing near a column break can return a result from an adjacent column when there is leading
https://bugs.webkit.org/show_bug.cgi?id=92524

Reviewed by Anders Carlsson.

Source/WebCore: 

The fix for <http://webkit.org/b/92311> relied on the existence of a pagination strut for
detecting that a line was at the beginning of a new column. However, when a line naturally
falls at the beginning of a column, there is no pagination strut, and the check failed.

Test: fast/multicol/hit-test-end-of-column-with-line-height.html

* rendering/InlineFlowBox.h:
(WebCore::InlineFlowBox::InlineFlowBox): Added initializer for new member variable.
(InlineFlowBox): Added m_isFirstAfterPageBreak member variable.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::positionForPointWithInlineChildren): Changed the test for whether a
line was at the beginning of a column from relying on a pagination strut to checking
isFirstAfterPageBreak(). Also refined the hit test itself to include the leading above such
a line.
(WebCore::RenderBlock::adjustLinePositionForPagination): Added calls to
setIsFirstAfterPageBreak() to first reset this flag, then set it to true if necessary.
* rendering/RootInlineBox.h:
(WebCore::RootInlineBox::isFirstAfterPageBreak): Added this accessor.
(WebCore::RootInlineBox::setIsFirstAfterPageBreak): Ditto.

LayoutTests: 

* fast/multicol/hit-test-end-of-column-with-line-height-expected.txt: Added.
* fast/multicol/hit-test-end-of-column-with-line-height.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123903 => 123904)


--- trunk/LayoutTests/ChangeLog	2012-07-27 19:03:07 UTC (rev 123903)
+++ trunk/LayoutTests/ChangeLog	2012-07-27 19:25:43 UTC (rev 123904)
@@ -1,3 +1,13 @@
+2012-07-27  Dan Bernstein  <[email protected]>
+
+        Hit testing near a column break can return a result from an adjacent column when there is leading
+        https://bugs.webkit.org/show_bug.cgi?id=92524
+
+        Reviewed by Anders Carlsson.
+
+        * fast/multicol/hit-test-end-of-column-with-line-height-expected.txt: Added.
+        * fast/multicol/hit-test-end-of-column-with-line-height.html: Added.
+
 2012-07-27  Mike West  <[email protected]>
 
         CSP directives containing invalid characters should log an error.

Added: trunk/LayoutTests/fast/multicol/hit-test-end-of-column-with-line-height-expected.txt (0 => 123904)


--- trunk/LayoutTests/fast/multicol/hit-test-end-of-column-with-line-height-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/hit-test-end-of-column-with-line-height-expected.txt	2012-07-27 19:25:43 UTC (rev 123904)
@@ -0,0 +1,4 @@
+Lorem ipsum dolor sit amet
+PASS
+PASS
+

Added: trunk/LayoutTests/fast/multicol/hit-test-end-of-column-with-line-height.html (0 => 123904)


--- trunk/LayoutTests/fast/multicol/hit-test-end-of-column-with-line-height.html	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/hit-test-end-of-column-with-line-height.html	2012-07-27 19:25:43 UTC (rev 123904)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<div id="target" style="
+    outline: dashed lightblue;
+    width: 400px;
+    -webkit-columns: 2;
+    -webkit-column-gap: 0;
+    height: 80px;
+    font: 20px ahem;
+    line-height: 2;
+">Lorem ipsum dolor sit amet</div>
+<pre id="console"></pre>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    function log(message)
+    {
+        document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
+    }
+
+    // Clicking below the last line in the first column should not select anything from the first
+    // line on the second column.
+    var target = document.getElementById("target");
+    var hitOffset = document.caretRangeFromPoint(target.offsetLeft + 190, target.offsetTop + 77).startOffset;
+    log(hitOffset === 11 ? "PASS" : "FAIL: hit offset " + hitOffset + ".");
+
+    // Clicking above the first line in the second column should not snap to the beginning of the line.
+    hitOffset = document.caretRangeFromPoint(target.offsetLeft + 250, target.offsetTop + 2).startOffset;
+    log(hitOffset === 14 ? "PASS" : "FAIL: hit offset " + hitOffset + ".");
+</script>

Modified: trunk/Source/WebCore/ChangeLog (123903 => 123904)


--- trunk/Source/WebCore/ChangeLog	2012-07-27 19:03:07 UTC (rev 123903)
+++ trunk/Source/WebCore/ChangeLog	2012-07-27 19:25:43 UTC (rev 123904)
@@ -1,3 +1,30 @@
+2012-07-27  Dan Bernstein  <[email protected]>
+
+        Hit testing near a column break can return a result from an adjacent column when there is leading
+        https://bugs.webkit.org/show_bug.cgi?id=92524
+
+        Reviewed by Anders Carlsson.
+
+        The fix for <http://webkit.org/b/92311> relied on the existence of a pagination strut for
+        detecting that a line was at the beginning of a new column. However, when a line naturally
+        falls at the beginning of a column, there is no pagination strut, and the check failed.
+
+        Test: fast/multicol/hit-test-end-of-column-with-line-height.html
+
+        * rendering/InlineFlowBox.h:
+        (WebCore::InlineFlowBox::InlineFlowBox): Added initializer for new member variable.
+        (InlineFlowBox): Added m_isFirstAfterPageBreak member variable.
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::positionForPointWithInlineChildren): Changed the test for whether a
+        line was at the beginning of a column from relying on a pagination strut to checking
+        isFirstAfterPageBreak(). Also refined the hit test itself to include the leading above such
+        a line.
+        (WebCore::RenderBlock::adjustLinePositionForPagination): Added calls to
+        setIsFirstAfterPageBreak() to first reset this flag, then set it to true if necessary.
+        * rendering/RootInlineBox.h:
+        (WebCore::RootInlineBox::isFirstAfterPageBreak): Added this accessor.
+        (WebCore::RootInlineBox::setIsFirstAfterPageBreak): Ditto.
+
 2012-07-27  John J. Barton  <[email protected]>
 
         Web Inspector: Allow front_end to be loaded into an iframe

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (123903 => 123904)


--- trunk/Source/WebCore/rendering/InlineFlowBox.h	2012-07-27 19:03:07 UTC (rev 123903)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h	2012-07-27 19:25:43 UTC (rev 123904)
@@ -49,6 +49,7 @@
         , m_baselineType(AlphabeticBaseline)
         , m_hasAnnotationsBefore(false)
         , m_hasAnnotationsAfter(false)
+        , m_isFirstAfterPageBreak(false)
 #ifndef NDEBUG
         , m_hasBadChildList(false)
 #endif
@@ -321,6 +322,7 @@
     // If the line contains any ruby runs, then this will be true.
     unsigned m_hasAnnotationsBefore : 1;
     unsigned m_hasAnnotationsAfter : 1;
+    bool m_isFirstAfterPageBreak : 1;
 
     unsigned m_lineBreakBidiStatusEor : 5; // WTF::Unicode::Direction
     unsigned m_lineBreakBidiStatusLastStrong : 5; // WTF::Unicode::Direction

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (123903 => 123904)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-07-27 19:03:07 UTC (rev 123903)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-07-27 19:25:43 UTC (rev 123904)
@@ -4926,7 +4926,7 @@
         if (!firstRootBoxWithChildren)
             firstRootBoxWithChildren = root;
 
-        if (root->paginationStrut() && pointInLogicalContents.y() < root->logicalTop())
+        if (root->isFirstAfterPageBreak() && pointInLogicalContents.y() < root->lineTopWithLeading())
             break;
 
         lastRootBoxWithChildren = root;
@@ -6961,6 +6961,7 @@
         layoutState->m_columnInfo->updateMinimumColumnHeight(lineHeight);
     logicalOffset += delta;
     lineBox->setPaginationStrut(0);
+    lineBox->setIsFirstAfterPageBreak(false);
     LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
     bool hasUniformPageLogicalHeight = !inRenderFlowThread() || enclosingRenderFlowThread()->regionsHaveUniformLogicalHeight();
     // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflow.height() still fits, we are
@@ -6984,8 +6985,10 @@
         else {
             delta += remainingLogicalHeight;
             lineBox->setPaginationStrut(remainingLogicalHeight);
+            lineBox->setIsFirstAfterPageBreak(true);
         }
-    }
+    } else if (remainingLogicalHeight == pageLogicalHeight && lineBox != firstRootBox())
+        lineBox->setIsFirstAfterPageBreak(true);
 }
 
 LayoutUnit RenderBlock::adjustBlockChildForPagination(LayoutUnit logicalTopAfterClear, LayoutUnit estimateWithoutPagination, RenderBox* child, bool atBeforeSideOfBlock)

Modified: trunk/Source/WebCore/rendering/RootInlineBox.h (123903 => 123904)


--- trunk/Source/WebCore/rendering/RootInlineBox.h	2012-07-27 19:03:07 UTC (rev 123903)
+++ trunk/Source/WebCore/rendering/RootInlineBox.h	2012-07-27 19:25:43 UTC (rev 123904)
@@ -56,6 +56,9 @@
     LayoutUnit paginationStrut() const { return m_paginationStrut; }
     void setPaginationStrut(LayoutUnit s) { m_paginationStrut = s; }
 
+    bool isFirstAfterPageBreak() const { return m_isFirstAfterPageBreak; }
+    void setIsFirstAfterPageBreak(bool isFirstAfterPageBreak) { m_isFirstAfterPageBreak = isFirstAfterPageBreak; }
+
     LayoutUnit paginatedLineWidth() const { return m_paginatedLineWidth; }
     void setPaginatedLineWidth(LayoutUnit width) { m_paginatedLineWidth = width; }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to