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, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return logicalHeight() - borderAndPaddingLogicalHeight(); | 100 return logicalHeight() - borderAndPaddingLogicalHeight(); |
101 } | 101 } |
102 | 102 |
103 int LayoutTextControl::textBlockLogicalWidth() const | 103 int LayoutTextControl::textBlockLogicalWidth() const |
104 { | 104 { |
105 Element* innerEditor = innerEditorElement(); | 105 Element* innerEditor = innerEditorElement(); |
106 ASSERT(innerEditor); | 106 ASSERT(innerEditor); |
107 | 107 |
108 LayoutUnit unitWidth = logicalWidth() - borderAndPaddingLogicalWidth(); | 108 LayoutUnit unitWidth = logicalWidth() - borderAndPaddingLogicalWidth(); |
109 if (innerEditor->renderer()) | 109 if (innerEditor->renderer()) |
110 unitWidth -= innerEditor->renderBox()->paddingStart() + innerEditor->ren
derBox()->paddingEnd(); | 110 unitWidth -= innerEditor->layoutBox()->paddingStart() + innerEditor->lay
outBox()->paddingEnd(); |
111 | 111 |
112 return unitWidth; | 112 return unitWidth; |
113 } | 113 } |
114 | 114 |
115 void LayoutTextControl::updateFromElement() | 115 void LayoutTextControl::updateFromElement() |
116 { | 116 { |
117 Element* innerEditor = innerEditorElement(); | 117 Element* innerEditor = innerEditorElement(); |
118 if (innerEditor && innerEditor->renderer()) | 118 if (innerEditor && innerEditor->renderer()) |
119 updateUserModifyProperty(*textFormControlElement(), innerEditor->rendere
r()->mutableStyleRef()); | 119 updateUserModifyProperty(*textFormControlElement(), innerEditor->rendere
r()->mutableStyleRef()); |
120 } | 120 } |
121 | 121 |
122 int LayoutTextControl::scrollbarThickness() const | 122 int LayoutTextControl::scrollbarThickness() const |
123 { | 123 { |
124 // FIXME: We should get the size of the scrollbar from the LayoutTheme inste
ad. | 124 // FIXME: We should get the size of the scrollbar from the LayoutTheme inste
ad. |
125 return ScrollbarTheme::theme()->scrollbarThickness(); | 125 return ScrollbarTheme::theme()->scrollbarThickness(); |
126 } | 126 } |
127 | 127 |
128 void LayoutTextControl::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUni
t logicalTop, LogicalExtentComputedValues& computedValues) const | 128 void LayoutTextControl::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUni
t logicalTop, LogicalExtentComputedValues& computedValues) const |
129 { | 129 { |
130 HTMLElement* innerEditor = innerEditorElement(); | 130 HTMLElement* innerEditor = innerEditorElement(); |
131 ASSERT(innerEditor); | 131 ASSERT(innerEditor); |
132 if (RenderBox* innerEditorBox = innerEditor->renderBox()) { | 132 if (LayoutBox* innerEditorBox = innerEditor->layoutBox()) { |
133 LayoutUnit nonContentHeight = innerEditorBox->borderAndPaddingHeight() +
innerEditorBox->marginHeight(); | 133 LayoutUnit nonContentHeight = innerEditorBox->borderAndPaddingHeight() +
innerEditorBox->marginHeight(); |
134 logicalHeight = computeControlLogicalHeight(innerEditorBox->lineHeight(t
rue, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight); | 134 logicalHeight = computeControlLogicalHeight(innerEditorBox->lineHeight(t
rue, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight); |
135 | 135 |
136 // We are able to have a horizontal scrollbar if the overflow style is s
croll, or if its auto and there's no word wrap. | 136 // We are able to have a horizontal scrollbar if the overflow style is s
croll, or if its auto and there's no word wrap. |
137 if ((isHorizontalWritingMode() && (style()->overflowX() == OSCROLL || (
style()->overflowX() == OAUTO && innerEditor->renderer()->style()->overflowWrap(
) == NormalOverflowWrap))) | 137 if ((isHorizontalWritingMode() && (style()->overflowX() == OSCROLL || (
style()->overflowX() == OAUTO && innerEditor->renderer()->style()->overflowWrap(
) == NormalOverflowWrap))) |
138 || (!isHorizontalWritingMode() && (style()->overflowY() == OSCROLL |
| (style()->overflowY() == OAUTO && innerEditor->renderer()->style()->overflowW
rap() == NormalOverflowWrap)))) | 138 || (!isHorizontalWritingMode() && (style()->overflowY() == OSCROLL |
| (style()->overflowY() == OAUTO && innerEditor->renderer()->style()->overflowW
rap() == NormalOverflowWrap)))) |
139 logicalHeight += scrollbarThickness(); | 139 logicalHeight += scrollbarThickness(); |
140 | 140 |
141 // FIXME: The logical height of the inner text box should have been adde
d before calling computeLogicalHeight to | 141 // FIXME: The logical height of the inner text box should have been adde
d before calling computeLogicalHeight to |
142 // avoid this hack. | 142 // avoid this hack. |
143 setIntrinsicContentLogicalHeight(logicalHeight); | 143 setIntrinsicContentLogicalHeight(logicalHeight); |
144 | 144 |
145 logicalHeight += borderAndPaddingHeight(); | 145 logicalHeight += borderAndPaddingHeight(); |
146 } | 146 } |
147 | 147 |
148 RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); | 148 LayoutBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); |
149 } | 149 } |
150 | 150 |
151 void LayoutTextControl::hitInnerEditorElement(HitTestResult& result, const Layou
tPoint& pointInContainer, const LayoutPoint& accumulatedOffset) | 151 void LayoutTextControl::hitInnerEditorElement(HitTestResult& result, const Layou
tPoint& pointInContainer, const LayoutPoint& accumulatedOffset) |
152 { | 152 { |
153 HTMLElement* innerEditor = innerEditorElement(); | 153 HTMLElement* innerEditor = innerEditorElement(); |
154 if (!innerEditor->renderer()) | 154 if (!innerEditor->renderer()) |
155 return; | 155 return; |
156 | 156 |
157 LayoutPoint adjustedLocation = accumulatedOffset + location(); | 157 LayoutPoint adjustedLocation = accumulatedOffset + location(); |
158 LayoutPoint localPoint = pointInContainer - toLayoutSize(adjustedLocation +
innerEditor->renderBox()->location()); | 158 LayoutPoint localPoint = pointInContainer - toLayoutSize(adjustedLocation +
innerEditor->layoutBox()->location()); |
159 if (hasOverflowClip()) | 159 if (hasOverflowClip()) |
160 localPoint += scrolledContentOffset(); | 160 localPoint += scrolledContentOffset(); |
161 result.setInnerNode(innerEditor); | 161 result.setInnerNode(innerEditor); |
162 result.setInnerNonSharedNode(innerEditor); | 162 result.setInnerNonSharedNode(innerEditor); |
163 result.setLocalPoint(localPoint); | 163 result.setLocalPoint(localPoint); |
164 } | 164 } |
165 | 165 |
166 static const char* const fontFamiliesWithInvalidCharWidth[] = { | 166 static const char* const fontFamiliesWithInvalidCharWidth[] = { |
167 "American Typewriter", | 167 "American Typewriter", |
168 "Arial Hebrew", | 168 "Arial Hebrew", |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // This matches the unitsPerEm value for MS Shell Dlg and Courier New from t
he "head" font table. | 239 // This matches the unitsPerEm value for MS Shell Dlg and Courier New from t
he "head" font table. |
240 float unitsPerEm = 2048.0f; | 240 float unitsPerEm = 2048.0f; |
241 return roundf(style()->font().fontDescription().computedSize() * x / unitsPe
rEm); | 241 return roundf(style()->font().fontDescription().computedSize() * x / unitsPe
rEm); |
242 } | 242 } |
243 | 243 |
244 void LayoutTextControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt
h, LayoutUnit& maxLogicalWidth) const | 244 void LayoutTextControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt
h, LayoutUnit& maxLogicalWidth) const |
245 { | 245 { |
246 // Use average character width. Matches IE. | 246 // Use average character width. Matches IE. |
247 AtomicString family = style()->font().fontDescription().family().family(); | 247 AtomicString family = style()->font().fontDescription().family().family(); |
248 maxLogicalWidth = preferredContentLogicalWidth(const_cast<LayoutTextControl*
>(this)->getAvgCharWidth(family)); | 248 maxLogicalWidth = preferredContentLogicalWidth(const_cast<LayoutTextControl*
>(this)->getAvgCharWidth(family)); |
249 if (RenderBox* innerEditorRenderBox = innerEditorElement()->renderBox()) | 249 if (LayoutBox* innerEditorLayoutBox = innerEditorElement()->layoutBox()) |
250 maxLogicalWidth += innerEditorRenderBox->paddingStart() + innerEditorRen
derBox->paddingEnd(); | 250 maxLogicalWidth += innerEditorLayoutBox->paddingStart() + innerEditorLay
outBox->paddingEnd(); |
251 if (!style()->logicalWidth().isPercent()) | 251 if (!style()->logicalWidth().isPercent()) |
252 minLogicalWidth = maxLogicalWidth; | 252 minLogicalWidth = maxLogicalWidth; |
253 } | 253 } |
254 | 254 |
255 void LayoutTextControl::computePreferredLogicalWidths() | 255 void LayoutTextControl::computePreferredLogicalWidths() |
256 { | 256 { |
257 ASSERT(preferredLogicalWidthsDirty()); | 257 ASSERT(preferredLogicalWidthsDirty()); |
258 | 258 |
259 m_minPreferredLogicalWidth = 0; | 259 m_minPreferredLogicalWidth = 0; |
260 m_maxPreferredLogicalWidth = 0; | 260 m_maxPreferredLogicalWidth = 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholder
Element(); | 294 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholder
Element(); |
295 LayoutObject* placeholderRenderer = placeholder ? placeholder->renderer() :
0; | 295 LayoutObject* placeholderRenderer = placeholder ? placeholder->renderer() :
0; |
296 if (!placeholderRenderer) | 296 if (!placeholderRenderer) |
297 return 0; | 297 return 0; |
298 if (relayoutChildren) | 298 if (relayoutChildren) |
299 layoutScope.setChildNeedsLayout(placeholderRenderer); | 299 layoutScope.setChildNeedsLayout(placeholderRenderer); |
300 return placeholderRenderer; | 300 return placeholderRenderer; |
301 } | 301 } |
302 | 302 |
303 } // namespace blink | 303 } // namespace blink |
OLD | NEW |