summaryrefslogtreecommitdiffstats
path: root/WebCore/svg/SVGFont.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/svg/SVGFont.cpp')
-rw-r--r--WebCore/svg/SVGFont.cpp59
1 files changed, 26 insertions, 33 deletions
diff --git a/WebCore/svg/SVGFont.cpp b/WebCore/svg/SVGFont.cpp
index b7ca5f2..898c259 100644
--- a/WebCore/svg/SVGFont.cpp
+++ b/WebCore/svg/SVGFont.cpp
@@ -1,5 +1,6 @@
-/**
+/*
* Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -15,7 +16,6 @@
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
- *
*/
#include "config.h"
@@ -26,6 +26,7 @@
#include "CSSFontSelector.h"
#include "GraphicsContext.h"
#include "RenderObject.h"
+#include "RenderSVGResourceSolidColor.h"
#include "SimpleFontData.h"
#include "SVGAltGlyphElement.h"
#include "SVGFontData.h"
@@ -34,8 +35,6 @@
#include "SVGFontElement.h"
#include "SVGFontFaceElement.h"
#include "SVGMissingGlyphElement.h"
-#include "SVGPaintServer.h"
-#include "SVGPaintServerSolid.h"
#include "XMLNames.h"
using namespace WTF::Unicode;
@@ -183,8 +182,8 @@ static inline bool isCompatibleGlyph(const SVGGlyphIdentifier& identifier, bool
// Split subcode from language, if existant.
String languagePrefix;
- int subCodeSeparator = language.find('-');
- if (subCodeSeparator != -1)
+ size_t subCodeSeparator = language.find('-');
+ if (subCodeSeparator != notFound)
languagePrefix = language.left(subCodeSeparator);
Vector<String>::const_iterator it = identifier.languages.begin();
@@ -413,7 +412,7 @@ static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun&
}
SVGTextRunWalker<SVGTextRunWalkerMeasuredLengthData> runWalker(fontData, fontElement, data, floatWidthUsingSVGFontCallback, floatWidthMissingGlyphCallback);
- runWalker.walk(run, isVerticalText, language, 0, run.length());
+ runWalker.walk(run, isVerticalText, language, from, to);
charsConsumed = data.charsConsumed;
glyphName = data.glyphName;
return data.length;
@@ -470,20 +469,20 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
FloatPoint currentPoint = point;
float scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f);
- SVGPaintServer* activePaintServer = run.activePaintServer();
+ RenderSVGResource* activePaintingResource = run.activePaintingResource();
// If renderObject is not set, we're dealing for HTML text rendered using SVG Fonts.
if (!run.referencingRenderObject()) {
- ASSERT(!activePaintServer);
+ ASSERT(!activePaintingResource);
// TODO: We're only supporting simple filled HTML text so far.
- SVGPaintServerSolid* solidPaintServer = SVGPaintServer::sharedSolidPaintServer();
- solidPaintServer->setColor(context->fillColor());
+ RenderSVGResourceSolidColor* solidPaintingResource = RenderSVGResource::sharedSolidPaintingResource();
+ solidPaintingResource->setColor(context->fillColor());
- activePaintServer = solidPaintServer;
+ activePaintingResource = solidPaintingResource;
}
- ASSERT(activePaintServer);
+ ASSERT(activePaintingResource);
int charsConsumed;
String glyphName;
@@ -512,7 +511,7 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
SVGTextRunWalker<SVGTextRunWalkerDrawTextData> runWalker(fontData, fontElement, data, drawTextUsingSVGFontCallback, drawTextMissingGlyphCallback);
runWalker.walk(run, isVerticalText, language, from, to);
- SVGPaintTargetType targetType = context->textDrawingMode() == cTextStroke ? ApplyToStrokeTargetType : ApplyToFillTargetType;
+ RenderSVGResourceMode resourceMode = context->textDrawingMode() == cTextStroke ? ApplyToStrokeMode : ApplyToFillMode;
unsigned numGlyphs = data.glyphIdentifiers.size();
unsigned fallbackCharacterIndex = 0;
@@ -528,25 +527,19 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
glyphOrigin.setY(identifier.verticalOriginY * scale);
}
- context->translate(xStartOffset + currentPoint.x() + glyphOrigin.x(), currentPoint.y() + glyphOrigin.y());
- context->scale(FloatSize(scale, -scale));
+ AffineTransform glyphPathTransform;
+ glyphPathTransform.translate(xStartOffset + currentPoint.x() + glyphOrigin.x(), currentPoint.y() + glyphOrigin.y());
+ glyphPathTransform.scale(scale, -scale);
+
+ Path glyphPath = identifier.pathData;
+ glyphPath.transform(glyphPathTransform);
context->beginPath();
- context->addPath(identifier.pathData);
-
- // FIXME: setup() tries to get objectBoundingBox() from run.referencingRenderObject()
- // which is wrong. We need to change setup() to take a bounding box instead, or pass
- // a RenderObject which would return the bounding box for identifier.pathData
- if (activePaintServer->setup(context, run.referencingRenderObject(), targetType)) {
- // Spec: Any properties specified on a text elements which represents a length, such as the
- // 'stroke-width' property, might produce surprising results since the length value will be
- // processed in the coordinate system of the glyph. (TODO: What other lengths? miter-limit? dash-offset?)
- if (targetType == ApplyToStrokeTargetType && scale != 0.0f)
- context->setStrokeThickness(context->strokeThickness() / scale);
-
- activePaintServer->renderPath(context, run.referencingRenderObject(), targetType);
- activePaintServer->teardown(context, run.referencingRenderObject(), targetType);
- }
+ context->addPath(glyphPath);
+
+ RenderStyle* style = run.referencingRenderObject() ? run.referencingRenderObject()->style() : 0;
+ if (activePaintingResource->applyResource(run.referencingRenderObject(), style, context, resourceMode))
+ activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode);
context->restore();
}
@@ -577,7 +570,7 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
}
}
-FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const IntPoint& point, int height, int from, int to) const
+FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const FloatPoint& point, int height, int from, int to) const
{
int charsConsumed;
String glyphName;
@@ -586,7 +579,7 @@ FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const IntPo
point.y(), floatWidthOfSubStringUsingSVGFont(this, run, 0, from, to, charsConsumed, glyphName), height);
}
-int Font::offsetForPositionForTextUsingSVGFont(const TextRun&, int, bool) const
+int Font::offsetForPositionForTextUsingSVGFont(const TextRun&, float, bool) const
{
// TODO: Fix text selection when HTML text is drawn using a SVG Font
// We need to integrate the SVG text selection code in the offsetForPosition() framework.