zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 1 | /** |
joepeck@webkit.org | 1fbeab3 | 2010-05-01 02:54:08 +0000 | [diff] [blame] | 2 | * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved. |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 3 | * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) |
jorlow@chromium.org | 777bf4b | 2010-06-24 10:40:28 +0000 | [diff] [blame] | 4 | * Copyright (C) 2010 Google Inc. All rights reserved. |
luiz@webkit.org | 260550a | 2010-08-03 00:39:44 +0000 | [diff] [blame] | 5 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Library General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Library General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Library General Public License |
| 18 | * along with this library; see the file COPYING.LIB. If not, write to |
| 19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | * Boston, MA 02110-1301, USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include "config.h" |
| 25 | #include "RenderTextControlSingleLine.h" |
| 26 | |
tonyg@chromium.org | 8d183cb | 2011-05-10 08:19:52 +0000 | [diff] [blame] | 27 | #include "CSSFontSelector.h" |
jonlee@apple.com | 666eb27 | 2012-01-19 22:56:14 +0000 | [diff] [blame] | 28 | #include "CSSValueKeywords.h" |
tonyg@chromium.org | 8d183cb | 2011-05-10 08:19:52 +0000 | [diff] [blame] | 29 | #include "Chrome.h" |
antti@apple.com | 5a8f794 | 2015-01-22 21:57:04 +0000 | [diff] [blame] | 30 | #include "Font.h" |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 31 | #include "Frame.h" |
rniwa@webkit.org | 78bbc94 | 2011-05-05 18:14:43 +0000 | [diff] [blame] | 32 | #include "FrameSelection.h" |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 33 | #include "FrameView.h" |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 34 | #include "HTMLNames.h" |
eric@webkit.org | b35848a | 2010-06-10 08:33:22 +0000 | [diff] [blame] | 35 | #include "HitTestResult.h" |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 36 | #include "LocalizedStrings.h" |
weinig@apple.com | c5b2001d | 2011-05-13 19:09:09 +0000 | [diff] [blame] | 37 | #include "Page.h" |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 38 | #include "PlatformKeyboardEvent.h" |
eric@webkit.org | b35848a | 2010-06-10 08:33:22 +0000 | [diff] [blame] | 39 | #include "RenderLayer.h" |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 40 | #include "RenderScrollbar.h" |
| 41 | #include "RenderTheme.h" |
akling@apple.com | 836b22b | 2013-08-25 21:22:06 +0000 | [diff] [blame] | 42 | #include "RenderView.h" |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 43 | #include "Settings.h" |
alexis.menard@openbossa.org | e6db2f6 | 2012-04-25 15:49:08 +0000 | [diff] [blame] | 44 | #include "StyleResolver.h" |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 45 | #include "TextControlInnerElements.h" |
andersca@apple.com | a5fb7da | 2013-04-16 19:57:36 +0000 | [diff] [blame] | 46 | #include <wtf/StackStats.h> |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 47 | |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 48 | #if PLATFORM(IOS) |
| 49 | #include "RenderThemeIOS.h" |
| 50 | #endif |
| 51 | |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 52 | namespace WebCore { |
| 53 | |
| 54 | using namespace HTMLNames; |
| 55 | |
akling@apple.com | 689f761 | 2014-12-14 08:21:05 +0000 | [diff] [blame] | 56 | RenderTextControlSingleLine::RenderTextControlSingleLine(HTMLInputElement& element, Ref<RenderStyle>&& style) |
dbates@webkit.org | 0cefe4f | 2014-07-03 22:13:54 +0000 | [diff] [blame] | 57 | : RenderTextControl(element, WTF::move(style)) |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 58 | , m_desiredInnerTextLogicalHeight(-1) |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 59 | { |
| 60 | } |
| 61 | |
| 62 | RenderTextControlSingleLine::~RenderTextControlSingleLine() |
| 63 | { |
tkent@chromium.org | 72e4ae9 | 2011-05-23 10:10:38 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | inline HTMLElement* RenderTextControlSingleLine::innerSpinButtonElement() const |
| 67 | { |
akling@apple.com | ca97cfb | 2013-09-13 05:32:54 +0000 | [diff] [blame] | 68 | return inputElement().innerSpinButtonElement(); |
tkent@chromium.org | 72e4ae9 | 2011-05-23 10:10:38 +0000 | [diff] [blame] | 69 | } |
| 70 | |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 71 | LayoutUnit RenderTextControlSingleLine::computeLogicalHeightLimit() const |
yosin@chromium.org | f5c6243 | 2012-06-18 04:57:05 +0000 | [diff] [blame] | 72 | { |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 73 | return containerElement() ? contentLogicalHeight() : logicalHeight(); |
yosin@chromium.org | f5c6243 | 2012-06-18 04:57:05 +0000 | [diff] [blame] | 74 | } |
| 75 | |
zalan@apple.com | 70c7f31 | 2014-01-26 01:27:28 +0000 | [diff] [blame] | 76 | void RenderTextControlSingleLine::centerRenderer(RenderBox& renderer) const |
| 77 | { |
| 78 | LayoutUnit logicalHeightDiff = renderer.logicalHeight() - contentLogicalHeight(); |
| 79 | float center = logicalHeightDiff / 2; |
| 80 | renderer.setLogicalTop(renderer.logicalTop() - LayoutUnit(round(center))); |
| 81 | } |
| 82 | |
rniwa@webkit.org | 45ad2e5 | 2013-08-14 01:44:51 +0000 | [diff] [blame] | 83 | static void setNeedsLayoutOnAncestors(RenderObject* start, RenderObject* ancestor) |
| 84 | { |
| 85 | ASSERT(start != ancestor); |
| 86 | for (RenderObject* renderer = start; renderer != ancestor; renderer = renderer->parent()) { |
| 87 | ASSERT(renderer); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 88 | renderer->setNeedsLayout(MarkOnlyThis); |
rniwa@webkit.org | 45ad2e5 | 2013-08-14 01:44:51 +0000 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 92 | void RenderTextControlSingleLine::layout() |
| 93 | { |
mark.lam@apple.com | 6df1a80 | 2012-10-19 20:09:36 +0000 | [diff] [blame] | 94 | StackStats::LayoutCheckPoint layoutCheckPoint; |
| 95 | |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 96 | // FIXME: We should remove the height-related hacks in layout() and |
| 97 | // styleDidChange(). We need them because |
| 98 | // - Center the inner elements vertically if the input height is taller than |
| 99 | // the intrinsic height of the inner elements. |
| 100 | // - Shrink the inner elment heights if the input height is samller than the |
| 101 | // intrinsic heights of the inner elements. |
| 102 | |
| 103 | // We don't honor paddings and borders for textfields without decorations |
| 104 | // and type=search if the text height is taller than the contentHeight() |
| 105 | // because of compability. |
| 106 | |
weinig@apple.com | eac56f7 | 2013-10-20 04:55:32 +0000 | [diff] [blame] | 107 | RenderTextControlInnerBlock* innerTextRenderer = innerTextElement()->renderer(); |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 108 | RenderBox* innerBlockRenderer = innerBlockElement() ? innerBlockElement()->renderBox() : 0; |
jchaffraix@webkit.org | a942822 | 2012-07-11 03:11:30 +0000 | [diff] [blame] | 109 | |
| 110 | // To ensure consistency between layouts, we need to reset any conditionally overriden height. |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 111 | if (innerTextRenderer && !innerTextRenderer->style().logicalHeight().isAuto()) { |
| 112 | innerTextRenderer->style().setLogicalHeight(Length(Auto)); |
rniwa@webkit.org | 45ad2e5 | 2013-08-14 01:44:51 +0000 | [diff] [blame] | 113 | setNeedsLayoutOnAncestors(innerTextRenderer, this); |
commit-queue@webkit.org | a393490 | 2013-03-16 02:27:56 +0000 | [diff] [blame] | 114 | } |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 115 | if (innerBlockRenderer && !innerBlockRenderer->style().logicalHeight().isAuto()) { |
| 116 | innerBlockRenderer->style().setLogicalHeight(Length(Auto)); |
rniwa@webkit.org | 45ad2e5 | 2013-08-14 01:44:51 +0000 | [diff] [blame] | 117 | setNeedsLayoutOnAncestors(innerBlockRenderer, this); |
commit-queue@webkit.org | a393490 | 2013-03-16 02:27:56 +0000 | [diff] [blame] | 118 | } |
jchaffraix@webkit.org | a942822 | 2012-07-11 03:11:30 +0000 | [diff] [blame] | 119 | |
hyatt@apple.com | c9b1aef | 2013-09-09 20:23:21 +0000 | [diff] [blame] | 120 | RenderBlockFlow::layoutBlock(false); |
jchaffraix@webkit.org | a942822 | 2012-07-11 03:11:30 +0000 | [diff] [blame] | 121 | |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 122 | HTMLElement* container = containerElement(); |
| 123 | RenderBox* containerRenderer = container ? container->renderBox() : 0; |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 124 | |
| 125 | // Set the text block height |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 126 | LayoutUnit desiredLogicalHeight = textBlockLogicalHeight(); |
| 127 | LayoutUnit logicalHeightLimit = computeLogicalHeightLimit(); |
| 128 | if (innerTextRenderer && innerTextRenderer->logicalHeight() > logicalHeightLimit) { |
| 129 | if (desiredLogicalHeight != innerTextRenderer->logicalHeight()) |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 130 | setNeedsLayout(MarkOnlyThis); |
jchaffraix@webkit.org | 6704525 | 2012-03-26 16:46:17 +0000 | [diff] [blame] | 131 | |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 132 | m_desiredInnerTextLogicalHeight = desiredLogicalHeight; |
| 133 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 134 | innerTextRenderer->style().setLogicalHeight(Length(desiredLogicalHeight, Fixed)); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 135 | innerTextRenderer->setNeedsLayout(MarkOnlyThis); |
commit-queue@webkit.org | a393490 | 2013-03-16 02:27:56 +0000 | [diff] [blame] | 136 | if (innerBlockRenderer) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 137 | innerBlockRenderer->style().setLogicalHeight(Length(desiredLogicalHeight, Fixed)); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 138 | innerBlockRenderer->setNeedsLayout(MarkOnlyThis); |
commit-queue@webkit.org | a393490 | 2013-03-16 02:27:56 +0000 | [diff] [blame] | 139 | } |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 140 | } |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 141 | // The container might be taller because of decoration elements. |
| 142 | if (containerRenderer) { |
| 143 | containerRenderer->layoutIfNeeded(); |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 144 | LayoutUnit containerLogicalHeight = containerRenderer->logicalHeight(); |
| 145 | if (containerLogicalHeight > logicalHeightLimit) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 146 | containerRenderer->style().setLogicalHeight(Length(logicalHeightLimit, Fixed)); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 147 | setNeedsLayout(MarkOnlyThis); |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 148 | } else if (containerRenderer->logicalHeight() < contentLogicalHeight()) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 149 | containerRenderer->style().setLogicalHeight(Length(contentLogicalHeight(), Fixed)); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 150 | setNeedsLayout(MarkOnlyThis); |
tkent@chromium.org | e62e37a | 2012-03-02 05:43:01 +0000 | [diff] [blame] | 151 | } else |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 152 | containerRenderer->style().setLogicalHeight(Length(containerLogicalHeight, Fixed)); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 153 | } |
| 154 | |
jchaffraix@webkit.org | 6704525 | 2012-03-26 16:46:17 +0000 | [diff] [blame] | 155 | // If we need another layout pass, we have changed one of children's height so we need to relayout them. |
| 156 | if (needsLayout()) |
hyatt@apple.com | c9b1aef | 2013-09-09 20:23:21 +0000 | [diff] [blame] | 157 | RenderBlockFlow::layoutBlock(true); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 158 | |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 159 | // Center the child block in the block progression direction (vertical centering for horizontal text fields). |
zalan@apple.com | 70c7f31 | 2014-01-26 01:27:28 +0000 | [diff] [blame] | 160 | if (!container && innerTextRenderer && innerTextRenderer->height() != contentLogicalHeight()) |
| 161 | centerRenderer(*innerTextRenderer); |
| 162 | else |
yosin@chromium.org | f5c6243 | 2012-06-18 04:57:05 +0000 | [diff] [blame] | 163 | centerContainerIfNeeded(containerRenderer); |
tkent@chromium.org | 5c8ac40 | 2010-04-30 07:45:09 +0000 | [diff] [blame] | 164 | |
tkent@chromium.org | 06dfd04 | 2010-07-14 08:20:42 +0000 | [diff] [blame] | 165 | // Ignores the paddings for the inner spin button. |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 166 | if (RenderBox* innerSpinBox = innerSpinButtonElement() ? innerSpinButtonElement()->renderBox() : 0) { |
| 167 | RenderBox* parentBox = innerSpinBox->parentBox(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 168 | if (containerRenderer && !containerRenderer->style().isLeftToRightDirection()) |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 169 | innerSpinBox->setLogicalLocation(LayoutPoint(-paddingLogicalLeft(), -paddingBefore())); |
tkent@chromium.org | c376109 | 2011-07-20 07:52:39 +0000 | [diff] [blame] | 170 | else |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 171 | innerSpinBox->setLogicalLocation(LayoutPoint(parentBox->logicalWidth() - innerSpinBox->logicalWidth() + paddingLogicalRight(), -paddingBefore())); |
| 172 | innerSpinBox->setLogicalHeight(logicalHeight() - borderBefore() - borderAfter()); |
tkent@chromium.org | 06dfd04 | 2010-07-14 08:20:42 +0000 | [diff] [blame] | 173 | } |
tkent@chromium.org | 8e17b7c | 2011-07-14 02:16:54 +0000 | [diff] [blame] | 174 | |
akling@apple.com | ca97cfb | 2013-09-13 05:32:54 +0000 | [diff] [blame] | 175 | HTMLElement* placeholderElement = inputElement().placeholderElement(); |
tkent@chromium.org | 8e17b7c | 2011-07-14 02:16:54 +0000 | [diff] [blame] | 176 | if (RenderBox* placeholderBox = placeholderElement ? placeholderElement->renderBox() : 0) { |
dominicc@chromium.org | 1ded05f | 2013-03-18 08:01:57 +0000 | [diff] [blame] | 177 | LayoutSize innerTextSize; |
| 178 | if (innerTextRenderer) |
| 179 | innerTextSize = innerTextRenderer->size(); |
bjonesbe@adobe.com | 562a50d | 2014-02-20 20:01:19 +0000 | [diff] [blame] | 180 | placeholderBox->style().setWidth(Length(innerTextSize.width() - placeholderBox->horizontalBorderAndPaddingExtent(), Fixed)); |
| 181 | placeholderBox->style().setHeight(Length(innerTextSize.height() - placeholderBox->verticalBorderAndPaddingExtent(), Fixed)); |
robert@webkit.org | 34541f5 | 2013-02-20 18:27:03 +0000 | [diff] [blame] | 182 | bool neededLayout = placeholderBox->needsLayout(); |
jchaffraix@webkit.org | 1d6b414 | 2012-03-26 16:52:01 +0000 | [diff] [blame] | 183 | bool placeholderBoxHadLayout = placeholderBox->everHadLayout(); |
tkent@chromium.org | 8e17b7c | 2011-07-14 02:16:54 +0000 | [diff] [blame] | 184 | placeholderBox->layoutIfNeeded(); |
dominicc@chromium.org | 1ded05f | 2013-03-18 08:01:57 +0000 | [diff] [blame] | 185 | LayoutPoint textOffset; |
| 186 | if (innerTextRenderer) |
| 187 | textOffset = innerTextRenderer->location(); |
tkent@chromium.org | 8e17b7c | 2011-07-14 02:16:54 +0000 | [diff] [blame] | 188 | if (innerBlockElement() && innerBlockElement()->renderBox()) |
| 189 | textOffset += toLayoutSize(innerBlockElement()->renderBox()->location()); |
| 190 | if (containerRenderer) |
| 191 | textOffset += toLayoutSize(containerRenderer->location()); |
| 192 | placeholderBox->setLocation(textOffset); |
jchaffraix@webkit.org | 1d6b414 | 2012-03-26 16:52:01 +0000 | [diff] [blame] | 193 | |
| 194 | if (!placeholderBoxHadLayout && placeholderBox->checkForRepaintDuringLayout()) { |
| 195 | // This assumes a shadow tree without floats. If floats are added, the |
| 196 | // logic should be shared with RenderBlock::layoutBlockChild. |
| 197 | placeholderBox->repaint(); |
| 198 | } |
robert@webkit.org | 34541f5 | 2013-02-20 18:27:03 +0000 | [diff] [blame] | 199 | // The placeholder gets layout last, after the parent text control and its other children, |
| 200 | // so in order to get the correct overflow from the placeholder we need to recompute it now. |
robert@webkit.org | bc4e556 | 2013-02-21 18:46:33 +0000 | [diff] [blame] | 201 | if (neededLayout) |
robert@webkit.org | 34541f5 | 2013-02-20 18:27:03 +0000 | [diff] [blame] | 202 | computeOverflow(clientLogicalBottom()); |
tkent@chromium.org | 8e17b7c | 2011-07-14 02:16:54 +0000 | [diff] [blame] | 203 | } |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 204 | |
| 205 | #if PLATFORM(IOS) |
| 206 | // FIXME: We should not be adjusting styles during layout. <rdar://problem/7675493> |
| 207 | if (inputElement().isSearchField()) |
achristensen@apple.com | 9fb77fc | 2014-06-25 21:04:17 +0000 | [diff] [blame] | 208 | RenderThemeIOS::adjustRoundBorderRadius(style(), *this); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 209 | #endif |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 210 | } |
| 211 | |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 212 | bool RenderTextControlSingleLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 213 | { |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 214 | if (!RenderTextControl::nodeAtPoint(request, result, locationInContainer, accumulatedOffset, hitTestAction)) |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 215 | return false; |
| 216 | |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 217 | // Say that we hit the inner text element if |
| 218 | // - we hit a node inside the inner text element, |
| 219 | // - we hit the <input> element (e.g. we're over the border or padding), or |
| 220 | // - we hit regions not in any decoration buttons. |
| 221 | HTMLElement* container = containerElement(); |
akling@apple.com | ca97cfb | 2013-09-13 05:32:54 +0000 | [diff] [blame] | 222 | if (result.innerNode()->isDescendantOf(innerTextElement()) || result.innerNode() == &inputElement() || (container && container == result.innerNode())) { |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 223 | LayoutPoint pointInParent = locationInContainer.point(); |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 224 | if (container && innerBlockElement()) { |
| 225 | if (innerBlockElement()->renderBox()) |
eae@chromium.org | 9fef0e6 | 2011-07-08 22:01:17 +0000 | [diff] [blame] | 226 | pointInParent -= toLayoutSize(innerBlockElement()->renderBox()->location()); |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 227 | if (container->renderBox()) |
eae@chromium.org | 9fef0e6 | 2011-07-08 22:01:17 +0000 | [diff] [blame] | 228 | pointInParent -= toLayoutSize(container->renderBox()->location()); |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 229 | } |
| 230 | hitInnerTextElement(result, pointInParent, accumulatedOffset); |
commit-queue@webkit.org | ae57830 | 2011-06-22 19:55:23 +0000 | [diff] [blame] | 231 | } |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 232 | return true; |
| 233 | } |
| 234 | |
weinig@apple.com | 1a57c82 | 2009-02-04 22:27:50 +0000 | [diff] [blame] | 235 | void RenderTextControlSingleLine::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 236 | { |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 237 | m_desiredInnerTextLogicalHeight = -1; |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 238 | RenderTextControl::styleDidChange(diff, oldStyle); |
| 239 | |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 240 | // We may have set the width and the height in the old style in layout(). |
| 241 | // Reset them now to avoid getting a spurious layout hint. |
tkent@chromium.org | 72e4ae9 | 2011-05-23 10:10:38 +0000 | [diff] [blame] | 242 | HTMLElement* innerBlock = innerBlockElement(); |
| 243 | if (RenderObject* innerBlockRenderer = innerBlock ? innerBlock->renderer() : 0) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 244 | innerBlockRenderer->style().setHeight(Length()); |
| 245 | innerBlockRenderer->style().setWidth(Length()); |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 246 | } |
| 247 | HTMLElement* container = containerElement(); |
| 248 | if (RenderObject* containerRenderer = container ? container->renderer() : 0) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 249 | containerRenderer->style().setHeight(Length()); |
| 250 | containerRenderer->style().setWidth(Length()); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 251 | } |
weinig@apple.com | eac56f7 | 2013-10-20 04:55:32 +0000 | [diff] [blame] | 252 | RenderTextControlInnerBlock* innerTextRenderer = innerTextElement()->renderer(); |
tkent@chromium.org | 67f1692 | 2013-04-04 01:16:55 +0000 | [diff] [blame] | 253 | if (innerTextRenderer && diff == StyleDifferenceLayout) |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 254 | innerTextRenderer->setNeedsLayout(MarkContainingBlockChain); |
akling@apple.com | ca97cfb | 2013-09-13 05:32:54 +0000 | [diff] [blame] | 255 | if (HTMLElement* placeholder = inputElement().placeholderElement()) |
antti@apple.com | 85635f0 | 2012-02-16 07:39:17 +0000 | [diff] [blame] | 256 | placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldBeTruncated() ? CSSValueEllipsis : CSSValueClip); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 257 | setHasOverflowClip(false); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 258 | } |
| 259 | |
jorlow@chromium.org | 777bf4b | 2010-06-24 10:40:28 +0000 | [diff] [blame] | 260 | bool RenderTextControlSingleLine::hasControlClip() const |
| 261 | { |
tkent@chromium.org | 99e49d8 | 2011-06-30 06:30:23 +0000 | [diff] [blame] | 262 | // Apply control clip for text fields with decorations. |
| 263 | return !!containerElement(); |
jorlow@chromium.org | 777bf4b | 2010-06-24 10:40:28 +0000 | [diff] [blame] | 264 | } |
| 265 | |
leviw@chromium.org | 49fdb33 | 2011-08-18 19:28:33 +0000 | [diff] [blame] | 266 | LayoutRect RenderTextControlSingleLine::controlClipRect(const LayoutPoint& additionalOffset) const |
joepeck@webkit.org | 1fbeab3 | 2010-05-01 02:54:08 +0000 | [diff] [blame] | 267 | { |
joepeck@webkit.org | 1fbeab3 | 2010-05-01 02:54:08 +0000 | [diff] [blame] | 268 | ASSERT(hasControlClip()); |
dominicc@chromium.org | 1caaa51 | 2013-03-08 18:12:39 +0000 | [diff] [blame] | 269 | LayoutRect clipRect = contentBoxRect(); |
| 270 | if (containerElement()->renderBox()) |
| 271 | clipRect = unionRect(clipRect, containerElement()->renderBox()->frameRect()); |
leviw@chromium.org | 35e0131 | 2011-06-03 02:41:09 +0000 | [diff] [blame] | 272 | clipRect.moveBy(additionalOffset); |
joepeck@webkit.org | 1fbeab3 | 2010-05-01 02:54:08 +0000 | [diff] [blame] | 273 | return clipRect; |
| 274 | } |
| 275 | |
mmaxfield@apple.com | d35ea3d | 2014-03-16 00:17:56 +0000 | [diff] [blame] | 276 | float RenderTextControlSingleLine::getAverageCharWidth() |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 277 | { |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 278 | #if !PLATFORM(IOS) |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 279 | // Since Lucida Grande is the default font, we want this to match the width |
| 280 | // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win and |
| 281 | // IE for some encodings (in IE, the default font is encoding specific). |
| 282 | // 901 is the avgCharWidth value in the OS/2 table for MS Shell Dlg. |
antti@apple.com | c54cbc9 | 2015-01-15 14:19:56 +0000 | [diff] [blame] | 283 | if (style().fontCascade().firstFamily() == "Lucida Grande") |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 284 | return scaleEmToUnits(901); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 285 | #endif |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 286 | |
mmaxfield@apple.com | d35ea3d | 2014-03-16 00:17:56 +0000 | [diff] [blame] | 287 | return RenderTextControl::getAverageCharWidth(); |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 288 | } |
commit-queue@webkit.org | 1b4801a | 2011-08-08 09:16:54 +0000 | [diff] [blame] | 289 | |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 290 | LayoutUnit RenderTextControlSingleLine::preferredContentLogicalWidth(float charWidth) const |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 291 | { |
commit-queue@webkit.org | 1b4801a | 2011-08-08 09:16:54 +0000 | [diff] [blame] | 292 | int factor; |
akling@apple.com | ca97cfb | 2013-09-13 05:32:54 +0000 | [diff] [blame] | 293 | bool includesDecoration = inputElement().sizeShouldIncludeDecoration(factor); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 294 | if (factor <= 0) |
| 295 | factor = 20; |
| 296 | |
zalan@apple.com | 81badc1 | 2014-08-26 19:29:09 +0000 | [diff] [blame] | 297 | LayoutUnit result = LayoutUnit::fromFloatCeil(charWidth * factor); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 298 | |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 299 | float maxCharWidth = 0.f; |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 300 | |
| 301 | #if !PLATFORM(IOS) |
antti@apple.com | c54cbc9 | 2015-01-15 14:19:56 +0000 | [diff] [blame] | 302 | const AtomicString& family = style().fontCascade().firstFamily(); |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 303 | // Since Lucida Grande is the default font, we want this to match the width |
| 304 | // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win and |
| 305 | // IE for some encodings (in IE, the default font is encoding specific). |
| 306 | // 4027 is the (xMax - xMin) value in the "head" font table for MS Shell Dlg. |
benjamin@webkit.org | dbf9529 | 2012-11-09 01:15:59 +0000 | [diff] [blame] | 307 | if (family == "Lucida Grande") |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 308 | maxCharWidth = scaleEmToUnits(4027); |
antti@apple.com | c54cbc9 | 2015-01-15 14:19:56 +0000 | [diff] [blame] | 309 | else if (style().fontCascade().hasValidAverageCharWidth()) |
antti@apple.com | 5a8f794 | 2015-01-22 21:57:04 +0000 | [diff] [blame] | 310 | maxCharWidth = roundf(style().fontCascade().primaryFont().maxCharWidth()); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 311 | #endif |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 312 | |
ojan@chromium.org | 149606a | 2009-04-29 20:31:53 +0000 | [diff] [blame] | 313 | // For text inputs, IE adds some extra width. |
ojan@chromium.org | 68b773d | 2010-02-13 03:20:20 +0000 | [diff] [blame] | 314 | if (maxCharWidth > 0.f) |
| 315 | result += maxCharWidth - charWidth; |
ojan@chromium.org | 149606a | 2009-04-29 20:31:53 +0000 | [diff] [blame] | 316 | |
graouts@apple.com | 629cf13 | 2013-08-02 14:58:09 +0000 | [diff] [blame] | 317 | if (includesDecoration) |
akling@apple.com | ca97cfb | 2013-09-13 05:32:54 +0000 | [diff] [blame] | 318 | result += inputElement().decorationWidth(); |
commit-queue@webkit.org | 1b4801a | 2011-08-08 09:16:54 +0000 | [diff] [blame] | 319 | |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 320 | return result; |
| 321 | } |
| 322 | |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 323 | LayoutUnit RenderTextControlSingleLine::computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 324 | { |
tkent@chromium.org | e69b1d1 | 2012-03-07 09:04:58 +0000 | [diff] [blame] | 325 | return lineHeight + nonContentHeight; |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 326 | } |
| 327 | |
akling@apple.com | 689f761 | 2014-12-14 08:21:05 +0000 | [diff] [blame] | 328 | Ref<RenderStyle> RenderTextControlSingleLine::createInnerTextStyle(const RenderStyle* startStyle) const |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 329 | { |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 330 | auto textBlockStyle = RenderStyle::create(); |
| 331 | textBlockStyle.get().inheritFrom(startStyle); |
cdumez@apple.com | 7814173 | 2014-11-04 23:00:48 +0000 | [diff] [blame] | 332 | adjustInnerTextStyle(startStyle, textBlockStyle.get()); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 333 | |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 334 | textBlockStyle.get().setWhiteSpace(PRE); |
| 335 | textBlockStyle.get().setOverflowWrap(NormalOverflowWrap); |
| 336 | textBlockStyle.get().setOverflowX(OHIDDEN); |
| 337 | textBlockStyle.get().setOverflowY(OHIDDEN); |
| 338 | textBlockStyle.get().setTextOverflow(textShouldBeTruncated() ? TextOverflowEllipsis : TextOverflowClip); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 339 | |
hyatt@apple.com | fce3dc7 | 2013-03-11 20:00:37 +0000 | [diff] [blame] | 340 | if (m_desiredInnerTextLogicalHeight >= 0) |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 341 | textBlockStyle.get().setLogicalHeight(Length(m_desiredInnerTextLogicalHeight, Fixed)); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 342 | // Do not allow line-height to be smaller than our default. |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 343 | if (textBlockStyle.get().fontMetrics().lineSpacing() > lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes)) |
| 344 | textBlockStyle.get().setLineHeight(RenderStyle::initialLineHeight()); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 345 | |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 346 | textBlockStyle.get().setDisplay(BLOCK); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 347 | |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 348 | return textBlockStyle; |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 349 | } |
| 350 | |
akling@apple.com | 689f761 | 2014-12-14 08:21:05 +0000 | [diff] [blame] | 351 | Ref<RenderStyle> RenderTextControlSingleLine::createInnerBlockStyle(const RenderStyle* startStyle) const |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 352 | { |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 353 | auto innerBlockStyle = RenderStyle::create(); |
| 354 | innerBlockStyle.get().inheritFrom(startStyle); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 355 | |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 356 | innerBlockStyle.get().setFlexGrow(1); |
commit-queue@webkit.org | a393490 | 2013-03-16 02:27:56 +0000 | [diff] [blame] | 357 | // min-width: 0; is needed for correct shrinking. |
| 358 | // FIXME: Remove this line when https://bugs.webkit.org/show_bug.cgi?id=111790 is fixed. |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 359 | innerBlockStyle.get().setMinWidth(Length(0, Fixed)); |
| 360 | innerBlockStyle.get().setDisplay(BLOCK); |
| 361 | innerBlockStyle.get().setDirection(LTR); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 362 | |
| 363 | // We don't want the shadow dom to be editable, so we set this block to read-only in case the input itself is editable. |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 364 | innerBlockStyle.get().setUserModify(READ_ONLY); |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 365 | |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 366 | return innerBlockStyle; |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 367 | } |
| 368 | |
jonlee@apple.com | 666eb27 | 2012-01-19 22:56:14 +0000 | [diff] [blame] | 369 | bool RenderTextControlSingleLine::textShouldBeTruncated() const |
| 370 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 371 | return document().focusedElement() != &inputElement() && style().textOverflow() == TextOverflowEllipsis; |
jonlee@apple.com | 666eb27 | 2012-01-19 22:56:14 +0000 | [diff] [blame] | 372 | } |
| 373 | |
yosin@chromium.org | b0690b6 | 2013-01-21 01:29:07 +0000 | [diff] [blame] | 374 | void RenderTextControlSingleLine::autoscroll(const IntPoint& position) |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 375 | { |
weinig@apple.com | eac56f7 | 2013-10-20 04:55:32 +0000 | [diff] [blame] | 376 | RenderTextControlInnerBlock* renderer = innerTextElement()->renderer(); |
dominicc@chromium.org | 1caaa51 | 2013-03-08 18:12:39 +0000 | [diff] [blame] | 377 | if (!renderer) |
| 378 | return; |
| 379 | RenderLayer* layer = renderer->layer(); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 380 | if (layer) |
yosin@chromium.org | b0690b6 | 2013-01-21 01:29:07 +0000 | [diff] [blame] | 381 | layer->autoscroll(position); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 382 | } |
| 383 | |
eae@chromium.org | 0559285 | 2011-11-23 08:21:18 +0000 | [diff] [blame] | 384 | int RenderTextControlSingleLine::scrollWidth() const |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 385 | { |
| 386 | if (innerTextElement()) |
| 387 | return innerTextElement()->scrollWidth(); |
weinig@apple.com | 19f6a18 | 2013-10-19 21:43:30 +0000 | [diff] [blame] | 388 | return RenderBlockFlow::scrollWidth(); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 389 | } |
| 390 | |
eae@chromium.org | 0559285 | 2011-11-23 08:21:18 +0000 | [diff] [blame] | 391 | int RenderTextControlSingleLine::scrollHeight() const |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 392 | { |
| 393 | if (innerTextElement()) |
| 394 | return innerTextElement()->scrollHeight(); |
weinig@apple.com | 19f6a18 | 2013-10-19 21:43:30 +0000 | [diff] [blame] | 395 | return RenderBlockFlow::scrollHeight(); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 396 | } |
| 397 | |
eae@chromium.org | 0559285 | 2011-11-23 08:21:18 +0000 | [diff] [blame] | 398 | int RenderTextControlSingleLine::scrollLeft() const |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 399 | { |
| 400 | if (innerTextElement()) |
| 401 | return innerTextElement()->scrollLeft(); |
weinig@apple.com | 19f6a18 | 2013-10-19 21:43:30 +0000 | [diff] [blame] | 402 | return RenderBlockFlow::scrollLeft(); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 403 | } |
| 404 | |
eae@chromium.org | 0559285 | 2011-11-23 08:21:18 +0000 | [diff] [blame] | 405 | int RenderTextControlSingleLine::scrollTop() const |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 406 | { |
| 407 | if (innerTextElement()) |
| 408 | return innerTextElement()->scrollTop(); |
weinig@apple.com | 19f6a18 | 2013-10-19 21:43:30 +0000 | [diff] [blame] | 409 | return RenderBlockFlow::scrollTop(); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 410 | } |
| 411 | |
eae@chromium.org | 0559285 | 2011-11-23 08:21:18 +0000 | [diff] [blame] | 412 | void RenderTextControlSingleLine::setScrollLeft(int newLeft) |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 413 | { |
| 414 | if (innerTextElement()) |
| 415 | innerTextElement()->setScrollLeft(newLeft); |
| 416 | } |
| 417 | |
eae@chromium.org | 0559285 | 2011-11-23 08:21:18 +0000 | [diff] [blame] | 418 | void RenderTextControlSingleLine::setScrollTop(int newTop) |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 419 | { |
| 420 | if (innerTextElement()) |
| 421 | innerTextElement()->setScrollTop(newTop); |
| 422 | } |
| 423 | |
bfulgham@apple.com | 9c36fbd | 2014-02-03 23:10:31 +0000 | [diff] [blame] | 424 | bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint) |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 425 | { |
weinig@apple.com | eac56f7 | 2013-10-20 04:55:32 +0000 | [diff] [blame] | 426 | RenderTextControlInnerBlock* renderer = innerTextElement()->renderer(); |
dominicc@chromium.org | 1caaa51 | 2013-03-08 18:12:39 +0000 | [diff] [blame] | 427 | if (!renderer) |
| 428 | return false; |
| 429 | RenderLayer* layer = renderer->layer(); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 430 | if (layer && layer->scroll(direction, granularity, multiplier)) |
| 431 | return true; |
bfulgham@apple.com | 9c36fbd | 2014-02-03 23:10:31 +0000 | [diff] [blame] | 432 | return RenderBlockFlow::scroll(direction, granularity, multiplier, stopElement, startBox, wheelEventAbsolutePoint); |
eric@webkit.org | d2bb5a0 | 2009-03-17 23:44:11 +0000 | [diff] [blame] | 433 | } |
| 434 | |
akling@apple.com | ca89545 | 2013-09-25 15:40:58 +0000 | [diff] [blame] | 435 | bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement) |
hyatt@apple.com | a60d0ce | 2010-12-13 20:14:28 +0000 | [diff] [blame] | 436 | { |
weinig@apple.com | eac56f7 | 2013-10-20 04:55:32 +0000 | [diff] [blame] | 437 | RenderLayer* layer = innerTextElement()->renderer()->layer(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 438 | if (layer && layer->scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, multiplier)) |
hyatt@apple.com | a60d0ce | 2010-12-13 20:14:28 +0000 | [diff] [blame] | 439 | return true; |
weinig@apple.com | 19f6a18 | 2013-10-19 21:43:30 +0000 | [diff] [blame] | 440 | return RenderBlockFlow::logicalScroll(direction, granularity, multiplier, stopElement); |
hyatt@apple.com | a60d0ce | 2010-12-13 20:14:28 +0000 | [diff] [blame] | 441 | } |
| 442 | |
akling@apple.com | ca97cfb | 2013-09-13 05:32:54 +0000 | [diff] [blame] | 443 | HTMLInputElement& RenderTextControlSingleLine::inputElement() const |
zimmermann@webkit.org | dceb5db | 2009-01-20 21:02:58 +0000 | [diff] [blame] | 444 | { |
cdumez@apple.com | 72754ba | 2014-09-23 22:03:15 +0000 | [diff] [blame] | 445 | return downcast<HTMLInputElement>(RenderTextControl::textFormControlElement()); |
zimmermann@webkit.org | dceb5db | 2009-01-20 21:02:58 +0000 | [diff] [blame] | 446 | } |
| 447 | |
zimmermann@webkit.org | 9402bba | 2008-12-28 13:54:17 +0000 | [diff] [blame] | 448 | } |