| 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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 if (m_inlineTextBox.truncation() == cFullTruncation) | 708 if (m_inlineTextBox.truncation() == cFullTruncation) |
| 709 return; | 709 return; |
| 710 | 710 |
| 711 GraphicsContext& context = paintInfo.context; | 711 GraphicsContext& context = paintInfo.context; |
| 712 GraphicsContextStateSaver stateSaver(context); | 712 GraphicsContextStateSaver stateSaver(context); |
| 713 | 713 |
| 714 LayoutPoint localOrigin(boxOrigin); | 714 LayoutPoint localOrigin(boxOrigin); |
| 715 | 715 |
| 716 LayoutUnit width = m_inlineTextBox.logicalWidth(); | 716 LayoutUnit width = m_inlineTextBox.logicalWidth(); |
| 717 if (m_inlineTextBox.truncation() != cNoTruncation) { | 717 if (m_inlineTextBox.truncation() != cNoTruncation) { |
| 718 width = LayoutUnit(m_inlineTextBox.getLineLayoutItem().width( | 718 bool ltr = m_inlineTextBox.isLeftToRightDirection(); |
| 719 m_inlineTextBox.start(), m_inlineTextBox.truncation(), m_inlineTextB
ox.textPos(), | 719 bool flowIsLTR = m_inlineTextBox.getLineLayoutItem().style()->isLeftToRi
ghtDirection(); |
| 720 m_inlineTextBox.isLeftToRightDirection() ? LTR : RTL, m_inlineTextBo
x.isFirstLineStyle())); | 720 width = LayoutUnit(m_inlineTextBox.getLineLayoutItem().width(ltr == flow
IsLTR ? m_inlineTextBox.start() : m_inlineTextBox.truncation(), |
| 721 if (!m_inlineTextBox.isLeftToRightDirection()) | 721 ltr == flowIsLTR ? m_inlineTextBox.truncation() : m_inlineTextBox.le
n() - m_inlineTextBox.truncation(), m_inlineTextBox.textPos(), |
| 722 flowIsLTR ? LTR : RTL, m_inlineTextBox.isFirstLineStyle())); |
| 723 if (!flowIsLTR) |
| 722 localOrigin.move(m_inlineTextBox.logicalWidth() - width, LayoutUnit(
)); | 724 localOrigin.move(m_inlineTextBox.logicalWidth() - width, LayoutUnit(
)); |
| 723 } | 725 } |
| 724 | 726 |
| 725 // Get the text decoration colors. | 727 // Get the text decoration colors. |
| 726 LayoutObject::AppliedTextDecoration underline, overline, linethrough; | 728 LayoutObject::AppliedTextDecoration underline, overline, linethrough; |
| 727 LayoutObject& textBoxLayoutObject = inlineLayoutObject(); | 729 LayoutObject& textBoxLayoutObject = inlineLayoutObject(); |
| 728 textBoxLayoutObject.getTextDecorations(deco, underline, overline, linethroug
h, true); | 730 textBoxLayoutObject.getTextDecorations(deco, underline, overline, linethroug
h, true); |
| 729 if (m_inlineTextBox.isFirstLineStyle()) | 731 if (m_inlineTextBox.isFirstLineStyle()) |
| 730 textBoxLayoutObject.getTextDecorations(deco, underline, overline, lineth
rough, true, true); | 732 textBoxLayoutObject.getTextDecorations(deco, underline, overline, lineth
rough, true, true); |
| 731 | 733 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 { | 770 { |
| 769 if (underline.color == Color::transparent) | 771 if (underline.color == Color::transparent) |
| 770 return; | 772 return; |
| 771 | 773 |
| 772 if (m_inlineTextBox.truncation() == cFullTruncation) | 774 if (m_inlineTextBox.truncation() == cFullTruncation) |
| 773 return; | 775 return; |
| 774 | 776 |
| 775 unsigned paintStart = underlinePaintStart(underline); | 777 unsigned paintStart = underlinePaintStart(underline); |
| 776 unsigned paintEnd = underlinePaintEnd(underline); | 778 unsigned paintEnd = underlinePaintEnd(underline); |
| 777 | 779 |
| 780 // TODO(crbug.com/636060): Handle mixed-flow contexts correctly. |
| 778 // start of line to draw | 781 // start of line to draw |
| 779 float start = paintStart == static_cast<unsigned>(m_inlineTextBox.start()) ?
0 : | 782 float start = paintStart == static_cast<unsigned>(m_inlineTextBox.start()) ?
0 : |
| 780 m_inlineTextBox.getLineLayoutItem().width(m_inlineTextBox.start(), paint
Start - m_inlineTextBox.start(), m_inlineTextBox.textPos(), m_inlineTextBox.isLe
ftToRightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); | 783 m_inlineTextBox.getLineLayoutItem().width(m_inlineTextBox.start(), paint
Start - m_inlineTextBox.start(), m_inlineTextBox.textPos(), m_inlineTextBox.isLe
ftToRightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); |
| 781 // how much line to draw | 784 // how much line to draw |
| 782 float width = (paintStart == static_cast<unsigned>(m_inlineTextBox.start())
&& paintEnd == static_cast<unsigned>(m_inlineTextBox.end()) + 1) ? m_inlineTextB
ox.logicalWidth().toFloat() : | 785 float width = (paintStart == static_cast<unsigned>(m_inlineTextBox.start())
&& paintEnd == static_cast<unsigned>(m_inlineTextBox.end()) + 1) ? m_inlineTextB
ox.logicalWidth().toFloat() : |
| 783 m_inlineTextBox.getLineLayoutItem().width(paintStart, paintEnd - paintSt
art, LayoutUnit(m_inlineTextBox.textPos() + start), m_inlineTextBox.isLeftToRigh
tDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); | 786 m_inlineTextBox.getLineLayoutItem().width(paintStart, paintEnd - paintSt
art, LayoutUnit(m_inlineTextBox.textPos() + start), m_inlineTextBox.isLeftToRigh
tDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); |
| 784 // In RTL mode, start and width are computed from the right end of the text
box: | 787 // In RTL mode, start and width are computed from the right end of the text
box: |
| 785 // starting at |logicalWidth| - |start| and continuing left by |width| to | 788 // starting at |logicalWidth| - |start| and continuing left by |width| to |
| 786 // |logicalWidth| - |start| - |width|. We will draw that line, but | 789 // |logicalWidth| - |start| - |width|. We will draw that line, but |
| 787 // backwards: |logicalWidth| - |start| - |width| to |logicalWidth| - |start|
. | 790 // backwards: |logicalWidth| - |start| - |width| to |logicalWidth| - |start|
. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 GraphicsContext& context = paintInfo.context; | 848 GraphicsContext& context = paintInfo.context; |
| 846 GraphicsContextStateSaver stateSaver(context); | 849 GraphicsContextStateSaver stateSaver(context); |
| 847 | 850 |
| 848 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i
nlineTextBox.logicalHeight())); | 851 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i
nlineTextBox.logicalHeight())); |
| 849 context.clip(FloatRect(boxRect)); | 852 context.clip(FloatRect(boxRect)); |
| 850 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh
t(), color, sPos, ePos); | 853 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh
t(), color, sPos, ePos); |
| 851 } | 854 } |
| 852 | 855 |
| 853 | 856 |
| 854 } // namespace blink | 857 } // namespace blink |
| OLD | NEW |