Title: [142335] trunk
Revision
142335
Author
aes...@apple.com
Date
2013-02-08 17:48:09 -0800 (Fri, 08 Feb 2013)

Log Message

Restore pre-r118852 behavior for EllipsisBox::nodeAtPoint()
https://bugs.webkit.org/show_bug.cgi?id=109277

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/flexbox/line-clamp-link-after-ellipsis.html

Roll out r118852. Enough time has passed that this can't be done
mechanically, so transcribe the old method definition to current
WebCore interfaces.

* rendering/EllipsisBox.cpp:
(WebCore::EllipsisBox::markupBox): EllipsisBox no longer has
m_markupBox, so break the logic for finding the markup box from
paintMarkupBox() into its own function.
(WebCore::EllipsisBox::paintMarkupBox): Call markupBox().
(WebCore::EllipsisBox::nodeAtPoint): Transcribe the pre-r118852 implementation.
* rendering/EllipsisBox.h:
(EllipsisBox): Declare markupBox().

LayoutTests:

Remove test added by r118852 and add a test that verifies the original
expected behavior.

* fast/css/text-overflow-ellipsis-hit-test-expected.txt: Removed.
* fast/css/text-overflow-ellipsis-hit-test.html: Removed.
* fast/flexbox/line-clamp-link-after-ellipsis-expected.txt: Added.
* fast/flexbox/line-clamp-link-after-ellipsis.html: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142334 => 142335)


--- trunk/LayoutTests/ChangeLog	2013-02-09 01:32:16 UTC (rev 142334)
+++ trunk/LayoutTests/ChangeLog	2013-02-09 01:48:09 UTC (rev 142335)
@@ -1,3 +1,18 @@
+2013-02-08  Andy Estes  <aes...@apple.com>
+
+        Restore pre-r118852 behavior for EllipsisBox::nodeAtPoint()
+        https://bugs.webkit.org/show_bug.cgi?id=109277
+
+        Reviewed by Simon Fraser.
+
+        Remove test added by r118852 and add a test that verifies the original
+        expected behavior.
+
+        * fast/css/text-overflow-ellipsis-hit-test-expected.txt: Removed.
+        * fast/css/text-overflow-ellipsis-hit-test.html: Removed.
+        * fast/flexbox/line-clamp-link-after-ellipsis-expected.txt: Added.
+        * fast/flexbox/line-clamp-link-after-ellipsis.html: Added.
+
 2013-02-08  Stephen Chenney  <schen...@chromium.org>
 
         [Chromium] Expectation modification after r142327

Deleted: trunk/LayoutTests/fast/css/text-overflow-ellipsis-hit-test-expected.txt (142334 => 142335)


--- trunk/LayoutTests/fast/css/text-overflow-ellipsis-hit-test-expected.txt	2013-02-09 01:32:16 UTC (rev 142334)
+++ trunk/LayoutTests/fast/css/text-overflow-ellipsis-hit-test-expected.txt	2013-02-09 01:48:09 UTC (rev 142335)
@@ -1,10 +0,0 @@
-This tests the hit-testing of text-overflow:ellipsis. Click and hover events should be unaffected by the ellipsis.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS test.firstElementChild.textContent is "clicked"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/fast/css/text-overflow-ellipsis-hit-test.html (142334 => 142335)


--- trunk/LayoutTests/fast/css/text-overflow-ellipsis-hit-test.html	2013-02-09 01:32:16 UTC (rev 142334)
+++ trunk/LayoutTests/fast/css/text-overflow-ellipsis-hit-test.html	2013-02-09 01:48:09 UTC (rev 142335)
@@ -1,39 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-#test {
-text-overflow: ellipsis;
-width: 3em;
-overflow: hidden;
-white-space: nowrap;
-position: absolute;
-left: 10px;
-top: 10px;
-font-size: 20px;
-font-family: ahem;
-}
-</style>
-<script src=""
-</head>
-<body>
-<div id="test"><a href="" _onclick_="this.textContent='clicked'">unclicked</a></div>
-<script>
-description('This tests the hit-testing of text-overflow:ellipsis. Click and hover events should be unaffected by the ellipsis.');
-
-var test = document.getElementById("test");
-
-if (window.eventSender) {
-  eventSender.mouseMoveTo(40, 20);
-  eventSender.mouseDown();
-  eventSender.mouseUp();
-}
-
-shouldBeEqualToString("test.firstElementChild.textContent", "clicked");
-
-// Clean up after ourselves
-test.parentNode.removeChild(test);
-</script>
-<script src=""
-</body>
-</html>

