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. |
| 4 * (http://www.torchmobile.com/) |
4 * | 5 * |
5 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
9 * | 10 * |
10 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 14 * Library General Public License for more details. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 67 |
67 static inline void updateUserModifyProperty(HTMLTextFormControlElement& node, | 68 static inline void updateUserModifyProperty(HTMLTextFormControlElement& node, |
68 ComputedStyle& style) { | 69 ComputedStyle& style) { |
69 style.setUserModify(node.isDisabledOrReadOnly() ? READ_ONLY | 70 style.setUserModify(node.isDisabledOrReadOnly() ? READ_ONLY |
70 : READ_WRITE_PLAINTEXT_ONLY); | 71 : READ_WRITE_PLAINTEXT_ONLY); |
71 } | 72 } |
72 | 73 |
73 void LayoutTextControl::adjustInnerEditorStyle( | 74 void LayoutTextControl::adjustInnerEditorStyle( |
74 ComputedStyle& textBlockStyle) const { | 75 ComputedStyle& textBlockStyle) const { |
75 // The inner block, if present, always has its direction set to LTR, | 76 // The inner block, if present, always has its direction set to LTR, |
76 // so we need to inherit the direction and unicode-bidi style from the element
. | 77 // so we need to inherit the direction and unicode-bidi style from the |
| 78 // element. |
77 textBlockStyle.setDirection(style()->direction()); | 79 textBlockStyle.setDirection(style()->direction()); |
78 textBlockStyle.setUnicodeBidi(style()->unicodeBidi()); | 80 textBlockStyle.setUnicodeBidi(style()->unicodeBidi()); |
79 | 81 |
80 updateUserModifyProperty(*textFormControlElement(), textBlockStyle); | 82 updateUserModifyProperty(*textFormControlElement(), textBlockStyle); |
81 } | 83 } |
82 | 84 |
83 int LayoutTextControl::textBlockLogicalHeight() const { | 85 int LayoutTextControl::textBlockLogicalHeight() const { |
84 return (logicalHeight() - borderAndPaddingLogicalHeight()).toInt(); | 86 return (logicalHeight() - borderAndPaddingLogicalHeight()).toInt(); |
85 } | 87 } |
86 | 88 |
(...skipping 10 matching lines...) Expand all Loading... |
97 } | 99 } |
98 | 100 |
99 void LayoutTextControl::updateFromElement() { | 101 void LayoutTextControl::updateFromElement() { |
100 Element* innerEditor = innerEditorElement(); | 102 Element* innerEditor = innerEditorElement(); |
101 if (innerEditor && innerEditor->layoutObject()) | 103 if (innerEditor && innerEditor->layoutObject()) |
102 updateUserModifyProperty(*textFormControlElement(), | 104 updateUserModifyProperty(*textFormControlElement(), |
103 innerEditor->layoutObject()->mutableStyleRef()); | 105 innerEditor->layoutObject()->mutableStyleRef()); |
104 } | 106 } |
105 | 107 |
106 int LayoutTextControl::scrollbarThickness() const { | 108 int LayoutTextControl::scrollbarThickness() const { |
107 // FIXME: We should get the size of the scrollbar from the LayoutTheme instead
. | 109 // FIXME: We should get the size of the scrollbar from the LayoutTheme |
| 110 // instead. |
108 return ScrollbarTheme::theme().scrollbarThickness(); | 111 return ScrollbarTheme::theme().scrollbarThickness(); |
109 } | 112 } |
110 | 113 |
111 void LayoutTextControl::computeLogicalHeight( | 114 void LayoutTextControl::computeLogicalHeight( |
112 LayoutUnit logicalHeight, | 115 LayoutUnit logicalHeight, |
113 LayoutUnit logicalTop, | 116 LayoutUnit logicalTop, |
114 LogicalExtentComputedValues& computedValues) const { | 117 LogicalExtentComputedValues& computedValues) const { |
115 HTMLElement* innerEditor = innerEditorElement(); | 118 HTMLElement* innerEditor = innerEditorElement(); |
116 ASSERT(innerEditor); | 119 ASSERT(innerEditor); |
117 if (LayoutBox* innerEditorBox = innerEditor->layoutBox()) { | 120 if (LayoutBox* innerEditorBox = innerEditor->layoutBox()) { |
118 LayoutUnit nonContentHeight = innerEditorBox->borderAndPaddingHeight() + | 121 LayoutUnit nonContentHeight = innerEditorBox->borderAndPaddingHeight() + |
119 innerEditorBox->marginHeight(); | 122 innerEditorBox->marginHeight(); |
120 logicalHeight = computeControlLogicalHeight( | 123 logicalHeight = computeControlLogicalHeight( |
121 innerEditorBox->lineHeight(true, HorizontalLine, | 124 innerEditorBox->lineHeight(true, HorizontalLine, |
122 PositionOfInteriorLineBoxes), | 125 PositionOfInteriorLineBoxes), |
123 nonContentHeight); | 126 nonContentHeight); |
124 | 127 |
125 // We are able to have a horizontal scrollbar if the overflow style is scrol
l, or if its auto and there's no word wrap. | 128 // We are able to have a horizontal scrollbar if the overflow style is |
| 129 // scroll, or if its auto and there's no word wrap. |
126 if (style()->overflowInlineDirection() == OverflowScroll || | 130 if (style()->overflowInlineDirection() == OverflowScroll || |
127 (style()->overflowInlineDirection() == OverflowAuto && | 131 (style()->overflowInlineDirection() == OverflowAuto && |
128 innerEditor->layoutObject()->style()->overflowWrap() == | 132 innerEditor->layoutObject()->style()->overflowWrap() == |
129 NormalOverflowWrap)) | 133 NormalOverflowWrap)) |
130 logicalHeight += scrollbarThickness(); | 134 logicalHeight += scrollbarThickness(); |
131 | 135 |
132 // FIXME: The logical height of the inner text box should have been added be
fore calling computeLogicalHeight to | 136 // FIXME: The logical height of the inner text box should have been added |
133 // avoid this hack. | 137 // before calling computeLogicalHeight to avoid this hack. |
134 setIntrinsicContentLogicalHeight(logicalHeight); | 138 setIntrinsicContentLogicalHeight(logicalHeight); |
135 | 139 |
136 logicalHeight += borderAndPaddingHeight(); | 140 logicalHeight += borderAndPaddingHeight(); |
137 } | 141 } |
138 | 142 |
139 LayoutBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); | 143 LayoutBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); |
140 } | 144 } |
141 | 145 |
142 void LayoutTextControl::hitInnerEditorElement( | 146 void LayoutTextControl::hitInnerEditorElement( |
143 HitTestResult& result, | 147 HitTestResult& result, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 "Apple LiSung", | 190 "Apple LiSung", |
187 "Apple Symbols", | 191 "Apple Symbols", |
188 "AppleGothic", | 192 "AppleGothic", |
189 "AppleMyungjo", | 193 "AppleMyungjo", |
190 "#GungSeo", | 194 "#GungSeo", |
191 "#HeadLineA", | 195 "#HeadLineA", |
192 "#PCMyungjo", | 196 "#PCMyungjo", |
193 "#PilGi", | 197 "#PilGi", |
194 }; | 198 }; |
195 | 199 |
196 // For font families where any of the fonts don't have a valid entry in the OS/2
table | 200 // For font families where any of the fonts don't have a valid entry in the OS/2 |
197 // for avgCharWidth, fallback to the legacy webkit behavior of getting the avgCh
arWidth | 201 // table for avgCharWidth, fallback to the legacy webkit behavior of getting the |
198 // from the width of a '0'. This only seems to apply to a fixed number of Mac fo
nts, | 202 // avgCharWidth from the width of a '0'. This only seems to apply to a fixed |
199 // but, in order to get similar rendering across platforms, we do this check for | 203 // number of Mac fonts, but, in order to get similar rendering across platforms, |
200 // all platforms. | 204 // we do this check for all platforms. |
201 bool LayoutTextControl::hasValidAvgCharWidth(const SimpleFontData* font, | 205 bool LayoutTextControl::hasValidAvgCharWidth(const SimpleFontData* font, |
202 const AtomicString& family) { | 206 const AtomicString& family) { |
203 // Some fonts match avgCharWidth to CJK full-width characters. | 207 // Some fonts match avgCharWidth to CJK full-width characters. |
204 // Heuristic check to avoid such fonts. | 208 // Heuristic check to avoid such fonts. |
205 DCHECK(font); | 209 DCHECK(font); |
206 const FontMetrics& metrics = font->getFontMetrics(); | 210 const FontMetrics& metrics = font->getFontMetrics(); |
207 if (metrics.hasZeroWidth() && | 211 if (metrics.hasZeroWidth() && |
208 font->avgCharWidth() > metrics.zeroWidth() * 1.7) | 212 font->avgCharWidth() > metrics.zeroWidth() * 1.7) |
209 return false; | 213 return false; |
210 | 214 |
(...skipping 22 matching lines...) Expand all Loading... |
233 return roundf(primaryFont->avgCharWidth()); | 237 return roundf(primaryFont->avgCharWidth()); |
234 | 238 |
235 const UChar ch = '0'; | 239 const UChar ch = '0'; |
236 const String str = String(&ch, 1); | 240 const String str = String(&ch, 1); |
237 TextRun textRun = | 241 TextRun textRun = |
238 constructTextRun(font, str, styleRef(), TextRun::AllowTrailingExpansion); | 242 constructTextRun(font, str, styleRef(), TextRun::AllowTrailingExpansion); |
239 return font.width(textRun); | 243 return font.width(textRun); |
240 } | 244 } |
241 | 245 |
242 float LayoutTextControl::scaleEmToUnits(int x) const { | 246 float LayoutTextControl::scaleEmToUnits(int x) const { |
243 // This matches the unitsPerEm value for MS Shell Dlg and Courier New from the
"head" font table. | 247 // This matches the unitsPerEm value for MS Shell Dlg and Courier New from the |
| 248 // "head" font table. |
244 float unitsPerEm = 2048.0f; | 249 float unitsPerEm = 2048.0f; |
245 return roundf(style()->font().getFontDescription().computedSize() * x / | 250 return roundf(style()->font().getFontDescription().computedSize() * x / |
246 unitsPerEm); | 251 unitsPerEm); |
247 } | 252 } |
248 | 253 |
249 void LayoutTextControl::computeIntrinsicLogicalWidths( | 254 void LayoutTextControl::computeIntrinsicLogicalWidths( |
250 LayoutUnit& minLogicalWidth, | 255 LayoutUnit& minLogicalWidth, |
251 LayoutUnit& maxLogicalWidth) const { | 256 LayoutUnit& maxLogicalWidth) const { |
252 // Use average character width. Matches IE. | 257 // Use average character width. Matches IE. |
253 AtomicString family = style()->font().getFontDescription().family().family(); | 258 AtomicString family = style()->font().getFontDescription().family().family(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 LayoutObject* placeholderLayoutObject = | 324 LayoutObject* placeholderLayoutObject = |
320 placeholder ? placeholder->layoutObject() : nullptr; | 325 placeholder ? placeholder->layoutObject() : nullptr; |
321 if (!placeholderLayoutObject) | 326 if (!placeholderLayoutObject) |
322 return nullptr; | 327 return nullptr; |
323 if (relayoutChildren) | 328 if (relayoutChildren) |
324 layoutScope.setChildNeedsLayout(placeholderLayoutObject); | 329 layoutScope.setChildNeedsLayout(placeholderLayoutObject); |
325 return placeholderLayoutObject; | 330 return placeholderLayoutObject; |
326 } | 331 } |
327 | 332 |
328 } // namespace blink | 333 } // namespace blink |
OLD | NEW |