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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 LayoutUnit width = m_inlineTextBox.logicalWidth(); | 1023 LayoutUnit width = m_inlineTextBox.logicalWidth(); |
1024 if (m_inlineTextBox.truncation() != cNoTruncation) { | 1024 if (m_inlineTextBox.truncation() != cNoTruncation) { |
1025 bool ltr = m_inlineTextBox.isLeftToRightDirection(); | 1025 bool ltr = m_inlineTextBox.isLeftToRightDirection(); |
1026 bool flowIsLTR = | 1026 bool flowIsLTR = |
1027 m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection(); | 1027 m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection(); |
1028 width = LayoutUnit(m_inlineTextBox.getLineLayoutItem().width( | 1028 width = LayoutUnit(m_inlineTextBox.getLineLayoutItem().width( |
1029 ltr == flowIsLTR ? m_inlineTextBox.start() | 1029 ltr == flowIsLTR ? m_inlineTextBox.start() |
1030 : m_inlineTextBox.truncation(), | 1030 : m_inlineTextBox.truncation(), |
1031 ltr == flowIsLTR ? m_inlineTextBox.truncation() | 1031 ltr == flowIsLTR ? m_inlineTextBox.truncation() |
1032 : m_inlineTextBox.len() - m_inlineTextBox.truncation(), | 1032 : m_inlineTextBox.len() - m_inlineTextBox.truncation(), |
1033 m_inlineTextBox.textPos(), flowIsLTR ? LTR : RTL, | 1033 m_inlineTextBox.textPos(), |
| 1034 flowIsLTR ? TextDirection::Ltr : TextDirection::Rtl, |
1034 m_inlineTextBox.isFirstLineStyle())); | 1035 m_inlineTextBox.isFirstLineStyle())); |
1035 if (!flowIsLTR) | 1036 if (!flowIsLTR) |
1036 localOrigin.move(m_inlineTextBox.logicalWidth() - width, LayoutUnit()); | 1037 localOrigin.move(m_inlineTextBox.logicalWidth() - width, LayoutUnit()); |
1037 } | 1038 } |
1038 | 1039 |
1039 LayoutObject& textBoxLayoutObject = inlineLayoutObject(); | 1040 LayoutObject& textBoxLayoutObject = inlineLayoutObject(); |
1040 | 1041 |
1041 const ComputedStyle& styleToUse = | 1042 const ComputedStyle& styleToUse = |
1042 textBoxLayoutObject.styleRef(m_inlineTextBox.isFirstLineStyle()); | 1043 textBoxLayoutObject.styleRef(m_inlineTextBox.isFirstLineStyle()); |
1043 const SimpleFontData* fontData = styleToUse.font().primaryFont(); | 1044 const SimpleFontData* fontData = styleToUse.font().primaryFont(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 unsigned paintEnd = underlinePaintEnd(underline); | 1135 unsigned paintEnd = underlinePaintEnd(underline); |
1135 DCHECK_LT(paintStart, paintEnd); | 1136 DCHECK_LT(paintStart, paintEnd); |
1136 | 1137 |
1137 // start of line to draw | 1138 // start of line to draw |
1138 float start = | 1139 float start = |
1139 paintStart == m_inlineTextBox.start() | 1140 paintStart == m_inlineTextBox.start() |
1140 ? 0 | 1141 ? 0 |
1141 : m_inlineTextBox.getLineLayoutItem().width( | 1142 : m_inlineTextBox.getLineLayoutItem().width( |
1142 m_inlineTextBox.start(), paintStart - m_inlineTextBox.start(), | 1143 m_inlineTextBox.start(), paintStart - m_inlineTextBox.start(), |
1143 m_inlineTextBox.textPos(), | 1144 m_inlineTextBox.textPos(), |
1144 m_inlineTextBox.isLeftToRightDirection() ? LTR : RTL, | 1145 m_inlineTextBox.isLeftToRightDirection() ? TextDirection::Ltr |
| 1146 : TextDirection::Rtl, |
1145 m_inlineTextBox.isFirstLineStyle()); | 1147 m_inlineTextBox.isFirstLineStyle()); |
1146 // how much line to draw | 1148 // how much line to draw |
1147 float width; | 1149 float width; |
1148 bool ltr = m_inlineTextBox.isLeftToRightDirection(); | 1150 bool ltr = m_inlineTextBox.isLeftToRightDirection(); |
1149 bool flowIsLTR = | 1151 bool flowIsLTR = |
1150 m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection(); | 1152 m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection(); |
1151 if (paintStart == m_inlineTextBox.start() && | 1153 if (paintStart == m_inlineTextBox.start() && |
1152 paintEnd == m_inlineTextBox.end() + 1) { | 1154 paintEnd == m_inlineTextBox.end() + 1) { |
1153 width = m_inlineTextBox.logicalWidth().toFloat(); | 1155 width = m_inlineTextBox.logicalWidth().toFloat(); |
1154 } else { | 1156 } else { |
1155 unsigned paintFrom = ltr == flowIsLTR ? paintStart : paintEnd; | 1157 unsigned paintFrom = ltr == flowIsLTR ? paintStart : paintEnd; |
1156 unsigned paintLength = | 1158 unsigned paintLength = |
1157 ltr == flowIsLTR | 1159 ltr == flowIsLTR |
1158 ? paintEnd - paintStart | 1160 ? paintEnd - paintStart |
1159 : m_inlineTextBox.start() + m_inlineTextBox.len() - paintEnd; | 1161 : m_inlineTextBox.start() + m_inlineTextBox.len() - paintEnd; |
1160 width = m_inlineTextBox.getLineLayoutItem().width( | 1162 width = m_inlineTextBox.getLineLayoutItem().width( |
1161 paintFrom, paintLength, LayoutUnit(m_inlineTextBox.textPos() + start), | 1163 paintFrom, paintLength, LayoutUnit(m_inlineTextBox.textPos() + start), |
1162 flowIsLTR ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); | 1164 flowIsLTR ? TextDirection::Ltr : TextDirection::Rtl, |
| 1165 m_inlineTextBox.isFirstLineStyle()); |
1163 } | 1166 } |
1164 // In RTL mode, start and width are computed from the right end of the text | 1167 // In RTL mode, start and width are computed from the right end of the text |
1165 // box: starting at |logicalWidth| - |start| and continuing left by |width| to | 1168 // box: starting at |logicalWidth| - |start| and continuing left by |width| to |
1166 // |logicalWidth| - |start| - |width|. We will draw that line, but backwards: | 1169 // |logicalWidth| - |start| - |width|. We will draw that line, but backwards: |
1167 // |logicalWidth| - |start| - |width| to |logicalWidth| - |start|. | 1170 // |logicalWidth| - |start| - |width| to |logicalWidth| - |start|. |
1168 if (!flowIsLTR) | 1171 if (!flowIsLTR) |
1169 start = m_inlineTextBox.logicalWidth().toFloat() - width - start; | 1172 start = m_inlineTextBox.logicalWidth().toFloat() - width - start; |
1170 | 1173 |
1171 // Thick marked text underlines are 2px thick as long as there is room for the | 1174 // Thick marked text underlines are 2px thick as long as there is room for the |
1172 // 2px line under the baseline. All other marked text underlines are 1px | 1175 // 2px line under the baseline. All other marked text underlines are 1px |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 GraphicsContextStateSaver stateSaver(context); | 1270 GraphicsContextStateSaver stateSaver(context); |
1268 | 1271 |
1269 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), | 1272 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), |
1270 m_inlineTextBox.logicalHeight())); | 1273 m_inlineTextBox.logicalHeight())); |
1271 context.clip(FloatRect(boxRect)); | 1274 context.clip(FloatRect(boxRect)); |
1272 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), | 1275 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), |
1273 boxRect.height().toInt(), color, sPos, ePos); | 1276 boxRect.height().toInt(), color, sPos, ePos); |
1274 } | 1277 } |
1275 | 1278 |
1276 } // namespace blink | 1279 } // namespace blink |
OLD | NEW |