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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutTextControl.cpp

Issue 1737933003: Add primaryFont ASSERT to LayoutTextControl::getAvgCharWidth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/layout/LayoutTextControl.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp b/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
index 2ea7fdd791a91b9d5012a6c0114b86f9ab797807..75c6f46e35a136c9489103022003e4fac1d10322 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
@@ -210,12 +210,14 @@ bool LayoutTextControl::hasValidAvgCharWidth(const AtomicString& family)
float LayoutTextControl::getAvgCharWidth(const AtomicString& family) const
{
- if (hasValidAvgCharWidth(family))
- return roundf(style()->font().primaryFont()->avgCharWidth());
+ const Font& font = style()->font();
+ if (hasValidAvgCharWidth(family)) {
+ ASSERT(font.primaryFont());
+ return roundf(font.primaryFont()->avgCharWidth());
+ }
const UChar ch = '0';
const String str = String(&ch, 1);
- const Font& font = style()->font();
TextRun textRun = constructTextRun(font, str, styleRef(), TextRun::AllowTrailingExpansion);
return font.width(textRun);
}
« 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