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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 void SVGInlineTextBoxPainter::paintTextFragments( | 138 void SVGInlineTextBoxPainter::paintTextFragments( |
139 const PaintInfo& paintInfo, | 139 const PaintInfo& paintInfo, |
140 LayoutObject& parentLayoutObject) { | 140 LayoutObject& parentLayoutObject) { |
141 const ComputedStyle& style = parentLayoutObject.styleRef(); | 141 const ComputedStyle& style = parentLayoutObject.styleRef(); |
142 const SVGComputedStyle& svgStyle = style.svgStyle(); | 142 const SVGComputedStyle& svgStyle = style.svgStyle(); |
143 | 143 |
144 bool hasFill = svgStyle.hasFill(); | 144 bool hasFill = svgStyle.hasFill(); |
145 bool hasVisibleStroke = svgStyle.hasVisibleStroke(); | 145 bool hasVisibleStroke = style.hasVisibleStroke(); |
146 | 146 |
147 const ComputedStyle* selectionStyle = &style; | 147 const ComputedStyle* selectionStyle = &style; |
148 bool shouldPaintSelection = this->shouldPaintSelection(paintInfo); | 148 bool shouldPaintSelection = this->shouldPaintSelection(paintInfo); |
149 if (shouldPaintSelection) { | 149 if (shouldPaintSelection) { |
150 selectionStyle = parentLayoutObject.getCachedPseudoStyle(PseudoIdSelection); | 150 selectionStyle = parentLayoutObject.getCachedPseudoStyle(PseudoIdSelection); |
151 if (selectionStyle) { | 151 if (selectionStyle) { |
152 const SVGComputedStyle& svgSelectionStyle = selectionStyle->svgStyle(); | 152 const SVGComputedStyle& svgSelectionStyle = selectionStyle->svgStyle(); |
153 | 153 |
154 if (!hasFill) | 154 if (!hasFill) |
155 hasFill = svgSelectionStyle.hasFill(); | 155 hasFill = svgSelectionStyle.hasFill(); |
156 if (!hasVisibleStroke) | 156 if (!hasVisibleStroke) |
157 hasVisibleStroke = svgSelectionStyle.hasVisibleStroke(); | 157 hasVisibleStroke = selectionStyle->hasVisibleStroke(); |
158 } else { | 158 } else { |
159 selectionStyle = &style; | 159 selectionStyle = &style; |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 if (paintInfo.isRenderingClipPathAsMaskImage()) { | 163 if (paintInfo.isRenderingClipPathAsMaskImage()) { |
164 hasFill = true; | 164 hasFill = true; |
165 hasVisibleStroke = false; | 165 hasVisibleStroke = false; |
166 } | 166 } |
167 | 167 |
(...skipping 13 matching lines...) Expand all Loading... |
181 const Vector<AppliedTextDecoration>& decorations = | 181 const Vector<AppliedTextDecoration>& decorations = |
182 style.appliedTextDecorations(); | 182 style.appliedTextDecorations(); |
183 for (const AppliedTextDecoration& decoration : decorations) { | 183 for (const AppliedTextDecoration& decoration : decorations) { |
184 if (decoration.lines() & TextDecorationUnderline) | 184 if (decoration.lines() & TextDecorationUnderline) |
185 paintDecoration(paintInfo, TextDecorationUnderline, fragment); | 185 paintDecoration(paintInfo, TextDecorationUnderline, fragment); |
186 if (decoration.lines() & TextDecorationOverline) | 186 if (decoration.lines() & TextDecorationOverline) |
187 paintDecoration(paintInfo, TextDecorationOverline, fragment); | 187 paintDecoration(paintInfo, TextDecorationOverline, fragment); |
188 } | 188 } |
189 | 189 |
190 for (int i = 0; i < 3; i++) { | 190 for (int i = 0; i < 3; i++) { |
191 switch (svgStyle.paintOrderType(i)) { | 191 switch (style.paintOrderType(i)) { |
192 case PT_FILL: | 192 case PT_FILL: |
193 if (hasFill) | 193 if (hasFill) |
194 paintText(paintInfo, style, *selectionStyle, fragment, | 194 paintText(paintInfo, style, *selectionStyle, fragment, |
195 ApplyToFillMode, shouldPaintSelection); | 195 ApplyToFillMode, shouldPaintSelection); |
196 break; | 196 break; |
197 case PT_STROKE: | 197 case PT_STROKE: |
198 if (hasVisibleStroke) | 198 if (hasVisibleStroke) |
199 paintText(paintInfo, style, *selectionStyle, fragment, | 199 paintText(paintInfo, style, *selectionStyle, fragment, |
200 ApplyToStrokeMode, shouldPaintSelection); | 200 ApplyToStrokeMode, shouldPaintSelection); |
201 break; | 201 break; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 FloatPoint decorationOrigin(fragment.x, | 346 FloatPoint decorationOrigin(fragment.x, |
347 fragment.y - decorationOffset / scalingFactor); | 347 fragment.y - decorationOffset / scalingFactor); |
348 | 348 |
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 (decorationStyle.paintOrderType(i)) { |
357 case PT_FILL: | 357 case PT_FILL: |
358 if (svgDecorationStyle.hasFill()) { | 358 if (svgDecorationStyle.hasFill()) { |
359 PaintFlags fillFlags; | 359 PaintFlags fillFlags; |
360 if (!SVGPaintContext::paintForLayoutObject( | 360 if (!SVGPaintContext::paintForLayoutObject( |
361 paintInfo, decorationStyle, *decorationLayoutObject, | 361 paintInfo, decorationStyle, *decorationLayoutObject, |
362 ApplyToFillMode, fillFlags)) | 362 ApplyToFillMode, fillFlags)) |
363 break; | 363 break; |
364 fillFlags.setAntiAlias(true); | 364 fillFlags.setAntiAlias(true); |
365 paintInfo.context.drawPath(path.getSkPath(), fillFlags); | 365 paintInfo.context.drawPath(path.getSkPath(), fillFlags); |
366 } | 366 } |
367 break; | 367 break; |
368 case PT_STROKE: | 368 case PT_STROKE: |
369 if (svgDecorationStyle.hasVisibleStroke()) { | 369 if (decorationStyle.hasVisibleStroke()) { |
370 PaintFlags strokeFlags; | 370 PaintFlags strokeFlags; |
371 if (!SVGPaintContext::paintForLayoutObject( | 371 if (!SVGPaintContext::paintForLayoutObject( |
372 paintInfo, decorationStyle, *decorationLayoutObject, | 372 paintInfo, decorationStyle, *decorationLayoutObject, |
373 ApplyToStrokeMode, strokeFlags)) | 373 ApplyToStrokeMode, strokeFlags)) |
374 break; | 374 break; |
375 strokeFlags.setAntiAlias(true); | 375 strokeFlags.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; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 } | 653 } |
654 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( | 654 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( |
655 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, | 655 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, |
656 style); | 656 style); |
657 paintInfo.context.setFillColor(color); | 657 paintInfo.context.setFillColor(color); |
658 paintInfo.context.fillRect(fragmentRect); | 658 paintInfo.context.fillRect(fragmentRect); |
659 } | 659 } |
660 } | 660 } |
661 | 661 |
662 } // namespace blink | 662 } // namespace blink |
OLD | NEW |