- Revision
- 123241
- Author
- [email protected]
- Date
- 2012-07-20 11:19:39 -0700 (Fri, 20 Jul 2012)
Log Message
[Chromium] Add WebView::zoomToFindInPageRect for Android
https://bugs.webkit.org/show_bug.cgi?id=91801
Reviewed by Tony Chang.
On Android, when you find in page, we scale the viewport to reveal what
you've found (because the screen is small). This function instructs the
WebView to zoom to display a given rect.
* public/WebView.h:
(WebView):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::animateZoomAroundPoint):
- This function is a bit more general than necessary for this patch
because it is also used in other cases for animating a zoom
around a given point (e.g., double-tap to zoom). These uses will
be upstreamed in later patches.
(WebKit::WebViewImpl::zoomToFindInPageRect):
* src/WebViewImpl.h:
(WebViewImpl):
Modified Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (123240 => 123241)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-07-20 18:13:17 UTC (rev 123240)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-07-20 18:19:39 UTC (rev 123241)
@@ -1,3 +1,26 @@
+2012-07-20 Adam Barth <[email protected]>
+
+ [Chromium] Add WebView::zoomToFindInPageRect for Android
+ https://bugs.webkit.org/show_bug.cgi?id=91801
+
+ Reviewed by Tony Chang.
+
+ On Android, when you find in page, we scale the viewport to reveal what
+ you've found (because the screen is small). This function instructs the
+ WebView to zoom to display a given rect.
+
+ * public/WebView.h:
+ (WebView):
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::animateZoomAroundPoint):
+ - This function is a bit more general than necessary for this patch
+ because it is also used in other cases for animating a zoom
+ around a given point (e.g., double-tap to zoom). These uses will
+ be upstreamed in later patches.
+ (WebKit::WebViewImpl::zoomToFindInPageRect):
+ * src/WebViewImpl.h:
+ (WebViewImpl):
+
2012-07-19 Luke Macpherson <[email protected]>
Enable CSS variables compile time flag in Chrome.
Modified: trunk/Source/WebKit/chromium/public/WebView.h (123240 => 123241)
--- trunk/Source/WebKit/chromium/public/WebView.h 2012-07-20 18:13:17 UTC (rev 123240)
+++ trunk/Source/WebKit/chromium/public/WebView.h 2012-07-20 18:19:39 UTC (rev 123241)
@@ -196,7 +196,10 @@
// previous element in the tab sequence (if reverse is true).
virtual void advanceFocus(bool reverse) { }
+ // Animate a scale into the specified find-in-page rect.
+ virtual void zoomToFindInPageRect(const WebRect&) = 0;
+
// Zoom ----------------------------------------------------------------
// Returns the current zoom level. 0 is "original size", and each increment
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (123240 => 123241)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-07-20 18:13:17 UTC (rev 123240)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-07-20 18:19:39 UTC (rev 123241)
@@ -195,7 +195,9 @@
static const float minScaleDifference = 0.01f;
static const float doubleTapZoomContentDefaultMargin = 5;
static const float doubleTapZoomContentMinimumMargin = 2;
+static const double doubleTabZoomAnimationDurationInSeconds = 0.25;
+
namespace WebKit {
// Change the text zoom level by kTextSizeMultiplierRatio each time the user
@@ -745,10 +747,10 @@
m_layerTreeView.renderingStats(stats);
}
-void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec)
+void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationInSeconds)
{
if (!m_layerTreeView.isNull())
- m_layerTreeView.startPageScaleAnimation(scroll, useAnchor, newScale, durationSec);
+ m_layerTreeView.startPageScaleAnimation(scroll, useAnchor, newScale, durationInSeconds);
}
#endif
@@ -1073,6 +1075,27 @@
}
#endif
+void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoomType)
+{
+#if ENABLE(GESTURE_EVENTS)
+ if (!mainFrameImpl())
+ return;
+
+ float scale;
+ WebPoint scroll;
+ computeScaleAndScrollForHitRect(WebRect(point.x(), point.y(), 0, 0), zoomType, scale, scroll);
+
+ bool isDoubleTap = (zoomType == DoubleTap);
+ double durationInSeconds = isDoubleTap ? doubleTabZoomAnimationDurationInSeconds : 0;
+ startPageScaleAnimation(scroll, isDoubleTap, scale, durationInSeconds);
+#endif
+}
+
+void WebViewImpl::zoomToFindInPageRect(const WebRect& rect)
+{
+ animateZoomAroundPoint(IntRect(rect).center(), FindInPage);
+}
+
void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandlers)
{
if (m_client)
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (123240 => 123241)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-07-20 18:13:17 UTC (rev 123240)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-07-20 18:19:39 UTC (rev 123241)
@@ -205,6 +205,7 @@
virtual void clearFocusedNode();
virtual void scrollFocusedNodeIntoView();
virtual void scrollFocusedNodeIntoRect(const WebRect&);
+ virtual void zoomToFindInPageRect(const WebRect&);
virtual void advanceFocus(bool reverse);
virtual double zoomLevel();
virtual double setZoomLevel(bool textOnly, double zoomLevel);
@@ -376,7 +377,7 @@
// Event related methods:
void mouseContextMenu(const WebMouseEvent&);
void mouseDoubleClick(const WebMouseEvent&);
- void startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationSec);
+ void startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds);
void numberOfWheelEventHandlersChanged(unsigned);
void numberOfTouchEventHandlersChanged(unsigned);
@@ -547,6 +548,7 @@
#if ENABLE(GESTURE_EVENTS)
void computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType, float& scale, WebPoint& scroll);
#endif
+ void animateZoomAroundPoint(const WebCore::IntPoint&, AutoZoomType);
void loseCompositorContext(int numTimes);