Added: trunk/LayoutTests/fast/flexbox/line-clamp-link-after-ellipsis-expected.txt (0 => 142335)


--- trunk/LayoutTests/fast/flexbox/line-clamp-link-after-ellipsis-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/flexbox/line-clamp-link-after-ellipsis-expected.txt	2013-02-09 01:48:09 UTC (rev 142335)
@@ -0,0 +1,12 @@
+Test that links painted after the ellipsis of a flexbox using -webkit-line-clamp is hit-testable.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementsByTagName('a')[0].textContent is "clicked"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+line one
+line twoclicked
+

Added: trunk/LayoutTests/fast/flexbox/line-clamp-link-after-ellipsis.html (0 => 142335)


--- trunk/LayoutTests/fast/flexbox/line-clamp-link-after-ellipsis.html	                        (rev 0)
+++ trunk/LayoutTests/fast/flexbox/line-clamp-link-after-ellipsis.html	2013-02-09 01:48:09 UTC (rev 142335)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+span#container {
+    display: inline-block; /* clamp the width of the enclosing P to its contents */
+}
+
+div#flexbox {
+    -webkit-box-orient: vertical;
+    -webkit-line-clamp: 1;
+    display: -webkit-box;
+    overflow-y: hidden;
+}
+</style>
+</head>
+<body>
+<span id="container">
+    <div id="flexbox">line one<br>line two<a id="link" href="" _onclick_="this.textContent='clicked'">not clicked</a></div>
+</span>
+<script>
+description('Test that links painted after the ellipsis of a flexbox using -webkit-line-clamp is hit-testable.');
+
+var divRect = document.getElementById("flexbox").getBoundingClientRect();
+var aRect = document.getElementById("link").getBoundingClientRect();
+var clickX = divRect.left + divRect.width - (aRect.width / 2);
+var clickY = divRect.top + divRect.height  - (aRect.height / 2);
+
+if (window.eventSender) {
+    eventSender.mouseMoveTo(clickX, clickY);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+shouldBeEqualToString("document.getElementsByTagName('a')[0].textContent", "clicked");
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (142334 => 142335)


--- trunk/Source/WebCore/ChangeLog	2013-02-09 01:32:16 UTC (rev 142334)
+++ trunk/Source/WebCore/ChangeLog	2013-02-09 01:48:09 UTC (rev 142335)
@@ -1,3 +1,25 @@
+2013-02-08  Andy Estes  <aes...@apple.com>
+
+        Restore pre-r118852 behavior for EllipsisBox::nodeAtPoint()
+        https://bugs.webkit.org/show_bug.cgi?id=109277
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/flexbox/line-clamp-link-after-ellipsis.html
+
+        Roll out r118852. Enough time has passed that this can't be done
+        mechanically, so transcribe the old method definition to current
+        WebCore interfaces.
+
+        * rendering/EllipsisBox.cpp:
+        (WebCore::EllipsisBox::markupBox): EllipsisBox no longer has
+        m_markupBox, so break the logic for finding the markup box from
+        paintMarkupBox() into its own function.
+        (WebCore::EllipsisBox::paintMarkupBox): Call markupBox().
+        (WebCore::EllipsisBox::nodeAtPoint): Transcribe the pre-r118852 implementation.
+        * rendering/EllipsisBox.h:
+        (EllipsisBox): Declare markupBox().
+
 2013-02-08  Eric Carlson  <eric.carl...@apple.com>
 
         [Mac] In-band closed caption tracks are not always initialized correctly

Modified: trunk/Source/WebCore/rendering/EllipsisBox.cpp (142334 => 142335)


--- trunk/Source/WebCore/rendering/EllipsisBox.cpp	2013-02-09 01:32:16 UTC (rev 142334)
+++ trunk/Source/WebCore/rendering/EllipsisBox.cpp	2013-02-09 01:48:09 UTC (rev 142335)
@@ -69,26 +69,35 @@
     paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
 }
 
