Diff
Modified: trunk/Source/WebCore/ChangeLog (183218 => 183219)
--- trunk/Source/WebCore/ChangeLog 2015-04-23 22:30:07 UTC (rev 183218)
+++ trunk/Source/WebCore/ChangeLog 2015-04-23 22:34:10 UTC (rev 183219)
@@ -1,3 +1,33 @@
+2015-04-23 Daniel Bates <[email protected]>
+
+ Clean up: Use references instead of pointers in more SVG files
+ https://bugs.webkit.org/show_bug.cgi?id=144045
+
+ Reviewed by Darin Adler.
+
+ * rendering/svg/SVGRootInlineBox.cpp:
+ (WebCore::SVGRootInlineBox::layoutCharactersInTextBoxes): Pass reference instead of pointer.
+
+ * rendering/svg/SVGTextLayoutEngine.cpp:
+ (WebCore::SVGTextLayoutEngine::recordTextFragment): Changed parameter textBox from pointer to reference.
+ (WebCore::SVGTextLayoutEngine::layoutInlineTextBox): Ditto.
+ (WebCore::SVGTextLayoutEngine::currentVisualCharacterMetrics): Changed parameter textBox from pointer to
+ reference and made it const since this function does not modify textBox.
+ (WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath): Changed parameters from pointers to references.
+ Also, removed comma from comment so that it reads well.
+ * rendering/svg/SVGTextLayoutEngine.h: Updated declarations for the above functions.
+
+ * rendering/svg/SVGTextLayoutEngineBaseline.cpp:
+ (WebCore::SVGTextLayoutEngineBaseline::calculateBaselineShift): Changed parameter style from pointer to reference.
+ Added case BS_LENGTH to switch block and removed default case so that the compiler checks that we handle all cases.
+ Renamed parameter contextElement to context since the name of its data type conveys that it is an element.
+ (WebCore::SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift): Changed parameter textRenderer from
+ pointer to reference and removed runtime assertion that textRenderer is non-null (since it well-formed reference
+ cannot point to a non-existent object).
+ (WebCore::SVGTextLayoutEngineBaseline::calculateGlyphOrientationAngle): Changed parameter style from pointer to reference
+ removed runtime assertion that style is non-null.
+ * rendering/svg/SVGTextLayoutEngineBaseline.h: Updated declarations for the above functions.
+
2015-04-23 Commit Queue <[email protected]>
Unreviewed, rolling out r183194.
Modified: trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp (183218 => 183219)
--- trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp 2015-04-23 22:30:07 UTC (rev 183218)
+++ trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp 2015-04-23 22:34:10 UTC (rev 183219)
@@ -105,7 +105,7 @@
for (InlineBox* child = start->firstChild(); child; child = child->nextOnLine()) {
if (is<SVGInlineTextBox>(*child)) {
ASSERT(is<RenderSVGInlineText>(child->renderer()));
- characterLayout.layoutInlineTextBox(downcast<SVGInlineTextBox>(child));
+ characterLayout.layoutInlineTextBox(downcast<SVGInlineTextBox>(*child));
} else {
// Skip generated content.
Node* node = child->renderer().node();
Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp (183218 => 183219)
--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp 2015-04-23 22:30:07 UTC (rev 183218)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp 2015-04-23 22:34:10 UTC (rev 183219)
@@ -110,7 +110,7 @@
m_dy = dy;
}
-void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox, Vector<SVGTextMetrics>& textMetricsValues)
+void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox& textBox, Vector<SVGTextMetrics>& textMetricsValues)
{
ASSERT(!m_currentTextFragment.length);
ASSERT(m_visualMetricsListOffset > 0);
@@ -137,7 +137,7 @@
}
}
- textBox->textFragments().append(m_currentTextFragment);
+ textBox.textFragments().append(m_currentTextFragment);
m_currentTextFragment = SVGTextFragment();
}
@@ -210,27 +210,25 @@
m_textPathScaling = 1;
}
-void SVGTextLayoutEngine::layoutInlineTextBox(SVGInlineTextBox* textBox)
+void SVGTextLayoutEngine::layoutInlineTextBox(SVGInlineTextBox& textBox)
{
- ASSERT(textBox);
-
- RenderSVGInlineText& text = textBox->renderer();
+ RenderSVGInlineText& text = textBox.renderer();
ASSERT(text.parent());
ASSERT(text.parent()->element());
ASSERT(text.parent()->element()->isSVGElement());
const RenderStyle& style = text.style();
- textBox->clearTextFragments();
+ textBox.clearTextFragments();
m_isVerticalText = style.svgStyle().isVerticalWritingMode();
- layoutTextOnLineOrPath(textBox, &text, &style);
+ layoutTextOnLineOrPath(textBox, text, style);
if (m_inPathLayout) {
- m_pathLayoutBoxes.append(textBox);
+ m_pathLayoutBoxes.append(&textBox);
return;
}
- m_lineLayoutBoxes.append(textBox);
+ m_lineLayoutBoxes.append(&textBox);
}
#if DUMP_TEXT_FRAGMENTS > 0
@@ -360,12 +358,12 @@
return true;
}
-bool SVGTextLayoutEngine::currentVisualCharacterMetrics(SVGInlineTextBox* textBox, Vector<SVGTextMetrics>& visualMetricsValues, SVGTextMetrics& visualMetrics)
+bool SVGTextLayoutEngine::currentVisualCharacterMetrics(const SVGInlineTextBox& textBox, Vector<SVGTextMetrics>& visualMetricsValues, SVGTextMetrics& visualMetrics)
{
ASSERT(!visualMetricsValues.isEmpty());
unsigned textMetricsSize = visualMetricsValues.size();
- unsigned boxStart = textBox->start();
- unsigned boxLength = textBox->len();
+ unsigned boxStart = textBox.start();
+ unsigned boxLength = textBox.len();
if (m_visualMetricsListOffset == textMetricsSize)
return false;
@@ -400,28 +398,28 @@
m_visualCharacterOffset += visualMetrics.length();
}
-void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, RenderSVGInlineText* text, const RenderStyle* style)
+void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox& textBox, RenderSVGInlineText& text, const RenderStyle& style)
{
if (m_inPathLayout && m_textPath.isEmpty())
return;
- RenderElement* textParent = text->parent();
+ RenderElement* textParent = text.parent();
ASSERT(textParent);
SVGElement* lengthContext = downcast<SVGElement>(textParent->element());
bool definesTextLength = parentDefinesTextLength(textParent);
- const SVGRenderStyle& svgStyle = style->svgStyle();
+ const SVGRenderStyle& svgStyle = style.svgStyle();
m_visualMetricsListOffset = 0;
m_visualCharacterOffset = 0;
- Vector<SVGTextMetrics>& visualMetricsValues = text->layoutAttributes()->textMetricsValues();
+ Vector<SVGTextMetrics>& visualMetricsValues = text.layoutAttributes()->textMetricsValues();
ASSERT(!visualMetricsValues.isEmpty());
- auto upconvertedCharacters = StringView(text->text()).upconvertedCharacters();
+ auto upconvertedCharacters = StringView(text.text()).upconvertedCharacters();
const UChar* characters = upconvertedCharacters;
- const FontCascade& font = style->fontCascade();
+ const FontCascade& font = style.fontCascade();
SVGTextLayoutEngineSpacing spacingLayout(font);
SVGTextLayoutEngineBaseline baselineLayout(font);
@@ -430,7 +428,7 @@
bool applySpacingToNextCharacter = false;
float lastAngle = 0;
- float baselineShift = baselineLayout.calculateBaselineShift(&svgStyle, lengthContext);
+ float baselineShift = baselineLayout.calculateBaselineShift(svgStyle, lengthContext);
baselineShift -= baselineLayout.calculateAlignmentBaselineShift(m_isVerticalText, text);
// Main layout algorithm.
@@ -463,16 +461,16 @@
float x = data.x;
float y = data.y;
- // When we've advanced to the box start offset, determine using the original x/y values,
- // whether this character starts a new text chunk, before doing any further processing.
- if (m_visualCharacterOffset == textBox->start())
- textBox->setStartsNewTextChunk(logicalAttributes->context().characterStartsNewTextChunk(m_logicalCharacterOffset));
+ // When we've advanced to the box start offset, determine using the original x/y values
+ // whether this character starts a new text chunk before doing any further processing.
+ if (m_visualCharacterOffset == textBox.start())
+ textBox.setStartsNewTextChunk(logicalAttributes->context().characterStartsNewTextChunk(m_logicalCharacterOffset));
float angle = data.rotate == SVGTextLayoutAttributes::emptyValue() ? 0 : data.rotate;
// Calculate glyph orientation angle.
const UChar* currentCharacter = characters + m_visualCharacterOffset;
- float orientationAngle = baselineLayout.calculateGlyphOrientationAngle(m_isVerticalText, &svgStyle, *currentCharacter);
+ float orientationAngle = baselineLayout.calculateGlyphOrientationAngle(m_isVerticalText, svgStyle, *currentCharacter);
// Calculate glyph advance & x/y orientation shifts.
float xOrientationShift = 0;
Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngine.h (183218 => 183219)
--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngine.h 2015-04-23 22:30:07 UTC (rev 183218)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngine.h 2015-04-23 22:34:10 UTC (rev 183219)
@@ -54,7 +54,7 @@
void beginTextPathLayout(RenderSVGTextPath&, SVGTextLayoutEngine& lineLayout);
void endTextPathLayout();
- void layoutInlineTextBox(SVGInlineTextBox*);
+ void layoutInlineTextBox(SVGInlineTextBox&);
void finishLayout();
private:
@@ -62,15 +62,15 @@
void updateCurrentTextPosition(float x, float y, float glyphAdvance);
void updateRelativePositionAdjustmentsIfNeeded(float dx, float dy);
- void recordTextFragment(SVGInlineTextBox*, Vector<SVGTextMetrics>&);
+ void recordTextFragment(SVGInlineTextBox&, Vector<SVGTextMetrics>&);
bool parentDefinesTextLength(RenderObject*) const;
- void layoutTextOnLineOrPath(SVGInlineTextBox*, RenderSVGInlineText*, const RenderStyle*);
+ void layoutTextOnLineOrPath(SVGInlineTextBox&, RenderSVGInlineText&, const RenderStyle&);
void finalizeTransformMatrices(Vector<SVGInlineTextBox*>&);
bool currentLogicalCharacterAttributes(SVGTextLayoutAttributes*&);
bool currentLogicalCharacterMetrics(SVGTextLayoutAttributes*&, SVGTextMetrics&);
- bool currentVisualCharacterMetrics(SVGInlineTextBox*, Vector<SVGTextMetrics>&, SVGTextMetrics&);
+ bool currentVisualCharacterMetrics(const SVGInlineTextBox&, Vector<SVGTextMetrics>&, SVGTextMetrics&);
void advanceToNextLogicalCharacter(const SVGTextMetrics&);
void advanceToNextVisualCharacter(const SVGTextMetrics&);
Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp (183218 => 183219)
--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp 2015-04-23 22:30:07 UTC (rev 183218)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp 2015-04-23 22:34:10 UTC (rev 183219)
@@ -33,28 +33,29 @@
{
}
-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) {
+ SVGLength 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
@@ -102,15 +103,12 @@
}
}
-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);
@@ -145,11 +143,9 @@
}
}
-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.
Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.h (183218 => 183219)
--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.h 2015-04-23 22:30:07 UTC (rev 183218)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.h 2015-04-23 22:34:10 UTC (rev 183219)
@@ -37,9 +37,9 @@
public:
SVGTextLayoutEngineBaseline(const FontCascade&);
- float calculateBaselineShift(const SVGRenderStyle*, SVGElement* lengthContext) const;
- float calculateAlignmentBaselineShift(bool isVerticalText, const RenderObject* textRenderer) const;
- float calculateGlyphOrientationAngle(bool isVerticalText, const SVGRenderStyle*, const UChar& character) const;
+ float calculateBaselineShift(const SVGRenderStyle&, SVGElement* context) const;
+ float calculateAlignmentBaselineShift(bool isVerticalText, const RenderObject& textRenderer) const;
+ float calculateGlyphOrientationAngle(bool isVerticalText, const SVGRenderStyle&, const UChar& character) const;
float calculateGlyphAdvanceAndOrientation(bool isVerticalText, SVGTextMetrics&, float angle, float& xOrientationShift, float& yOrientationShift) const;
private: