OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved. |
3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "core/layout/HitTestResult.h" | 33 #include "core/layout/HitTestResult.h" |
34 #include "core/layout/LayoutAnalyzer.h" | 34 #include "core/layout/LayoutAnalyzer.h" |
35 #include "core/layout/LayoutTheme.h" | 35 #include "core/layout/LayoutTheme.h" |
36 #include "core/paint/DeprecatedPaintLayer.h" | 36 #include "core/paint/DeprecatedPaintLayer.h" |
37 #include "core/paint/LayoutObjectDrawingRecorder.h" | 37 #include "core/paint/LayoutObjectDrawingRecorder.h" |
38 #include "core/paint/PaintInfo.h" | 38 #include "core/paint/PaintInfo.h" |
39 #include "core/paint/ThemePainter.h" | 39 #include "core/paint/ThemePainter.h" |
40 #include "platform/PlatformKeyboardEvent.h" | 40 #include "platform/PlatformKeyboardEvent.h" |
41 #include "platform/fonts/SimpleFontData.h" | 41 #include "platform/fonts/SimpleFontData.h" |
42 | 42 |
| 43 #if defined(WTF_OS_MACOSX) |
| 44 #include "platform/mac/VersionUtilMac.h" |
| 45 #endif // defined(WTF_OS_MACOSX) |
| 46 |
43 namespace blink { | 47 namespace blink { |
44 | 48 |
45 using namespace HTMLNames; | 49 using namespace HTMLNames; |
46 | 50 |
47 LayoutTextControlSingleLine::LayoutTextControlSingleLine(HTMLInputElement* eleme
nt) | 51 LayoutTextControlSingleLine::LayoutTextControlSingleLine(HTMLInputElement* eleme
nt) |
48 : LayoutTextControl(element) | 52 : LayoutTextControl(element) |
49 , m_shouldDrawCapsLockIndicator(false) | 53 , m_shouldDrawCapsLockIndicator(false) |
50 , m_desiredInnerEditorLogicalHeight(-1) | 54 , m_desiredInnerEditorLogicalHeight(-1) |
51 { | 55 { |
52 } | 56 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 ASSERT(hasControlClip()); | 296 ASSERT(hasControlClip()); |
293 LayoutRect clipRect = contentBoxRect(); | 297 LayoutRect clipRect = contentBoxRect(); |
294 if (containerElement()->layoutBox()) | 298 if (containerElement()->layoutBox()) |
295 clipRect = unionRect(clipRect, containerElement()->layoutBox()->frameRec
t()); | 299 clipRect = unionRect(clipRect, containerElement()->layoutBox()->frameRec
t()); |
296 clipRect.moveBy(additionalOffset); | 300 clipRect.moveBy(additionalOffset); |
297 return clipRect; | 301 return clipRect; |
298 } | 302 } |
299 | 303 |
300 float LayoutTextControlSingleLine::getAvgCharWidth(const AtomicString& family) c
onst | 304 float LayoutTextControlSingleLine::getAvgCharWidth(const AtomicString& family) c
onst |
301 { | 305 { |
302 // Since Lucida Grande is the default font, we want this to match the width | 306 // Match the default system font to the width of MS Shell Dlg, the default |
303 // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win an
d | 307 // font for textareas in Firefox, Safari Win and IE for some encodings (in |
304 // IE for some encodings (in IE, the default font is encoding specific). | 308 // IE, the default font is encoding specific). 901 is the avgCharWidth value |
305 // 901 is the avgCharWidth value in the OS/2 table for MS Shell Dlg. | 309 // in the OS/2 table for MS Shell Dlg. |
306 if (family == "Lucida Grande") | 310 // This is a hack which Blink no longer applies on OSX 10.10+. |
| 311 // https://code.google.com/p/chromium/issues/detail?id=515989#c8 |
| 312 #if defined(WTF_OS_MACOSX) |
| 313 if (family == "BlinkMacSystemFont" && IsOSMavericksOrEarlier()) |
307 return scaleEmToUnits(901); | 314 return scaleEmToUnits(901); |
| 315 #endif // defined(WTF_OS_MACOSX) |
308 | 316 |
309 return LayoutTextControl::getAvgCharWidth(family); | 317 return LayoutTextControl::getAvgCharWidth(family); |
310 } | 318 } |
311 | 319 |
312 LayoutUnit LayoutTextControlSingleLine::preferredContentLogicalWidth(float charW
idth) const | 320 LayoutUnit LayoutTextControlSingleLine::preferredContentLogicalWidth(float charW
idth) const |
313 { | 321 { |
314 int factor; | 322 int factor; |
315 bool includesDecoration = inputElement()->sizeShouldIncludeDecoration(factor
); | 323 bool includesDecoration = inputElement()->sizeShouldIncludeDecoration(factor
); |
316 if (factor <= 0) | 324 if (factor <= 0) |
317 factor = 20; | 325 factor = 20; |
318 | 326 |
319 LayoutUnit result = LayoutUnit::fromFloatCeil(charWidth * factor); | 327 LayoutUnit result = LayoutUnit::fromFloatCeil(charWidth * factor); |
320 | 328 |
321 float maxCharWidth = 0.f; | 329 float maxCharWidth = 0.f; |
322 AtomicString family = styleRef().font().fontDescription().family().family(); | 330 AtomicString family = styleRef().font().fontDescription().family().family(); |
323 // Since Lucida Grande is the default font, we want this to match the width | 331 // Match the default system font to the width of MS Shell Dlg, the default |
324 // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win an
d | 332 // font for textareas in Firefox, Safari Win and IE for some encodings (in |
325 // IE for some encodings (in IE, the default font is encoding specific). | 333 // IE, the default font is encoding specific). 4027 is the (xMax - xMin) |
326 // 4027 is the (xMax - xMin) value in the "head" font table for MS Shell Dlg
. | 334 // value in the "head" font table for MS Shell Dlg. |
327 if (family == "Lucida Grande") | 335 // This is a hack which Blink no longer applies on OSX 10.10+. |
| 336 // https://code.google.com/p/chromium/issues/detail?id=515989#c8 |
| 337 #if defined(WTF_OS_MACOSX) |
| 338 if (family == "BlinkMacSystemFont" && IsOSMavericksOrEarlier()) { |
328 maxCharWidth = scaleEmToUnits(4027); | 339 maxCharWidth = scaleEmToUnits(4027); |
329 else if (hasValidAvgCharWidth(family)) | 340 } else if (hasValidAvgCharWidth(family)) { |
| 341 #else |
| 342 if (hasValidAvgCharWidth(family)) { |
| 343 #endif // defined(WTF_OS_MACOSX) |
330 maxCharWidth = roundf(styleRef().font().primaryFont()->maxCharWidth()); | 344 maxCharWidth = roundf(styleRef().font().primaryFont()->maxCharWidth()); |
| 345 } |
331 | 346 |
332 // For text inputs, IE adds some extra width. | 347 // For text inputs, IE adds some extra width. |
333 if (maxCharWidth > 0.f) | 348 if (maxCharWidth > 0.f) |
334 result += maxCharWidth - charWidth; | 349 result += maxCharWidth - charWidth; |
335 | 350 |
336 if (includesDecoration) { | 351 if (includesDecoration) { |
337 HTMLElement* spinButton = innerSpinButtonElement(); | 352 HTMLElement* spinButton = innerSpinButtonElement(); |
338 if (LayoutBox* spinLayoutObject = spinButton ? spinButton->layoutBox() :
0) { | 353 if (LayoutBox* spinLayoutObject = spinButton ? spinButton->layoutBox() :
0) { |
339 result += spinLayoutObject->borderAndPaddingLogicalWidth(); | 354 result += spinLayoutObject->borderAndPaddingLogicalWidth(); |
340 // Since the width of spinLayoutObject is not calculated yet, spinLa
youtObject->logicalWidth() returns 0. | 355 // Since the width of spinLayoutObject is not calculated yet, spinLa
youtObject->logicalWidth() returns 0. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 if (innerEditorElement()) | 460 if (innerEditorElement()) |
446 innerEditorElement()->setScrollTop(newTop); | 461 innerEditorElement()->setScrollTop(newTop); |
447 } | 462 } |
448 | 463 |
449 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const | 464 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const |
450 { | 465 { |
451 return toHTMLInputElement(node()); | 466 return toHTMLInputElement(node()); |
452 } | 467 } |
453 | 468 |
454 } | 469 } |
OLD | NEW |