| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 RenderTextControlMultiLine::RenderTextControlMultiLine(HTMLTextAreaElement* elem
ent) | 30 RenderTextControlMultiLine::RenderTextControlMultiLine(HTMLTextAreaElement* elem
ent) |
| 31 : RenderTextControl(element) | 31 : RenderTextControl(element) |
| 32 { | 32 { |
| 33 ASSERT(element); | 33 ASSERT(element); |
| 34 } | 34 } |
| 35 | 35 |
| 36 RenderTextControlMultiLine::~RenderTextControlMultiLine() | 36 RenderTextControlMultiLine::~RenderTextControlMultiLine() |
| 37 { | 37 { |
| 38 if (node() && node()->inDocument()) | 38 if (node() && node()->inDocument()) |
| 39 static_cast<HTMLTextAreaElement*>(node())->rendererWillBeDestroyed(); | 39 toHTMLTextAreaElement(node())->rendererWillBeDestroyed(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool RenderTextControlMultiLine::nodeAtPoint(const HitTestRequest& request, HitT
estResult& result, const HitTestLocation& locationInContainer, const LayoutPoint
& accumulatedOffset, HitTestAction hitTestAction) | 42 bool RenderTextControlMultiLine::nodeAtPoint(const HitTestRequest& request, HitT
estResult& result, const HitTestLocation& locationInContainer, const LayoutPoint
& accumulatedOffset, HitTestAction hitTestAction) |
| 43 { | 43 { |
| 44 if (!RenderTextControl::nodeAtPoint(request, result, locationInContainer, ac
cumulatedOffset, hitTestAction)) | 44 if (!RenderTextControl::nodeAtPoint(request, result, locationInContainer, ac
cumulatedOffset, hitTestAction)) |
| 45 return false; | 45 return false; |
| 46 | 46 |
| 47 if (result.innerNode() == node() || result.innerNode() == innerTextElement()
) | 47 if (result.innerNode() == node() || result.innerNode() == innerTextElement()
) |
| 48 hitInnerTextElement(result, locationInContainer.point(), accumulatedOffs
et); | 48 hitInnerTextElement(result, locationInContainer.point(), accumulatedOffs
et); |
| 49 | 49 |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 | 52 |
| 53 float RenderTextControlMultiLine::getAvgCharWidth(AtomicString family) | 53 float RenderTextControlMultiLine::getAvgCharWidth(AtomicString family) |
| 54 { | 54 { |
| 55 // Since Lucida Grande is the default font, we want this to match the width | 55 // Since Lucida Grande is the default font, we want this to match the width |
| 56 // of Courier New, the default font for textareas in IE, Firefox and Safari
Win. | 56 // of Courier New, the default font for textareas in IE, Firefox and Safari
Win. |
| 57 // 1229 is the avgCharWidth value in the OS/2 table for Courier New. | 57 // 1229 is the avgCharWidth value in the OS/2 table for Courier New. |
| 58 if (family == "Lucida Grande") | 58 if (family == "Lucida Grande") |
| 59 return scaleEmToUnits(1229); | 59 return scaleEmToUnits(1229); |
| 60 | 60 |
| 61 return RenderTextControl::getAvgCharWidth(family); | 61 return RenderTextControl::getAvgCharWidth(family); |
| 62 } | 62 } |
| 63 | 63 |
| 64 LayoutUnit RenderTextControlMultiLine::preferredContentLogicalWidth(float charWi
dth) const | 64 LayoutUnit RenderTextControlMultiLine::preferredContentLogicalWidth(float charWi
dth) const |
| 65 { | 65 { |
| 66 int factor = static_cast<HTMLTextAreaElement*>(node())->cols(); | 66 int factor = toHTMLTextAreaElement(node())->cols(); |
| 67 return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickne
ss(); | 67 return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickne
ss(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 LayoutUnit RenderTextControlMultiLine::computeControlLogicalHeight(LayoutUnit li
neHeight, LayoutUnit nonContentHeight) const | 70 LayoutUnit RenderTextControlMultiLine::computeControlLogicalHeight(LayoutUnit li
neHeight, LayoutUnit nonContentHeight) const |
| 71 { | 71 { |
| 72 return lineHeight * static_cast<HTMLTextAreaElement*>(node())->rows() + nonC
ontentHeight; | 72 return lineHeight * toHTMLTextAreaElement(node())->rows() + nonContentHeight
; |
| 73 } | 73 } |
| 74 | 74 |
| 75 int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool
firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) cons
t | 75 int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool
firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) cons
t |
| 76 { | 76 { |
| 77 return RenderBox::baselinePosition(baselineType, firstLine, direction, lineP
ositionMode); | 77 return RenderBox::baselinePosition(baselineType, firstLine, direction, lineP
ositionMode); |
| 78 } | 78 } |
| 79 | 79 |
| 80 PassRefPtr<RenderStyle> RenderTextControlMultiLine::createInnerTextStyle(const R
enderStyle* startStyle) const | 80 PassRefPtr<RenderStyle> RenderTextControlMultiLine::createInnerTextStyle(const R
enderStyle* startStyle) const |
| 81 { | 81 { |
| 82 RefPtr<RenderStyle> textBlockStyle = RenderStyle::create(); | 82 RefPtr<RenderStyle> textBlockStyle = RenderStyle::create(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 101 return placeholderRenderer; | 101 return placeholderRenderer; |
| 102 RenderBox* placeholderBox = toRenderBox(placeholderRenderer); | 102 RenderBox* placeholderBox = toRenderBox(placeholderRenderer); |
| 103 placeholderBox->style()->setLogicalWidth(Length(contentLogicalWidth() - plac
eholderBox->borderAndPaddingLogicalWidth(), Fixed)); | 103 placeholderBox->style()->setLogicalWidth(Length(contentLogicalWidth() - plac
eholderBox->borderAndPaddingLogicalWidth(), Fixed)); |
| 104 placeholderBox->layoutIfNeeded(); | 104 placeholderBox->layoutIfNeeded(); |
| 105 placeholderBox->setX(borderLeft() + paddingLeft()); | 105 placeholderBox->setX(borderLeft() + paddingLeft()); |
| 106 placeholderBox->setY(borderTop() + paddingTop()); | 106 placeholderBox->setY(borderTop() + paddingTop()); |
| 107 return placeholderRenderer; | 107 return placeholderRenderer; |
| 108 } | 108 } |
| 109 | 109 |
| 110 } | 110 } |
| OLD | NEW |