| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // When only painting the selection, don't bother to paint if there is n
one. | 75 // When only painting the selection, don't bother to paint if there is n
one. |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Determine whether or not we have composition underlines to draw. | 79 // Determine whether or not we have composition underlines to draw. |
| 80 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline
TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i
nlineTextBox.layoutObject().node(); | 80 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline
TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i
nlineTextBox.layoutObject().node(); |
| 81 bool useCustomUnderlines = containsComposition && m_inlineTextBox.layoutObje
ct().frame()->inputMethodController().compositionUsesCustomUnderlines(); | 81 bool useCustomUnderlines = containsComposition && m_inlineTextBox.layoutObje
ct().frame()->inputMethodController().compositionUsesCustomUnderlines(); |
| 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 DrawingRecorder. Text clips are initiat
ed only in BoxPainter::paintLayerExtended, which is already |
| 84 // within a DrawingRecorder. | 84 // within a DrawingRecorder. |
| 85 OwnPtr<DrawingRecorder> drawingRecorder; | 85 DrawingRecorder drawingRecorder(*paintInfo.context, m_inlineTextBox, Display
Item::paintPhaseToDrawingType(paintInfo.phase)); |
| 86 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai
ntPhaseTextClip) { | 86 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai
ntPhaseTextClip) { |
| 87 LayoutRect paintRect(m_inlineTextBox.logicalRectToPhysicalRect(logicalVi
sualOverflow)); | 87 LayoutRect paintRect(m_inlineTextBox.logicalRectToPhysicalRect(logicalVi
sualOverflow)); |
| 88 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || contains
Composition || paintsMarkerHighlights(m_inlineTextBox.layoutObject()))) | 88 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || contains
Composition || paintsMarkerHighlights(m_inlineTextBox.layoutObject()))) |
| 89 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s
tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); | 89 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s
tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); |
| 90 paintRect.moveBy(adjustedPaintOffset); | 90 paintRect.moveBy(adjustedPaintOffset); |
| 91 drawingRecorder = adoptPtr(new DrawingRecorder(*paintInfo.context, m_inl
ineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase), paintRect)); | 91 drawingRecorder.begin(paintRect); |
| 92 if (drawingRecorder->canUseCachedDrawing()) | 92 if (drawingRecorder.canUseCachedDrawing()) |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 | 95 |
| 96 if (m_inlineTextBox.truncation() != cNoTruncation) { | 96 if (m_inlineTextBox.truncation() != cNoTruncation) { |
| 97 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR
ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { | 97 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR
ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { |
| 98 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin | 98 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin |
| 99 // at which we start drawing text. | 99 // at which we start drawing text. |
| 100 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: | 100 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: |
| 101 // |Hello|CBA| -> |...He|CBA| | 101 // |Hello|CBA| -> |...He|CBA| |
| 102 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing | 102 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 LayoutTheme::theme().platformActiveTextSearchHighlightColor() : | 809 LayoutTheme::theme().platformActiveTextSearchHighlightColor() : |
| 810 LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); | 810 LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); |
| 811 GraphicsContextStateSaver stateSaver(*pt); | 811 GraphicsContextStateSaver stateSaver(*pt); |
| 812 pt->clip(FloatRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_inlineTextBo
x.logicalWidth(), selHeight)); | 812 pt->clip(FloatRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_inlineTextBo
x.logicalWidth(), selHeight)); |
| 813 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin.
y() - deltaY), selHeight, color, sPos, ePos); | 813 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin.
y() - deltaY), selHeight, color, sPos, ePos); |
| 814 } | 814 } |
| 815 } | 815 } |
| 816 | 816 |
| 817 | 817 |
| 818 } // namespace blink | 818 } // namespace blink |
| OLD | NEW |