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/SVGInlineTextBoxPainter.h" | 5 #include "core/paint/SVGInlineTextBoxPainter.h" |
6 | 6 |
7 #include "core/editing/Editor.h" | 7 #include "core/editing/Editor.h" |
8 #include "core/editing/markers/DocumentMarkerController.h" | 8 #include "core/editing/markers/DocumentMarkerController.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/layout/LayoutTheme.h" | 10 #include "core/layout/LayoutTheme.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 break; | 195 break; |
196 case PT_STROKE: | 196 case PT_STROKE: |
197 if (has_visible_stroke) | 197 if (has_visible_stroke) |
198 PaintText(paint_info, style, *selection_style, fragment, | 198 PaintText(paint_info, style, *selection_style, fragment, |
199 kApplyToStrokeMode, should_paint_selection); | 199 kApplyToStrokeMode, should_paint_selection); |
200 break; | 200 break; |
201 case PT_MARKERS: | 201 case PT_MARKERS: |
202 // Markers don't apply to text | 202 // Markers don't apply to text |
203 break; | 203 break; |
204 default: | 204 default: |
205 ASSERT_NOT_REACHED(); | 205 NOTREACHED(); |
206 break; | 206 break; |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 // Spec: Line-through should be drawn after the text is filled and stroked; | 210 // Spec: Line-through should be drawn after the text is filled and stroked; |
211 // thus, the line-through is rendered on top of the text. | 211 // thus, the line-through is rendered on top of the text. |
212 for (const AppliedTextDecoration& decoration : decorations) { | 212 for (const AppliedTextDecoration& decoration : decorations) { |
213 if (decoration.Lines() & kTextDecorationLineThrough) | 213 if (decoration.Lines() & kTextDecorationLineThrough) |
214 PaintDecoration(paint_info, kTextDecorationLineThrough, fragment); | 214 PaintDecoration(paint_info, kTextDecorationLineThrough, fragment); |
215 } | 215 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // FIXME: For SVG Fonts we need to use the attributes defined in the | 289 // FIXME: For SVG Fonts we need to use the attributes defined in the |
290 // <font-face> if specified. | 290 // <font-face> if specified. |
291 // Compatible with Batik/Presto. | 291 // Compatible with Batik/Presto. |
292 if (decoration == kTextDecorationUnderline) | 292 if (decoration == kTextDecorationUnderline) |
293 return -thickness * 1.5f; | 293 return -thickness * 1.5f; |
294 if (decoration == kTextDecorationOverline) | 294 if (decoration == kTextDecorationOverline) |
295 return font_metrics.FloatAscent() - thickness; | 295 return font_metrics.FloatAscent() - thickness; |
296 if (decoration == kTextDecorationLineThrough) | 296 if (decoration == kTextDecorationLineThrough) |
297 return font_metrics.FloatAscent() * 3 / 8.0f; | 297 return font_metrics.FloatAscent() * 3 / 8.0f; |
298 | 298 |
299 ASSERT_NOT_REACHED(); | 299 NOTREACHED(); |
300 return 0.0f; | 300 return 0.0f; |
301 } | 301 } |
302 | 302 |
303 static inline float ThicknessForDecoration(TextDecoration, const Font& font) { | 303 static inline float ThicknessForDecoration(TextDecoration, const Font& font) { |
304 // FIXME: For SVG Fonts we need to use the attributes defined in the | 304 // FIXME: For SVG Fonts we need to use the attributes defined in the |
305 // <font-face> if specified. | 305 // <font-face> if specified. |
306 // Compatible with Batik/Presto | 306 // Compatible with Batik/Presto |
307 return font.GetFontDescription().ComputedSize() / 20.0f; | 307 return font.GetFontDescription().ComputedSize() / 20.0f; |
308 } | 308 } |
309 | 309 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 if (stroke_scale_factor != 1) | 386 if (stroke_scale_factor != 1) |
387 stroke_data.SetThickness(stroke_data.Thickness() * | 387 stroke_data.SetThickness(stroke_data.Thickness() * |
388 stroke_scale_factor); | 388 stroke_scale_factor); |
389 stroke_data.SetupPaint(&stroke_flags); | 389 stroke_data.SetupPaint(&stroke_flags); |
390 paint_info.context.DrawPath(path.GetSkPath(), stroke_flags); | 390 paint_info.context.DrawPath(path.GetSkPath(), stroke_flags); |
391 } | 391 } |
392 break; | 392 break; |
393 case PT_MARKERS: | 393 case PT_MARKERS: |
394 break; | 394 break; |
395 default: | 395 default: |
396 ASSERT_NOT_REACHED(); | 396 NOTREACHED(); |
397 } | 397 } |
398 } | 398 } |
399 } | 399 } |
400 | 400 |
401 bool SVGInlineTextBoxPainter::SetupTextPaint( | 401 bool SVGInlineTextBoxPainter::SetupTextPaint( |
402 const PaintInfo& paint_info, | 402 const PaintInfo& paint_info, |
403 const ComputedStyle& style, | 403 const ComputedStyle& style, |
404 LayoutSVGResourceMode resource_mode, | 404 LayoutSVGResourceMode resource_mode, |
405 PaintFlags& flags) { | 405 PaintFlags& flags) { |
406 LayoutSVGInlineText& text_layout_object = InlineText(); | 406 LayoutSVGInlineText& text_layout_object = InlineText(); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 } | 662 } |
663 FloatRect fragment_rect = svg_inline_text_box_.SelectionRectForTextFragment( | 663 FloatRect fragment_rect = svg_inline_text_box_.SelectionRectForTextFragment( |
664 fragment, text_match_info.start_position, text_match_info.end_position, | 664 fragment, text_match_info.start_position, text_match_info.end_position, |
665 style); | 665 style); |
666 paint_info.context.SetFillColor(color); | 666 paint_info.context.SetFillColor(color); |
667 paint_info.context.FillRect(fragment_rect); | 667 paint_info.context.FillRect(fragment_rect); |
668 } | 668 } |
669 } | 669 } |
670 | 670 |
671 } // namespace blink | 671 } // namespace blink |
OLD | NEW |