| 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 "core/paint/InlineTextBoxPainter.h" | 5 #include "core/paint/InlineTextBoxPainter.h" |
| 6 | 6 |
| 7 #include "core/editing/CompositionUnderline.h" | 7 #include "core/editing/CompositionUnderline.h" |
| 8 #include "core/editing/Editor.h" | 8 #include "core/editing/Editor.h" |
| 9 #include "core/editing/markers/DocumentMarkerController.h" | 9 #include "core/editing/markers/DocumentMarkerController.h" |
| 10 #include "core/editing/markers/RenderedDocumentMarker.h" | 10 #include "core/editing/markers/RenderedDocumentMarker.h" |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m
_inlineTextBox.isHorizontal()); | 835 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m
_inlineTextBox.isHorizontal()); |
| 836 | 836 |
| 837 textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0); | 837 textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0); |
| 838 } | 838 } |
| 839 | 839 |
| 840 void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paint
Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle&
style, const Font& font) | 840 void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paint
Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle&
style, const Font& font) |
| 841 { | 841 { |
| 842 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem()
)->frame()->editor().markedTextMatchesAreHighlighted()) | 842 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem()
)->frame()->editor().markedTextMatchesAreHighlighted()) |
| 843 return; | 843 return; |
| 844 | 844 |
| 845 // Use same y positioning and height as for selection, so that when the sele
ction and this highlight are on | |
| 846 // the same word there are no pieces sticking out. | |
| 847 int deltaY = m_inlineTextBox.getLineLayoutItem().style()->isFlippedLinesWrit
ingMode() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBo
ttom() : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop(); | |
| 848 int selHeight = m_inlineTextBox.root().selectionHeight(); | |
| 849 | |
| 850 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign
ed)0); | 845 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign
ed)0); |
| 851 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT
extBox.len()); | 846 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT
extBox.len()); |
| 852 TextRun run = m_inlineTextBox.constructTextRun(style, font); | 847 TextRun run = m_inlineTextBox.constructTextRun(style, font); |
| 853 | 848 |
| 854 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker->
activeMatch()); | 849 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker->
activeMatch()); |
| 855 GraphicsContext& context = paintInfo.context; | 850 GraphicsContext& context = paintInfo.context; |
| 856 GraphicsContextStateSaver stateSaver(context); | 851 GraphicsContextStateSaver stateSaver(context); |
| 857 context.clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF
loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); | 852 |
| 858 context.drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(),
(boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); | 853 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i
nlineTextBox.logicalHeight())); |
| 854 context.clip(FloatRect(boxRect)); |
| 855 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh
t(), color, sPos, ePos); |
| 859 } | 856 } |
| 860 | 857 |
| 861 | 858 |
| 862 } // namespace blink | 859 } // namespace blink |
| OLD | NEW |