Skip to content
Permalink
Browse files
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.

Canonical link: https://commits.webkit.org/127576@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aestes committed Feb 9, 2013
1 parent 5158983 commit 4d7e4729549aa9e94736390918366d49367fb369
Showing 8 changed files with 126 additions and 56 deletions.
@@ -1,3 +1,18 @@
2013-02-08 Andy Estes <aestes@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 <schenney@chromium.org>

[Chromium] Expectation modification after r142327

This file was deleted.

This file was deleted.

@@ -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

@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
<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="../js/resources/js-test-post.js"></script>
</body>
</html>
@@ -1,3 +1,25 @@
2013-02-08 Andy Estes <aestes@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.carlson@apple.com>

[Mac] In-band closed caption tracks are not always initialized correctly
@@ -69,26 +69,35 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
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 @@ void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa
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;
}

@@ -49,6 +49,7 @@ class EllipsisBox : public InlineBox {
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;

0 comments on commit 4d7e472

Please sign in to comment.