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

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: Made Windows happy and brought back bool return because fake tests. 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 218f70fe9f3dfa61695497b476055adf4a9d0b69..b8cd9a1a3a0e1098d30747a50eb51dd1a129359d 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -1460,6 +1460,9 @@ void WebViewImpl::animateDoubleTapZoom(const IntPoint& pointInRootFrame)
isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoomAnimationDurationInSeconds);
}
+ // TODO(dglazkov): The only reason why we're using isAnimating and not just checking for
+ // m_layerTreeView->hasPendingPageScaleAnimation() is because of fake page scale animation plumbing
+ // for testing, which doesn't actually initiate a page scale animation.
if (isAnimating) {
m_doubleTapZoomPageScaleFactor = scale;
m_doubleTapZoomPending = true;
@@ -2950,7 +2953,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())
+ 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)
{
LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame()
? page()->deprecatedLocalMainFrame() : nullptr;
@@ -2958,6 +2977,9 @@ bool WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rectInViewport)
if (!frame || !frame->view() || !element)
return false;
+ if (!isElementEditable(element))
+ return false;
+
element->document().updateStyleAndLayoutIgnorePendingStylesheets();
bool zoomInToLegibleScale = m_webSettings->autoZoomFocusedNodeToLegibleScale()
@@ -2977,9 +2999,9 @@ bool WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rectInViewport)
bool needAnimation;
computeScaleAndScrollForFocusedNode(element, zoomInToLegibleScale, scale, scroll, needAnimation);
if (needAnimation)
- return startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnimationDurationInSeconds);
+ startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnimationDurationInSeconds);
- return false;
+ return true;
}
void WebViewImpl::smoothScroll(int targetX, int targetY, long durationMs)
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/web/tests/VisualViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698