Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Re-add ios changes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 Path path; 349 Path path;
350 path.addRect(FloatRect(decorationOrigin, 350 path.addRect(FloatRect(decorationOrigin,
351 FloatSize(fragment.width, thickness / scalingFactor))); 351 FloatSize(fragment.width, thickness / scalingFactor)));
352 352
353 const SVGComputedStyle& svgDecorationStyle = decorationStyle.svgStyle(); 353 const SVGComputedStyle& svgDecorationStyle = decorationStyle.svgStyle();
354 354
355 for (int i = 0; i < 3; i++) { 355 for (int i = 0; i < 3; i++) {
356 switch (svgDecorationStyle.paintOrderType(i)) { 356 switch (svgDecorationStyle.paintOrderType(i)) {
357 case PT_FILL: 357 case PT_FILL:
358 if (svgDecorationStyle.hasFill()) { 358 if (svgDecorationStyle.hasFill()) {
359 SkPaint fillPaint; 359 PaintFlags fillPaint;
360 if (!SVGPaintContext::paintForLayoutObject( 360 if (!SVGPaintContext::paintForLayoutObject(
361 paintInfo, decorationStyle, *decorationLayoutObject, 361 paintInfo, decorationStyle, *decorationLayoutObject,
362 ApplyToFillMode, fillPaint)) 362 ApplyToFillMode, fillPaint))
363 break; 363 break;
364 fillPaint.setAntiAlias(true); 364 fillPaint.setAntiAlias(true);
365 paintInfo.context.drawPath(path.getSkPath(), fillPaint); 365 paintInfo.context.drawPath(path.getSkPath(), fillPaint);
366 } 366 }
367 break; 367 break;
368 case PT_STROKE: 368 case PT_STROKE:
369 if (svgDecorationStyle.hasVisibleStroke()) { 369 if (svgDecorationStyle.hasVisibleStroke()) {
370 SkPaint strokePaint; 370 PaintFlags strokePaint;
371 if (!SVGPaintContext::paintForLayoutObject( 371 if (!SVGPaintContext::paintForLayoutObject(
372 paintInfo, decorationStyle, *decorationLayoutObject, 372 paintInfo, decorationStyle, *decorationLayoutObject,
373 ApplyToStrokeMode, strokePaint)) 373 ApplyToStrokeMode, strokePaint))
374 break; 374 break;
375 strokePaint.setAntiAlias(true); 375 strokePaint.setAntiAlias(true);
376 float strokeScaleFactor = 376 float strokeScaleFactor =
377 svgDecorationStyle.vectorEffect() == VE_NON_SCALING_STROKE 377 svgDecorationStyle.vectorEffect() == VE_NON_SCALING_STROKE
378 ? 1 / scalingFactor 378 ? 1 / scalingFactor
379 : 1; 379 : 1;
380 StrokeData strokeData; 380 StrokeData strokeData;
(...skipping 10 matching lines...) Expand all
391 break; 391 break;
392 default: 392 default:
393 ASSERT_NOT_REACHED(); 393 ASSERT_NOT_REACHED();
394 } 394 }
395 } 395 }
396 } 396 }
397 397
398 bool SVGInlineTextBoxPainter::setupTextPaint(const PaintInfo& paintInfo, 398 bool SVGInlineTextBoxPainter::setupTextPaint(const PaintInfo& paintInfo,
399 const ComputedStyle& style, 399 const ComputedStyle& style,
400 LayoutSVGResourceMode resourceMode, 400 LayoutSVGResourceMode resourceMode,
401 SkPaint& paint) { 401 PaintFlags& paint) {
402 LayoutSVGInlineText& textLayoutObject = inlineText(); 402 LayoutSVGInlineText& textLayoutObject = inlineText();
403 403
404 float scalingFactor = textLayoutObject.scalingFactor(); 404 float scalingFactor = textLayoutObject.scalingFactor();
405 DCHECK(scalingFactor); 405 DCHECK(scalingFactor);
406 406
407 AffineTransform paintServerTransform; 407 AffineTransform paintServerTransform;
408 const AffineTransform* additionalPaintServerTransform = nullptr; 408 const AffineTransform* additionalPaintServerTransform = nullptr;
409 409
410 if (scalingFactor != 1) { 410 if (scalingFactor != 1) {
411 // Adjust the paint-server coordinate space. 411 // Adjust the paint-server coordinate space.
(...skipping 26 matching lines...) Expand all
438 strokeData.setupPaint(&paint); 438 strokeData.setupPaint(&paint);
439 } 439 }
440 return true; 440 return true;
441 } 441 }
442 442
443 void SVGInlineTextBoxPainter::paintText(const PaintInfo& paintInfo, 443 void SVGInlineTextBoxPainter::paintText(const PaintInfo& paintInfo,
444 TextRun& textRun, 444 TextRun& textRun,
445 const SVGTextFragment& fragment, 445 const SVGTextFragment& fragment,
446 int startPosition, 446 int startPosition,
447 int endPosition, 447 int endPosition,
448 const SkPaint& paint) { 448 const PaintFlags& paint) {
449 LayoutSVGInlineText& textLayoutObject = inlineText(); 449 LayoutSVGInlineText& textLayoutObject = inlineText();
450 const Font& scaledFont = textLayoutObject.scaledFont(); 450 const Font& scaledFont = textLayoutObject.scaledFont();
451 451
452 float scalingFactor = textLayoutObject.scalingFactor(); 452 float scalingFactor = textLayoutObject.scalingFactor();
453 DCHECK(scalingFactor); 453 DCHECK(scalingFactor);
454 454
455 FloatPoint textOrigin(fragment.x, fragment.y); 455 FloatPoint textOrigin(fragment.x, fragment.y);
456 FloatSize textSize(fragment.width, fragment.height); 456 FloatSize textSize(fragment.width, fragment.height);
457 457
458 GraphicsContext& context = paintInfo.context; 458 GraphicsContext& context = paintInfo.context;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 m_svgInlineTextBox.selectionStartEnd(startPosition, endPosition); 491 m_svgInlineTextBox.selectionStartEnd(startPosition, endPosition);
492 shouldPaintSelection = 492 shouldPaintSelection =
493 m_svgInlineTextBox.mapStartEndPositionsIntoFragmentCoordinates( 493 m_svgInlineTextBox.mapStartEndPositionsIntoFragmentCoordinates(
494 fragment, startPosition, endPosition); 494 fragment, startPosition, endPosition);
495 } 495 }
496 496
497 // Fast path if there is no selection, just draw the whole chunk part using 497 // Fast path if there is no selection, just draw the whole chunk part using
498 // the regular style. 498 // the regular style.
499 TextRun textRun = m_svgInlineTextBox.constructTextRun(style, fragment); 499 TextRun textRun = m_svgInlineTextBox.constructTextRun(style, fragment);
500 if (!shouldPaintSelection || startPosition >= endPosition) { 500 if (!shouldPaintSelection || startPosition >= endPosition) {
501 SkPaint paint; 501 PaintFlags paint;
502 if (setupTextPaint(paintInfo, style, resourceMode, paint)) 502 if (setupTextPaint(paintInfo, style, resourceMode, paint))
503 paintText(paintInfo, textRun, fragment, 0, fragment.length, paint); 503 paintText(paintInfo, textRun, fragment, 0, fragment.length, paint);
504 return; 504 return;
505 } 505 }
506 506
507 // Eventually draw text using regular style until the start position of the 507 // Eventually draw text using regular style until the start position of the
508 // selection. 508 // selection.
509 bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection; 509 bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
510 if (startPosition > 0 && !paintSelectedTextOnly) { 510 if (startPosition > 0 && !paintSelectedTextOnly) {
511 SkPaint paint; 511 PaintFlags paint;
512 if (setupTextPaint(paintInfo, style, resourceMode, paint)) 512 if (setupTextPaint(paintInfo, style, resourceMode, paint))
513 paintText(paintInfo, textRun, fragment, 0, startPosition, paint); 513 paintText(paintInfo, textRun, fragment, 0, startPosition, paint);
514 } 514 }
515 515
516 // Draw text using selection style from the start to the end position of the 516 // Draw text using selection style from the start to the end position of the
517 // selection. 517 // selection.
518 if (style != selectionStyle) { 518 if (style != selectionStyle) {
519 StyleDifference diff; 519 StyleDifference diff;
520 diff.setNeedsPaintInvalidationObject(); 520 diff.setNeedsPaintInvalidationObject();
521 SVGResourcesCache::clientStyleChanged(&parentInlineLayoutObject(), diff, 521 SVGResourcesCache::clientStyleChanged(&parentInlineLayoutObject(), diff,
522 selectionStyle); 522 selectionStyle);
523 } 523 }
524 524
525 SkPaint paint; 525 PaintFlags paint;
526 if (setupTextPaint(paintInfo, selectionStyle, resourceMode, paint)) 526 if (setupTextPaint(paintInfo, selectionStyle, resourceMode, paint))
527 paintText(paintInfo, textRun, fragment, startPosition, endPosition, paint); 527 paintText(paintInfo, textRun, fragment, startPosition, endPosition, paint);
528 528
529 if (style != selectionStyle) { 529 if (style != selectionStyle) {
530 StyleDifference diff; 530 StyleDifference diff;
531 diff.setNeedsPaintInvalidationObject(); 531 diff.setNeedsPaintInvalidationObject();
532 SVGResourcesCache::clientStyleChanged(&parentInlineLayoutObject(), diff, 532 SVGResourcesCache::clientStyleChanged(&parentInlineLayoutObject(), diff,
533 style); 533 style);
534 } 534 }
535 535
536 // Eventually draw text using regular style from the end position of the 536 // Eventually draw text using regular style from the end position of the
537 // selection to the end of the current chunk part. 537 // selection to the end of the current chunk part.
538 if (endPosition < static_cast<int>(fragment.length) && 538 if (endPosition < static_cast<int>(fragment.length) &&
539 !paintSelectedTextOnly) { 539 !paintSelectedTextOnly) {
540 SkPaint paint; 540 PaintFlags paint;
541 if (setupTextPaint(paintInfo, style, resourceMode, paint)) 541 if (setupTextPaint(paintInfo, style, resourceMode, paint))
542 paintText(paintInfo, textRun, fragment, endPosition, fragment.length, 542 paintText(paintInfo, textRun, fragment, endPosition, fragment.length,
543 paint); 543 paint);
544 } 544 }
545 } 545 }
546 546
547 Vector<SVGTextFragmentWithRange> SVGInlineTextBoxPainter::collectTextMatches( 547 Vector<SVGTextFragmentWithRange> SVGInlineTextBoxPainter::collectTextMatches(
548 const DocumentMarker& marker) const { 548 const DocumentMarker& marker) const {
549 const Vector<SVGTextFragmentWithRange> emptyTextMatchList; 549 const Vector<SVGTextFragmentWithRange> emptyTextMatchList;
550 550
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 const ComputedStyle& style, 594 const ComputedStyle& style,
595 const Font& font) { 595 const Font& font) {
596 const Vector<SVGTextFragmentWithRange> textMatchInfoList = 596 const Vector<SVGTextFragmentWithRange> textMatchInfoList =
597 collectTextMatches(marker); 597 collectTextMatches(marker);
598 if (textMatchInfoList.isEmpty()) 598 if (textMatchInfoList.isEmpty())
599 return; 599 return;
600 600
601 Color textColor = 601 Color textColor =
602 LayoutTheme::theme().platformTextSearchColor(marker.activeMatch()); 602 LayoutTheme::theme().platformTextSearchColor(marker.activeMatch());
603 603
604 SkPaint fillPaint; 604 PaintFlags fillPaint;
605 fillPaint.setColor(textColor.rgb()); 605 fillPaint.setColor(textColor.rgb());
606 fillPaint.setAntiAlias(true); 606 fillPaint.setAntiAlias(true);
607 607
608 SkPaint strokePaint; 608 PaintFlags strokePaint;
609 bool shouldPaintStroke = false; 609 bool shouldPaintStroke = false;
610 if (setupTextPaint(paintInfo, style, ApplyToStrokeMode, strokePaint)) { 610 if (setupTextPaint(paintInfo, style, ApplyToStrokeMode, strokePaint)) {
611 shouldPaintStroke = true; 611 shouldPaintStroke = true;
612 strokePaint.setLooper(nullptr); 612 strokePaint.setLooper(nullptr);
613 strokePaint.setColor(textColor.rgb()); 613 strokePaint.setColor(textColor.rgb());
614 } 614 }
615 615
616 for (const SVGTextFragmentWithRange& textMatchInfo : textMatchInfoList) { 616 for (const SVGTextFragmentWithRange& textMatchInfo : textMatchInfoList) {
617 const SVGTextFragment& fragment = textMatchInfo.fragment; 617 const SVGTextFragment& fragment = textMatchInfo.fragment;
618 GraphicsContextStateSaver stateSaver(paintInfo.context); 618 GraphicsContextStateSaver stateSaver(paintInfo.context);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 } 651 }
652 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( 652 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment(
653 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, 653 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition,
654 style); 654 style);
655 paintInfo.context.setFillColor(color); 655 paintInfo.context.setFillColor(color);
656 paintInfo.context.fillRect(fragmentRect); 656 paintInfo.context.fillRect(fragmentRect);
657 } 657 }
658 } 658 }
659 659
660 } // namespace blink 660 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698