| 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" |
| 11 #include "core/layout/LayoutTheme.h" | 11 #include "core/layout/LayoutTheme.h" |
| 12 #include "core/layout/api/LineLayoutAPIShim.h" | 12 #include "core/layout/api/LineLayoutAPIShim.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/PaintInfo.h" | 21 #include "core/paint/PaintInfo.h" |
| 22 #include "core/paint/SVGPaintContext.h" | 22 #include "core/paint/SVGPaintContext.h" |
| 23 #include "core/style/AppliedTextDecoration.h" |
| 23 #include "core/style/ShadowList.h" | 24 #include "core/style/ShadowList.h" |
| 24 #include "platform/graphics/GraphicsContextStateSaver.h" | 25 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 25 #include <memory> | 26 #include <memory> |
| 26 | 27 |
| 27 namespace blink { | 28 namespace blink { |
| 28 | 29 |
| 29 static inline bool textShouldBePainted( | 30 static inline bool textShouldBePainted( |
| 30 const LayoutSVGInlineText& textLayoutObject) { | 31 const LayoutSVGInlineText& textLayoutObject) { |
| 31 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which | 32 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which |
| 32 // returns "int(x + 0.5)". If the absolute font size on screen is below | 33 // returns "int(x + 0.5)". If the absolute font size on screen is below |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 169 |
| 169 GraphicsContextStateSaver stateSaver(paintInfo.context, false); | 170 GraphicsContextStateSaver stateSaver(paintInfo.context, false); |
| 170 if (fragment.isTransformed()) { | 171 if (fragment.isTransformed()) { |
| 171 stateSaver.save(); | 172 stateSaver.save(); |
| 172 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); | 173 paintInfo.context.concatCTM(fragment.buildFragmentTransform()); |
| 173 } | 174 } |
| 174 | 175 |
| 175 // Spec: All text decorations except line-through should be drawn before the | 176 // Spec: All text decorations except line-through should be drawn before the |
| 176 // text is filled and stroked; thus, the text is rendered on top of these | 177 // text is filled and stroked; thus, the text is rendered on top of these |
| 177 // decorations. | 178 // decorations. |
| 178 unsigned decorations = style.textDecorationsInEffect(); | 179 const Vector<AppliedTextDecoration>& decorations = |
| 179 if (decorations & TextDecorationUnderline) | 180 style.appliedTextDecorations(); |
| 180 paintDecoration(paintInfo, TextDecorationUnderline, fragment); | 181 for (const AppliedTextDecoration& decoration : decorations) { |
| 181 if (decorations & TextDecorationOverline) | 182 if (decoration.lines() & TextDecorationUnderline) |
| 182 paintDecoration(paintInfo, TextDecorationOverline, fragment); | 183 paintDecoration(paintInfo, TextDecorationUnderline, fragment); |
| 184 if (decoration.lines() & TextDecorationOverline) |
| 185 paintDecoration(paintInfo, TextDecorationOverline, fragment); |
| 186 } |
| 183 | 187 |
| 184 for (int i = 0; i < 3; i++) { | 188 for (int i = 0; i < 3; i++) { |
| 185 switch (svgStyle.paintOrderType(i)) { | 189 switch (svgStyle.paintOrderType(i)) { |
| 186 case PT_FILL: | 190 case PT_FILL: |
| 187 if (hasFill) | 191 if (hasFill) |
| 188 paintText(paintInfo, style, *selectionStyle, fragment, | 192 paintText(paintInfo, style, *selectionStyle, fragment, |
| 189 ApplyToFillMode, shouldPaintSelection); | 193 ApplyToFillMode, shouldPaintSelection); |
| 190 break; | 194 break; |
| 191 case PT_STROKE: | 195 case PT_STROKE: |
| 192 if (hasVisibleStroke) | 196 if (hasVisibleStroke) |
| 193 paintText(paintInfo, style, *selectionStyle, fragment, | 197 paintText(paintInfo, style, *selectionStyle, fragment, |
| 194 ApplyToStrokeMode, shouldPaintSelection); | 198 ApplyToStrokeMode, shouldPaintSelection); |
| 195 break; | 199 break; |
| 196 case PT_MARKERS: | 200 case PT_MARKERS: |
| 197 // Markers don't apply to text | 201 // Markers don't apply to text |
| 198 break; | 202 break; |
| 199 default: | 203 default: |
| 200 ASSERT_NOT_REACHED(); | 204 ASSERT_NOT_REACHED(); |
| 201 break; | 205 break; |
| 202 } | 206 } |
| 203 } | 207 } |
| 204 | 208 |
| 205 // Spec: Line-through should be drawn after the text is filled and stroked; | 209 // Spec: Line-through should be drawn after the text is filled and stroked; |
| 206 // thus, the line-through is rendered on top of the text. | 210 // thus, the line-through is rendered on top of the text. |
| 207 if (decorations & TextDecorationLineThrough) | 211 for (const AppliedTextDecoration& decoration : decorations) { |
| 208 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); | 212 if (decoration.lines() & TextDecorationLineThrough) |
| 213 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); |
| 214 } |
| 209 } | 215 } |
| 210 } | 216 } |
| 211 | 217 |
| 212 void SVGInlineTextBoxPainter::paintSelectionBackground( | 218 void SVGInlineTextBoxPainter::paintSelectionBackground( |
| 213 const PaintInfo& paintInfo) { | 219 const PaintInfo& paintInfo) { |
| 214 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != | 220 if (m_svgInlineTextBox.getLineLayoutItem().style()->visibility() != |
| 215 EVisibility::Visible) | 221 EVisibility::Visible) |
| 216 return; | 222 return; |
| 217 | 223 |
| 218 DCHECK(!paintInfo.isPrinting()); | 224 DCHECK(!paintInfo.isPrinting()); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 } | 640 } |
| 635 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( | 641 FloatRect fragmentRect = m_svgInlineTextBox.selectionRectForTextFragment( |
| 636 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, | 642 fragment, textMatchInfo.startPosition, textMatchInfo.endPosition, |
| 637 style); | 643 style); |
| 638 paintInfo.context.setFillColor(color); | 644 paintInfo.context.setFillColor(color); |
| 639 paintInfo.context.fillRect(fragmentRect); | 645 paintInfo.context.fillRect(fragmentRect); |
| 640 } | 646 } |
| 641 } | 647 } |
| 642 | 648 |
| 643 } // namespace blink | 649 } // namespace blink |
| OLD | NEW |