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/editing/CompositionUnderline.h" | 8 #include "core/editing/CompositionUnderline.h" |
9 #include "core/editing/Editor.h" | 9 #include "core/editing/Editor.h" |
10 #include "core/editing/markers/DocumentMarkerController.h" | 10 #include "core/editing/markers/DocumentMarkerController.h" |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 } | 481 } |
482 | 482 |
483 LayoutUnit selectionBottom = m_inlineTextBox.root().selectionBottom(); | 483 LayoutUnit selectionBottom = m_inlineTextBox.root().selectionBottom(); |
484 LayoutUnit selectionTop = m_inlineTextBox.root().selectionTopAdjustedForPrec
edingBlock(); | 484 LayoutUnit selectionTop = m_inlineTextBox.root().selectionTopAdjustedForPrec
edingBlock(); |
485 | 485 |
486 int deltaY = roundToInt(m_inlineTextBox.lineLayoutItem().style()->isFlippedL
inesWritingMode() ? selectionBottom - m_inlineTextBox.logicalBottom() : m_inline
TextBox.logicalTop() - selectionTop); | 486 int deltaY = roundToInt(m_inlineTextBox.lineLayoutItem().style()->isFlippedL
inesWritingMode() ? selectionBottom - m_inlineTextBox.logicalBottom() : m_inline
TextBox.logicalTop() - selectionTop); |
487 int selHeight = std::max(0, roundToInt(selectionBottom - selectionTop)); | 487 int selHeight = std::max(0, roundToInt(selectionBottom - selectionTop)); |
488 | 488 |
489 FloatPoint localOrigin(boxRect.x().toFloat(), (boxRect.y() - deltaY).toFloat
()); | 489 FloatPoint localOrigin(boxRect.x().toFloat(), (boxRect.y() - deltaY).toFloat
()); |
490 LayoutRect selectionRect = LayoutRect(font.selectionRectForText(textRun, loc
alOrigin, selHeight, sPos, ePos)); | 490 LayoutRect selectionRect = LayoutRect(font.selectionRectForText(textRun, loc
alOrigin, selHeight, sPos, ePos)); |
491 if (m_inlineTextBox.hasWrappedSelectionNewline()) | 491 if (m_inlineTextBox.hasWrappedSelectionNewline() |
| 492 // For line breaks, just painting a selection where the line break itsel
f is rendered is sufficient. |
| 493 && !m_inlineTextBox.isLineBreak()) |
492 expandToIncludeNewlineForSelection(selectionRect); | 494 expandToIncludeNewlineForSelection(selectionRect); |
493 | 495 |
494 context->fillRect(FloatRect(selectionRect), c); | 496 context->fillRect(FloatRect(selectionRect), c); |
495 } | 497 } |
496 | 498 |
497 void InlineTextBoxPainter::expandToIncludeNewlineForSelection(LayoutRect& rect) | 499 void InlineTextBoxPainter::expandToIncludeNewlineForSelection(LayoutRect& rect) |
498 { | 500 { |
499 FloatRectOutsets outsets = FloatRectOutsets(); | 501 FloatRectOutsets outsets = FloatRectOutsets(); |
500 float spaceWidth = m_inlineTextBox.newlineSpaceWidth(); | 502 float spaceWidth = m_inlineTextBox.newlineSpaceWidth(); |
501 if (m_inlineTextBox.isLeftToRightDirection()) | 503 if (m_inlineTextBox.isLeftToRightDirection()) |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri
cs().ascent()); | 847 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri
cs().ascent()); |
846 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline
TextBox.isHorizontal()); | 848 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline
TextBox.isHorizontal()); |
847 | 849 |
848 textPainter.paint(sPos, ePos, length, textStyle, 0); | 850 textPainter.paint(sPos, ePos, length, textStyle, 0); |
849 } | 851 } |
850 } | 852 } |
851 } | 853 } |
852 | 854 |
853 | 855 |
854 } // namespace blink | 856 } // namespace blink |
OLD | NEW |