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

Unified Diff: Source/core/paint/SVGInlineTextBoxPainter.cpp

Issue 654873002: Fold away SVGInlineTextBoxPainter::paintDecorationWithStyle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/paint/SVGInlineTextBoxPainter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/SVGInlineTextBoxPainter.cpp
diff --git a/Source/core/paint/SVGInlineTextBoxPainter.cpp b/Source/core/paint/SVGInlineTextBoxPainter.cpp
index 3c108b61d46d08150a1628b7ec373bf1d17fac26..da2841d3565ff09c7ddcfeeeb6f7bb5eac261e54 100644
--- a/Source/core/paint/SVGInlineTextBoxPainter.cpp
+++ b/Source/core/paint/SVGInlineTextBoxPainter.cpp
@@ -204,38 +204,6 @@ static inline RenderObject* findRenderObjectDefininingTextDecoration(InlineFlowB
return renderer;
}
-void SVGInlineTextBoxPainter::paintDecoration(GraphicsContext* context, TextDecoration decoration, const SVGTextFragment& fragment)
-{
- if (m_svgInlineTextBox.renderer().style()->textDecorationsInEffect() == TextDecorationNone)
- return;
-
- // Find out which render style defined the text-decoration, as its fill/stroke properties have to be used for drawing instead of ours.
- RenderObject* decorationRenderer = findRenderObjectDefininingTextDecoration(m_svgInlineTextBox.parent());
- RenderStyle* decorationStyle = decorationRenderer->style();
- ASSERT(decorationStyle);
-
- if (decorationStyle->visibility() == HIDDEN)
- return;
-
- const SVGRenderStyle& svgDecorationStyle = decorationStyle->svgStyle();
-
- for (int i = 0; i < 3; i++) {
- switch (svgDecorationStyle.paintOrderType(i)) {
- case PT_FILL:
- if (svgDecorationStyle.hasFill())
- paintDecorationWithStyle(context, decoration, fragment, decorationRenderer, ApplyToFillMode);
- break;
- case PT_STROKE:
- if (svgDecorationStyle.hasVisibleStroke())
- paintDecorationWithStyle(context, decoration, fragment, decorationRenderer, ApplyToStrokeMode);
- break;
- case PT_MARKERS:
- break;
- default:
- ASSERT_NOT_REACHED();
- }
- }
-}
// Offset from the baseline for |decoration|. Positive offsets are above the baseline.
static inline float baselineOffsetForDecoration(TextDecoration decoration, const FontMetrics& fontMetrics, float thickness)
@@ -260,20 +228,29 @@ static inline float thicknessForDecoration(TextDecoration, const Font& font)
return font.fontDescription().computedSize() / 20.0f;
}
-void SVGInlineTextBoxPainter::paintDecorationWithStyle(GraphicsContext* context, TextDecoration decoration,
- const SVGTextFragment& fragment, RenderObject* decorationRenderer, RenderSVGResourceMode resourceMode)
+void SVGInlineTextBoxPainter::paintDecoration(GraphicsContext* context, TextDecoration decoration, const SVGTextFragment& fragment)
{
+ if (m_svgInlineTextBox.renderer().style()->textDecorationsInEffect() == TextDecorationNone)
+ return;
+
+ if (fragment.width <= 0)
+ return;
+
+ // Find out which render style defined the text-decoration, as its fill/stroke properties have to be used for drawing instead of ours.
+ RenderObject* decorationRenderer = findRenderObjectDefininingTextDecoration(m_svgInlineTextBox.parent());
RenderStyle* decorationStyle = decorationRenderer->style();
ASSERT(decorationStyle);
+ if (decorationStyle->visibility() == HIDDEN)
+ return;
+
float scalingFactor = 1;
Font scaledFont;
RenderSVGInlineText::computeNewScaledFontForStyle(decorationRenderer, decorationStyle, scalingFactor, scaledFont);
ASSERT(scalingFactor);
float thickness = thicknessForDecoration(decoration, scaledFont);
-
- if (fragment.width <= 0 && thickness <= 0)
+ if (thickness <= 0)
return;
float decorationOffset = baselineOffsetForDecoration(decoration, scaledFont.fontMetrics(), thickness);
@@ -282,10 +259,32 @@ void SVGInlineTextBoxPainter::paintDecorationWithStyle(GraphicsContext* context,
Path path;
path.addRect(FloatRect(decorationOrigin, FloatSize(fragment.width, thickness / scalingFactor)));
- GraphicsContextStateSaver stateSaver(*context, false);
- if (!SVGRenderSupport::updateGraphicsContext(stateSaver, decorationStyle, *decorationRenderer, resourceMode))
- return;
- SVGRenderSupport::fillOrStrokePath(context, resourceMode, path);
+ const SVGRenderStyle& svgDecorationStyle = decorationStyle->svgStyle();
+
+ for (int i = 0; i < 3; i++) {
+ switch (svgDecorationStyle.paintOrderType(i)) {
+ case PT_FILL:
+ if (svgDecorationStyle.hasFill()) {
+ GraphicsContextStateSaver stateSaver(*context, false);
+ if (!SVGRenderSupport::updateGraphicsContext(stateSaver, decorationStyle, *decorationRenderer, ApplyToFillMode))
+ break;
+ context->fillPath(path);
+ }
+ break;
+ case PT_STROKE:
+ if (svgDecorationStyle.hasVisibleStroke()) {
+ GraphicsContextStateSaver stateSaver(*context, false);
+ if (!SVGRenderSupport::updateGraphicsContext(stateSaver, decorationStyle, *decorationRenderer, ApplyToStrokeMode))
+ break;
+ context->strokePath(path);
+ }
+ break;
+ case PT_MARKERS:
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
}
void SVGInlineTextBoxPainter::paintTextWithShadows(GraphicsContext* context, RenderStyle* style,
« no previous file with comments | « Source/core/paint/SVGInlineTextBoxPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698