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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 drawingRecorder.emplace(paintInfo.context, m_inlineTextBox, DisplayItem: :paintPhaseToDrawingType(paintInfo.phase), FloatRect(paintRect)); | 99 drawingRecorder.emplace(paintInfo.context, m_inlineTextBox, DisplayItem: :paintPhaseToDrawingType(paintInfo.phase), FloatRect(paintRect)); |
100 } | 100 } |
101 | 101 |
102 GraphicsContext& context = paintInfo.context; | 102 GraphicsContext& context = paintInfo.context; |
103 const ComputedStyle& styleToUse = m_inlineTextBox.getLineLayoutItem().styleR ef(m_inlineTextBox.isFirstLineStyle()); | 103 const ComputedStyle& styleToUse = m_inlineTextBox.getLineLayoutItem().styleR ef(m_inlineTextBox.isFirstLineStyle()); |
104 | 104 |
105 LayoutPoint boxOrigin(m_inlineTextBox.locationIncludingFlipping()); | 105 LayoutPoint boxOrigin(m_inlineTextBox.locationIncludingFlipping()); |
106 boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y()); | 106 boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y()); |
107 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight())); | 107 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight())); |
108 | 108 |
109 int length = m_inlineTextBox.len(); | |
110 StringView string = StringView(m_inlineTextBox.getLineLayoutItem().text(), m _inlineTextBox.start(), length); | |
111 int maximumLength = m_inlineTextBox.getLineLayoutItem().textLength() - m_inl ineTextBox.start(); | |
112 | |
113 StringBuilder charactersWithHyphen; | |
114 TextRun textRun = m_inlineTextBox.constructTextRun(styleToUse, styleToUse.fo nt(), string, maximumLength, m_inlineTextBox.hasHyphen() ? &charactersWithHyphen : 0); | |
115 if (m_inlineTextBox.hasHyphen()) | |
116 length = textRun.length(); | |
117 | |
kojii
2016/08/16 05:59:56
This block is simply a move from line 152 so that
| |
109 bool shouldRotate = false; | 118 bool shouldRotate = false; |
110 LayoutTextCombine* combinedText = nullptr; | 119 LayoutTextCombine* combinedText = nullptr; |
111 if (!m_inlineTextBox.isHorizontal()) { | 120 if (!m_inlineTextBox.isHorizontal()) { |
112 if (styleToUse.hasTextCombine() && m_inlineTextBox.getLineLayoutItem().i sCombineText()) { | 121 if (styleToUse.hasTextCombine() && m_inlineTextBox.getLineLayoutItem().i sCombineText()) { |
113 combinedText = &toLayoutTextCombine(inlineLayoutObject()); | 122 combinedText = &toLayoutTextCombine(inlineLayoutObject()); |
114 if (!combinedText->isCombined()) | 123 if (!combinedText->isCombined()) |
115 combinedText = nullptr; | 124 combinedText = nullptr; |
116 } | 125 } |
117 if (combinedText) { | 126 if (combinedText) { |
118 combinedText->updateFont(); | 127 combinedText->updateFont(); |
119 boxRect.setWidth(combinedText->inlineWidthForLayout()); | 128 boxRect.setWidth(combinedText->inlineWidthForLayout()); |
129 // Justfication applies to before and after the combined text as if | |
130 // it is an ideographic character, and is prohibited inside the | |
131 // combined text. | |
132 if (float expansion = textRun.expansion()) { | |
133 textRun.setExpansion(0); | |
134 if (textRun.allowsLeadingExpansion()) { | |
135 if (textRun.allowsTrailingExpansion()) | |
136 expansion /= 2; | |
137 LayoutSize offset = LayoutSize(LayoutUnit(), LayoutUnit::fro mFloatRound(expansion)); | |
138 boxOrigin.move(offset); | |
139 boxRect.move(offset); | |
140 } | |
141 } | |
120 } else { | 142 } else { |
121 shouldRotate = true; | 143 shouldRotate = true; |
122 context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockw ise)); | 144 context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockw ise)); |
123 } | 145 } |
124 } | 146 } |
125 | 147 |
126 // Determine text colors. | 148 // Determine text colors. |
127 TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_inlineTextBo x.getLineLayoutItem(), styleToUse, paintInfo); | 149 TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_inlineTextBo x.getLineLayoutItem(), styleToUse, paintInfo); |
128 TextPainter::Style selectionStyle = TextPainter::selectionPaintingStyle(m_in lineTextBox.getLineLayoutItem(), haveSelection, paintInfo, textStyle); | 150 TextPainter::Style selectionStyle = TextPainter::selectionPaintingStyle(m_in lineTextBox.getLineLayoutItem(), haveSelection, paintInfo, textStyle); |
129 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection); | 151 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection); |
(...skipping 12 matching lines...) Expand all Loading... | |
142 const LayoutObject& textBoxLayoutObject = inlineLayoutObject(); | 164 const LayoutObject& textBoxLayoutObject = inlineLayoutObject(); |
143 if (haveSelection && !paintsCompositionMarkers(textBoxLayoutObject)) { | 165 if (haveSelection && !paintsCompositionMarkers(textBoxLayoutObject)) { |
144 if (combinedText) | 166 if (combinedText) |
145 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText> (context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText); | 167 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText> (context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText); |
146 else | 168 else |
147 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte xt, boxRect, styleToUse, font, selectionStyle.fillColor); | 169 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte xt, boxRect, styleToUse, font, selectionStyle.fillColor); |
148 } | 170 } |
149 } | 171 } |
150 | 172 |
151 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only). | 173 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only). |
152 int length = m_inlineTextBox.len(); | |
153 StringView string = StringView(m_inlineTextBox.getLineLayoutItem().text(), m _inlineTextBox.start(), length); | |
154 int maximumLength = m_inlineTextBox.getLineLayoutItem().textLength() - m_inl ineTextBox.start(); | |
155 | |
156 StringBuilder charactersWithHyphen; | |
157 TextRun textRun = m_inlineTextBox.constructTextRun(styleToUse, font, string, maximumLength, m_inlineTextBox.hasHyphen() ? &charactersWithHyphen : 0); | |
158 if (m_inlineTextBox.hasHyphen()) | |
159 length = textRun.length(); | |
160 | |
161 int selectionStart = 0; | 174 int selectionStart = 0; |
162 int selectionEnd = 0; | 175 int selectionEnd = 0; |
163 if (paintSelectedTextOnly || paintSelectedTextSeparately) | 176 if (paintSelectedTextOnly || paintSelectedTextSeparately) |
164 m_inlineTextBox.selectionStartEnd(selectionStart, selectionEnd); | 177 m_inlineTextBox.selectionStartEnd(selectionStart, selectionEnd); |
165 | 178 |
166 bool respectHyphen = selectionEnd == static_cast<int>(m_inlineTextBox.len()) && m_inlineTextBox.hasHyphen(); | 179 bool respectHyphen = selectionEnd == static_cast<int>(m_inlineTextBox.len()) && m_inlineTextBox.hasHyphen(); |
167 if (respectHyphen) | 180 if (respectHyphen) |
168 selectionEnd = textRun.length(); | 181 selectionEnd = textRun.length(); |
169 | 182 |
170 if (m_inlineTextBox.truncation() != cNoTruncation) { | 183 if (m_inlineTextBox.truncation() != cNoTruncation) { |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
853 GraphicsContext& context = paintInfo.context; | 866 GraphicsContext& context = paintInfo.context; |
854 GraphicsContextStateSaver stateSaver(context); | 867 GraphicsContextStateSaver stateSaver(context); |
855 | 868 |
856 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight())); | 869 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight())); |
857 context.clip(FloatRect(boxRect)); | 870 context.clip(FloatRect(boxRect)); |
858 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh t(), color, sPos, ePos); | 871 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh t(), color, sPos, ePos); |
859 } | 872 } |
860 | 873 |
861 | 874 |
862 } // namespace blink | 875 } // namespace blink |
OLD | NEW |