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

Unified Diff: Source/core/layout/LayoutTextControlSingleLine.cpp

Issue 1276003003: Reland 2: mac: Use a placeholder string for the family name of the system font. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaseline Yosemite tests that use bold fonts. Created 5 years, 4 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
Index: Source/core/layout/LayoutTextControlSingleLine.cpp
diff --git a/Source/core/layout/LayoutTextControlSingleLine.cpp b/Source/core/layout/LayoutTextControlSingleLine.cpp
index bf8ec2b730dad4147596d39d95d85dae3816184b..fd04ad6c0a2fe661631df2f11dffab5d0665bf03 100644
--- a/Source/core/layout/LayoutTextControlSingleLine.cpp
+++ b/Source/core/layout/LayoutTextControlSingleLine.cpp
@@ -40,6 +40,10 @@
#include "platform/PlatformKeyboardEvent.h"
#include "platform/fonts/SimpleFontData.h"
+#if defined(WTF_OS_MACOSX)
+#include "platform/mac/VersionUtilMac.h"
+#endif // defined(WTF_OS_MACOSX)
+
namespace blink {
using namespace HTMLNames;
@@ -299,12 +303,16 @@ LayoutRect LayoutTextControlSingleLine::controlClipRect(const LayoutPoint& addit
float LayoutTextControlSingleLine::getAvgCharWidth(const AtomicString& family) const
{
- // Since Lucida Grande is the default font, we want this to match the width
- // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win and
- // IE for some encodings (in IE, the default font is encoding specific).
- // 901 is the avgCharWidth value in the OS/2 table for MS Shell Dlg.
- if (family == "Lucida Grande")
+// Match the default system font to the width of MS Shell Dlg, the default
+// font for textareas in Firefox, Safari Win and IE for some encodings (in
+// IE, the default font is encoding specific). 901 is the avgCharWidth value
+// in the OS/2 table for MS Shell Dlg.
+// This is a hack which Blink no longer applies on OSX 10.10+.
+// https://code.google.com/p/chromium/issues/detail?id=515989#c8
+#if defined(WTF_OS_MACOSX)
+ if (family == "BlinkMacSystemFont" && IsOSMavericksOrEarlier())
return scaleEmToUnits(901);
+#endif // defined(WTF_OS_MACOSX)
return LayoutTextControl::getAvgCharWidth(family);
}
@@ -320,14 +328,21 @@ LayoutUnit LayoutTextControlSingleLine::preferredContentLogicalWidth(float charW
float maxCharWidth = 0.f;
AtomicString family = styleRef().font().fontDescription().family().family();
- // Since Lucida Grande is the default font, we want this to match the width
- // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win and
- // IE for some encodings (in IE, the default font is encoding specific).
- // 4027 is the (xMax - xMin) value in the "head" font table for MS Shell Dlg.
- if (family == "Lucida Grande")
+// Match the default system font to the width of MS Shell Dlg, the default
+// font for textareas in Firefox, Safari Win and IE for some encodings (in
+// IE, the default font is encoding specific). 4027 is the (xMax - xMin)
+// value in the "head" font table for MS Shell Dlg.
+// This is a hack which Blink no longer applies on OSX 10.10+.
+// https://code.google.com/p/chromium/issues/detail?id=515989#c8
+#if defined(WTF_OS_MACOSX)
+ if (family == "BlinkMacSystemFont" && IsOSMavericksOrEarlier()) {
maxCharWidth = scaleEmToUnits(4027);
- else if (hasValidAvgCharWidth(family))
+ } else if (hasValidAvgCharWidth(family)) {
+#else
+ if (hasValidAvgCharWidth(family)) {
+#endif // defined(WTF_OS_MACOSX)
maxCharWidth = roundf(styleRef().font().primaryFont()->maxCharWidth());
+ }
// For text inputs, IE adds some extra width.
if (maxCharWidth > 0.f)

Powered by Google App Engine
This is Rietveld 408576698