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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return toLayoutSVGInlineText(inlineLayoutObject()); | 77 return toLayoutSVGInlineText(inlineLayoutObject()); |
78 } | 78 } |
79 | 79 |
80 void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, | 80 void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, |
81 const LayoutPoint& paintOffset) { | 81 const LayoutPoint& paintOffset) { |
82 DCHECK(paintInfo.phase == PaintPhaseForeground || | 82 DCHECK(paintInfo.phase == PaintPhaseForeground || |
83 paintInfo.phase == PaintPhaseSelection); | 83 paintInfo.phase == PaintPhaseSelection); |
84 DCHECK(m_svgInlineTextBox.truncation() == cNoTruncation); | 84 DCHECK(m_svgInlineTextBox.truncation() == cNoTruncation); |
85 | 85 |
86 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != | 86 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != |
87 EVisibility::Visible || | 87 EVisibility::kVisible || |
88 !m_svgInlineTextBox.len()) | 88 !m_svgInlineTextBox.len()) |
89 return; | 89 return; |
90 | 90 |
91 // We're explicitly not supporting composition & custom underlines and custom | 91 // We're explicitly not supporting composition & custom underlines and custom |
92 // highlighters -- unlike InlineTextBox. If we ever need that for SVG, it's | 92 // highlighters -- unlike InlineTextBox. If we ever need that for SVG, it's |
93 // very easy to refactor and reuse the code. | 93 // very easy to refactor and reuse the code. |
94 | 94 |
95 bool haveSelection = shouldPaintSelection(paintInfo); | 95 bool haveSelection = shouldPaintSelection(paintInfo); |
96 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) | 96 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) |
97 return; | 97 return; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 for (const AppliedTextDecoration& decoration : decorations) { | 207 for (const AppliedTextDecoration& decoration : decorations) { |
208 if (decoration.lines() & TextDecorationLineThrough) | 208 if (decoration.lines() & TextDecorationLineThrough) |
209 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); | 209 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); |
210 } | 210 } |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 void SVGInlineTextBoxPainter::paintSelectionBackground( | 214 void SVGInlineTextBoxPainter::paintSelectionBackground( |
215 const PaintInfo& paintInfo) { | 215 const PaintInfo& paintInfo) { |
216 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != | 216 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != |
217 EVisibility::Visible) | 217 EVisibility::kVisible) |
218 return; | 218 return; |
219 | 219 |
220 DCHECK(!paintInfo.isPrinting()); | 220 DCHECK(!paintInfo.isPrinting()); |
221 | 221 |
222 if (paintInfo.phase == PaintPhaseSelection || | 222 if (paintInfo.phase == PaintPhaseSelection || |
223 !shouldPaintSelection(paintInfo)) | 223 !shouldPaintSelection(paintInfo)) |
224 return; | 224 return; |
225 | 225 |
226 Color backgroundColor = | 226 Color backgroundColor = |
227 m_svgInlineTextBox.getLineLayoutItem().selectionBackgroundColor(); | 227 m_svgInlineTextBox.getLineLayoutItem().selectionBackgroundColor(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 310 |
311 if (fragment.width <= 0) | 311 if (fragment.width <= 0) |
312 return; | 312 return; |
313 | 313 |
314 // Find out which style defined the text-decoration, as its fill/stroke | 314 // Find out which style defined the text-decoration, as its fill/stroke |
315 // properties have to be used for drawing instead of ours. | 315 // properties have to be used for drawing instead of ours. |
316 LayoutObject* decorationLayoutObject = | 316 LayoutObject* decorationLayoutObject = |
317 findLayoutObjectDefininingTextDecoration(m_svgInlineTextBox.parent()); | 317 findLayoutObjectDefininingTextDecoration(m_svgInlineTextBox.parent()); |
318 const ComputedStyle& decorationStyle = decorationLayoutObject->styleRef(); | 318 const ComputedStyle& decorationStyle = decorationLayoutObject->styleRef(); |
319 | 319 |
320 if (decorationStyle.visibility() != EVisibility::Visible) | 320 if (decorationStyle.visibility() != EVisibility::kVisible) |
321 return; | 321 return; |
322 | 322 |
323 float scalingFactor = 1; | 323 float scalingFactor = 1; |
324 Font scaledFont; | 324 Font scaledFont; |
325 LayoutSVGInlineText::computeNewScaledFontForStyle(*decorationLayoutObject, | 325 LayoutSVGInlineText::computeNewScaledFontForStyle(*decorationLayoutObject, |
326 scalingFactor, scaledFont); | 326 scalingFactor, scaledFont); |
327 DCHECK(scalingFactor); | 327 DCHECK(scalingFactor); |
328 | 328 |
329 float thickness = thicknessForDecoration(decoration, scaledFont); | 329 float thickness = thicknessForDecoration(decoration, scaledFont); |
330 if (thickness <= 0) | 330 if (thickness <= 0) |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 } | 645 } |
646 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( | 646 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( |
647 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, | 647 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, |
648 style); | 648 style); |
649 paintInfo.context.setFillColor(color); | 649 paintInfo.context.setFillColor(color); |
650 paintInfo.context.fillRect(fragmentRect); | 650 paintInfo.context.fillRect(fragmentRect); |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 } // namespace blink | 654 } // namespace blink |
OLD | NEW |