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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 bool isAnimating; 1453 bool isAnimating;
1454 1454
1455 if (shouldZoomOut) { 1455 if (shouldZoomOut) {
1456 scale = minimumPageScaleFactor(); 1456 scale = minimumPageScaleFactor();
1457 IntPoint targetPosition = mainFrameImpl()->frameView()->rootFrameToConte nts(pointInRootFrame); 1457 IntPoint targetPosition = mainFrameImpl()->frameView()->rootFrameToConte nts(pointInRootFrame);
1458 isAnimating = startPageScaleAnimation(targetPosition, true, scale, doubl eTapZoomAnimationDurationInSeconds); 1458 isAnimating = startPageScaleAnimation(targetPosition, true, scale, doubl eTapZoomAnimationDurationInSeconds);
1459 } else { 1459 } else {
1460 isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoo mAnimationDurationInSeconds); 1460 isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoo mAnimationDurationInSeconds);
1461 } 1461 }
1462 1462
1463 // TODO(dglazkov): The only reason why we're using isAnimating and not just checking for
1464 // m_layerTreeView->hasPendingPageScaleAnimation() is because of fake page s cale animation plumbing
1465 // for testing, which doesn't actually initiate a page scale animation.
1463 if (isAnimating) { 1466 if (isAnimating) {
1464 m_doubleTapZoomPageScaleFactor = scale; 1467 m_doubleTapZoomPageScaleFactor = scale;
1465 m_doubleTapZoomPending = true; 1468 m_doubleTapZoomPending = true;
1466 } 1469 }
1467 } 1470 }
1468 1471
1469 void WebViewImpl::zoomToFindInPageRect(const WebRect& rectInRootFrame) 1472 void WebViewImpl::zoomToFindInPageRect(const WebRect& rectInRootFrame)
1470 { 1473 {
1471 if (!mainFrameImpl()) 1474 if (!mainFrameImpl())
1472 return; 1475 return;
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 return; 2946 return;
2944 2947
2945 // If a text field has focus, we need to make sure the selection controller 2948 // If a text field has focus, we need to make sure the selection controller
2946 // knows to remove selection from it. Otherwise, the text field is still 2949 // knows to remove selection from it. Otherwise, the text field is still
2947 // processing keyboard events even though focus has been moved to the page a nd 2950 // processing keyboard events even though focus has been moved to the page a nd
2948 // keystrokes get eaten as a result. 2951 // keystrokes get eaten as a result.
2949 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC ontrol()) 2952 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC ontrol())
2950 localFrame->selection().clear(); 2953 localFrame->selection().clear();
2951 } 2954 }
2952 2955
2953 bool WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rectInViewport) 2956 // TODO(dglazkov): Remove and replace with Node:hasEditableStyle.
2957 // http://crbug.com/612560
2958 static bool isElementEditable(const Element* element)
2959 {
2960 if (element->isContentEditable())
2961 return true;
2962
2963 if (element->isTextFormControl()) {
2964 const HTMLTextFormControlElement* input = toHTMLTextFormControlElement(e lement);
2965 if (!input->isDisabledOrReadOnly())
2966 return true;
2967 }
2968
2969 return equalIgnoringCase(element->getAttribute(HTMLNames::roleAttr), "textbo x");
2970 }
2971
2972 bool WebViewImpl::scrollFocusedEditableElementIntoRect(const WebRect& rectInView port)
2954 { 2973 {
2955 LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame () 2974 LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame ()
2956 ? page()->deprecatedLocalMainFrame() : nullptr; 2975 ? page()->deprecatedLocalMainFrame() : nullptr;
2957 Element* element = focusedElement(); 2976 Element* element = focusedElement();
2958 if (!frame || !frame->view() || !element) 2977 if (!frame || !frame->view() || !element)
2959 return false; 2978 return false;
2960 2979
2980 if (!isElementEditable(element))
2981 return false;
2982
2961 element->document().updateStyleAndLayoutIgnorePendingStylesheets(); 2983 element->document().updateStyleAndLayoutIgnorePendingStylesheets();
2962 2984
2963 bool zoomInToLegibleScale = m_webSettings->autoZoomFocusedNodeToLegibleScale () 2985 bool zoomInToLegibleScale = m_webSettings->autoZoomFocusedNodeToLegibleScale ()
2964 && !page()->frameHost().visualViewport().shouldDisableDesktopWorkarounds (); 2986 && !page()->frameHost().visualViewport().shouldDisableDesktopWorkarounds ();
2965 2987
2966 if (zoomInToLegibleScale) { 2988 if (zoomInToLegibleScale) {
2967 // When deciding whether to zoom in on a focused text box, we should dec ide not to 2989 // When deciding whether to zoom in on a focused text box, we should dec ide not to
2968 // zoom in if the user won't be able to zoom out. e.g if the textbox is within a 2990 // zoom in if the user won't be able to zoom out. e.g if the textbox is within a
2969 // touch-action: none container the user can't zoom back out. 2991 // touch-action: none container the user can't zoom back out.
2970 TouchAction action = TouchActionUtil::computeEffectiveTouchAction(*eleme nt); 2992 TouchAction action = TouchActionUtil::computeEffectiveTouchAction(*eleme nt);
2971 if (!(action & TouchActionPinchZoom)) 2993 if (!(action & TouchActionPinchZoom))
2972 zoomInToLegibleScale = false; 2994 zoomInToLegibleScale = false;
2973 } 2995 }
2974 2996
2975 float scale; 2997 float scale;
2976 IntPoint scroll; 2998 IntPoint scroll;
2977 bool needAnimation; 2999 bool needAnimation;
2978 computeScaleAndScrollForFocusedNode(element, zoomInToLegibleScale, scale, sc roll, needAnimation); 3000 computeScaleAndScrollForFocusedNode(element, zoomInToLegibleScale, scale, sc roll, needAnimation);
2979 if (needAnimation) 3001 if (needAnimation)
2980 return startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnima tionDurationInSeconds); 3002 startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnimationDur ationInSeconds);
2981 3003
2982 return false; 3004 return true;
2983 } 3005 }
2984 3006
2985 void WebViewImpl::smoothScroll(int targetX, int targetY, long durationMs) 3007 void WebViewImpl::smoothScroll(int targetX, int targetY, long durationMs)
2986 { 3008 {
2987 IntPoint targetPosition(targetX, targetY); 3009 IntPoint targetPosition(targetX, targetY);
2988 startPageScaleAnimation(targetPosition, false, pageScaleFactor(), (double)du rationMs / 1000); 3010 startPageScaleAnimation(targetPosition, false, pageScaleFactor(), (double)du rationMs / 1000);
2989 } 3011 }
2990 3012
2991 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, bool zo omInToLegibleScale, float& newScale, IntPoint& newScroll, bool& needAnimation) 3013 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, bool zo omInToLegibleScale, float& newScale, IntPoint& newScroll, bool& needAnimation)
2992 { 3014 {
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
4534 { 4556 {
4535 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4557 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4536 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4558 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4537 if (!page()) 4559 if (!page())
4538 return 1; 4560 return 1;
4539 4561
4540 return page()->deviceScaleFactor(); 4562 return page()->deviceScaleFactor();
4541 } 4563 }
4542 4564
4543 } // namespace blink 4565 } // namespace blink
OLDNEW
« 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