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

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: Really works now. 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 3422f11af0f4d3c0f441cb0314a142b345b403bd..ba95ffb7624822434a7bf84c68d9d7eec87d71da 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -976,7 +976,7 @@ bool WebViewImpl::endActiveFlingAnimation()
return false;
}
-bool WebViewImpl::startPageScaleAnimation(const IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds)
+void WebViewImpl::startPageScaleAnimation(const IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds)
{
VisualViewport& visualViewport = page()->frameHost().visualViewport();
WebPoint clampedPoint = targetPosition;
@@ -988,23 +988,18 @@ bool WebViewImpl::startPageScaleAnimation(const IntPoint& targetPosition, bool u
FrameView* view = mainFrameImpl()->frameView();
if (view && view->getScrollableArea())
view->getScrollableArea()->setScrollPosition(DoublePoint(clampedPoint.x, clampedPoint.y), ProgrammaticScroll);
-
- return false;
}
}
if (useAnchor && newScale == pageScaleFactor())
- return false;
+ return;
if (m_enableFakePageScaleAnimationForTesting) {
m_fakePageScaleAnimationTargetPosition = targetPosition;
m_fakePageScaleAnimationUseAnchor = useAnchor;
m_fakePageScaleAnimationPageScaleFactor = newScale;
- } else {
- if (!m_layerTreeView)
- return false;
+ } else if (m_layerTreeView) {
m_layerTreeView->startPageScaleAnimation(targetPosition, useAnchor, newScale, durationInSeconds);
}
- return true;
}
void WebViewImpl::enableFakePageScaleAnimationForTesting(bool enable)
@@ -1449,17 +1444,15 @@ void WebViewImpl::animateDoubleTapZoom(const IntPoint& pointInRootFrame)
bool scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference;
bool shouldZoomOut = blockBounds.isEmpty() || scaleUnchanged || stillAtPreviousDoubleTapScale;
- bool isAnimating;
-
if (shouldZoomOut) {
scale = minimumPageScaleFactor();
IntPoint targetPosition = mainFrameImpl()->frameView()->rootFrameToContents(pointInRootFrame);
- isAnimating = startPageScaleAnimation(targetPosition, true, scale, doubleTapZoomAnimationDurationInSeconds);
+ startPageScaleAnimation(targetPosition, true, scale, doubleTapZoomAnimationDurationInSeconds);
} else {
- isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoomAnimationDurationInSeconds);
+ startPageScaleAnimation(scroll, false, scale, doubleTapZoomAnimationDurationInSeconds);
}
- if (isAnimating) {
+ if (m_layerTreeView->hasPendingPageScaleAnimation()) {
m_doubleTapZoomPageScaleFactor = scale;
m_doubleTapZoomPending = true;
}
@@ -2938,7 +2931,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;
@@ -2946,6 +2955,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()
@@ -2965,9 +2977,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)

Powered by Google App Engine
This is Rietveld 408576698