Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(726)

Unified Diff: third_party/WebKit/Source/core/svg/SVGLengthContext.cpp

Issue 2449433002: Fix more null-checks in SVGLengthContext::convertValueFrom* (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/SVGLengthContext.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGLengthContext.cpp b/third_party/WebKit/Source/core/svg/SVGLengthContext.cpp
index a8d35f3e0110ee72e1112f3d8a39bc4e6f773837..7422e3dd0357ba2bb200f3b4b8036c85c666885c 100644
--- a/third_party/WebKit/Source/core/svg/SVGLengthContext.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGLengthContext.cpp
@@ -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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698