Chromium Code Reviews| 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/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 825 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m _inlineTextBox.isHorizontal()); | 825 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m _inlineTextBox.isHorizontal()); |
| 826 | 826 |
| 827 textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0); | 827 textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0); |
| 828 } | 828 } |
| 829 | 829 |
| 830 void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paint Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font) | 830 void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paint Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font) |
| 831 { | 831 { |
| 832 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem() )->frame()->editor().markedTextMatchesAreHighlighted()) | 832 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem() )->frame()->editor().markedTextMatchesAreHighlighted()) |
| 833 return; | 833 return; |
| 834 | 834 |
| 835 // Use same y positioning and height as for selection, so that when the sele ction and this highlight are on | |
| 836 // the same word there are no pieces sticking out. | |
| 837 int deltaY = m_inlineTextBox.getLineLayoutItem().style()->isFlippedLinesWrit ingMode() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBo ttom() : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop(); | |
| 838 int selHeight = m_inlineTextBox.root().selectionHeight(); | |
| 839 | |
| 840 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign ed)0); | 835 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign ed)0); |
| 841 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT extBox.len()); | 836 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT extBox.len()); |
| 842 TextRun run = m_inlineTextBox.constructTextRun(style, font); | 837 TextRun run = m_inlineTextBox.constructTextRun(style, font); |
| 843 | 838 |
| 844 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch()); | 839 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch()); |
| 845 GraphicsContext& context = paintInfo.context; | 840 GraphicsContext& context = paintInfo.context; |
| 846 GraphicsContextStateSaver stateSaver(context); | 841 GraphicsContextStateSaver stateSaver(context); |
| 847 context.clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); | 842 int height = m_inlineTextBox.logicalHeight(); |
|
jbroman
2016/06/15 08:37:10
Why coerce this to int, but not the other dimensio
Xianzhu
2016/06/15 16:40:48
This is because GraphicsContext::drawHighlightForT
jbroman
2016/06/15 18:19:47
For consistency, would you mind matching the way t
Xianzhu
2016/06/15 19:41:11
Done.
| |
| 848 context.drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); | 843 FloatRect clipRect(boxOrigin.x().toFloat(), boxOrigin.y().toFloat(), m_inlin eTextBox.logicalWidth().toFloat(), height); |
| 844 context.clip(clipRect); | |
| 845 context.drawHighlightForText(font, run, clipRect.location(), height, color, sPos, ePos); | |
| 849 } | 846 } |
| 850 | 847 |
| 851 | 848 |
| 852 } // namespace blink | 849 } // namespace blink |
| OLD | NEW |