| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 // We don't honor paddings and borders for textfields without decorations | 104 // We don't honor paddings and borders for textfields without decorations |
| 105 // and type=search if the text height is taller than the contentHeight() | 105 // and type=search if the text height is taller than the contentHeight() |
| 106 // because of compability. | 106 // because of compability. |
| 107 | 107 |
| 108 RenderBox* innerEditorRenderer = innerEditorElement()->renderBox(); | 108 RenderBox* innerEditorRenderer = innerEditorElement()->renderBox(); |
| 109 RenderBox* viewPortRenderer = editingViewPortElement() ? editingViewPortElem
ent()->renderBox() : 0; | 109 RenderBox* viewPortRenderer = editingViewPortElement() ? editingViewPortElem
ent()->renderBox() : 0; |
| 110 | 110 |
| 111 // To ensure consistency between layouts, we need to reset any conditionally
overriden height. | 111 // To ensure consistency between layouts, we need to reset any conditionally
overriden height. |
| 112 if (innerEditorRenderer && !innerEditorRenderer->style()->logicalHeight().is
Auto()) { | 112 if (innerEditorRenderer && !innerEditorRenderer->style()->logicalHeight().is
Auto()) { |
| 113 innerEditorRenderer->style()->setLogicalHeight(Length(Auto)); | 113 innerEditorRenderer->deprecatedMutableStyle()->setLogicalHeight(Length(A
uto)); |
| 114 layoutScope.setNeedsLayout(innerEditorRenderer); | 114 layoutScope.setNeedsLayout(innerEditorRenderer); |
| 115 HTMLElement* placeholderElement = inputElement()->placeholderElement(); | 115 HTMLElement* placeholderElement = inputElement()->placeholderElement(); |
| 116 if (RenderBox* placeholderBox = placeholderElement ? placeholderElement-
>renderBox() : 0) | 116 if (RenderBox* placeholderBox = placeholderElement ? placeholderElement-
>renderBox() : 0) |
| 117 layoutScope.setNeedsLayout(placeholderBox); | 117 layoutScope.setNeedsLayout(placeholderBox); |
| 118 } | 118 } |
| 119 if (viewPortRenderer && !viewPortRenderer->style()->logicalHeight().isAuto()
) { | 119 if (viewPortRenderer && !viewPortRenderer->style()->logicalHeight().isAuto()
) { |
| 120 viewPortRenderer->style()->setLogicalHeight(Length(Auto)); | 120 viewPortRenderer->deprecatedMutableStyle()->setLogicalHeight(Length(Auto
)); |
| 121 layoutScope.setNeedsLayout(viewPortRenderer); | 121 layoutScope.setNeedsLayout(viewPortRenderer); |
| 122 } | 122 } |
| 123 | 123 |
| 124 RenderBlockFlow::layoutBlock(false); | 124 RenderBlockFlow::layoutBlock(false); |
| 125 | 125 |
| 126 Element* container = containerElement(); | 126 Element* container = containerElement(); |
| 127 RenderBox* containerRenderer = container ? container->renderBox() : 0; | 127 RenderBox* containerRenderer = container ? container->renderBox() : 0; |
| 128 | 128 |
| 129 // Set the text block height | 129 // Set the text block height |
| 130 LayoutUnit desiredLogicalHeight = textBlockLogicalHeight(); | 130 LayoutUnit desiredLogicalHeight = textBlockLogicalHeight(); |
| 131 LayoutUnit logicalHeightLimit = computeLogicalHeightLimit(); | 131 LayoutUnit logicalHeightLimit = computeLogicalHeightLimit(); |
| 132 if (innerEditorRenderer && innerEditorRenderer->logicalHeight() > logicalHei
ghtLimit) { | 132 if (innerEditorRenderer && innerEditorRenderer->logicalHeight() > logicalHei
ghtLimit) { |
| 133 if (desiredLogicalHeight != innerEditorRenderer->logicalHeight()) | 133 if (desiredLogicalHeight != innerEditorRenderer->logicalHeight()) |
| 134 layoutScope.setNeedsLayout(this); | 134 layoutScope.setNeedsLayout(this); |
| 135 | 135 |
| 136 m_desiredInnerEditorLogicalHeight = desiredLogicalHeight; | 136 m_desiredInnerEditorLogicalHeight = desiredLogicalHeight; |
| 137 | 137 |
| 138 innerEditorRenderer->style()->setLogicalHeight(Length(desiredLogicalHeig
ht, Fixed)); | 138 innerEditorRenderer->deprecatedMutableStyle()->setLogicalHeight(Length(d
esiredLogicalHeight, Fixed)); |
| 139 layoutScope.setNeedsLayout(innerEditorRenderer); | 139 layoutScope.setNeedsLayout(innerEditorRenderer); |
| 140 if (viewPortRenderer) { | 140 if (viewPortRenderer) { |
| 141 viewPortRenderer->style()->setLogicalHeight(Length(desiredLogicalHei
ght, Fixed)); | 141 viewPortRenderer->deprecatedMutableStyle()->setLogicalHeight(Length(
desiredLogicalHeight, Fixed)); |
| 142 layoutScope.setNeedsLayout(viewPortRenderer); | 142 layoutScope.setNeedsLayout(viewPortRenderer); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 // The container might be taller because of decoration elements. | 145 // The container might be taller because of decoration elements. |
| 146 if (containerRenderer) { | 146 if (containerRenderer) { |
| 147 containerRenderer->layoutIfNeeded(); | 147 containerRenderer->layoutIfNeeded(); |
| 148 LayoutUnit containerLogicalHeight = containerRenderer->logicalHeight(); | 148 LayoutUnit containerLogicalHeight = containerRenderer->logicalHeight(); |
| 149 if (containerLogicalHeight > logicalHeightLimit) { | 149 if (containerLogicalHeight > logicalHeightLimit) { |
| 150 containerRenderer->style()->setLogicalHeight(Length(logicalHeightLim
it, Fixed)); | 150 containerRenderer->deprecatedMutableStyle()->setLogicalHeight(Length
(logicalHeightLimit, Fixed)); |
| 151 layoutScope.setNeedsLayout(this); | 151 layoutScope.setNeedsLayout(this); |
| 152 } else if (containerRenderer->logicalHeight() < contentLogicalHeight())
{ | 152 } else if (containerRenderer->logicalHeight() < contentLogicalHeight())
{ |
| 153 containerRenderer->style()->setLogicalHeight(Length(contentLogicalHe
ight(), Fixed)); | 153 containerRenderer->deprecatedMutableStyle()->setLogicalHeight(Length
(contentLogicalHeight(), Fixed)); |
| 154 layoutScope.setNeedsLayout(this); | 154 layoutScope.setNeedsLayout(this); |
| 155 } else | 155 } else { |
| 156 containerRenderer->style()->setLogicalHeight(Length(containerLogical
Height, Fixed)); | 156 containerRenderer->deprecatedMutableStyle()->setLogicalHeight(Length
(containerLogicalHeight, Fixed)); |
| 157 } |
| 157 } | 158 } |
| 158 | 159 |
| 159 // If we need another layout pass, we have changed one of children's height
so we need to relayout them. | 160 // If we need another layout pass, we have changed one of children's height
so we need to relayout them. |
| 160 if (needsLayout()) | 161 if (needsLayout()) |
| 161 RenderBlockFlow::layoutBlock(true); | 162 RenderBlockFlow::layoutBlock(true); |
| 162 | 163 |
| 163 // Center the child block in the block progression direction (vertical cente
ring for horizontal text fields). | 164 // Center the child block in the block progression direction (vertical cente
ring for horizontal text fields). |
| 164 if (!container && innerEditorRenderer && innerEditorRenderer->size().height(
) != contentLogicalHeight()) { | 165 if (!container && innerEditorRenderer && innerEditorRenderer->size().height(
) != contentLogicalHeight()) { |
| 165 LayoutUnit logicalHeightDiff = innerEditorRenderer->logicalHeight() - co
ntentLogicalHeight(); | 166 LayoutUnit logicalHeightDiff = innerEditorRenderer->logicalHeight() - co
ntentLogicalHeight(); |
| 166 innerEditorRenderer->setLogicalTop(innerEditorRenderer->logicalTop() - (
logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2))); | 167 innerEditorRenderer->setLogicalTop(innerEditorRenderer->logicalTop() - (
logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2))); |
| 167 } else | 168 } else |
| 168 centerContainerIfNeeded(containerRenderer); | 169 centerContainerIfNeeded(containerRenderer); |
| 169 | 170 |
| 170 HTMLElement* placeholderElement = inputElement()->placeholderElement(); | 171 HTMLElement* placeholderElement = inputElement()->placeholderElement(); |
| 171 if (RenderBox* placeholderBox = placeholderElement ? placeholderElement->ren
derBox() : 0) { | 172 if (RenderBox* placeholderBox = placeholderElement ? placeholderElement->ren
derBox() : 0) { |
| 172 LayoutSize innerEditorSize; | 173 LayoutSize innerEditorSize; |
| 173 | 174 |
| 174 if (innerEditorRenderer) | 175 if (innerEditorRenderer) |
| 175 innerEditorSize = innerEditorRenderer->size(); | 176 innerEditorSize = innerEditorRenderer->size(); |
| 176 placeholderBox->style()->setWidth(Length(innerEditorSize.width() - place
holderBox->borderAndPaddingWidth(), Fixed)); | 177 placeholderBox->deprecatedMutableStyle()->setWidth(Length(innerEditorSiz
e.width() - placeholderBox->borderAndPaddingWidth(), Fixed)); |
| 177 placeholderBox->style()->setHeight(Length(innerEditorSize.height() - pla
ceholderBox->borderAndPaddingHeight(), Fixed)); | 178 placeholderBox->deprecatedMutableStyle()->setHeight(Length(innerEditorSi
ze.height() - placeholderBox->borderAndPaddingHeight(), Fixed)); |
| 178 bool neededLayout = placeholderBox->needsLayout(); | 179 bool neededLayout = placeholderBox->needsLayout(); |
| 179 placeholderBox->layoutIfNeeded(); | 180 placeholderBox->layoutIfNeeded(); |
| 180 LayoutPoint textOffset; | 181 LayoutPoint textOffset; |
| 181 if (innerEditorRenderer) | 182 if (innerEditorRenderer) |
| 182 textOffset = innerEditorRenderer->location(); | 183 textOffset = innerEditorRenderer->location(); |
| 183 if (editingViewPortElement() && editingViewPortElement()->renderBox()) | 184 if (editingViewPortElement() && editingViewPortElement()->renderBox()) |
| 184 textOffset += toLayoutSize(editingViewPortElement()->renderBox()->lo
cation()); | 185 textOffset += toLayoutSize(editingViewPortElement()->renderBox()->lo
cation()); |
| 185 if (containerRenderer) | 186 if (containerRenderer) |
| 186 textOffset += toLayoutSize(containerRenderer->location()); | 187 textOffset += toLayoutSize(containerRenderer->location()); |
| 187 placeholderBox->setLocation(textOffset); | 188 placeholderBox->setLocation(textOffset); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 218 | 219 |
| 219 void RenderTextControlSingleLine::styleDidChange(StyleDifference diff, const Ren
derStyle* oldStyle) | 220 void RenderTextControlSingleLine::styleDidChange(StyleDifference diff, const Ren
derStyle* oldStyle) |
| 220 { | 221 { |
| 221 m_desiredInnerEditorLogicalHeight = -1; | 222 m_desiredInnerEditorLogicalHeight = -1; |
| 222 RenderTextControl::styleDidChange(diff, oldStyle); | 223 RenderTextControl::styleDidChange(diff, oldStyle); |
| 223 | 224 |
| 224 // We may have set the width and the height in the old style in layout(). | 225 // We may have set the width and the height in the old style in layout(). |
| 225 // Reset them now to avoid getting a spurious layout hint. | 226 // Reset them now to avoid getting a spurious layout hint. |
| 226 Element* viewPort = editingViewPortElement(); | 227 Element* viewPort = editingViewPortElement(); |
| 227 if (RenderObject* viewPortRenderer = viewPort ? viewPort->renderer() : 0) { | 228 if (RenderObject* viewPortRenderer = viewPort ? viewPort->renderer() : 0) { |
| 228 viewPortRenderer->style()->setHeight(Length()); | 229 viewPortRenderer->deprecatedMutableStyle()->setHeight(Length()); |
| 229 viewPortRenderer->style()->setWidth(Length()); | 230 viewPortRenderer->deprecatedMutableStyle()->setWidth(Length()); |
| 230 } | 231 } |
| 231 Element* container = containerElement(); | 232 Element* container = containerElement(); |
| 232 if (RenderObject* containerRenderer = container ? container->renderer() : 0)
{ | 233 if (RenderObject* containerRenderer = container ? container->renderer() : 0)
{ |
| 233 containerRenderer->style()->setHeight(Length()); | 234 containerRenderer->deprecatedMutableStyle()->setHeight(Length()); |
| 234 containerRenderer->style()->setWidth(Length()); | 235 containerRenderer->deprecatedMutableStyle()->setWidth(Length()); |
| 235 } | 236 } |
| 236 RenderObject* innerEditorRenderer = innerEditorElement()->renderer(); | 237 RenderObject* innerEditorRenderer = innerEditorElement()->renderer(); |
| 237 if (innerEditorRenderer && diff.needsFullLayout()) | 238 if (innerEditorRenderer && diff.needsFullLayout()) |
| 238 innerEditorRenderer->setNeedsLayoutAndFullPaintInvalidation(); | 239 innerEditorRenderer->setNeedsLayoutAndFullPaintInvalidation(); |
| 239 if (HTMLElement* placeholder = inputElement()->placeholderElement()) | 240 if (HTMLElement* placeholder = inputElement()->placeholderElement()) |
| 240 placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldB
eTruncated() ? CSSValueEllipsis : CSSValueClip); | 241 placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldB
eTruncated() ? CSSValueEllipsis : CSSValueClip); |
| 241 setHasOverflowClip(false); | 242 setHasOverflowClip(false); |
| 242 } | 243 } |
| 243 | 244 |
| 244 void RenderTextControlSingleLine::capsLockStateMayHaveChanged() | 245 void RenderTextControlSingleLine::capsLockStateMayHaveChanged() |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 if (innerEditorElement()) | 421 if (innerEditorElement()) |
| 421 innerEditorElement()->setScrollTop(newTop); | 422 innerEditorElement()->setScrollTop(newTop); |
| 422 } | 423 } |
| 423 | 424 |
| 424 HTMLInputElement* RenderTextControlSingleLine::inputElement() const | 425 HTMLInputElement* RenderTextControlSingleLine::inputElement() const |
| 425 { | 426 { |
| 426 return toHTMLInputElement(node()); | 427 return toHTMLInputElement(node()); |
| 427 } | 428 } |
| 428 | 429 |
| 429 } | 430 } |
| OLD | NEW |