| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/SVGInlineTextBoxPainter.h" | 6 #include "core/paint/SVGInlineTextBoxPainter.h" |
| 7 | 7 |
| 8 #include "core/editing/Editor.h" | 8 #include "core/editing/Editor.h" |
| 9 #include "core/editing/markers/DocumentMarkerController.h" | 9 #include "core/editing/markers/DocumentMarkerController.h" |
| 10 #include "core/editing/markers/RenderedDocumentMarker.h" | 10 #include "core/editing/markers/RenderedDocumentMarker.h" |
| 11 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
| 12 #include "core/layout/LayoutTheme.h" | 12 #include "core/layout/LayoutTheme.h" |
| 13 #include "core/layout/api/SelectionState.h" | 13 #include "core/layout/api/SelectionState.h" |
| 14 #include "core/layout/line/InlineFlowBox.h" | 14 #include "core/layout/line/InlineFlowBox.h" |
| 15 #include "core/layout/svg/LayoutSVGInlineText.h" | 15 #include "core/layout/svg/LayoutSVGInlineText.h" |
| 16 #include "core/layout/svg/SVGLayoutSupport.h" | 16 #include "core/layout/svg/SVGLayoutSupport.h" |
| 17 #include "core/layout/svg/SVGResourcesCache.h" | 17 #include "core/layout/svg/SVGResourcesCache.h" |
| 18 #include "core/layout/svg/line/SVGInlineTextBox.h" | 18 #include "core/layout/svg/line/SVGInlineTextBox.h" |
| 19 #include "core/paint/InlineTextBoxPainter.h" | 19 #include "core/paint/InlineTextBoxPainter.h" |
| 20 #include "core/paint/LayoutObjectDrawingRecorder.h" | 20 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 21 #include "core/paint/LineLayoutPaintShim.h" | 21 #include "core/paint/LineLayoutPaintShim.h" |
| 22 #include "core/paint/PaintInfo.h" | 22 #include "core/paint/PaintInfo.h" |
| 23 #include "core/paint/SVGPaintContext.h" | 23 #include "core/paint/SVGPaintContext.h" |
| 24 #include "core/style/AppliedTextDecoration.h" |
| 24 #include "core/style/ShadowList.h" | 25 #include "core/style/ShadowList.h" |
| 25 #include "platform/graphics/GraphicsContextStateSaver.h" | 26 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 26 | 27 |
| 27 namespace blink { | 28 namespace blink { |
| 28 | 29 |
| 29 static inline bool textShouldBePainted(const LayoutSVGInlineText& textLayoutObje
ct) | 30 static inline bool textShouldBePainted(const LayoutSVGInlineText& textLayoutObje
ct) |
| 30 { | 31 { |
| 31 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re
turns "int(x + 0.5)". | 32 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re
turns "int(x + 0.5)". |
| 32 // If the absolute font size on screen is below x=0.5, don't render anything
. | 33 // If the absolute font size on screen is below x=0.5, don't render anything
. |
| 33 return textLayoutObject.scaledFont().fontDescription().computedPixelSize(); | 34 return textLayoutObject.scaledFont().fontDescription().computedPixelSize(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 const SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at(
i); | 109 const SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at(
i); |
| 109 | 110 |
| 110 GraphicsContextStateSaver stateSaver(paintInfo.context, false); | 111 GraphicsContextStateSaver stateSaver(paintInfo.context, false); |
| 111 fragment.buildFragmentTransform(fragmentTransform); | 112 fragment.buildFragmentTransform(fragmentTransform); |
| 112 if (!fragmentTransform.isIdentity()) { | 113 if (!fragmentTransform.isIdentity()) { |
| 113 stateSaver.save(); | 114 stateSaver.save(); |
| 114 paintInfo.context.concatCTM(fragmentTransform); | 115 paintInfo.context.concatCTM(fragmentTransform); |
| 115 } | 116 } |
| 116 | 117 |
| 117 // 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. |
| 118 unsigned decorations = style.textDecorationsInEffect(); | 119 const Vector<AppliedTextDecoration>& decorations = style.appliedTextDeco
rations(); |
| 119 if (decorations & TextDecorationUnderline) | 120 for (const AppliedTextDecoration& decoration : decorations) { |
| 120 paintDecoration(paintInfo, TextDecorationUnderline, fragment); | 121 if (decoration.lines() & TextDecorationUnderline) |
| 121 if (decorations & TextDecorationOverline) | 122 paintDecoration(paintInfo, TextDecorationUnderline, fragment); |
| 122 paintDecoration(paintInfo, TextDecorationOverline, fragment); | 123 if (decoration.lines() & TextDecorationOverline) |
| 124 paintDecoration(paintInfo, TextDecorationOverline, fragment); |
| 125 } |
| 123 | 126 |
| 124 for (int i = 0; i < 3; i++) { | 127 for (int i = 0; i < 3; i++) { |
| 125 switch (svgStyle.paintOrderType(i)) { | 128 switch (svgStyle.paintOrderType(i)) { |
| 126 case PT_FILL: | 129 case PT_FILL: |
| 127 if (hasFill) | 130 if (hasFill) |
| 128 paintText(paintInfo, style, *selectionStyle, fragment, Apply
ToFillMode, shouldPaintSelection); | 131 paintText(paintInfo, style, *selectionStyle, fragment, Apply
ToFillMode, shouldPaintSelection); |
| 129 break; | 132 break; |
| 130 case PT_STROKE: | 133 case PT_STROKE: |
| 131 if (hasVisibleStroke) | 134 if (hasVisibleStroke) |
| 132 paintText(paintInfo, style, *selectionStyle, fragment, Apply
ToStrokeMode, shouldPaintSelection); | 135 paintText(paintInfo, style, *selectionStyle, fragment, Apply
ToStrokeMode, shouldPaintSelection); |
| 133 break; | 136 break; |
| 134 case PT_MARKERS: | 137 case PT_MARKERS: |
| 135 // Markers don't apply to text | 138 // Markers don't apply to text |
| 136 break; | 139 break; |
| 137 default: | 140 default: |
| 138 ASSERT_NOT_REACHED(); | 141 ASSERT_NOT_REACHED(); |
| 139 break; | 142 break; |
| 140 } | 143 } |
| 141 } | 144 } |
| 142 | 145 |
| 143 // 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. | 146 // 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. |
| 144 if (decorations & TextDecorationLineThrough) | 147 for (const AppliedTextDecoration& decoration : decorations) { |
| 145 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); | 148 if (decoration.lines() & TextDecorationLineThrough) |
| 149 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); |
| 150 } |
| 146 } | 151 } |
| 147 } | 152 } |
| 148 | 153 |
| 149 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf
o) | 154 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf
o) |
| 150 { | 155 { |
| 151 if (m_svgInlineTextBox.lineLayoutItem().style()->visibility() != VISIBLE) | 156 if (m_svgInlineTextBox.lineLayoutItem().style()->visibility() != VISIBLE) |
| 152 return; | 157 return; |
| 153 | 158 |
| 154 ASSERT(!paintInfo.isPrinting()); | 159 ASSERT(!paintInfo.isPrinting()); |
| 155 | 160 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 if (!fragmentTransform.isIdentity()) | 449 if (!fragmentTransform.isIdentity()) |
| 445 context.concatCTM(fragmentTransform); | 450 context.concatCTM(fragmentTransform); |
| 446 context.setFillColor(color); | 451 context.setFillColor(color); |
| 447 context.fillRect(fragmentRect, color); | 452 context.fillRect(fragmentRect, color); |
| 448 } | 453 } |
| 449 } | 454 } |
| 450 } | 455 } |
| 451 } | 456 } |
| 452 | 457 |
| 453 } // namespace blink | 458 } // namespace blink |
| OLD | NEW |