diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/rendering/svg/SVGInlineTextBox.cpp | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/rendering/svg/SVGInlineTextBox.cpp')
-rw-r--r-- | Source/WebCore/rendering/svg/SVGInlineTextBox.cpp | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp index 52976f2..05e1357 100644 --- a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp +++ b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp @@ -47,7 +47,7 @@ SVGInlineTextBox::SVGInlineTextBox(RenderObject* object) { } -int SVGInlineTextBox::offsetForPosition(int, bool) const +int SVGInlineTextBox::offsetForPosition(float, bool) const { // SVG doesn't use the standard offset <-> position selection system, as it's not suitable for SVGs complex needs. // vertical text selection, inline boxes spanning multiple lines (contrary to HTML, etc.) @@ -76,7 +76,7 @@ int SVGInlineTextBox::offsetForPositionInFragment(const SVGTextFragment& fragmen return fragment.positionListOffset - start() + textRenderer->scaledFont().offsetForPosition(textRun, position * scalingFactor, includePartialGlyphs); } -int SVGInlineTextBox::positionForOffset(int) const +float SVGInlineTextBox::positionForOffset(int) const { // SVG doesn't use the offset <-> position selection system. ASSERT_NOT_REACHED(); @@ -415,9 +415,6 @@ TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag run.setReferencingRenderObject(text); #endif - // Disable any word/character rounding. - run.disableRoundingHacks(); - // We handle letter & word spacing ourselves. run.disableSpacing(); return run; @@ -519,6 +516,29 @@ void SVGInlineTextBox::paintDecoration(GraphicsContext* context, ETextDecoration } } +static inline void normalizeTransform(AffineTransform& transform) +{ + // Obtain consistent numerical results for the AffineTransform on both 32/64bit platforms. + // Tested with SnowLeopard on Core Duo vs. Core 2 Duo. + static const float s_floatEpsilon = std::numeric_limits<float>::epsilon(); + + if (fabs(transform.a() - 1) <= s_floatEpsilon) + transform.setA(1); + else if (fabs(transform.a() + 1) <= s_floatEpsilon) + transform.setA(-1); + + if (fabs(transform.d() - 1) <= s_floatEpsilon) + transform.setD(1); + else if (fabs(transform.d() + 1) <= s_floatEpsilon) + transform.setD(-1); + + if (fabs(transform.e()) <= s_floatEpsilon) + transform.setE(0); + + if (fabs(transform.f()) <= s_floatEpsilon) + transform.setF(0); +} + void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, ETextDecoration decoration, const SVGTextFragment& fragment, RenderObject* decorationRenderer) { ASSERT(!m_paintingResource); @@ -546,7 +566,12 @@ void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, ETextD if (scalingFactor != 1) { width *= scalingFactor; decorationOrigin.scale(scalingFactor, scalingFactor); - context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor)); + + AffineTransform newTransform = context->getCTM(); + newTransform.scale(1 / scalingFactor); + normalizeTransform(newTransform); + + context->setCTM(newTransform); } decorationOrigin.move(0, -scaledFontMetrics.floatAscent() + positionOffsetForDecoration(decoration, scaledFontMetrics, thickness)); @@ -589,13 +614,21 @@ void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyl if (shadow) extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */); - if (scalingFactor != 1) - context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor)); + AffineTransform originalTransform; + if (scalingFactor != 1) { + originalTransform = context->getCTM(); + + AffineTransform newTransform = originalTransform; + newTransform.scale(1 / scalingFactor); + normalizeTransform(newTransform); + + context->setCTM(newTransform); + } scaledFont.drawText(context, textRun, textOrigin + extraOffset, startPosition, endPosition); if (scalingFactor != 1) - context->scale(FloatSize(scalingFactor, scalingFactor)); + context->setCTM(originalTransform); restoreGraphicsContextAfterTextPainting(context, textRun); |