Commit 4c55d78b authored by fs's avatar fs Committed by Commit bot

Fix more null-checks in SVGLengthContext::convertValueFrom*

The following methods in SVGLengthContext:

 convertValueFromUserUnitsToCHS
 convertValueFromUserUnitsToEXS
 convertValueFromEXSToUserUnits

needs the same treatment as convertValueFromCHSToUserUnits got in
https://chromiumcodereview.appspot.com/2445463002.

R=pdr@chromium.org,eae@chromium.org
BUG=657438,658585,658613

Review-Url: https://codereview.chromium.org/2449433002
Cr-Commit-Position: refs/heads/master@{#427080}
parent b89d026b
......@@ -373,15 +373,15 @@ float SVGLengthContext::convertValueFromUserUnits(
float SVGLengthContext::convertValueFromUserUnitsToCHS(float value) const {
const ComputedStyle* style = computedStyleForLengthResolving(m_context);
if (!style)
return 0;
const SimpleFontData* fontData = style->font().primaryFont();
if (!style || !fontData)
if (!fontData)
return 0;
float zeroWidth =
fontData->getFontMetrics().zeroWidth() / style->effectiveZoom();
if (!zeroWidth)
return 0;
return value / zeroWidth;
}
......@@ -389,21 +389,20 @@ float SVGLengthContext::convertValueFromCHSToUserUnits(float value) const {
const ComputedStyle* style = computedStyleForLengthResolving(m_context);
if (!style)
return 0;
const SimpleFontData* fontData = style->font().primaryFont();
if (!fontData)
return 0;
return value * fontData->getFontMetrics().zeroWidth() /
style->effectiveZoom();
}
float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const {
const ComputedStyle* style = computedStyleForLengthResolving(m_context);
if (!style)
return 0;
const SimpleFontData* fontData = style->font().primaryFont();
if (!style || !fontData)
if (!fontData)
return 0;
// Use of ceil allows a pixel match to the W3Cs expected output of
// coords-units-03-b.svg, if this causes problems in real world cases maybe it
// would be best to remove this.
......@@ -411,16 +410,16 @@ float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const {
ceilf(fontData->getFontMetrics().xHeight() / style->effectiveZoom());
if (!xHeight)
return 0;
return value / xHeight;
}
float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const {
const ComputedStyle* style = computedStyleForLengthResolving(m_context);
if (!style)
return 0;
const SimpleFontData* fontData = style->font().primaryFont();
if (!style || !fontData)
if (!fontData)
return 0;
// Use of ceil allows a pixel match to the W3Cs expected output of
// coords-units-03-b.svg, if this causes problems in real world cases maybe it
// would be best to remove this.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment