| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 else | 61 else |
| 62 LayoutBlockFlow::addChild(newChild, beforeChild); | 62 LayoutBlockFlow::addChild(newChild, beforeChild); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void LayoutTextControl::styleDidChange(StyleDifference diff, const LayoutStyle*
oldStyle) | 65 void LayoutTextControl::styleDidChange(StyleDifference diff, const LayoutStyle*
oldStyle) |
| 66 { | 66 { |
| 67 LayoutBlockFlow::styleDidChange(diff, oldStyle); | 67 LayoutBlockFlow::styleDidChange(diff, oldStyle); |
| 68 Element* innerEditor = innerEditorElement(); | 68 Element* innerEditor = innerEditorElement(); |
| 69 if (!innerEditor) | 69 if (!innerEditor) |
| 70 return; | 70 return; |
| 71 LayoutBlock* innerEditorRenderer = toLayoutBlock(innerEditor->renderer()); | 71 LayoutBlock* innerEditorRenderer = toLayoutBlock(innerEditor->layoutObject()
); |
| 72 if (innerEditorRenderer) { | 72 if (innerEditorRenderer) { |
| 73 // We may have set the width and the height in the old style in layout()
. | 73 // We may have set the width and the height in the old style in layout()
. |
| 74 // Reset them now to avoid getting a spurious layout hint. | 74 // Reset them now to avoid getting a spurious layout hint. |
| 75 innerEditorRenderer->style()->setHeight(Length()); | 75 innerEditorRenderer->style()->setHeight(Length()); |
| 76 innerEditorRenderer->style()->setWidth(Length()); | 76 innerEditorRenderer->style()->setWidth(Length()); |
| 77 innerEditorRenderer->setStyle(createInnerEditorStyle(styleRef())); | 77 innerEditorRenderer->setStyle(createInnerEditorStyle(styleRef())); |
| 78 innerEditor->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo
rTracing::create(StyleChangeReason::Control)); | 78 innerEditor->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo
rTracing::create(StyleChangeReason::Control)); |
| 79 } | 79 } |
| 80 textFormControlElement()->updatePlaceholderVisibility(false); | 80 textFormControlElement()->updatePlaceholderVisibility(false); |
| 81 } | 81 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 99 { | 99 { |
| 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->layoutObject()) |
| 110 unitWidth -= innerEditor->layoutBox()->paddingStart() + innerEditor->lay
outBox()->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->layoutObject()) |
| 119 updateUserModifyProperty(*textFormControlElement(), innerEditor->rendere
r()->mutableStyleRef()); | 119 updateUserModifyProperty(*textFormControlElement(), innerEditor->layoutO
bject()->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 (LayoutBox* innerEditorBox = innerEditor->layoutBox()) { | 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->layoutObject()->style()->overflowW
rap() == NormalOverflowWrap))) |
| 138 || (!isHorizontalWritingMode() && (style()->overflowY() == OSCROLL |
| (style()->overflowY() == OAUTO && innerEditor->renderer()->style()->overflowW
rap() == NormalOverflowWrap)))) | 138 || (!isHorizontalWritingMode() && (style()->overflowY() == OSCROLL |
| (style()->overflowY() == OAUTO && innerEditor->layoutObject()->style()->overf
lowWrap() == 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 LayoutBox::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->layoutObject()) |
| 155 return; | 155 return; |
| 156 | 156 |
| 157 LayoutPoint adjustedLocation = accumulatedOffset + location(); | 157 LayoutPoint adjustedLocation = accumulatedOffset + location(); |
| 158 LayoutPoint localPoint = pointInContainer - toLayoutSize(adjustedLocation +
innerEditor->layoutBox()->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 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 | 285 |
| 286 void LayoutTextControl::addFocusRingRects(Vector<LayoutRect>& rects, const Layou
tPoint& additionalOffset) const | 286 void LayoutTextControl::addFocusRingRects(Vector<LayoutRect>& rects, const Layou
tPoint& additionalOffset) const |
| 287 { | 287 { |
| 288 if (!size().isEmpty()) | 288 if (!size().isEmpty()) |
| 289 rects.append(LayoutRect(additionalOffset, size())); | 289 rects.append(LayoutRect(additionalOffset, size())); |
| 290 } | 290 } |
| 291 | 291 |
| 292 LayoutObject* LayoutTextControl::layoutSpecialExcludedChild(bool relayoutChildre
n, SubtreeLayoutScope& layoutScope) | 292 LayoutObject* LayoutTextControl::layoutSpecialExcludedChild(bool relayoutChildre
n, SubtreeLayoutScope& layoutScope) |
| 293 { | 293 { |
| 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->layoutObject(
) : 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 |