summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp')
-rw-r--r--Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp40
1 files changed, 16 insertions, 24 deletions
diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp b/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
index 0497a3456..e0377167f 100644
--- a/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
+++ b/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
@@ -18,11 +18,9 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGTextLayoutEngineBaseline.h"
-#include "Font.h"
+#include "FontCascade.h"
#include "RenderElement.h"
#include "SVGLengthContext.h"
#include "SVGRenderStyle.h"
@@ -30,33 +28,34 @@
namespace WebCore {
-SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font)
+SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const FontCascade& font)
: m_font(font)
{
}
-float SVGTextLayoutEngineBaseline::calculateBaselineShift(const SVGRenderStyle* style, SVGElement* contextElement) const
+float SVGTextLayoutEngineBaseline::calculateBaselineShift(const SVGRenderStyle& style, SVGElement* context) const
{
- if (style->baselineShift() == BS_LENGTH) {
- SVGLength baselineShiftValueLength = style->baselineShiftValue();
+ if (style.baselineShift() == BS_LENGTH) {
+ auto baselineShiftValueLength = style.baselineShiftValue();
if (baselineShiftValueLength.unitType() == LengthTypePercentage)
return baselineShiftValueLength.valueAsPercentage() * m_font.pixelSize();
- SVGLengthContext lengthContext(contextElement);
+ SVGLengthContext lengthContext(context);
return baselineShiftValueLength.value(lengthContext);
}
- switch (style->baselineShift()) {
+ switch (style.baselineShift()) {
case BS_BASELINE:
return 0;
case BS_SUB:
return -m_font.fontMetrics().floatHeight() / 2;
case BS_SUPER:
return m_font.fontMetrics().floatHeight() / 2;
- default:
- ASSERT_NOT_REACHED();
- return 0;
+ case BS_LENGTH:
+ break;
}
+ ASSERT_NOT_REACHED();
+ return 0;
}
EAlignmentBaseline SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBaseline(bool isVerticalText, const RenderObject* textRenderer) const
@@ -104,15 +103,12 @@ EAlignmentBaseline SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBasel
}
}
-float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(bool isVerticalText, const RenderObject* textRenderer) const
+float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(bool isVerticalText, const RenderObject& textRenderer) const
{
- ASSERT(textRenderer);
- ASSERT(textRenderer->parent());
-
- const RenderObject* textRendererParent = textRenderer->parent();
+ const RenderObject* textRendererParent = textRenderer.parent();
ASSERT(textRendererParent);
- EAlignmentBaseline baseline = textRenderer->style().svgStyle().alignmentBaseline();
+ EAlignmentBaseline baseline = textRenderer.style().svgStyle().alignmentBaseline();
if (baseline == AB_AUTO) {
baseline = dominantBaselineToAlignmentBaseline(isVerticalText, textRendererParent);
ASSERT(baseline != AB_AUTO);
@@ -147,11 +143,9 @@ float SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift(bool isVertic
}
}
-float SVGTextLayoutEngineBaseline::calculateGlyphOrientationAngle(bool isVerticalText, const SVGRenderStyle* style, const UChar& character) const
+float SVGTextLayoutEngineBaseline::calculateGlyphOrientationAngle(bool isVerticalText, const SVGRenderStyle& style, const UChar& character) const
{
- ASSERT(style);
-
- switch (isVerticalText ? style->glyphOrientationVertical() : style->glyphOrientationHorizontal()) {
+ switch (isVerticalText ? style.glyphOrientationVertical() : style.glyphOrientationHorizontal()) {
case GO_AUTO:
// Spec: Fullwidth ideographic and fullwidth Latin text will be set with a glyph-orientation of 0-degrees.
// Text which is not fullwidth will be set with a glyph-orientation of 90-degrees.
@@ -240,5 +234,3 @@ float SVGTextLayoutEngineBaseline::calculateGlyphAdvanceAndOrientation(bool isVe
}
}
-
-#endif // ENABLE(SVG)