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

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

Issue 1549503002: Return AffineTransform from SVGTextFragment::buildFragmentTransform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/line/SVGInlineTextBox.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } else { 98 } else {
99 selectionStyle = &style; 99 selectionStyle = &style;
100 } 100 }
101 } 101 }
102 102
103 if (paintInfo.isRenderingClipPathAsMaskImage()) { 103 if (paintInfo.isRenderingClipPathAsMaskImage()) {
104 hasFill = true; 104 hasFill = true;
105 hasVisibleStroke = false; 105 hasVisibleStroke = false;
106 } 106 }
107 107
108 AffineTransform fragmentTransform;
109 unsigned textFragmentsSize = m_svgInlineTextBox.textFragments().size(); 108 unsigned textFragmentsSize = m_svgInlineTextBox.textFragments().size();
110 for (unsigned i = 0; i < textFragmentsSize; ++i) { 109 for (unsigned i = 0; i < textFragmentsSize; ++i) {
111 const SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at( i); 110 const SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at( i);
112 111
113 GraphicsContextStateSaver stateSaver(paintInfo.context, false); 112 GraphicsContextStateSaver stateSaver(paintInfo.context, false);
114 if (fragment.isTransformed()) { 113 if (fragment.isTransformed()) {
115 fragment.buildFragmentTransform(fragmentTransform);
116 stateSaver.save(); 114 stateSaver.save();
117 paintInfo.context.concatCTM(fragmentTransform); 115 paintInfo.context.concatCTM(fragment.buildFragmentTransform());
118 } 116 }
119 117
120 // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these deco rations. 118 // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these deco rations.
121 unsigned decorations = style.textDecorationsInEffect(); 119 unsigned decorations = style.textDecorationsInEffect();
122 if (decorations & TextDecorationUnderline) 120 if (decorations & TextDecorationUnderline)
123 paintDecoration(paintInfo, TextDecorationUnderline, fragment); 121 paintDecoration(paintInfo, TextDecorationUnderline, fragment);
124 if (decorations & TextDecorationOverline) 122 if (decorations & TextDecorationOverline)
125 paintDecoration(paintInfo, TextDecorationOverline, fragment); 123 paintDecoration(paintInfo, TextDecorationOverline, fragment);
126 124
127 for (int i = 0; i < 3; i++) { 125 for (int i = 0; i < 3; i++) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 163
166 LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayoutPai ntShim::layoutObjectFrom(m_svgInlineTextBox.lineLayoutItem())); 164 LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayoutPai ntShim::layoutObjectFrom(m_svgInlineTextBox.lineLayoutItem()));
167 if (!textShouldBePainted(textLayoutObject)) 165 if (!textShouldBePainted(textLayoutObject))
168 return; 166 return;
169 167
170 const ComputedStyle& style = m_svgInlineTextBox.parent()->lineLayoutItem().s tyleRef(); 168 const ComputedStyle& style = m_svgInlineTextBox.parent()->lineLayoutItem().s tyleRef();
171 169
172 int startPosition, endPosition; 170 int startPosition, endPosition;
173 m_svgInlineTextBox.selectionStartEnd(startPosition, endPosition); 171 m_svgInlineTextBox.selectionStartEnd(startPosition, endPosition);
174 172
175 AffineTransform fragmentTransform;
176 const Vector<SVGTextFragmentWithRange> fragmentInfoList = collectFragmentsIn Range(startPosition, endPosition); 173 const Vector<SVGTextFragmentWithRange> fragmentInfoList = collectFragmentsIn Range(startPosition, endPosition);
177 for (const SVGTextFragmentWithRange& fragmentWithRange : fragmentInfoList) { 174 for (const SVGTextFragmentWithRange& fragmentWithRange : fragmentInfoList) {
178 const SVGTextFragment& fragment = fragmentWithRange.fragment; 175 const SVGTextFragment& fragment = fragmentWithRange.fragment;
179 GraphicsContextStateSaver stateSaver(paintInfo.context); 176 GraphicsContextStateSaver stateSaver(paintInfo.context);
180 if (fragment.isTransformed()) { 177 if (fragment.isTransformed())
181 fragment.buildFragmentTransform(fragmentTransform); 178 paintInfo.context.concatCTM(fragment.buildFragmentTransform());
182 paintInfo.context.concatCTM(fragmentTransform);
183 }
184 179
185 paintInfo.context.setFillColor(backgroundColor); 180 paintInfo.context.setFillColor(backgroundColor);
186 paintInfo.context.fillRect(m_svgInlineTextBox.selectionRectForTextFragme nt(fragment, fragmentWithRange.startPosition, fragmentWithRange.endPosition, sty le), backgroundColor); 181 paintInfo.context.fillRect(m_svgInlineTextBox.selectionRectForTextFragme nt(fragment, fragmentWithRange.startPosition, fragmentWithRange.endPosition, sty le), backgroundColor);
187 } 182 }
188 } 183 }
189 184
190 static inline LayoutObject* findLayoutObjectDefininingTextDecoration(InlineFlowB ox* parentBox) 185 static inline LayoutObject* findLayoutObjectDefininingTextDecoration(InlineFlowB ox* parentBox)
191 { 186 {
192 // Lookup first layout object in parent hierarchy which has text-decoration set. 187 // Lookup first layout object in parent hierarchy which has text-decoration set.
193 LayoutObject* layoutObject = 0; 188 LayoutObject* layoutObject = 0;
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 fillPaint.setAntiAlias(true); 462 fillPaint.setAntiAlias(true);
468 463
469 SkPaint strokePaint; 464 SkPaint strokePaint;
470 bool shouldPaintStroke = false; 465 bool shouldPaintStroke = false;
471 if (setupTextPaint(paintInfo, style, ApplyToStrokeMode, strokePaint)) { 466 if (setupTextPaint(paintInfo, style, ApplyToStrokeMode, strokePaint)) {
472 shouldPaintStroke = true; 467 shouldPaintStroke = true;
473 strokePaint.setLooper(nullptr); 468 strokePaint.setLooper(nullptr);
474 strokePaint.setColor(textColor.rgb()); 469 strokePaint.setColor(textColor.rgb());
475 } 470 }
476 471
477 AffineTransform fragmentTransform;
478 for (const SVGTextFragmentWithRange& textMatchInfo : textMatchInfoList) { 472 for (const SVGTextFragmentWithRange& textMatchInfo : textMatchInfoList) {
479 const SVGTextFragment& fragment = textMatchInfo.fragment; 473 const SVGTextFragment& fragment = textMatchInfo.fragment;
480 GraphicsContextStateSaver stateSaver(paintInfo.context); 474 GraphicsContextStateSaver stateSaver(paintInfo.context);
481 if (fragment.isTransformed()) { 475 if (fragment.isTransformed())
482 fragment.buildFragmentTransform(fragmentTransform); 476 paintInfo.context.concatCTM(fragment.buildFragmentTransform());
483 paintInfo.context.concatCTM(fragmentTransform);
484 }
485 477
486 TextRun textRun = m_svgInlineTextBox.constructTextRun(style, fragment); 478 TextRun textRun = m_svgInlineTextBox.constructTextRun(style, fragment);
487 paintText(paintInfo, textRun, fragment, textMatchInfo.startPosition, tex tMatchInfo.endPosition, fillPaint); 479 paintText(paintInfo, textRun, fragment, textMatchInfo.startPosition, tex tMatchInfo.endPosition, fillPaint);
488 if (shouldPaintStroke) 480 if (shouldPaintStroke)
489 paintText(paintInfo, textRun, fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, strokePaint); 481 paintText(paintInfo, textRun, fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, strokePaint);
490 } 482 }
491 } 483 }
492 484
493 void SVGInlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& pa intInfo, const LayoutPoint& point, DocumentMarker* marker, const ComputedStyle& style, const Font& font) 485 void SVGInlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& pa intInfo, const LayoutPoint& point, DocumentMarker* marker, const ComputedStyle& style, const Font& font)
494 { 486 {
495 const Vector<SVGTextFragmentWithRange> textMatchInfoList = collectTextMatche s(marker); 487 const Vector<SVGTextFragmentWithRange> textMatchInfoList = collectTextMatche s(marker);
496 if (textMatchInfoList.isEmpty()) 488 if (textMatchInfoList.isEmpty())
497 return; 489 return;
498 490
499 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch()); 491 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch());
500 AffineTransform fragmentTransform;
501 for (const SVGTextFragmentWithRange& textMatchInfo : textMatchInfoList) { 492 for (const SVGTextFragmentWithRange& textMatchInfo : textMatchInfoList) {
502 const SVGTextFragment& fragment = textMatchInfo.fragment; 493 const SVGTextFragment& fragment = textMatchInfo.fragment;
503 494
504 GraphicsContextStateSaver stateSaver(paintInfo.context, false); 495 GraphicsContextStateSaver stateSaver(paintInfo.context, false);
505 if (fragment.isTransformed()) { 496 if (fragment.isTransformed()) {
506 stateSaver.save(); 497 stateSaver.save();
507 fragment.buildFragmentTransform(fragmentTransform); 498 paintInfo.context.concatCTM(fragment.buildFragmentTransform());
508 paintInfo.context.concatCTM(fragmentTransform);
509 } 499 }
510 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment (fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style); 500 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment (fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style);
511 paintInfo.context.setFillColor(color); 501 paintInfo.context.setFillColor(color);
512 paintInfo.context.fillRect(fragmentRect); 502 paintInfo.context.fillRect(fragmentRect);
513 } 503 }
514 } 504 }
515 505
516 } // namespace blink 506 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/line/SVGInlineTextBox.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698