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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 } | 698 } |
699 | 699 |
700 namespace { | 700 namespace { |
701 | 701 |
702 #if !OS(MACOSX) | 702 #if !OS(MACOSX) |
703 | 703 |
704 static const float kMarkerWidth = 4; | 704 static const float kMarkerWidth = 4; |
705 static const float kMarkerHeight = 2; | 705 static const float kMarkerHeight = 2; |
706 | 706 |
707 sk_sp<PaintRecord> RecordMarker(DocumentMarker::MarkerType marker_type) { | 707 sk_sp<PaintRecord> RecordMarker(DocumentMarker::MarkerType marker_type) { |
708 SkColor color = (marker_type == DocumentMarker::kGrammar) | 708 SkColor color = |
709 ? SkColorSetRGB(0xC0, 0xC0, 0xC0) | 709 (marker_type == DocumentMarker::kGrammar) |
710 : SK_ColorRED; | 710 ? LayoutTheme::GetTheme().GrammarMarkerUnderlineColor().Rgb() |
| 711 : LayoutTheme::GetTheme().SpellingMarkerUnderlineColor().Rgb(); |
711 | 712 |
712 // Record the path equivalent to this legacy pattern: | 713 // Record the path equivalent to this legacy pattern: |
713 // X o o X o o X | 714 // X o o X o o X |
714 // o X o o X o | 715 // o X o o X o |
715 | 716 |
716 // Adjust the phase such that f' == 0 is "pixel"-centered | 717 // Adjust the phase such that f' == 0 is "pixel"-centered |
717 // (for optimal rasterization at native rez). | 718 // (for optimal rasterization at native rez). |
718 SkPath path; | 719 SkPath path; |
719 path.moveTo(kMarkerWidth * -3 / 8, kMarkerHeight * 3 / 4); | 720 path.moveTo(kMarkerWidth * -3 / 8, kMarkerHeight * 3 / 4); |
720 path.cubicTo(kMarkerWidth * -1 / 8, kMarkerHeight * 3 / 4, | 721 path.cubicTo(kMarkerWidth * -1 / 8, kMarkerHeight * 3 / 4, |
(...skipping 18 matching lines...) Expand all Loading... |
739 | 740 |
740 return recorder.finishRecordingAsPicture(); | 741 return recorder.finishRecordingAsPicture(); |
741 } | 742 } |
742 | 743 |
743 #else // OS(MACOSX) | 744 #else // OS(MACOSX) |
744 | 745 |
745 static const float kMarkerWidth = 4; | 746 static const float kMarkerWidth = 4; |
746 static const float kMarkerHeight = 3; | 747 static const float kMarkerHeight = 3; |
747 | 748 |
748 sk_sp<PaintRecord> RecordMarker(DocumentMarker::MarkerType marker_type) { | 749 sk_sp<PaintRecord> RecordMarker(DocumentMarker::MarkerType marker_type) { |
749 SkColor color = (marker_type == DocumentMarker::kGrammar) | 750 SkColor color = |
750 ? SkColorSetRGB(0x6B, 0x6B, 0x6B) | 751 (marker_type == DocumentMarker::kGrammar) |
751 : SkColorSetRGB(0xFB, 0x2D, 0x1D); | 752 ? LayoutTheme::GetTheme().GrammarMarkerUnderlineColor().Rgb() |
| 753 : LayoutTheme::GetTheme().SpellingMarkerUnderlineColor().Rgb(); |
752 | 754 |
753 // Match the artwork used by the Mac. | 755 // Match the artwork used by the Mac. |
754 static const float kR = 1.5f; | 756 static const float kR = 1.5f; |
755 | 757 |
756 // top->bottom translucent gradient. | 758 // top->bottom translucent gradient. |
757 const SkColor colors[2] = { | 759 const SkColor colors[2] = { |
758 SkColorSetARGB(0x48, | 760 SkColorSetARGB(0x48, |
759 SkColorGetR(color), | 761 SkColorGetR(color), |
760 SkColorGetG(color), | 762 SkColorGetG(color), |
761 SkColorGetB(color)), | 763 SkColorGetB(color)), |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 | 1178 |
1177 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), | 1179 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), |
1178 inline_text_box_.LogicalHeight())); | 1180 inline_text_box_.LogicalHeight())); |
1179 context.Clip(FloatRect(box_rect)); | 1181 context.Clip(FloatRect(box_rect)); |
1180 context.DrawHighlightForText(font, run, FloatPoint(box_origin), | 1182 context.DrawHighlightForText(font, run, FloatPoint(box_origin), |
1181 box_rect.Height().ToInt(), color, | 1183 box_rect.Height().ToInt(), color, |
1182 paint_offsets.first, paint_offsets.second); | 1184 paint_offsets.first, paint_offsets.second); |
1183 } | 1185 } |
1184 | 1186 |
1185 } // namespace blink | 1187 } // namespace blink |
OLD | NEW |