- Revision
- 184149
- Author
- [email protected]
- Date
- 2015-05-11 19:45:47 -0700 (Mon, 11 May 2015)
Log Message
<rdar://problem/19773721> [iOS] Find on page feels like it zooms in too much
https://bugs.webkit.org/show_bug.cgi?id=144891
Reviewed by Darin Adler.
Sometimes, Find on Page’s constant 1.6 scale factor is too much. Smart magnification is
designed to choose a scale factor that is just right.
* UIProcess/ios/SmartMagnificationController.h:
* UIProcess/ios/SmartMagnificationController.messages.in: Added Magnify message.
* UIProcess/ios/SmartMagnificationController.mm:
(WebKit::SmartMagnificationController::magnify): Added. Handle the new message using
-[WKContentView _soomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:].
* WebProcess/WebPage/ios/FindControllerIOS.mm:
(WebKit::FindController::updateFindIndicator): Instead of zooming to the selection rect,
get the surrounding render rect (the area we would target for a double-tap at the beginning
of the selection), and tell the magnification controller to target it. Use the center of the
start of the selection as the origin.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (184148 => 184149)
--- trunk/Source/WebKit2/ChangeLog 2015-05-12 02:39:37 UTC (rev 184148)
+++ trunk/Source/WebKit2/ChangeLog 2015-05-12 02:45:47 UTC (rev 184149)
@@ -1,3 +1,24 @@
+2015-05-11 Dan Bernstein <[email protected]>
+
+ <rdar://problem/19773721> [iOS] Find on page feels like it zooms in too much
+ https://bugs.webkit.org/show_bug.cgi?id=144891
+
+ Reviewed by Darin Adler.
+
+ Sometimes, Find on Page’s constant 1.6 scale factor is too much. Smart magnification is
+ designed to choose a scale factor that is just right.
+
+ * UIProcess/ios/SmartMagnificationController.h:
+ * UIProcess/ios/SmartMagnificationController.messages.in: Added Magnify message.
+ * UIProcess/ios/SmartMagnificationController.mm:
+ (WebKit::SmartMagnificationController::magnify): Added. Handle the new message using
+ -[WKContentView _soomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:].
+ * WebProcess/WebPage/ios/FindControllerIOS.mm:
+ (WebKit::FindController::updateFindIndicator): Instead of zooming to the selection rect,
+ get the surrounding render rect (the area we would target for a double-tap at the beginning
+ of the selection), and tell the magnification controller to target it. Use the center of the
+ start of the selection as the origin.
+
2015-05-11 Brent Fulgham <[email protected]>
Scroll snap logic should be triggered when resizing the WebView
Modified: trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.h (184148 => 184149)
--- trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.h 2015-05-12 02:39:37 UTC (rev 184148)
+++ trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.h 2015-05-12 02:45:47 UTC (rev 184149)
@@ -54,6 +54,7 @@
virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);
+ void magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale);
WebPageProxy& m_webPageProxy;
WKContentView *m_contentView;
Modified: trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.messages.in (184148 => 184149)
--- trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.messages.in 2015-05-12 02:39:37 UTC (rev 184148)
+++ trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.messages.in 2015-05-12 02:45:47 UTC (rev 184149)
@@ -24,6 +24,7 @@
messages -> SmartMagnificationController {
DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)
+ Magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale)
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm (184148 => 184149)
--- trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm 2015-05-12 02:39:37 UTC (rev 184148)
+++ trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm 2015-05-12 02:45:47 UTC (rev 184149)
@@ -115,7 +115,18 @@
// FIXME: If we still don't zoom, send the tap along to text selection (see <rdar://problem/6810344>).
[m_contentView _zoomOutWithOrigin:origin];
}
-
+
+void SmartMagnificationController::magnify(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale)
+{
+ targetRect.inflateX(smartMagnificationElementPadding * targetRect.width());
+ targetRect.inflateY(smartMagnificationElementPadding * targetRect.height());
+
+ double maximumScale = std::min(viewportMaximumScale, smartMagnificationMaximumScale);
+ double minimumScale = std::max(viewportMinimumScale, smartMagnificationMinimumScale);
+
+ [m_contentView _zoomToRect:targetRect withOrigin:origin fitEntireRect:NO minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:0];
+}
+
} // namespace WebKit
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm (184148 => 184149)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm 2015-05-12 02:39:37 UTC (rev 184148)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm 2015-05-12 02:45:47 UTC (rev 184149)
@@ -29,6 +29,7 @@
#import "FindController.h"
#import "FindIndicatorOverlayClientIOS.h"
+#import "SmartMagnificationControllerMessages.h"
#import "WebCoreArgumentCoders.h"
#import "WebPage.h"
#import "WebPageProxyMessages.h"
@@ -44,8 +45,6 @@
const int totalHorizontalMargin = 2;
const int totalVerticalMargin = 1;
-const double maximumFindIndicatorZoom = 1.6;
-
static Color highlightColor()
{
return Color(255, 228, 56, 255);
@@ -95,9 +94,18 @@
m_findIndicatorOverlay->setFrame(matchRect);
m_findIndicatorOverlay->setNeedsDisplay();
- if (isShowingOverlay || shouldAnimate)
- m_webPage->zoomToRect(matchRect, m_webPage->minimumPageScaleFactor(), std::min(m_webPage->maximumPageScaleFactor(), maximumFindIndicatorZoom));
+ if (isShowingOverlay || shouldAnimate) {
+ FloatRect visibleContentRect = m_webPage->mainFrameView()->unobscuredContentRectIncludingScrollbars();
+ bool isReplaced;
+ const VisibleSelection& visibleSelection = selectedFrame.selection().selection();
+ FloatRect renderRect = visibleSelection.start().containerNode()->renderRect(&isReplaced);
+
+ IntRect startRect = visibleSelection.visibleStart().absoluteCaretBounds();
+
+ m_webPage->send(Messages::SmartMagnificationController::Magnify(startRect.center(), renderRect, visibleContentRect, m_webPage->minimumPageScaleFactor(), m_webPage->maximumPageScaleFactor()));
+ }
+
m_findIndicatorRect = matchRect;
m_isShowingFindIndicator = true;