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

Side by Side Diff: Source/core/layout/LayoutTextControlMultiLine.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 unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 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 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 * 19 *
20 */ 20 */
21 21
22 #include "config.h" 22 #include "config.h"
23 #include "core/layout/LayoutTextControlMultiLine.h" 23 #include "core/layout/LayoutTextControlMultiLine.h"
24 24
25 #include "core/html/HTMLTextAreaElement.h" 25 #include "core/html/HTMLTextAreaElement.h"
26 #include "core/layout/HitTestResult.h" 26 #include "core/layout/HitTestResult.h"
27 27
28 #if defined(WTF_OS_MACOSX)
29 #include "platform/mac/VersionUtilMac.h"
30 #endif // defined(WTF_OS_MACOSX)
31
28 namespace blink { 32 namespace blink {
29 33
30 LayoutTextControlMultiLine::LayoutTextControlMultiLine(HTMLTextAreaElement* elem ent) 34 LayoutTextControlMultiLine::LayoutTextControlMultiLine(HTMLTextAreaElement* elem ent)
31 : LayoutTextControl(element) 35 : LayoutTextControl(element)
32 { 36 {
33 ASSERT(element); 37 ASSERT(element);
34 } 38 }
35 39
36 LayoutTextControlMultiLine::~LayoutTextControlMultiLine() 40 LayoutTextControlMultiLine::~LayoutTextControlMultiLine()
37 { 41 {
38 } 42 }
39 43
40 bool LayoutTextControlMultiLine::nodeAtPoint(HitTestResult& result, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct ion hitTestAction) 44 bool LayoutTextControlMultiLine::nodeAtPoint(HitTestResult& result, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct ion hitTestAction)
41 { 45 {
42 if (!LayoutTextControl::nodeAtPoint(result, locationInContainer, accumulated Offset, hitTestAction)) 46 if (!LayoutTextControl::nodeAtPoint(result, locationInContainer, accumulated Offset, hitTestAction))
43 return false; 47 return false;
44 48
45 if (result.innerNode() == node() || result.innerNode() == innerEditorElement ()) 49 if (result.innerNode() == node() || result.innerNode() == innerEditorElement ())
46 hitInnerEditorElement(result, locationInContainer.point(), accumulatedOf fset); 50 hitInnerEditorElement(result, locationInContainer.point(), accumulatedOf fset);
47 51
48 return true; 52 return true;
49 } 53 }
50 54
51 float LayoutTextControlMultiLine::getAvgCharWidth(const AtomicString& family) co nst 55 float LayoutTextControlMultiLine::getAvgCharWidth(const AtomicString& family) co nst
52 { 56 {
53 // Since Lucida Grande is the default font, we want this to match the width 57 // Match the default system font to the width of MS Shell Dlg, the default
54 // of Courier New, the default font for textareas in IE, Firefox and Safari Win. 58 // font for textareas in Firefox, Safari Win and IE for some encodings (in
55 // 1229 is the avgCharWidth value in the OS/2 table for Courier New. 59 // IE, the default font is encoding specific). 1229 is the avgCharWidth
56 if (family == "Lucida Grande") 60 // value in the OS/2 table for Courier New.
61 // This is a hack which Blink no longer applies on OSX 10.10+.
62 // https://code.google.com/p/chromium/issues/detail?id=515989#c8
63 #if defined(WTF_OS_MACOSX)
tkent 2015/08/11 01:34:36 We'd like to minimize OS-specific code in core/.
erikchen 2015/08/11 05:21:13 Done. I made a method called needsHackForTextContr
64 if (family == "BlinkMacSystemFont" && IsOSMavericksOrEarlier())
57 return scaleEmToUnits(1229); 65 return scaleEmToUnits(1229);
66 #endif // defined(WTF_OS_MACOSX)
58 67
59 return LayoutTextControl::getAvgCharWidth(family); 68 return LayoutTextControl::getAvgCharWidth(family);
60 } 69 }
61 70
62 LayoutUnit LayoutTextControlMultiLine::preferredContentLogicalWidth(float charWi dth) const 71 LayoutUnit LayoutTextControlMultiLine::preferredContentLogicalWidth(float charWi dth) const
63 { 72 {
64 int factor = toHTMLTextAreaElement(node())->cols(); 73 int factor = toHTMLTextAreaElement(node())->cols();
65 return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickne ss(); 74 return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickne ss();
66 } 75 }
67 76
(...skipping 27 matching lines...) Expand all
95 return placeholderLayoutObject; 104 return placeholderLayoutObject;
96 LayoutBox* placeholderBox = toLayoutBox(placeholderLayoutObject); 105 LayoutBox* placeholderBox = toLayoutBox(placeholderLayoutObject);
97 placeholderBox->mutableStyleRef().setLogicalWidth(Length(contentLogicalWidth () - placeholderBox->borderAndPaddingLogicalWidth(), Fixed)); 106 placeholderBox->mutableStyleRef().setLogicalWidth(Length(contentLogicalWidth () - placeholderBox->borderAndPaddingLogicalWidth(), Fixed));
98 placeholderBox->layoutIfNeeded(); 107 placeholderBox->layoutIfNeeded();
99 placeholderBox->setX(borderLeft() + paddingLeft()); 108 placeholderBox->setX(borderLeft() + paddingLeft());
100 placeholderBox->setY(borderTop() + paddingTop()); 109 placeholderBox->setY(borderTop() + paddingTop());
101 return placeholderLayoutObject; 110 return placeholderLayoutObject;
102 } 111 }
103 112
104 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698