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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 m_svgInlineTextBox.start(), m_svgInlineTextBox.start() + m_svgInline
TextBox.len())); | 60 m_svgInlineTextBox.start(), m_svgInlineTextBox.start() + m_svgInline
TextBox.len())); |
61 } | 61 } |
62 return FloatRect(bounds); | 62 return FloatRect(bounds); |
63 } | 63 } |
64 | 64 |
65 void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin
t& paintOffset) | 65 void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin
t& paintOffset) |
66 { | 66 { |
67 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh
aseSelection); | 67 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh
aseSelection); |
68 ASSERT(m_svgInlineTextBox.truncation() == cNoTruncation); | 68 ASSERT(m_svgInlineTextBox.truncation() == cNoTruncation); |
69 | 69 |
70 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != VISIBLE) | 70 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != EVisibil
ity::Visible) |
71 return; | 71 return; |
72 | 72 |
73 // We're explicitly not supporting composition & custom underlines and custo
m highlighters -- unlike InlineTextBox. | 73 // We're explicitly not supporting composition & custom underlines and custo
m highlighters -- unlike InlineTextBox. |
74 // If we ever need that for SVG, it's very easy to refactor and reuse the co
de. | 74 // If we ever need that for SVG, it's very easy to refactor and reuse the co
de. |
75 | 75 |
76 bool haveSelection = shouldPaintSelection(paintInfo); | 76 bool haveSelection = shouldPaintSelection(paintInfo); |
77 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) | 77 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) |
78 return; | 78 return; |
79 | 79 |
80 LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayoutAPI
Shim::layoutObjectFrom(m_svgInlineTextBox.getLineLayoutItem())); | 80 LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayoutAPI
Shim::layoutObjectFrom(m_svgInlineTextBox.getLineLayoutItem())); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 | 170 |
171 // Spec: Line-through should be drawn after the text is filled and strok
ed; thus, the line-through is rendered on top of the text. | 171 // Spec: Line-through should be drawn after the text is filled and strok
ed; thus, the line-through is rendered on top of the text. |
172 if (decorations & TextDecorationLineThrough) | 172 if (decorations & TextDecorationLineThrough) |
173 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); | 173 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf
o) | 177 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf
o) |
178 { | 178 { |
179 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != VISIBLE) | 179 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != EVisibil
ity::Visible) |
180 return; | 180 return; |
181 | 181 |
182 ASSERT(!paintInfo.isPrinting()); | 182 ASSERT(!paintInfo.isPrinting()); |
183 | 183 |
184 if (paintInfo.phase == PaintPhaseSelection || !shouldPaintSelection(paintInf
o)) | 184 if (paintInfo.phase == PaintPhaseSelection || !shouldPaintSelection(paintInf
o)) |
185 return; | 185 return; |
186 | 186 |
187 Color backgroundColor = m_svgInlineTextBox.getLineLayoutItem().selectionBack
groundColor(); | 187 Color backgroundColor = m_svgInlineTextBox.getLineLayoutItem().selectionBack
groundColor(); |
188 if (!backgroundColor.alpha()) | 188 if (!backgroundColor.alpha()) |
189 return; | 189 return; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 if (m_svgInlineTextBox.getLineLayoutItem().style()->textDecorationsInEffect(
) == TextDecorationNone) | 254 if (m_svgInlineTextBox.getLineLayoutItem().style()->textDecorationsInEffect(
) == TextDecorationNone) |
255 return; | 255 return; |
256 | 256 |
257 if (fragment.width <= 0) | 257 if (fragment.width <= 0) |
258 return; | 258 return; |
259 | 259 |
260 // Find out which style defined the text-decoration, as its fill/stroke prop
erties have to be used for drawing instead of ours. | 260 // Find out which style defined the text-decoration, as its fill/stroke prop
erties have to be used for drawing instead of ours. |
261 LayoutObject* decorationLayoutObject = findLayoutObjectDefininingTextDecorat
ion(m_svgInlineTextBox.parent()); | 261 LayoutObject* decorationLayoutObject = findLayoutObjectDefininingTextDecorat
ion(m_svgInlineTextBox.parent()); |
262 const ComputedStyle& decorationStyle = decorationLayoutObject->styleRef(); | 262 const ComputedStyle& decorationStyle = decorationLayoutObject->styleRef(); |
263 | 263 |
264 if (decorationStyle.visibility() != VISIBLE) | 264 if (decorationStyle.visibility() != EVisibility::Visible) |
265 return; | 265 return; |
266 | 266 |
267 float scalingFactor = 1; | 267 float scalingFactor = 1; |
268 Font scaledFont; | 268 Font scaledFont; |
269 LayoutSVGInlineText::computeNewScaledFontForStyle(decorationLayoutObject, sc
alingFactor, scaledFont); | 269 LayoutSVGInlineText::computeNewScaledFontForStyle(decorationLayoutObject, sc
alingFactor, scaledFont); |
270 ASSERT(scalingFactor); | 270 ASSERT(scalingFactor); |
271 | 271 |
272 float thickness = thicknessForDecoration(decoration, scaledFont); | 272 float thickness = thicknessForDecoration(decoration, scaledFont); |
273 if (thickness <= 0) | 273 if (thickness <= 0) |
274 return; | 274 return; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 stateSaver.save(); | 518 stateSaver.save(); |
519 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); | 519 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); |
520 } | 520 } |
521 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment
(fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style); | 521 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment
(fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style); |
522 paintInfo.context.setFillColor(color); | 522 paintInfo.context.setFillColor(color); |
523 paintInfo.context.fillRect(fragmentRect); | 523 paintInfo.context.fillRect(fragmentRect); |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 } // namespace blink | 527 } // namespace blink |
OLD | NEW |