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

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 again 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/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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at( i); 108 const SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at( i);
108 109
109 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); 110 GraphicsContextStateSaver stateSaver(*paintInfo.context, false);
110 fragment.buildFragmentTransform(fragmentTransform); 111 fragment.buildFragmentTransform(fragmentTransform);
111 if (!fragmentTransform.isIdentity()) { 112 if (!fragmentTransform.isIdentity()) {
112 stateSaver.save(); 113 stateSaver.save();
113 paintInfo.context->concatCTM(fragmentTransform); 114 paintInfo.context->concatCTM(fragmentTransform);
114 } 115 }
115 116
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. 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.
117 unsigned decorations = style.textDecorationsInEffect(); 118 const Vector<AppliedTextDecoration>& decorations = style.appliedTextDeco rations();
118 if (decorations & TextDecorationUnderline) 119 for (const auto& decoration : decorations) {
119 paintDecoration(paintInfo, TextDecorationUnderline, fragment); 120 if (decoration.lines() & TextDecorationUnderline)
120 if (decorations & TextDecorationOverline) 121 paintDecoration(paintInfo, TextDecorationUnderline, fragment);
121 paintDecoration(paintInfo, TextDecorationOverline, fragment); 122 if (decoration.lines() & TextDecorationOverline)
123 paintDecoration(paintInfo, TextDecorationOverline, fragment);
124 }
122 125
123 for (int i = 0; i < 3; i++) { 126 for (int i = 0; i < 3; i++) {
124 switch (svgStyle.paintOrderType(i)) { 127 switch (svgStyle.paintOrderType(i)) {
125 case PT_FILL: 128 case PT_FILL:
126 if (hasFill) 129 if (hasFill)
127 paintText(paintInfo, style, *selectionStyle, fragment, Apply ToFillMode, shouldPaintSelection); 130 paintText(paintInfo, style, *selectionStyle, fragment, Apply ToFillMode, shouldPaintSelection);
128 break; 131 break;
129 case PT_STROKE: 132 case PT_STROKE:
130 if (hasVisibleStroke) 133 if (hasVisibleStroke)
131 paintText(paintInfo, style, *selectionStyle, fragment, Apply ToStrokeMode, shouldPaintSelection); 134 paintText(paintInfo, style, *selectionStyle, fragment, Apply ToStrokeMode, shouldPaintSelection);
132 break; 135 break;
133 case PT_MARKERS: 136 case PT_MARKERS:
134 // Markers don't apply to text 137 // Markers don't apply to text
135 break; 138 break;
136 default: 139 default:
137 ASSERT_NOT_REACHED(); 140 ASSERT_NOT_REACHED();
138 break; 141 break;
139 } 142 }
140 } 143 }
141 144
142 // 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. 145 // 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.
143 if (decorations & TextDecorationLineThrough) 146 for (const auto& decoration : decorations) {
144 paintDecoration(paintInfo, TextDecorationLineThrough, fragment); 147 if (decoration.lines() & TextDecorationLineThrough)
148 paintDecoration(paintInfo, TextDecorationLineThrough, fragment);
149 }
145 } 150 }
146 } 151 }
147 152
148 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf o) 153 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf o)
149 { 154 {
150 if (m_svgInlineTextBox.lineLayoutItem().style()->visibility() != VISIBLE) 155 if (m_svgInlineTextBox.lineLayoutItem().style()->visibility() != VISIBLE)
151 return; 156 return;
152 157
153 ASSERT(!paintInfo.isPrinting()); 158 ASSERT(!paintInfo.isPrinting());
154 159
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 if (!fragmentTransform.isIdentity()) 448 if (!fragmentTransform.isIdentity())
444 context->concatCTM(fragmentTransform); 449 context->concatCTM(fragmentTransform);
445 context->setFillColor(color); 450 context->setFillColor(color);
446 context->fillRect(fragmentRect, color); 451 context->fillRect(fragmentRect, color);
447 } 452 }
448 } 453 }
449 } 454 }
450 } 455 }
451 456
452 } // namespace blink 457 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698