Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp

Issue 1328283005: Add support for multiple text decorations with same line positioning (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 26
26 namespace blink { 27 namespace blink {
27 28
28 static inline bool textShouldBePainted(LayoutSVGInlineText& textLayoutObject) 29 static inline bool textShouldBePainted(LayoutSVGInlineText& textLayoutObject)
29 { 30 {
30 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re turns "int(x + 0.5)". 31 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re turns "int(x + 0.5)".
31 // If the absolute font size on screen is below x=0.5, don't render anything . 32 // If the absolute font size on screen is below x=0.5, don't render anything .
32 return textLayoutObject.scaledFont().fontDescription().computedPixelSize(); 33 return textLayoutObject.scaledFont().fontDescription().computedPixelSize();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at(i); 107 SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at(i);
107 108
108 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); 109 GraphicsContextStateSaver stateSaver(*paintInfo.context, false);
109 fragment.buildFragmentTransform(fragmentTransform); 110 fragment.buildFragmentTransform(fragmentTransform);
110 if (!fragmentTransform.isIdentity()) { 111 if (!fragmentTransform.isIdentity()) {
111 stateSaver.save(); 112 stateSaver.save();
112 paintInfo.context->concatCTM(fragmentTransform); 113 paintInfo.context->concatCTM(fragmentTransform);
113 } 114 }
114 115
115 // 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. 116 // 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.
116 unsigned decorations = style.textDecorationsInEffect(); 117 const Vector<AppliedTextDecoration>& decorations = style.appliedTextDeco rations();
117 if (decorations & TextDecorationUnderline) 118 for (const auto& decoration : decorations) {
118 paintDecoration(paintInfo, TextDecorationUnderline, fragment); 119 if (decoration.lines() & TextDecorationUnderline)
119 if (decorations & TextDecorationOverline) 120 paintDecoration(paintInfo, TextDecorationUnderline, fragment);
120 paintDecoration(paintInfo, TextDecorationOverline, fragment); 121 if (decoration.lines() & TextDecorationOverline)
122 paintDecoration(paintInfo, TextDecorationOverline, fragment);
123 }
121 124
122 for (int i = 0; i < 3; i++) { 125 for (int i = 0; i < 3; i++) {
123 switch (svgStyle.paintOrderType(i)) { 126 switch (svgStyle.paintOrderType(i)) {
124 case PT_FILL: 127 case PT_FILL:
125 if (hasFill) 128 if (hasFill)
126 paintText(paintInfo, style, *selectionStyle, fragment, Apply ToFillMode, shouldPaintSelection); 129 paintText(paintInfo, style, *selectionStyle, fragment, Apply ToFillMode, shouldPaintSelection);
127 break; 130 break;
128 case PT_STROKE: 131 case PT_STROKE:
129 if (hasVisibleStroke) 132 if (hasVisibleStroke)
130 paintText(paintInfo, style, *selectionStyle, fragment, Apply ToStrokeMode, shouldPaintSelection); 133 paintText(paintInfo, style, *selectionStyle, fragment, Apply ToStrokeMode, shouldPaintSelection);
131 break; 134 break;
132 case PT_MARKERS: 135 case PT_MARKERS:
133 // Markers don't apply to text 136 // Markers don't apply to text
134 break; 137 break;
135 default: 138 default:
136 ASSERT_NOT_REACHED(); 139 ASSERT_NOT_REACHED();
137 break; 140 break;
138 } 141 }
139 } 142 }
140 143
141 // 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 // 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.
142 if (decorations & TextDecorationLineThrough) 145 for (const auto& decoration : decorations) {
143 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); 146 if (decoration.lines() & TextDecorationLineThrough)
147 paintDecoration(paintInfo, TextDecorationLineThrough, fragment);
148 }
144 } 149 }
145 } 150 }
146 151
147 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf o) 152 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf o)
148 { 153 {
149 if (m_svgInlineTextBox.lineLayoutItem().style()->visibility() != VISIBLE) 154 if (m_svgInlineTextBox.lineLayoutItem().style()->visibility() != VISIBLE)
150 return; 155 return;
151 156
152 ASSERT(!paintInfo.isPrinting()); 157 ASSERT(!paintInfo.isPrinting());
153 158
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 if (!fragmentTransform.isIdentity()) 447 if (!fragmentTransform.isIdentity())
443 context->concatCTM(fragmentTransform); 448 context->concatCTM(fragmentTransform);
444 context->setFillColor(color); 449 context->setFillColor(color);
445 context->fillRect(fragmentRect, color); 450 context->fillRect(fragmentRect, color);
446 } 451 }
447 } 452 }
448 } 453 }
449 } 454 }
450 455
451 } // namespace blink 456 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698