Chromium Code Reviews| Index: third_party/WebKit/Source/web/WebViewImpl.cpp |
| diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp |
| index fd23e7d86da1bf751f3944a3aa9ea218c16baeb4..d8b1b4f0860907b0f58d578e48020b05ea052e44 100644 |
| --- a/third_party/WebKit/Source/web/WebViewImpl.cpp |
| +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp |
| @@ -2938,7 +2938,23 @@ void WebViewImpl::clearFocusedElement() |
| localFrame->selection().clear(); |
| } |
| -bool WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rectInViewport) |
| +// TODO(dglazkov): Remove and replace with Node:hasEditableStyle. |
| +// http://crbug.com/612560 |
| +static bool isElementEditable(const Element* element) |
| +{ |
| + if (element->isContentEditable()) |
|
dglazkov
2016/05/17 22:00:15
Not loving this duplication. I can try to fold rem
esprehn
2016/05/17 22:16:43
Nah, lets do that next. Feels more likely to break
|
| + return true; |
| + |
| + if (element->isTextFormControl()) { |
| + const HTMLTextFormControlElement* input = toHTMLTextFormControlElement(element); |
| + if (!input->isDisabledOrReadOnly()) |
| + return true; |
| + } |
| + |
| + return equalIgnoringCase(element->getAttribute(HTMLNames::roleAttr), "textbox"); |
| +} |
| + |
| +bool WebViewImpl::scrollFocusedEditableElementIntoRect(const WebRect& rectInViewport, bool& willAnimate) |
| { |
| LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame() |
| ? page()->deprecatedLocalMainFrame() : nullptr; |
| @@ -2946,6 +2962,9 @@ bool WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rectInViewport) |
| if (!frame || !frame->view() || !element) |
| return false; |
| + if (!isElementEditable(element)) |
| + return false; |
| + |
| element->document().updateLayoutIgnorePendingStylesheets(); |
| bool zoomInToLegibleScale = m_webSettings->autoZoomFocusedNodeToLegibleScale() |
| @@ -2964,10 +2983,9 @@ bool WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rectInViewport) |
| IntPoint scroll; |
| bool needAnimation; |
| computeScaleAndScrollForFocusedNode(element, zoomInToLegibleScale, scale, scroll, needAnimation); |
| - if (needAnimation) |
| - return startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnimationDurationInSeconds); |
| + willAnimate = needAnimation ? startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnimationDurationInSeconds) : false; |
| - return false; |
| + return true; |
| } |
| void WebViewImpl::smoothScroll(int targetX, int targetY, long durationMs) |