| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 float scalingFactor = 1; | 322 float scalingFactor = 1; |
| 323 Font scaledFont; | 323 Font scaledFont; |
| 324 LayoutSVGInlineText::computeNewScaledFontForStyle(decorationLayoutObject, | 324 LayoutSVGInlineText::computeNewScaledFontForStyle(decorationLayoutObject, |
| 325 scalingFactor, scaledFont); | 325 scalingFactor, scaledFont); |
| 326 ASSERT(scalingFactor); | 326 ASSERT(scalingFactor); |
| 327 | 327 |
| 328 float thickness = thicknessForDecoration(decoration, scaledFont); | 328 float thickness = thicknessForDecoration(decoration, scaledFont); |
| 329 if (thickness <= 0) | 329 if (thickness <= 0) |
| 330 return; | 330 return; |
| 331 | 331 |
| 332 const SimpleFontData* fontData = scaledFont.primaryFont(); |
| 333 DCHECK(fontData); |
| 334 if (!fontData) |
| 335 return; |
| 336 |
| 332 float decorationOffset = baselineOffsetForDecoration( | 337 float decorationOffset = baselineOffsetForDecoration( |
| 333 decoration, scaledFont.getFontMetrics(), thickness); | 338 decoration, fontData->getFontMetrics(), thickness); |
| 334 FloatPoint decorationOrigin(fragment.x, | 339 FloatPoint decorationOrigin(fragment.x, |
| 335 fragment.y - decorationOffset / scalingFactor); | 340 fragment.y - decorationOffset / scalingFactor); |
| 336 | 341 |
| 337 Path path; | 342 Path path; |
| 338 path.addRect(FloatRect(decorationOrigin, | 343 path.addRect(FloatRect(decorationOrigin, |
| 339 FloatSize(fragment.width, thickness / scalingFactor))); | 344 FloatSize(fragment.width, thickness / scalingFactor))); |
| 340 | 345 |
| 341 const SVGComputedStyle& svgDecorationStyle = decorationStyle.svgStyle(); | 346 const SVGComputedStyle& svgDecorationStyle = decorationStyle.svgStyle(); |
| 342 | 347 |
| 343 for (int i = 0; i < 3; i++) { | 348 for (int i = 0; i < 3; i++) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 textOrigin.scale(scalingFactor, scalingFactor); | 447 textOrigin.scale(scalingFactor, scalingFactor); |
| 443 textSize.scale(scalingFactor); | 448 textSize.scale(scalingFactor); |
| 444 stateSaver.save(); | 449 stateSaver.save(); |
| 445 context.scale(1 / scalingFactor, 1 / scalingFactor); | 450 context.scale(1 / scalingFactor, 1 / scalingFactor); |
| 446 } | 451 } |
| 447 | 452 |
| 448 TextRunPaintInfo textRunPaintInfo(textRun); | 453 TextRunPaintInfo textRunPaintInfo(textRun); |
| 449 textRunPaintInfo.from = startPosition; | 454 textRunPaintInfo.from = startPosition; |
| 450 textRunPaintInfo.to = endPosition; | 455 textRunPaintInfo.to = endPosition; |
| 451 | 456 |
| 452 float baseline = scaledFont.getFontMetrics().floatAscent(); | 457 const SimpleFontData* fontData = scaledFont.primaryFont(); |
| 458 DCHECK(fontData); |
| 459 if (!fontData) |
| 460 return; |
| 461 float baseline = fontData->getFontMetrics().floatAscent(); |
| 453 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - baseline, | 462 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - baseline, |
| 454 textSize.width(), textSize.height()); | 463 textSize.width(), textSize.height()); |
| 455 | 464 |
| 456 context.drawText(scaledFont, textRunPaintInfo, textOrigin, paint); | 465 context.drawText(scaledFont, textRunPaintInfo, textOrigin, paint); |
| 457 } | 466 } |
| 458 | 467 |
| 459 void SVGInlineTextBoxPainter::paintText(const PaintInfo& paintInfo, | 468 void SVGInlineTextBoxPainter::paintText(const PaintInfo& paintInfo, |
| 460 const ComputedStyle& style, | 469 const ComputedStyle& style, |
| 461 const ComputedStyle& selectionStyle, | 470 const ComputedStyle& selectionStyle, |
| 462 const SVGTextFragment& fragment, | 471 const SVGTextFragment& fragment, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 637 } |
| 629 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( | 638 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( |
| 630 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, | 639 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, |
| 631 style); | 640 style); |
| 632 paintInfo.context.setFillColor(color); | 641 paintInfo.context.setFillColor(color); |
| 633 paintInfo.context.fillRect(fragmentRect); | 642 paintInfo.context.fillRect(fragmentRect); |
| 634 } | 643 } |
| 635 } | 644 } |
| 636 | 645 |
| 637 } // namespace blink | 646 } // namespace blink |
| OLD | NEW |