<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160923] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160923">160923</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2013-12-20 14:01:27 -0800 (Fri, 20 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebKit2 View Gestures: Implement smartMagnifyWithEvent: and make it work
https://bugs.webkit.org/show_bug.cgi?id=125752
&lt;rdar://problem/15664245&gt;

Reviewed by Anders Carlsson.

Implement &quot;smart magnify&quot;, which is the double-tap-to-zoom gesture on OS X.

* UIProcess/API/mac/WKView.mm:
(-[WKView smartMagnifyWithEvent:]):
Forward smartMagnifyWithEvent to ViewGestureController.

* UIProcess/mac/ViewGestureController.cpp:
(WebKit::ViewGestureController::handleMagnificationGesture):
Drive-by repair a comment.

(WebKit::ViewGestureController::handleSmartMagnificationGesture):
Added. Immediately dispatch a message to the web process to retrieve
the rendered rect of the element under the gesture.

(WebKit::maximumRectangleComponentDelta):
Return the absolute maximum delta between corresponding components of two rects.

(WebKit::ViewGestureController::didCollectGeometryForSmartMagnificationGesture):
Once the WebProcess has replied with the relevant geometry, use it to
determine our target rectangle (the element's rect, with some padding)
and target magnification (attempting to keep replaced elements
fully in-view, and otherwise zooming in as far as possible to fit the
element's width).

If this gesture occurs after the page is already magnified, and targets
a similar region to the previous smart magnification gesture, zoom out
instead of panning across the page.

Begin a transient zoom with the current magnification, and immediately
commit it at our target magnification and offset, so that the drawing
area will animate to the new parameters.

(WebKit::ViewGestureController::endActiveGesture):
* UIProcess/mac/ViewGestureController.h:
* UIProcess/mac/ViewGestureController.messages.in:
* WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
(WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture):
Hit-test the document to determine the node under the smart magnification
gesture, and return it to the UI process along with various other bits of data.

* WebProcess/WebPage/ViewGestureGeometryCollector.h:
* WebProcess/WebPage/ViewGestureGeometryCollector.messages.in:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::adjustTransientZoom):
(WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):
(WebKit::TiledCoreAnimationDrawingArea::applyTransientZoomToPage):
Instead of short-circuiting the animation if we didn't have to constrain
the origin, short-circuit if we're already *at* the right origin,
like the comment said. This prevents jarring jumps when double-tap-panning
between elements when zoomed all the way in.

* WebCore.exp.in:
Add some exports.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllercpp">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerh">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllermessagesin">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageViewGestureGeometryCollectorcpp">trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageViewGestureGeometryCollectorh">trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageViewGestureGeometryCollectormessagesin">trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreamm">trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebCore/ChangeLog        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2013-12-20  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        WebKit2 View Gestures: Implement smartMagnifyWithEvent: and make it work
+        https://bugs.webkit.org/show_bug.cgi?id=125752
+        &lt;rdar://problem/15664245&gt;
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.exp.in:
+        Add some exports.
+
</ins><span class="cx"> 2013-12-20  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         http/tests/misc/object-image-error.html asserts
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebCore/WebCore.exp.in        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -283,6 +283,7 @@
</span><span class="cx"> __ZN7WebCore13HTTPHeaderMapD1Ev
</span><span class="cx"> __ZN7WebCore13HitTestResultC1ERKNS_11LayoutPointE
</span><span class="cx"> __ZN7WebCore13HitTestResultC1ERKNS_11LayoutPointEjjjj
</span><ins>+__ZN7WebCore13HitTestResultC1ERKNS_15HitTestLocationE
</ins><span class="cx"> __ZN7WebCore13HitTestResultC1ERKS0_
</span><span class="cx"> __ZN7WebCore13HitTestResultD1Ev
</span><span class="cx"> __ZN7WebCore13IdentifierRep3getEPKc
</span><span class="lines">@@ -576,6 +577,8 @@
</span><span class="cx"> __ZN7WebCore15GraphicsLayerCAD2Ev
</span><span class="cx"> __ZN7WebCore15GraphicsLayerCA19setCustomAppearanceENS_13GraphicsLayer16CustomAppearanceE
</span><span class="cx"> __ZN7WebCore15HitTestLocation12rectForPointERKNS_11LayoutPointEjjjj
</span><ins>+__ZN7WebCore15HitTestLocationC1ERKNS_10FloatPointE
+__ZN7WebCore15HitTestLocationD1Ev
</ins><span class="cx"> __ZN7WebCore15JSDOMWindowBase8commonVMEv
</span><span class="cx"> __ZN7WebCore15PasteboardImageC1Ev
</span><span class="cx"> __ZN7WebCore15PasteboardImageD1Ev
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/ChangeLog        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -1,3 +1,64 @@
</span><ins>+2013-12-20  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        WebKit2 View Gestures: Implement smartMagnifyWithEvent: and make it work
+        https://bugs.webkit.org/show_bug.cgi?id=125752
+        &lt;rdar://problem/15664245&gt;
+
+        Reviewed by Anders Carlsson.
+
+        Implement &quot;smart magnify&quot;, which is the double-tap-to-zoom gesture on OS X.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView smartMagnifyWithEvent:]):
+        Forward smartMagnifyWithEvent to ViewGestureController.
+
+        * UIProcess/mac/ViewGestureController.cpp:
+        (WebKit::ViewGestureController::handleMagnificationGesture):
+        Drive-by repair a comment.
+
+        (WebKit::ViewGestureController::handleSmartMagnificationGesture):
+        Added. Immediately dispatch a message to the web process to retrieve
+        the rendered rect of the element under the gesture.
+
+        (WebKit::maximumRectangleComponentDelta):
+        Return the absolute maximum delta between corresponding components of two rects.
+
+        (WebKit::ViewGestureController::didCollectGeometryForSmartMagnificationGesture):
+        Once the WebProcess has replied with the relevant geometry, use it to
+        determine our target rectangle (the element's rect, with some padding)
+        and target magnification (attempting to keep replaced elements
+        fully in-view, and otherwise zooming in as far as possible to fit the
+        element's width).
+
+        If this gesture occurs after the page is already magnified, and targets
+        a similar region to the previous smart magnification gesture, zoom out
+        instead of panning across the page.
+
+        Begin a transient zoom with the current magnification, and immediately
+        commit it at our target magnification and offset, so that the drawing
+        area will animate to the new parameters.
+
+        (WebKit::ViewGestureController::endActiveGesture):
+        * UIProcess/mac/ViewGestureController.h:
+        * UIProcess/mac/ViewGestureController.messages.in:
+        * WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
+        (WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture):
+        Hit-test the document to determine the node under the smart magnification
+        gesture, and return it to the UI process along with various other bits of data.
+
+        * WebProcess/WebPage/ViewGestureGeometryCollector.h:
+        * WebProcess/WebPage/ViewGestureGeometryCollector.messages.in:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+        (WebKit::TiledCoreAnimationDrawingArea::adjustTransientZoom):
+        (WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):
+        (WebKit::TiledCoreAnimationDrawingArea::applyTransientZoomToPage):
+        Instead of short-circuiting the animation if we didn't have to constrain
+        the origin, short-circuit if we're already *at* the right origin,
+        like the comment said. This prevents jarring jumps when double-tap-panning
+        between elements when zoomed all the way in.
+
</ins><span class="cx"> 2013-12-20  Ricky Mondello  &lt;rmondello@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Allow partial application of PlugInAutoStart tables based on timestamp
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -3221,6 +3221,18 @@
</span><span class="cx">     _data-&gt;_gestureController-&gt;handleMagnificationGesture(event.magnification, [self convertPoint:event.locationInWindow fromView:nil]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)smartMagnifyWithEvent:(NSEvent *)event
+{
+    if (!_data-&gt;_allowsMagnification) {
+        [super smartMagnifyWithEvent:event];
+        return;
+    }
+
+    [self _ensureGestureController];
+
+    _data-&gt;_gestureController-&gt;handleSmartMagnificationGesture([self convertPoint:event.locationInWindow fromView:nil]);
+}
+
</ins><span class="cx"> -(void)endGestureWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><span class="cx">     if (!_data-&gt;_gestureController) {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -42,6 +42,9 @@
</span><span class="cx"> static const double zoomOutBoost = 1.6;
</span><span class="cx"> static const double zoomOutResistance = 0.10;
</span><span class="cx"> 
</span><ins>+static const float smartMagnificationElementPadding = 0.05;
+static const float smartMagnificationPanScrollThreshold = 100;
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> ViewGestureController::ViewGestureController(WebPageProxy&amp; webPageProxy)
</span><span class="lines">@@ -104,7 +107,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // We're still waiting for the DidBeginTransientZoom callback.
</del><ins>+    // We're still waiting for the DidCollectGeometry callback.
</ins><span class="cx">     if (!m_visibleContentRectIsValid)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -128,10 +131,60 @@
</span><span class="cx">     m_webPageProxy.drawingArea()-&gt;commitTransientZoom(newMagnification, scaledMagnificationOrigin(m_magnificationOrigin, newMagnification));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ViewGestureController::handleSmartMagnificationGesture(FloatPoint origin)
+{
+    if (m_activeGestureType != ViewGestureType::None)
+        return;
+
+    m_webPageProxy.process().send(Messages::ViewGestureGeometryCollector::CollectGeometryForSmartMagnificationGesture(origin), m_webPageProxy.pageID());
+}
+
+static float maximumRectangleComponentDelta(FloatRect a, FloatRect b)
+{
+    return std::max(fabs(a.x() - b.x()), std::max(fabs(a.y() - b.y()), std::max(fabs(a.width() - b.width()), fabs(a.height() - b.height()))));
+}
+
+void ViewGestureController::didCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect renderRect, FloatRect visibleContentRect, bool isReplacedElement)
+{
+    double currentScaleFactor = m_webPageProxy.pageScaleFactor();
+
+    FloatRect unscaledTargetRect = renderRect;
+    unscaledTargetRect.scale(1 / currentScaleFactor);
+    unscaledTargetRect.inflateX(unscaledTargetRect.width() * smartMagnificationElementPadding);
+    unscaledTargetRect.inflateY(unscaledTargetRect.height() * smartMagnificationElementPadding);
+
+    double targetMagnification = visibleContentRect.width() / unscaledTargetRect.width();
+
+    // For replaced elements like images, we want to fit the whole element
+    // in the view, so scale it down enough to make both dimensions fit if possible.
+    if (isReplacedElement)
+        targetMagnification = std::min(targetMagnification, static_cast&lt;double&gt;(visibleContentRect.height() / unscaledTargetRect.height()));
+
+    targetMagnification = std::min(std::max(targetMagnification, minMagnification), maxMagnification);
+
+    // Allow panning between elements via double-tap while magnified, unless the target rect is
+    // similar to the last one, in which case we'll zoom all the way out.
+    if (currentScaleFactor &gt; 1
+        &amp;&amp; !m_lastSmartMagnificationUnscaledTargetRect.isEmpty()
+        &amp;&amp; maximumRectangleComponentDelta(m_lastSmartMagnificationUnscaledTargetRect, unscaledTargetRect) &lt; smartMagnificationPanScrollThreshold)
+        targetMagnification = 1;
+
+    FloatRect targetRect(unscaledTargetRect);
+    targetRect.scale(targetMagnification);
+    FloatPoint targetOrigin(visibleContentRect.center());
+    targetOrigin.moveBy(-targetRect.center());
+
+    m_webPageProxy.drawingArea()-&gt;adjustTransientZoom(m_webPageProxy.pageScaleFactor(), scaledMagnificationOrigin(FloatPoint(), m_webPageProxy.pageScaleFactor()));
+    m_webPageProxy.drawingArea()-&gt;commitTransientZoom(targetMagnification, targetOrigin);
+
+    m_lastSmartMagnificationUnscaledTargetRect = unscaledTargetRect;
+}
+
</ins><span class="cx"> void ViewGestureController::endActiveGesture()
</span><span class="cx"> {
</span><span class="cx">     switch (m_activeGestureType) {
</span><span class="cx">     case ViewGestureType::None:
</span><ins>+    case ViewGestureType::SmartMagnification:
</ins><span class="cx">         break;
</span><span class="cx">     case ViewGestureType::Magnification:
</span><span class="cx">         endMagnificationGesture();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -39,14 +39,17 @@
</span><span class="cx">     ViewGestureController(WebPageProxy&amp;);
</span><span class="cx">     ~ViewGestureController();
</span><span class="cx"> 
</span><del>-    void handleMagnificationGesture(double scale, WebCore::FloatPoint origin);
</del><span class="cx">     double magnification() const;
</span><span class="cx"> 
</span><ins>+    void handleMagnificationGesture(double scale, WebCore::FloatPoint origin);
+    void handleSmartMagnificationGesture(WebCore::FloatPoint origin);
+
</ins><span class="cx">     void endActiveGesture();
</span><span class="cx"> 
</span><span class="cx">     enum class ViewGestureType {
</span><span class="cx">         None,
</span><span class="cx">         Magnification,
</span><ins>+        SmartMagnification,
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -55,6 +58,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Message handlers.
</span><span class="cx">     void didCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds);
</span><ins>+    void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement);
</ins><span class="cx"> 
</span><span class="cx">     void endMagnificationGesture();
</span><span class="cx">     WebCore::FloatPoint scaledMagnificationOrigin(WebCore::FloatPoint origin, double scale);
</span><span class="lines">@@ -64,6 +68,8 @@
</span><span class="cx">     double m_magnification;
</span><span class="cx">     WebCore::FloatPoint m_magnificationOrigin;
</span><span class="cx"> 
</span><ins>+    WebCore::FloatRect m_lastSmartMagnificationUnscaledTargetRect;
+
</ins><span class="cx">     ViewGestureType m_activeGestureType;
</span><span class="cx"> 
</span><span class="cx">     WebCore::FloatRect m_visibleContentRect;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -22,4 +22,5 @@
</span><span class="cx"> 
</span><span class="cx"> messages -&gt; ViewGestureController {
</span><span class="cx">     DidCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds)
</span><ins>+    DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement)
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageViewGestureGeometryCollectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.cpp (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.cpp        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.cpp        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -32,6 +32,8 @@
</span><span class="cx"> #include &quot;WebPage.h&quot;
</span><span class="cx"> #include &quot;WebProcess.h&quot;
</span><span class="cx"> #include &lt;WebCore/FrameView.h&gt;
</span><ins>+#include &lt;WebCore/HitTestResult.h&gt;
+#include &lt;WebCore/RenderView.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -54,4 +56,22 @@
</span><span class="cx">     m_webPage.send(Messages::ViewGestureController::DidCollectGeometryForMagnificationGesture(visibleContentRect));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture(FloatPoint origin)
+{
+    FloatRect visibleContentRect = m_webPage.mainFrameView()-&gt;visibleContentRect(ScrollableArea::IncludeScrollbars);
+
+    FloatPoint scrolledOrigin = origin;
+    scrolledOrigin.moveBy(m_webPage.mainFrameView()-&gt;scrollPosition());
+
+    HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
+    HitTestResult hitTestResult = HitTestResult(scrolledOrigin);
+    m_webPage.mainFrameView()-&gt;renderView()-&gt;hitTest(request, hitTestResult);
+
+    if (hitTestResult.innerNode()) {
+        bool isReplaced;
+        FloatRect renderRect = hitTestResult.innerNode()-&gt;renderRect(&amp;isReplaced);
+        m_webPage.send(Messages::ViewGestureController::DidCollectGeometryForSmartMagnificationGesture(origin, renderRect, visibleContentRect, isReplaced));
+    }
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageViewGestureGeometryCollectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -28,6 +28,10 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;MessageReceiver.h&quot;
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+class FloatPoint;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class WebPage;
</span><span class="lines">@@ -43,6 +47,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Message handlers.
</span><span class="cx">     void collectGeometryForMagnificationGesture();
</span><ins>+    void collectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin);
</ins><span class="cx"> 
</span><span class="cx">     WebPage&amp; m_webPage;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageViewGestureGeometryCollectormessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.messages.in (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.messages.in        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.messages.in        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -23,5 +23,6 @@
</span><span class="cx"> messages -&gt; ViewGestureGeometryCollector {
</span><span class="cx"> 
</span><span class="cx"> CollectGeometryForMagnificationGesture()
</span><ins>+CollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin)
</ins><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -149,6 +149,7 @@
</span><span class="cx">     bool m_inUpdateGeometry;
</span><span class="cx"> 
</span><span class="cx">     double m_transientZoomScale;
</span><ins>+    WebCore::FloatPoint m_transientZoomOrigin;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (160922 => 160923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm        2013-12-20 21:00:46 UTC (rev 160922)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm        2013-12-20 22:01:27 UTC (rev 160923)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx">     , m_isPaintingSuspended(!(parameters.viewState &amp; ViewState::IsVisible))
</span><span class="cx">     , m_clipsToExposedRect(false)
</span><span class="cx">     , m_updateIntrinsicContentSizeTimer(this, &amp;TiledCoreAnimationDrawingArea::updateIntrinsicContentSizeTimerFired)
</span><ins>+    , m_transientZoomScale(1)
</ins><span class="cx"> {
</span><span class="cx">     m_webPage-&gt;corePage()-&gt;settings().setForceCompositingMode(true);
</span><span class="cx"> 
</span><span class="lines">@@ -729,6 +730,7 @@
</span><span class="cx">     shadowLayer-&gt;setPosition(origin + shadowBounds.center());
</span><span class="cx"> 
</span><span class="cx">     m_transientZoomScale = scale;
</span><ins>+    m_transientZoomOrigin = origin;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static RetainPtr&lt;CABasicAnimation&gt; transientZoomSnapAnimationForKeyPath(String keyPath)
</span><span class="lines">@@ -765,7 +767,7 @@
</span><span class="cx">     constrainedOrigin.moveBy(-visibleContentRect.location());
</span><span class="cx">     constrainedOrigin = -constrainedOrigin;
</span><span class="cx"> 
</span><del>-    if (m_transientZoomScale == scale &amp;&amp; roundedIntPoint(origin) == roundedIntPoint(constrainedOrigin)) {
</del><ins>+    if (m_transientZoomScale == scale &amp;&amp; roundedIntPoint(m_transientZoomOrigin) == roundedIntPoint(constrainedOrigin)) {
</ins><span class="cx">         // We're already at the right scale and position, so we don't need to animate.
</span><span class="cx">         applyTransientZoomToPage(scale, origin);
</span><span class="cx">         return;
</span><span class="lines">@@ -829,6 +831,8 @@
</span><span class="cx">     unscrolledOrigin.moveBy(-visibleContentRect.location());
</span><span class="cx">     m_webPage-&gt;scalePage(scale, roundedIntPoint(-unscrolledOrigin));
</span><span class="cx">     flushLayers();
</span><ins>+
+    m_transientZoomScale = 1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>

</body>
</html>