OLD | NEW |
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 #include "core/layout/LayoutTheme.h" |
27 | 28 |
28 namespace blink { | 29 namespace blink { |
29 | 30 |
30 LayoutTextControlMultiLine::LayoutTextControlMultiLine(HTMLTextAreaElement* elem
ent) | 31 LayoutTextControlMultiLine::LayoutTextControlMultiLine(HTMLTextAreaElement* elem
ent) |
31 : LayoutTextControl(element) | 32 : LayoutTextControl(element) |
32 { | 33 { |
33 ASSERT(element); | 34 ASSERT(element); |
34 } | 35 } |
35 | 36 |
36 LayoutTextControlMultiLine::~LayoutTextControlMultiLine() | 37 LayoutTextControlMultiLine::~LayoutTextControlMultiLine() |
37 { | 38 { |
38 } | 39 } |
39 | 40 |
40 bool LayoutTextControlMultiLine::nodeAtPoint(HitTestResult& result, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct
ion hitTestAction) | 41 bool LayoutTextControlMultiLine::nodeAtPoint(HitTestResult& result, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct
ion hitTestAction) |
41 { | 42 { |
42 if (!LayoutTextControl::nodeAtPoint(result, locationInContainer, accumulated
Offset, hitTestAction)) | 43 if (!LayoutTextControl::nodeAtPoint(result, locationInContainer, accumulated
Offset, hitTestAction)) |
43 return false; | 44 return false; |
44 | 45 |
45 if (result.innerNode() == node() || result.innerNode() == innerEditorElement
()) | 46 if (result.innerNode() == node() || result.innerNode() == innerEditorElement
()) |
46 hitInnerEditorElement(result, locationInContainer.point(), accumulatedOf
fset); | 47 hitInnerEditorElement(result, locationInContainer.point(), accumulatedOf
fset); |
47 | 48 |
48 return true; | 49 return true; |
49 } | 50 } |
50 | 51 |
51 float LayoutTextControlMultiLine::getAvgCharWidth(const AtomicString& family) co
nst | 52 float LayoutTextControlMultiLine::getAvgCharWidth(const AtomicString& family) co
nst |
52 { | 53 { |
53 // Since Lucida Grande is the default font, we want this to match the width | 54 // 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. | 55 // 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. | 56 // IE, the default font is encoding specific). 1229 is the avgCharWidth |
56 if (family == "Lucida Grande") | 57 // value in the OS/2 table for Courier New. |
| 58 if (LayoutTheme::theme().needsHackForTextControlWithFontFamily(family)) |
57 return scaleEmToUnits(1229); | 59 return scaleEmToUnits(1229); |
58 | 60 |
59 return LayoutTextControl::getAvgCharWidth(family); | 61 return LayoutTextControl::getAvgCharWidth(family); |
60 } | 62 } |
61 | 63 |
62 LayoutUnit LayoutTextControlMultiLine::preferredContentLogicalWidth(float charWi
dth) const | 64 LayoutUnit LayoutTextControlMultiLine::preferredContentLogicalWidth(float charWi
dth) const |
63 { | 65 { |
64 int factor = toHTMLTextAreaElement(node())->cols(); | 66 int factor = toHTMLTextAreaElement(node())->cols(); |
65 return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickne
ss(); | 67 return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickne
ss(); |
66 } | 68 } |
(...skipping 28 matching lines...) Expand all Loading... |
95 return placeholderLayoutObject; | 97 return placeholderLayoutObject; |
96 LayoutBox* placeholderBox = toLayoutBox(placeholderLayoutObject); | 98 LayoutBox* placeholderBox = toLayoutBox(placeholderLayoutObject); |
97 placeholderBox->mutableStyleRef().setLogicalWidth(Length(contentLogicalWidth
() - placeholderBox->borderAndPaddingLogicalWidth(), Fixed)); | 99 placeholderBox->mutableStyleRef().setLogicalWidth(Length(contentLogicalWidth
() - placeholderBox->borderAndPaddingLogicalWidth(), Fixed)); |
98 placeholderBox->layoutIfNeeded(); | 100 placeholderBox->layoutIfNeeded(); |
99 placeholderBox->setX(borderLeft() + paddingLeft()); | 101 placeholderBox->setX(borderLeft() + paddingLeft()); |
100 placeholderBox->setY(borderTop() + paddingTop()); | 102 placeholderBox->setY(borderTop() + paddingTop()); |
101 return placeholderLayoutObject; | 103 return placeholderLayoutObject; |
102 } | 104 } |
103 | 105 |
104 } | 106 } |
OLD | NEW |