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) |