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

Unified Diff: third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp

Issue 2192483002: Move bounds and width function sanity checks to computation function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « third_party/WebKit/Source/platform/fonts/SimpleFontData.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
index 07c733561eb673c384bae6c7bf0d828326a4b6d3..ec4178843c45a72f90f71ec4e3314d3e510f402a 100644
--- a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
+++ b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
@@ -373,6 +373,11 @@ PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
{
+ if (!m_platformData.size())
+ return FloatRect();
+
+ static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
+
SkRect bounds;
SkiaTextMetrics(&m_paint).getSkiaBoundsForGlyph(glyph, &bounds);
return FloatRect(bounds);
@@ -380,6 +385,11 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
{
+ if (!m_platformData.size())
+ return 0;
+
+ static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
+
return SkiaTextMetrics(&m_paint).getSkiaWidthForGlyph(glyph);
}
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/SimpleFontData.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698