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/dom/DocumentMarkerController.h" | 8 #include "core/dom/DocumentMarkerController.h" |
9 #include "core/dom/RenderedDocumentMarker.h" | 9 #include "core/dom/RenderedDocumentMarker.h" |
10 #include "core/editing/CompositionUnderline.h" | 10 #include "core/editing/CompositionUnderline.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 // Determine whether or not we have composition underlines to draw. | 80 // Determine whether or not we have composition underlines to draw. |
81 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline
TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i
nlineTextBox.layoutObject().node(); | 81 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline
TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i
nlineTextBox.layoutObject().node(); |
82 bool useCustomUnderlines = containsComposition && m_inlineTextBox.layoutObje
ct().frame()->inputMethodController().compositionUsesCustomUnderlines(); | 82 bool useCustomUnderlines = containsComposition && m_inlineTextBox.layoutObje
ct().frame()->inputMethodController().compositionUsesCustomUnderlines(); |
83 | 83 |
84 // The text clip phase already has a DrawingRecorder. Text clips are initiat
ed only in BoxPainter::paintLayerExtended, which is already | 84 // The text clip phase already has a DrawingRecorder. Text clips are initiat
ed only in BoxPainter::paintLayerExtended, which is already |
85 // within a DrawingRecorder. | 85 // within a DrawingRecorder. |
86 Optional<DrawingRecorder> drawingRecorder; | 86 Optional<DrawingRecorder> drawingRecorder; |
87 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai
ntPhaseTextClip) { | 87 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai
ntPhaseTextClip) { |
| 88 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in
lineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase))) |
| 89 return; |
88 LayoutRect paintRect(logicalVisualOverflow); | 90 LayoutRect paintRect(logicalVisualOverflow); |
89 m_inlineTextBox.logicalRectToPhysicalRect(paintRect); | 91 m_inlineTextBox.logicalRectToPhysicalRect(paintRect); |
90 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || contains
Composition || paintsMarkerHighlights(m_inlineTextBox.layoutObject()))) | 92 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || contains
Composition || paintsMarkerHighlights(m_inlineTextBox.layoutObject()))) |
91 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s
tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); | 93 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s
tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); |
92 paintRect.moveBy(adjustedPaintOffset); | 94 paintRect.moveBy(adjustedPaintOffset); |
93 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem
::paintPhaseToDrawingType(paintInfo.phase), paintRect); | 95 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem
::paintPhaseToDrawingType(paintInfo.phase), paintRect); |
94 if (drawingRecorder->canUseCachedDrawing()) | |
95 return; | |
96 } | 96 } |
97 | 97 |
98 if (m_inlineTextBox.truncation() != cNoTruncation) { | 98 if (m_inlineTextBox.truncation() != cNoTruncation) { |
99 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR
ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { | 99 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR
ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { |
100 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin | 100 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin |
101 // at which we start drawing text. | 101 // at which we start drawing text. |
102 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: | 102 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: |
103 // |Hello|CBA| -> |...He|CBA| | 103 // |Hello|CBA| -> |...He|CBA| |
104 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing | 104 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing |
105 // farther to the right. | 105 // farther to the right. |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 LayoutTheme::theme().platformActiveTextSearchHighlightColor() : | 812 LayoutTheme::theme().platformActiveTextSearchHighlightColor() : |
813 LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); | 813 LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); |
814 GraphicsContextStateSaver stateSaver(*pt); | 814 GraphicsContextStateSaver stateSaver(*pt); |
815 pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF
loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); | 815 pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF
loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); |
816 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(),
(boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); | 816 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(),
(boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); |
817 } | 817 } |
818 } | 818 } |
819 | 819 |
820 | 820 |
821 } // namespace blink | 821 } // namespace blink |
OLD | NEW |