OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/paint/EllipsisBoxPainter.h" | 6 #include "core/paint/EllipsisBoxPainter.h" |
7 | 7 |
8 #include "core/paint/TextPainter.h" | 8 #include "core/paint/TextPainter.h" |
9 #include "core/rendering/EllipsisBox.h" | 9 #include "core/rendering/EllipsisBox.h" |
10 #include "core/rendering/InlineTextBox.h" | |
11 #include "core/rendering/PaintInfo.h" | 10 #include "core/rendering/PaintInfo.h" |
12 #include "core/rendering/RootInlineBox.h" | 11 #include "core/rendering/RootInlineBox.h" |
13 #include "core/rendering/TextRunConstructor.h" | 12 #include "core/rendering/TextRunConstructor.h" |
14 #include "platform/graphics/GraphicsContextStateSaver.h" | 13 #include "platform/graphics/GraphicsContextStateSaver.h" |
15 | 14 |
16 namespace blink { | 15 namespace blink { |
17 | 16 |
18 void EllipsisBoxPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOff
set, LayoutUnit lineTop, LayoutUnit lineBottom) | 17 void EllipsisBoxPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOff
set, LayoutUnit lineTop, LayoutUnit lineBottom) |
19 { | 18 { |
20 GraphicsContext* context = paintInfo.context; | 19 GraphicsContext* context = paintInfo.context; |
21 RenderStyle* style = m_ellipsisBox.renderer().style(m_ellipsisBox.isFirstLin
eStyle()); | 20 RenderStyle* style = m_ellipsisBox.renderer().style(m_ellipsisBox.isFirstLin
eStyle()); |
22 const Font& font = style->font(); | 21 const Font& font = style->font(); |
23 FloatPoint boxOrigin = m_ellipsisBox.locationIncludingFlipping(); | 22 FloatPoint boxOrigin = m_ellipsisBox.locationIncludingFlipping(); |
24 boxOrigin.moveBy(FloatPoint(paintOffset)); | 23 boxOrigin.moveBy(FloatPoint(paintOffset)); |
25 if (!m_ellipsisBox.isHorizontal()) | 24 if (!m_ellipsisBox.isHorizontal()) |
26 boxOrigin.move(0, -m_ellipsisBox.virtualLogicalHeight()); | 25 boxOrigin.move(0, -m_ellipsisBox.virtualLogicalHeight()); |
27 FloatRect boxRect(boxOrigin, LayoutSize(m_ellipsisBox.logicalWidth(), m_elli
psisBox.virtualLogicalHeight())); | 26 FloatRect boxRect(boxOrigin, LayoutSize(m_ellipsisBox.logicalWidth(), m_elli
psisBox.virtualLogicalHeight())); |
28 GraphicsContextStateSaver stateSaver(*context); | 27 GraphicsContextStateSaver stateSaver(*context); |
29 if (!m_ellipsisBox.isHorizontal()) | 28 if (!m_ellipsisBox.isHorizontal()) |
30 context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clock
wise)); | 29 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockwise
)); |
31 FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().asce
nt()); | 30 FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().asce
nt()); |
32 | 31 |
33 bool isPrinting = m_ellipsisBox.renderer().document().printing(); | 32 bool isPrinting = m_ellipsisBox.renderer().document().printing(); |
34 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
m_ellipsisBox.selectionState() != RenderObject::SelectionNone; | 33 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
m_ellipsisBox.selectionState() != RenderObject::SelectionNone; |
35 | 34 |
36 if (haveSelection) | 35 if (haveSelection) |
37 paintSelection(context, boxOrigin, style, font); | 36 paintSelection(context, boxOrigin, style, font); |
38 else if (paintInfo.phase == PaintPhaseSelection) | 37 else if (paintInfo.phase == PaintPhaseSelection) |
39 return; | 38 return; |
40 | 39 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 LayoutUnit top = m_ellipsisBox.root().selectionTop(); | 77 LayoutUnit top = m_ellipsisBox.root().selectionTop(); |
79 LayoutUnit h = m_ellipsisBox.root().selectionHeight(); | 78 LayoutUnit h = m_ellipsisBox.root().selectionHeight(); |
80 const int deltaY = roundToInt(m_ellipsisBox.renderer().style()->isFlippedLin
esWritingMode() ? selectionBottom - m_ellipsisBox.logicalBottom() : m_ellipsisBo
x.logicalTop() - top); | 79 const int deltaY = roundToInt(m_ellipsisBox.renderer().style()->isFlippedLin
esWritingMode() ? selectionBottom - m_ellipsisBox.logicalBottom() : m_ellipsisBo
x.logicalTop() - top); |
81 const FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); | 80 const FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); |
82 FloatRect clipRect(localOrigin, FloatSize(m_ellipsisBox.logicalWidth(), h.to
Float())); | 81 FloatRect clipRect(localOrigin, FloatSize(m_ellipsisBox.logicalWidth(), h.to
Float())); |
83 context->clip(clipRect); | 82 context->clip(clipRect); |
84 context->drawHighlightForText(font, constructTextRun(&m_ellipsisBox.renderer
(), font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion),
localOrigin, h, c); | 83 context->drawHighlightForText(font, constructTextRun(&m_ellipsisBox.renderer
(), font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion),
localOrigin, h, c); |
85 } | 84 } |
86 | 85 |
87 } // namespace blink | 86 } // namespace blink |
OLD | NEW |