| 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/CompositionMarker.h" | 9 #include "core/editing/markers/CompositionMarker.h" |
| 10 #include "core/editing/markers/DocumentMarkerController.h" | 10 #include "core/editing/markers/DocumentMarkerController.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 static void RestoreContextFromDecoration(GraphicsContext& context, | 172 static void RestoreContextFromDecoration(GraphicsContext& context, |
| 173 const LayoutTextCombine* combined_text, | 173 const LayoutTextCombine* combined_text, |
| 174 const LayoutRect& box_rect) { | 174 const LayoutRect& box_rect) { |
| 175 if (combined_text) { | 175 if (combined_text) { |
| 176 context.ConcatCTM(TextPainterBase::Rotation( | 176 context.ConcatCTM(TextPainterBase::Rotation( |
| 177 box_rect, TextPainterBase::kCounterclockwise)); | 177 box_rect, TextPainterBase::kCounterclockwise)); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 | |
| 182 static void ComputeOriginAndWidthForBox(const InlineTextBox& box, | 181 static void ComputeOriginAndWidthForBox(const InlineTextBox& box, |
| 183 LayoutPoint& local_origin, | 182 LayoutPoint& local_origin, |
| 184 LayoutUnit& width) { | 183 LayoutUnit& width) { |
| 185 if (box.Truncation() != kCNoTruncation) { | 184 if (box.Truncation() != kCNoTruncation) { |
| 186 bool ltr = box.IsLeftToRightDirection(); | 185 bool ltr = box.IsLeftToRightDirection(); |
| 187 bool flow_is_ltr = | 186 bool flow_is_ltr = |
| 188 box.GetLineLayoutItem().Style()->IsLeftToRightDirection(); | 187 box.GetLineLayoutItem().Style()->IsLeftToRightDirection(); |
| 189 width = LayoutUnit(box.GetLineLayoutItem().Width( | 188 width = LayoutUnit(box.GetLineLayoutItem().Width( |
| 190 ltr == flow_is_ltr ? box.Start() : box.Start() + box.Truncation(), | 189 ltr == flow_is_ltr ? box.Start() : box.Start() + box.Truncation(), |
| 191 ltr == flow_is_ltr ? box.Truncation() : box.Len() - box.Truncation(), | 190 ltr == flow_is_ltr ? box.Truncation() : box.Len() - box.Truncation(), |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 sk_sp<PaintRecord> RecordMarker(DocumentMarker::MarkerType marker_type) { | 747 sk_sp<PaintRecord> RecordMarker(DocumentMarker::MarkerType marker_type) { |
| 749 SkColor color = (marker_type == DocumentMarker::kGrammar) | 748 SkColor color = (marker_type == DocumentMarker::kGrammar) |
| 750 ? SkColorSetRGB(0x6B, 0x6B, 0x6B) | 749 ? SkColorSetRGB(0x6B, 0x6B, 0x6B) |
| 751 : SkColorSetRGB(0xFB, 0x2D, 0x1D); | 750 : SkColorSetRGB(0xFB, 0x2D, 0x1D); |
| 752 | 751 |
| 753 // Match the artwork used by the Mac. | 752 // Match the artwork used by the Mac. |
| 754 static const float kR = 1.5f; | 753 static const float kR = 1.5f; |
| 755 | 754 |
| 756 // top->bottom translucent gradient. | 755 // top->bottom translucent gradient. |
| 757 const SkColor colors[2] = { | 756 const SkColor colors[2] = { |
| 758 SkColorSetARGB(0x48, | 757 SkColorSetARGB(0x48, SkColorGetR(color), SkColorGetG(color), |
| 759 SkColorGetR(color), | |
| 760 SkColorGetG(color), | |
| 761 SkColorGetB(color)), | 758 SkColorGetB(color)), |
| 762 color | 759 color}; |
| 763 }; | 760 const SkPoint pts[2] = {SkPoint::Make(0, 0), SkPoint::Make(0, 2 * kR)}; |
| 764 const SkPoint pts[2] = { | |
| 765 SkPoint::Make(0, 0), | |
| 766 SkPoint::Make(0, 2 * kR) | |
| 767 }; | |
| 768 | 761 |
| 769 PaintFlags flags; | 762 PaintFlags flags; |
| 770 flags.setAntiAlias(true); | 763 flags.setAntiAlias(true); |
| 771 flags.setColor(color); | 764 flags.setColor(color); |
| 772 flags.setShader(PaintShader::MakeLinearGradient( | 765 flags.setShader(PaintShader::MakeLinearGradient( |
| 773 pts, colors, nullptr, ARRAY_SIZE(colors), SkShader::kClamp_TileMode)); | 766 pts, colors, nullptr, ARRAY_SIZE(colors), SkShader::kClamp_TileMode)); |
| 774 PaintRecorder recorder; | 767 PaintRecorder recorder; |
| 775 recorder.beginRecording(kMarkerWidth, kMarkerHeight); | 768 recorder.beginRecording(kMarkerWidth, kMarkerHeight); |
| 776 recorder.getRecordingCanvas()->drawCircle(kR, kR, kR, flags); | 769 recorder.getRecordingCanvas()->drawCircle(kR, kR, kR, flags); |
| 777 | 770 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 | 1169 |
| 1177 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), | 1170 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), |
| 1178 inline_text_box_.LogicalHeight())); | 1171 inline_text_box_.LogicalHeight())); |
| 1179 context.Clip(FloatRect(box_rect)); | 1172 context.Clip(FloatRect(box_rect)); |
| 1180 context.DrawHighlightForText(font, run, FloatPoint(box_origin), | 1173 context.DrawHighlightForText(font, run, FloatPoint(box_origin), |
| 1181 box_rect.Height().ToInt(), color, | 1174 box_rect.Height().ToInt(), color, |
| 1182 paint_offsets.first, paint_offsets.second); | 1175 paint_offsets.first, paint_offsets.second); |
| 1183 } | 1176 } |
| 1184 | 1177 |
| 1185 } // namespace blink | 1178 } // namespace blink |
| OLD | NEW |