Changeset 184149 in webkit


Ignore:
Timestamp:
May 11, 2015 7:45:47 PM (9 years ago)
Author:
mitz@apple.com
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.

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r184139 r184149  
     12015-05-11  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/19773721> [iOS] Find on page feels like it zooms in too much
     4        https://bugs.webkit.org/show_bug.cgi?id=144891
     5
     6        Reviewed by Darin Adler.
     7
     8        Sometimes, Find on Page’s constant 1.6 scale factor is too much. Smart magnification is
     9        designed to choose a scale factor that is just right.
     10
     11        * UIProcess/ios/SmartMagnificationController.h:
     12        * UIProcess/ios/SmartMagnificationController.messages.in: Added Magnify message.
     13        * UIProcess/ios/SmartMagnificationController.mm:
     14        (WebKit::SmartMagnificationController::magnify): Added. Handle the new message using
     15        -[WKContentView _soomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:].
     16        * WebProcess/WebPage/ios/FindControllerIOS.mm:
     17        (WebKit::FindController::updateFindIndicator): Instead of zooming to the selection rect,
     18        get the surrounding render rect (the area we would target for a double-tap at the beginning
     19        of the selection), and tell the magnification controller to target it. Use the center of the
     20        start of the selection as the origin.
     21
    1222015-05-11  Brent Fulgham  <bfulgham@apple.com>
    223
  • trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.h

    r177917 r184149  
    5555
    5656    void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);
     57    void magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale);
    5758
    5859    WebPageProxy& m_webPageProxy;
  • trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.messages.in

    r164937 r184149  
    2525messages -> SmartMagnificationController {
    2626    DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)
     27    Magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale)
    2728}
    2829
  • trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm

    r178080 r184149  
    116116    [m_contentView _zoomOutWithOrigin:origin];
    117117}
    118    
     118
     119void SmartMagnificationController::magnify(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale)
     120{
     121    targetRect.inflateX(smartMagnificationElementPadding * targetRect.width());
     122    targetRect.inflateY(smartMagnificationElementPadding * targetRect.height());
     123
     124    double maximumScale = std::min(viewportMaximumScale, smartMagnificationMaximumScale);
     125    double minimumScale = std::max(viewportMinimumScale, smartMagnificationMinimumScale);
     126
     127    [m_contentView _zoomToRect:targetRect withOrigin:origin fitEntireRect:NO minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:0];
     128}
     129
    119130} // namespace WebKit
    120131
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm

    r178755 r184149  
    3030#import "FindController.h"
    3131#import "FindIndicatorOverlayClientIOS.h"
     32#import "SmartMagnificationControllerMessages.h"
    3233#import "WebCoreArgumentCoders.h"
    3334#import "WebPage.h"
     
    4445const int totalHorizontalMargin = 2;
    4546const int totalVerticalMargin = 1;
    46 
    47 const double maximumFindIndicatorZoom = 1.6;
    4847
    4948static Color highlightColor()
     
    9695    m_findIndicatorOverlay->setNeedsDisplay();
    9796
    98     if (isShowingOverlay || shouldAnimate)
    99         m_webPage->zoomToRect(matchRect, m_webPage->minimumPageScaleFactor(), std::min(m_webPage->maximumPageScaleFactor(), maximumFindIndicatorZoom));
     97    if (isShowingOverlay || shouldAnimate) {
     98        FloatRect visibleContentRect = m_webPage->mainFrameView()->unobscuredContentRectIncludingScrollbars();
     99
     100        bool isReplaced;
     101        const VisibleSelection& visibleSelection = selectedFrame.selection().selection();
     102        FloatRect renderRect = visibleSelection.start().containerNode()->renderRect(&isReplaced);
     103
     104        IntRect startRect = visibleSelection.visibleStart().absoluteCaretBounds();
     105
     106        m_webPage->send(Messages::SmartMagnificationController::Magnify(startRect.center(), renderRect, visibleContentRect, m_webPage->minimumPageScaleFactor(), m_webPage->maximumPageScaleFactor()));
     107    }
    100108
    101109    m_findIndicatorRect = matchRect;
Note: See TracChangeset for help on using the changeset viewer.