| 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. | 3 * (C) 2008 Torch Mobile Inc. All rights reserved. |
| 4 * (http://www.torchmobile.com/) | 4 * (http://www.torchmobile.com/) |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * 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. |
| 10 * | 10 * |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #include "core/dom/StyleChangeReason.h" | 25 #include "core/dom/StyleChangeReason.h" |
| 26 #include "core/html/TextControlElement.h" | 26 #include "core/html/TextControlElement.h" |
| 27 #include "core/layout/HitTestResult.h" | 27 #include "core/layout/HitTestResult.h" |
| 28 #include "platform/scroll/ScrollbarTheme.h" | 28 #include "platform/scroll/ScrollbarTheme.h" |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 LayoutTextControl::LayoutTextControl(TextControlElement* element) | 32 LayoutTextControl::LayoutTextControl(TextControlElement* element) |
| 33 : LayoutBlockFlow(element) { | 33 : LayoutBlockFlow(element) { |
| 34 ASSERT(element); | 34 DCHECK(element); |
| 35 } | 35 } |
| 36 | 36 |
| 37 LayoutTextControl::~LayoutTextControl() {} | 37 LayoutTextControl::~LayoutTextControl() {} |
| 38 | 38 |
| 39 TextControlElement* LayoutTextControl::textControlElement() const { | 39 TextControlElement* LayoutTextControl::textControlElement() const { |
| 40 return toTextControlElement(node()); | 40 return toTextControlElement(node()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 HTMLElement* LayoutTextControl::innerEditorElement() const { | 43 HTMLElement* LayoutTextControl::innerEditorElement() const { |
| 44 return textControlElement()->innerEditorElement(); | 44 return textControlElement()->innerEditorElement(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 updateUserModifyProperty(*textControlElement(), textBlockStyle); | 82 updateUserModifyProperty(*textControlElement(), textBlockStyle); |
| 83 } | 83 } |
| 84 | 84 |
| 85 int LayoutTextControl::textBlockLogicalHeight() const { | 85 int LayoutTextControl::textBlockLogicalHeight() const { |
| 86 return (logicalHeight() - borderAndPaddingLogicalHeight()).toInt(); | 86 return (logicalHeight() - borderAndPaddingLogicalHeight()).toInt(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 int LayoutTextControl::textBlockLogicalWidth() const { | 89 int LayoutTextControl::textBlockLogicalWidth() const { |
| 90 Element* innerEditor = innerEditorElement(); | 90 Element* innerEditor = innerEditorElement(); |
| 91 ASSERT(innerEditor); | 91 DCHECK(innerEditor); |
| 92 | 92 |
| 93 LayoutUnit unitWidth = logicalWidth() - borderAndPaddingLogicalWidth(); | 93 LayoutUnit unitWidth = logicalWidth() - borderAndPaddingLogicalWidth(); |
| 94 if (innerEditor->layoutObject()) | 94 if (innerEditor->layoutObject()) |
| 95 unitWidth -= innerEditor->layoutBox()->paddingStart() + | 95 unitWidth -= innerEditor->layoutBox()->paddingStart() + |
| 96 innerEditor->layoutBox()->paddingEnd(); | 96 innerEditor->layoutBox()->paddingEnd(); |
| 97 | 97 |
| 98 return unitWidth.toInt(); | 98 return unitWidth.toInt(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void LayoutTextControl::updateFromElement() { | 101 void LayoutTextControl::updateFromElement() { |
| 102 Element* innerEditor = innerEditorElement(); | 102 Element* innerEditor = innerEditorElement(); |
| 103 if (innerEditor && innerEditor->layoutObject()) | 103 if (innerEditor && innerEditor->layoutObject()) |
| 104 updateUserModifyProperty(*textControlElement(), | 104 updateUserModifyProperty(*textControlElement(), |
| 105 innerEditor->layoutObject()->mutableStyleRef()); | 105 innerEditor->layoutObject()->mutableStyleRef()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 int LayoutTextControl::scrollbarThickness() const { | 108 int LayoutTextControl::scrollbarThickness() const { |
| 109 // FIXME: We should get the size of the scrollbar from the LayoutTheme | 109 // FIXME: We should get the size of the scrollbar from the LayoutTheme |
| 110 // instead. | 110 // instead. |
| 111 return ScrollbarTheme::theme().scrollbarThickness(); | 111 return ScrollbarTheme::theme().scrollbarThickness(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void LayoutTextControl::computeLogicalHeight( | 114 void LayoutTextControl::computeLogicalHeight( |
| 115 LayoutUnit logicalHeight, | 115 LayoutUnit logicalHeight, |
| 116 LayoutUnit logicalTop, | 116 LayoutUnit logicalTop, |
| 117 LogicalExtentComputedValues& computedValues) const { | 117 LogicalExtentComputedValues& computedValues) const { |
| 118 HTMLElement* innerEditor = innerEditorElement(); | 118 HTMLElement* innerEditor = innerEditorElement(); |
| 119 ASSERT(innerEditor); | 119 DCHECK(innerEditor); |
| 120 if (LayoutBox* innerEditorBox = innerEditor->layoutBox()) { | 120 if (LayoutBox* innerEditorBox = innerEditor->layoutBox()) { |
| 121 LayoutUnit nonContentHeight = innerEditorBox->borderAndPaddingHeight() + | 121 LayoutUnit nonContentHeight = innerEditorBox->borderAndPaddingHeight() + |
| 122 innerEditorBox->marginHeight(); | 122 innerEditorBox->marginHeight(); |
| 123 logicalHeight = computeControlLogicalHeight( | 123 logicalHeight = computeControlLogicalHeight( |
| 124 innerEditorBox->lineHeight(true, HorizontalLine, | 124 innerEditorBox->lineHeight(true, HorizontalLine, |
| 125 PositionOfInteriorLineBoxes), | 125 PositionOfInteriorLineBoxes), |
| 126 nonContentHeight); | 126 nonContentHeight); |
| 127 | 127 |
| 128 // We are able to have a horizontal scrollbar if the overflow style is | 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. | 129 // scroll, or if its auto and there's no word wrap. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 if (innerEditorElement()) { | 263 if (innerEditorElement()) { |
| 264 if (LayoutBox* innerEditorLayoutBox = innerEditorElement()->layoutBox()) | 264 if (LayoutBox* innerEditorLayoutBox = innerEditorElement()->layoutBox()) |
| 265 maxLogicalWidth += innerEditorLayoutBox->paddingStart() + | 265 maxLogicalWidth += innerEditorLayoutBox->paddingStart() + |
| 266 innerEditorLayoutBox->paddingEnd(); | 266 innerEditorLayoutBox->paddingEnd(); |
| 267 } | 267 } |
| 268 if (!style()->logicalWidth().isPercentOrCalc()) | 268 if (!style()->logicalWidth().isPercentOrCalc()) |
| 269 minLogicalWidth = maxLogicalWidth; | 269 minLogicalWidth = maxLogicalWidth; |
| 270 } | 270 } |
| 271 | 271 |
| 272 void LayoutTextControl::computePreferredLogicalWidths() { | 272 void LayoutTextControl::computePreferredLogicalWidths() { |
| 273 ASSERT(preferredLogicalWidthsDirty()); | 273 DCHECK(preferredLogicalWidthsDirty()); |
| 274 | 274 |
| 275 m_minPreferredLogicalWidth = LayoutUnit(); | 275 m_minPreferredLogicalWidth = LayoutUnit(); |
| 276 m_maxPreferredLogicalWidth = LayoutUnit(); | 276 m_maxPreferredLogicalWidth = LayoutUnit(); |
| 277 const ComputedStyle& styleToUse = styleRef(); | 277 const ComputedStyle& styleToUse = styleRef(); |
| 278 | 278 |
| 279 if (styleToUse.logicalWidth().isFixed() && | 279 if (styleToUse.logicalWidth().isFixed() && |
| 280 styleToUse.logicalWidth().value() >= 0) | 280 styleToUse.logicalWidth().value() >= 0) |
| 281 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = | 281 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = |
| 282 adjustContentBoxLogicalWidthForBoxSizing( | 282 adjustContentBoxLogicalWidthForBoxSizing( |
| 283 styleToUse.logicalWidth().value()); | 283 styleToUse.logicalWidth().value()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 LayoutUnit baseline(fontData->getFontMetrics().ascent(AlphabeticBaseline)); | 353 LayoutUnit baseline(fontData->getFontMetrics().ascent(AlphabeticBaseline)); |
| 354 for (LayoutObject* box = innerEditorLayoutObject; box && box != this; | 354 for (LayoutObject* box = innerEditorLayoutObject; box && box != this; |
| 355 box = box->parent()) { | 355 box = box->parent()) { |
| 356 if (box->isBox()) | 356 if (box->isBox()) |
| 357 baseline += toLayoutBox(box)->logicalTop(); | 357 baseline += toLayoutBox(box)->logicalTop(); |
| 358 } | 358 } |
| 359 return baseline.toInt(); | 359 return baseline.toInt(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace blink | 362 } // namespace blink |
| OLD | NEW |