| 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 LayoutRect selectionRect = LayoutRect(font.selectionRectForText(textRun, loc
alOrigin, selHeight, sPos, ePos)); | 488 LayoutRect selectionRect = LayoutRect(font.selectionRectForText(textRun, loc
alOrigin, selHeight, sPos, ePos)); |
| 489 if (m_inlineTextBox.hasWrappedSelectionNewline() | 489 if (m_inlineTextBox.hasWrappedSelectionNewline() |
| 490 // For line breaks, just painting a selection where the line break itsel
f is rendered is sufficient. | 490 // For line breaks, just painting a selection where the line break itsel
f is rendered is sufficient. |
| 491 && !m_inlineTextBox.isLineBreak()) | 491 && !m_inlineTextBox.isLineBreak()) |
| 492 expandToIncludeNewlineForSelection(selectionRect); | 492 expandToIncludeNewlineForSelection(selectionRect); |
| 493 | 493 |
| 494 // Line breaks report themselves as having zero width for layout purposes, | 494 // Line breaks report themselves as having zero width for layout purposes, |
| 495 // and so will end up positioned at (0, 0), even though we paint their | 495 // and so will end up positioned at (0, 0), even though we paint their |
| 496 // selection highlight with character width. For RTL then, we have to | 496 // selection highlight with character width. For RTL then, we have to |
| 497 // explicitly shift the selection rect over to paint in the right location. | 497 // explicitly shift the selection rect over to paint in the right location. |
| 498 if (!m_inlineTextBox.isLeftToRightDirection() && m_inlineTextBox.isLineBreak
()) { | 498 if (!m_inlineTextBox.isLeftToRightDirection() && m_inlineTextBox.isLineBreak
()) |
| 499 // TODO(crbug.com/638981): Is the conversion to int intentional? | 499 selectionRect.move(-selectionRect.width(), LayoutUnit()); |
| 500 selectionRect.move(-selectionRect.width().toInt(), 0); | |
| 501 } | |
| 502 if (!flowIsLTR && m_inlineTextBox.truncation() != cNoTruncation) | 500 if (!flowIsLTR && m_inlineTextBox.truncation() != cNoTruncation) |
| 503 selectionRect.move(m_inlineTextBox.logicalWidth() - selectionRect.width(
), LayoutUnit()); | 501 selectionRect.move(m_inlineTextBox.logicalWidth() - selectionRect.width(
), LayoutUnit()); |
| 504 | 502 |
| 505 context.fillRect(FloatRect(selectionRect), c); | 503 context.fillRect(FloatRect(selectionRect), c); |
| 506 } | 504 } |
| 507 | 505 |
| 508 void InlineTextBoxPainter::expandToIncludeNewlineForSelection(LayoutRect& rect) | 506 void InlineTextBoxPainter::expandToIncludeNewlineForSelection(LayoutRect& rect) |
| 509 { | 507 { |
| 510 FloatRectOutsets outsets = FloatRectOutsets(); | 508 FloatRectOutsets outsets = FloatRectOutsets(); |
| 511 float spaceWidth = m_inlineTextBox.newlineSpaceWidth(); | 509 float spaceWidth = m_inlineTextBox.newlineSpaceWidth(); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 GraphicsContext& context = paintInfo.context; | 876 GraphicsContext& context = paintInfo.context; |
| 879 GraphicsContextStateSaver stateSaver(context); | 877 GraphicsContextStateSaver stateSaver(context); |
| 880 | 878 |
| 881 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i
nlineTextBox.logicalHeight())); | 879 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i
nlineTextBox.logicalHeight())); |
| 882 context.clip(FloatRect(boxRect)); | 880 context.clip(FloatRect(boxRect)); |
| 883 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh
t().toInt(), color, sPos, ePos); | 881 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh
t().toInt(), color, sPos, ePos); |
| 884 } | 882 } |
| 885 | 883 |
| 886 | 884 |
| 887 } // namespace blink | 885 } // namespace blink |
| OLD | NEW |