-void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, RenderStyle* style)
+InlineBox* EllipsisBox::markupBox() const
 {
     if (!m_shouldPaintMarkupBox || !m_renderer->isRenderBlock())
-        return;
+        return 0;
 
     RenderBlock* block = toRenderBlock(m_renderer);
     RootInlineBox* lastLine = block->lineAtIndex(block->lineCount() - 1);
     if (!lastLine)
-        return;
+        return 0;
 
     // If the last line-box on the last line of a block is a link, -webkit-line-clamp paints that box after the ellipsis.
     // It does not actually move the link.
     InlineBox* anchorBox = lastLine->lastChild();
     if (!anchorBox || !anchorBox->renderer()->style()->isLink())
+        return 0;
+
+    return anchorBox;
+}
+
+void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, RenderStyle* style)
+{
+    InlineBox* markupBox = this->markupBox();
+    if (!markupBox)
         return;
 
     LayoutPoint adjustedPaintOffset = paintOffset;
-    adjustedPaintOffset.move(x() + m_logicalWidth - anchorBox->x(),
-        y() + style->fontMetrics().ascent() - (anchorBox->y() + anchorBox->renderer()->style(isFirstLineStyle())->fontMetrics().ascent()));
-    anchorBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom);
+    adjustedPaintOffset.move(x() + m_logicalWidth - markupBox->x(),
+        y() + style->fontMetrics().ascent() - (markupBox->y() + markupBox->renderer()->style(isFirstLineStyle())->fontMetrics().ascent()));
+    markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom);
 }
 
 IntRect EllipsisBox::selectionRect()
@@ -121,8 +130,28 @@
     context->drawHighlightForText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style->colorSpace());
 }
 
-bool EllipsisBox::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, LayoutUnit, LayoutUnit)
+bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
 {
+    LayoutPoint adjustedLocation = accumulatedOffset + roundedLayoutPoint(topLeft());
+
+    // Hit test the markup box.
+    if (InlineBox* markupBox = this->markupBox()) {
+        RenderStyle* style = m_renderer->style(isFirstLineStyle());
+        LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x();
+        LayoutUnit mty = adjustedLocation.y() + style->fontMetrics().ascent() - (markupBox->y() + markupBox->renderer()->style(isFirstLineStyle())->fontMetrics().ascent());
+        if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutPoint(mtx, mty), lineTop, lineBottom)) {
+            renderer()->updateHitTestResult(result, locationInContainer.point() - LayoutSize(mtx, mty));
+            return true;
+        }
+    }
+
+    LayoutRect boundsRect(adjustedLocation, LayoutSize(m_logicalWidth, m_height));
+    if (visibleToHitTesting() && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
+        renderer()->updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
+        if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, locationInContainer, boundsRect))
+            return true;
+    }
+
     return false;
 }
 

Modified: trunk/Source/WebCore/rendering/EllipsisBox.h (142334 => 142335)


--- trunk/Source/WebCore/rendering/EllipsisBox.h	2013-02-09 01:32:16 UTC (rev 142334)
+++ trunk/Source/WebCore/rendering/EllipsisBox.h	2013-02-09 01:48:09 UTC (rev 142335)
@@ -49,6 +49,7 @@
     virtual int height() const { return m_height; }
     virtual RenderObject::SelectionState selectionState() { return m_selectionState; }
     void paintSelection(GraphicsContext*, const LayoutPoint&, RenderStyle*, const Font&);
+    InlineBox* markupBox() const;
 
     bool m_shouldPaintMarkupBox;
     int m_height;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to