| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 LayoutSVGInlineText& SVGInlineTextBoxPainter::inlineText() const | 75 LayoutSVGInlineText& SVGInlineTextBoxPainter::inlineText() const |
| 76 { | 76 { |
| 77 return toLayoutSVGInlineText(inlineLayoutObject()); | 77 return toLayoutSVGInlineText(inlineLayoutObject()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin
t& paintOffset) | 80 void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin
t& paintOffset) |
| 81 { | 81 { |
| 82 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh
aseSelection); | 82 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh
aseSelection); |
| 83 ASSERT(m_svgInlineTextBox.truncation() == cNoTruncation); | 83 ASSERT(m_svgInlineTextBox.truncation() == cNoTruncation); |
| 84 | 84 |
| 85 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != VISIBLE) | 85 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != EVisibil
ity::Visible) |
| 86 return; | 86 return; |
| 87 | 87 |
| 88 // We're explicitly not supporting composition & custom underlines and custo
m highlighters -- unlike InlineTextBox. | 88 // We're explicitly not supporting composition & custom underlines and custo
m highlighters -- unlike InlineTextBox. |
| 89 // If we ever need that for SVG, it's very easy to refactor and reuse the co
de. | 89 // If we ever need that for SVG, it's very easy to refactor and reuse the co
de. |
| 90 | 90 |
| 91 bool haveSelection = shouldPaintSelection(paintInfo); | 91 bool haveSelection = shouldPaintSelection(paintInfo); |
| 92 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) | 92 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 LayoutSVGInlineText& textLayoutObject = inlineText(); | 95 LayoutSVGInlineText& textLayoutObject = inlineText(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 // 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. | 186 // 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. |
| 187 if (decorations & TextDecorationLineThrough) | 187 if (decorations & TextDecorationLineThrough) |
| 188 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); | 188 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf
o) | 192 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf
o) |
| 193 { | 193 { |
| 194 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != VISIBLE) | 194 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != EVisibil
ity::Visible) |
| 195 return; | 195 return; |
| 196 | 196 |
| 197 ASSERT(!paintInfo.isPrinting()); | 197 ASSERT(!paintInfo.isPrinting()); |
| 198 | 198 |
| 199 if (paintInfo.phase == PaintPhaseSelection || !shouldPaintSelection(paintInf
o)) | 199 if (paintInfo.phase == PaintPhaseSelection || !shouldPaintSelection(paintInf
o)) |
| 200 return; | 200 return; |
| 201 | 201 |
| 202 Color backgroundColor = m_svgInlineTextBox.getLineLayoutItem().selectionBack
groundColor(); | 202 Color backgroundColor = m_svgInlineTextBox.getLineLayoutItem().selectionBack
groundColor(); |
| 203 if (!backgroundColor.alpha()) | 203 if (!backgroundColor.alpha()) |
| 204 return; | 204 return; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if (m_svgInlineTextBox.getLineLayoutItem().style()->textDecorationsInEffect(
) == TextDecorationNone) | 269 if (m_svgInlineTextBox.getLineLayoutItem().style()->textDecorationsInEffect(
) == TextDecorationNone) |
| 270 return; | 270 return; |
| 271 | 271 |
| 272 if (fragment.width <= 0) | 272 if (fragment.width <= 0) |
| 273 return; | 273 return; |
| 274 | 274 |
| 275 // Find out which style defined the text-decoration, as its fill/stroke prop
erties have to be used for drawing instead of ours. | 275 // Find out which style defined the text-decoration, as its fill/stroke prop
erties have to be used for drawing instead of ours. |
| 276 LayoutObject* decorationLayoutObject = findLayoutObjectDefininingTextDecorat
ion(m_svgInlineTextBox.parent()); | 276 LayoutObject* decorationLayoutObject = findLayoutObjectDefininingTextDecorat
ion(m_svgInlineTextBox.parent()); |
| 277 const ComputedStyle& decorationStyle = decorationLayoutObject->styleRef(); | 277 const ComputedStyle& decorationStyle = decorationLayoutObject->styleRef(); |
| 278 | 278 |
| 279 if (decorationStyle.visibility() != VISIBLE) | 279 if (decorationStyle.visibility() != EVisibility::Visible) |
| 280 return; | 280 return; |
| 281 | 281 |
| 282 float scalingFactor = 1; | 282 float scalingFactor = 1; |
| 283 Font scaledFont; | 283 Font scaledFont; |
| 284 LayoutSVGInlineText::computeNewScaledFontForStyle(decorationLayoutObject, sc
alingFactor, scaledFont); | 284 LayoutSVGInlineText::computeNewScaledFontForStyle(decorationLayoutObject, sc
alingFactor, scaledFont); |
| 285 ASSERT(scalingFactor); | 285 ASSERT(scalingFactor); |
| 286 | 286 |
| 287 float thickness = thicknessForDecoration(decoration, scaledFont); | 287 float thickness = thicknessForDecoration(decoration, scaledFont); |
| 288 if (thickness <= 0) | 288 if (thickness <= 0) |
| 289 return; | 289 return; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 stateSaver.save(); | 533 stateSaver.save(); |
| 534 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); | 534 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); |
| 535 } | 535 } |
| 536 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment
(fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style); | 536 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment
(fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, style); |
| 537 paintInfo.context.setFillColor(color); | 537 paintInfo.context.setFillColor(color); |
| 538 paintInfo.context.fillRect(fragmentRect); | 538 paintInfo.context.fillRect(fragmentRect); |
| 539 } | 539 } |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace blink | 542 } // namespace blink |
| OLD | NEW |