Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 1990553002: Remove RenderViewImpl::GetFocusedElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698