| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 bool isPrinting = m_inlineTextBox.layoutObject().document().printing(); | 70 bool isPrinting = m_inlineTextBox.layoutObject().document().printing(); |
| 71 | 71 |
| 72 // Determine whether or not we're selected. | 72 // Determine whether or not we're selected. |
| 73 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
m_inlineTextBox.selectionState() != LayoutObject::SelectionNone; | 73 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
m_inlineTextBox.selectionState() != LayoutObject::SelectionNone; |
| 74 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { | 74 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { |
| 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 = !haveSelection && m_inlineTextBox.layoutObject().
node() && m_inlineTextBox.layoutObject().frame()->inputMethodController().compos
itionNode() == m_inlineTextBox.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 OwnPtr<DrawingRecorder> drawingRecorder; |
| 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); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds
include selection | 149 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds
include selection |
| 150 // and composition highlights. | 150 // and composition highlights. |
| 151 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT
extClip && !isPrinting) { | 151 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT
extClip && !isPrinting) { |
| 152 if (containsComposition) { | 152 if (containsComposition) { |
| 153 paintCompositionBackgrounds(context, boxOrigin, styleToUse, font, us
eCustomUnderlines); | 153 paintCompositionBackgrounds(context, boxOrigin, styleToUse, font, us
eCustomUnderlines); |
| 154 } | 154 } |
| 155 | 155 |
| 156 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); | 156 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); |
| 157 | 157 |
| 158 if (haveSelection && !useCustomUnderlines) { | 158 if (haveSelection) { |
| 159 if (combinedText) | 159 if (combinedText) |
| 160 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText>
(context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText); | 160 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText>
(context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText); |
| 161 else | 161 else |
| 162 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte
xt, boxRect, styleToUse, font, selectionStyle.fillColor); | 162 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte
xt, boxRect, styleToUse, font, selectionStyle.fillColor); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 // 2. Now paint the foreground, including text and decorations like underlin
e/overline (in quirks mode only). | 166 // 2. Now paint the foreground, including text and decorations like underlin
e/overline (in quirks mode only). |
| 167 int length = m_inlineTextBox.len(); | 167 int length = m_inlineTextBox.len(); |
| 168 StringView string = m_inlineTextBox.layoutObject().text().createView(); | 168 StringView string = m_inlineTextBox.layoutObject().text().createView(); |
| (...skipping 640 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 |