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/editing/markers/RenderedDocumentMarker.h" | 9 #include "core/editing/markers/RenderedDocumentMarker.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 364 } |
365 break; | 365 break; |
366 case PT_STROKE: | 366 case PT_STROKE: |
367 if (svgDecorationStyle.hasVisibleStroke()) { | 367 if (svgDecorationStyle.hasVisibleStroke()) { |
368 SkPaint strokePaint; | 368 SkPaint strokePaint; |
369 if (!SVGPaintContext::paintForLayoutObject( | 369 if (!SVGPaintContext::paintForLayoutObject( |
370 paintInfo, decorationStyle, *decorationLayoutObject, | 370 paintInfo, decorationStyle, *decorationLayoutObject, |
371 ApplyToStrokeMode, strokePaint)) | 371 ApplyToStrokeMode, strokePaint)) |
372 break; | 372 break; |
373 strokePaint.setAntiAlias(true); | 373 strokePaint.setAntiAlias(true); |
| 374 float strokeScaleFactor = |
| 375 svgDecorationStyle.vectorEffect() == VE_NON_SCALING_STROKE |
| 376 ? 1 / scalingFactor |
| 377 : 1; |
374 StrokeData strokeData; | 378 StrokeData strokeData; |
375 SVGLayoutSupport::applyStrokeStyleToStrokeData( | 379 SVGLayoutSupport::applyStrokeStyleToStrokeData( |
376 strokeData, decorationStyle, *decorationLayoutObject, 1); | 380 strokeData, decorationStyle, *decorationLayoutObject, |
377 if (svgDecorationStyle.vectorEffect() == VE_NON_SCALING_STROKE) | 381 strokeScaleFactor); |
378 strokeData.setThickness(strokeData.thickness() / scalingFactor); | 382 if (strokeScaleFactor != 1) |
| 383 strokeData.setThickness(strokeData.thickness() * strokeScaleFactor); |
379 strokeData.setupPaint(&strokePaint); | 384 strokeData.setupPaint(&strokePaint); |
380 paintInfo.context.drawPath(path.getSkPath(), strokePaint); | 385 paintInfo.context.drawPath(path.getSkPath(), strokePaint); |
381 } | 386 } |
382 break; | 387 break; |
383 case PT_MARKERS: | 388 case PT_MARKERS: |
384 break; | 389 break; |
385 default: | 390 default: |
386 ASSERT_NOT_REACHED(); | 391 ASSERT_NOT_REACHED(); |
387 } | 392 } |
388 } | 393 } |
(...skipping 23 matching lines...) Expand all Loading... |
412 return false; | 417 return false; |
413 paint.setAntiAlias(true); | 418 paint.setAntiAlias(true); |
414 | 419 |
415 if (hasShadow(paintInfo, style)) { | 420 if (hasShadow(paintInfo, style)) { |
416 paint.setLooper(style.textShadow()->createDrawLooper( | 421 paint.setLooper(style.textShadow()->createDrawLooper( |
417 DrawLooperBuilder::ShadowRespectsAlpha, | 422 DrawLooperBuilder::ShadowRespectsAlpha, |
418 style.visitedDependentColor(CSSPropertyColor))); | 423 style.visitedDependentColor(CSSPropertyColor))); |
419 } | 424 } |
420 | 425 |
421 if (resourceMode == ApplyToStrokeMode) { | 426 if (resourceMode == ApplyToStrokeMode) { |
| 427 // The stroke geometry needs be generated based on the scaled font. |
| 428 float strokeScaleFactor = |
| 429 style.svgStyle().vectorEffect() != VE_NON_SCALING_STROKE ? scalingFactor |
| 430 : 1; |
422 StrokeData strokeData; | 431 StrokeData strokeData; |
423 SVGLayoutSupport::applyStrokeStyleToStrokeData( | 432 SVGLayoutSupport::applyStrokeStyleToStrokeData( |
424 strokeData, style, parentInlineLayoutObject(), 1); | 433 strokeData, style, parentInlineLayoutObject(), strokeScaleFactor); |
425 if (style.svgStyle().vectorEffect() != VE_NON_SCALING_STROKE) | 434 if (strokeScaleFactor != 1) |
426 strokeData.setThickness(strokeData.thickness() * scalingFactor); | 435 strokeData.setThickness(strokeData.thickness() * strokeScaleFactor); |
427 strokeData.setupPaint(&paint); | 436 strokeData.setupPaint(&paint); |
428 } | 437 } |
429 return true; | 438 return true; |
430 } | 439 } |
431 | 440 |
432 void SVGInlineTextBoxPainter::paintText(const PaintInfo& paintInfo, | 441 void SVGInlineTextBoxPainter::paintText(const PaintInfo& paintInfo, |
433 TextRun& textRun, | 442 TextRun& textRun, |
434 const SVGTextFragment& fragment, | 443 const SVGTextFragment& fragment, |
435 int startPosition, | 444 int startPosition, |
436 int endPosition, | 445 int endPosition, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 } | 649 } |
641 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( | 650 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( |
642 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, | 651 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, |
643 style); | 652 style); |
644 paintInfo.context.setFillColor(color); | 653 paintInfo.context.setFillColor(color); |
645 paintInfo.context.fillRect(fragmentRect); | 654 paintInfo.context.fillRect(fragmentRect); |
646 } | 655 } |
647 } | 656 } |
648 | 657 |
649 } // namespace blink | 658 } // namespace blink |
OLD | NEW |