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/InlineTextBoxPainter.h" | 6 #include "core/paint/InlineTextBoxPainter.h" |
7 | 7 |
8 #include "core/editing/CompositionUnderline.h" | 8 #include "core/editing/CompositionUnderline.h" |
9 #include "core/editing/Editor.h" | 9 #include "core/editing/Editor.h" |
10 #include "core/editing/markers/DocumentMarkerController.h" | 10 #include "core/editing/markers/DocumentMarkerController.h" |
11 #include "core/editing/markers/RenderedDocumentMarker.h" | 11 #include "core/editing/markers/RenderedDocumentMarker.h" |
12 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
13 #include "core/layout/LayoutBlock.h" | 13 #include "core/layout/LayoutBlock.h" |
14 #include "core/layout/LayoutTextCombine.h" | 14 #include "core/layout/LayoutTextCombine.h" |
15 #include "core/layout/LayoutTheme.h" | 15 #include "core/layout/LayoutTheme.h" |
16 #include "core/layout/line/InlineTextBox.h" | 16 #include "core/layout/line/InlineTextBox.h" |
17 #include "core/paint/BoxPainter.h" | 17 #include "core/paint/BoxPainter.h" |
| 18 #include "core/paint/LayoutObjectDrawingRecorder.h" |
18 #include "core/paint/PaintInfo.h" | 19 #include "core/paint/PaintInfo.h" |
19 #include "core/paint/TextPainter.h" | 20 #include "core/paint/TextPainter.h" |
20 #include "platform/graphics/GraphicsContextStateSaver.h" | 21 #include "platform/graphics/GraphicsContextStateSaver.h" |
21 #include "platform/graphics/paint/DrawingRecorder.h" | |
22 #include "wtf/Optional.h" | 22 #include "wtf/Optional.h" |
23 | 23 |
24 namespace blink { | 24 namespace blink { |
25 | 25 |
26 typedef WTF::HashMap<const InlineTextBox*, TextBlobPtr> InlineTextBoxBlobCacheMa
p; | 26 typedef WTF::HashMap<const InlineTextBox*, TextBlobPtr> InlineTextBoxBlobCacheMa
p; |
27 static InlineTextBoxBlobCacheMap* gTextBlobCache; | 27 static InlineTextBoxBlobCacheMap* gTextBlobCache; |
28 | 28 |
29 static const int misspellingLineThickness = 3; | 29 static const int misspellingLineThickness = 3; |
30 | 30 |
31 void InlineTextBoxPainter::removeFromTextBlobCache(InlineTextBox& inlineTextBox) | 31 void InlineTextBoxPainter::removeFromTextBlobCache(InlineTextBox& inlineTextBox) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 bool isPrinting = paintInfo.isPrinting(); | 74 bool isPrinting = paintInfo.isPrinting(); |
75 | 75 |
76 // Determine whether or not we're selected. | 76 // Determine whether or not we're selected. |
77 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
m_inlineTextBox.selectionState() != SelectionNone; | 77 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
m_inlineTextBox.selectionState() != SelectionNone; |
78 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { | 78 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { |
79 // When only painting the selection, don't bother to paint if there is n
one. | 79 // When only painting the selection, don't bother to paint if there is n
one. |
80 return; | 80 return; |
81 } | 81 } |
82 | 82 |
83 // The text clip phase already has a DrawingRecorder. Text clips are initiat
ed only in BoxPainter::paintLayerExtended, which is already | 83 // The text clip phase already has a LayoutObjectDrawingRecorder. Text clips
are initiated only in BoxPainter::paintLayerExtended, |
84 // within a DrawingRecorder. | 84 // which is already within a LayoutObjectDrawingRecorder. |
85 Optional<DrawingRecorder> drawingRecorder; | 85 Optional<LayoutObjectDrawingRecorder> drawingRecorder; |
86 if (paintInfo.phase != PaintPhaseTextClip) { | 86 if (paintInfo.phase != PaintPhaseTextClip) { |
87 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in
lineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase))) | 87 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.c
ontext, m_inlineTextBox, paintInfo.phase, paintOffset)) |
88 return; | 88 return; |
89 LayoutRect paintRect(logicalVisualOverflow); | 89 LayoutRect paintRect(logicalVisualOverflow); |
90 m_inlineTextBox.logicalRectToPhysicalRect(paintRect); | 90 m_inlineTextBox.logicalRectToPhysicalRect(paintRect); |
91 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || paintsMa
rkerHighlights(m_inlineTextBox.layoutObject()))) | 91 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || paintsMa
rkerHighlights(m_inlineTextBox.layoutObject()))) |
92 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s
tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); | 92 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s
tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); |
93 paintRect.moveBy(adjustedPaintOffset); | 93 paintRect.moveBy(adjustedPaintOffset); |
94 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem
::paintPhaseToDrawingType(paintInfo.phase), FloatRect(paintRect)); | 94 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, paintInfo.p
hase, paintRect, paintOffset); |
95 } | 95 } |
96 | 96 |
97 if (m_inlineTextBox.truncation() != cNoTruncation) { | 97 if (m_inlineTextBox.truncation() != cNoTruncation) { |
98 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR
ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { | 98 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR
ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { |
99 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin | 99 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin |
100 // at which we start drawing text. | 100 // at which we start drawing text. |
101 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: | 101 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: |
102 // |Hello|CBA| -> |...He|CBA| | 102 // |Hello|CBA| -> |...He|CBA| |
103 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing | 103 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing |
104 // farther to the right. | 104 // farther to the right. |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri
cs().ascent()); | 809 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri
cs().ascent()); |
810 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline
TextBox.isHorizontal()); | 810 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline
TextBox.isHorizontal()); |
811 | 811 |
812 textPainter.paint(sPos, ePos, length, textStyle, 0); | 812 textPainter.paint(sPos, ePos, length, textStyle, 0); |
813 } | 813 } |
814 } | 814 } |
815 } | 815 } |
816 | 816 |
817 | 817 |
818 } // namespace blink | 818 } // namespace blink |
OLD | NEW |