Commit b066a99d authored by robhogan's avatar robhogan Committed by Commit bot

Don't paint ellipsis selection

FF and Edge don't paint a selection on the ellipsis.

BUG=642460
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2340533002
Cr-Commit-Position: refs/heads/master@{#419379}
parent 795773c2
......@@ -10,7 +10,7 @@
</head>
<body>
<!-- This expectation depends on the ellipsis is U+2026. -->
<div id="target" class="testDiv"><span style="font-family: Ahem">B</span>&#x2026;</div>
<div class="testDiv"><span id="target" style="font-family: Ahem">B</span>&#x2026;</div>
<script>
var range = document.createRange();
range.selectNode(document.getElementById("target"));
......
......@@ -18,17 +18,16 @@ namespace blink {
void EllipsisBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
if (paintInfo.phase == PaintPhaseSelection)
return;
const ComputedStyle& style = m_ellipsisBox.getLineLayoutItem().styleRef(m_ellipsisBox.isFirstLineStyle());
paintEllipsis(paintInfo, paintOffset, lineTop, lineBottom, style);
}
void EllipsisBoxPainter::paintEllipsis(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const ComputedStyle& style)
{
bool haveSelection = !paintInfo.isPrinting() && paintInfo.phase != PaintPhaseTextClip && m_ellipsisBox.getSelectionState() != SelectionNone;
LayoutRect paintRect(m_ellipsisBox.logicalFrameRect());
if (haveSelection)
paintRect.unite(LayoutRect(m_ellipsisBox.selectionRect()));
m_ellipsisBox.logicalRectToPhysicalRect(paintRect);
paintRect.moveBy(paintOffset);
......@@ -49,42 +48,11 @@ void EllipsisBoxPainter::paintEllipsis(const PaintInfo& paintInfo, const LayoutP
const Font& font = style.font();
if (haveSelection)
paintSelection(context, boxOrigin, style, font);
else if (paintInfo.phase == PaintPhaseSelection)
return;
TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_ellipsisBox.getLineLayoutItem(), style, paintInfo);
if (haveSelection)
textStyle = TextPainter::selectionPaintingStyle(m_ellipsisBox.getLineLayoutItem(), true, paintInfo, textStyle);
TextRun textRun = constructTextRun(font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion);
LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.getFontMetrics().ascent());
TextPainter textPainter(context, font, textRun, textOrigin, boxRect, m_ellipsisBox.isHorizontal());
textPainter.paint(0, m_ellipsisBox.ellipsisStr().length(), m_ellipsisBox.ellipsisStr().length(), textStyle);
}
void EllipsisBoxPainter::paintSelection(GraphicsContext& context, const LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& font)
{
Color textColor = m_ellipsisBox.getLineLayoutItem().resolveColor(style, CSSPropertyColor);
Color c = m_ellipsisBox.getLineLayoutItem().selectionBackgroundColor();
if (!c.alpha())
return;
// If the text color ends up being the same as the selection background, invert the selection
// background.
if (textColor == c)
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
GraphicsContextStateSaver stateSaver(context);
LayoutUnit selectionBottom = m_ellipsisBox.root().selectionBottom();
LayoutUnit top = m_ellipsisBox.root().selectionTop();
LayoutUnit h = m_ellipsisBox.root().selectionHeight();
const int deltaY = roundToInt(m_ellipsisBox.getLineLayoutItem().styleRef().isFlippedLinesWritingMode() ? selectionBottom - m_ellipsisBox.logicalBottom() : m_ellipsisBox.logicalTop() - top);
const FloatPoint localOrigin(LayoutPoint(boxOrigin.x(), boxOrigin.y() - deltaY));
FloatRect clipRect(localOrigin, FloatSize(LayoutSize(m_ellipsisBox.logicalWidth(), h)));
context.clip(clipRect);
context.drawHighlightForText(font, constructTextRun(font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion), localOrigin, h.toInt(), c);
}
} // namespace blink
......@@ -28,7 +28,6 @@ public:
private:
void paintEllipsis(const PaintInfo&, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const ComputedStyle&);
void paintSelection(GraphicsContext&, const LayoutPoint&, const ComputedStyle&, const Font&);
const EllipsisBox& m_ellipsisBox;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment