diff options
author | Victoria Lease <violets@google.com> | 2012-02-29 17:22:42 -0800 |
---|---|---|
committer | Victoria Lease <violets@google.com> | 2012-03-01 09:33:38 -0800 |
commit | a30818b6d22801f8f2f4d6f29dd83d3eddb67b6f (patch) | |
tree | 3e14eb069d3e4d265c3188a3072d54e4687fbcfa | |
parent | 6753735b5cf1b2396d387b9f876a11a5fd2b3c3d (diff) | |
download | external_webkit-a30818b6d22801f8f2f4d6f29dd83d3eddb67b6f.zip external_webkit-a30818b6d22801f8f2f4d6f29dd83d3eddb67b6f.tar.gz external_webkit-a30818b6d22801f8f2f4d6f29dd83d3eddb67b6f.tar.bz2 |
pin find-on-page scrolls to content edges
Bug: 6066283
This change also contains code to prevent find-on-page from scrolling in
unnecessary circumstances, for example when a match is already being displayed.
Change-Id: I555c84f8851a82e854d12cb34b8805c9d3f22f5e
-rw-r--r-- | Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp index b684a1a..e536701 100644 --- a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -49,6 +49,8 @@ #include <wtf/android/AndroidThreading.h> #include <wtf/MainThread.h> +#include <algorithm> + using namespace android; namespace WebCore { @@ -169,18 +171,21 @@ void PlatformBridge::updateTextfield(FrameView* frameView, Node* nodePtr, bool c } void PlatformBridge::setScrollPosition(ScrollView* scrollView, int x, int y) { + FrameView* frameView = scrollView->frameView(); + if (!frameView) return; // Check to make sure the view is the main FrameView. android::WebViewCore *webViewCore = android::WebViewCore::getWebViewCore(scrollView); - if (webViewCore->mainFrame()->view() == scrollView) - webViewCore->scrollTo(x, y); - else { - FrameView* frameView = scrollView->frameView(); - if (frameView) { - RenderView* renderer = frameView->frame()->contentRenderer(); - if (renderer) { - RenderLayer* layer = renderer->layer(); - layer->scrollToOffset(x, y); - } + if (webViewCore->mainFrame()->view() == scrollView) { + const IntRect& visibleContentRect = frameView->visibleContentRect(); + x = std::max(0, std::min(frameView->contentsWidth(), x)); + y = std::max(0, std::min(frameView->contentsHeight(), y)); + if ((x != visibleContentRect.x()) || (y != visibleContentRect.y())) + webViewCore->scrollTo(x, y); + } else { + RenderView* renderer = frameView->frame()->contentRenderer(); + if (renderer) { + RenderLayer* layer = renderer->layer(); + layer->scrollToOffset(x, y); } } } |