<!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>[162485] trunk/Source/WebKit2</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/162485">162485</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-01-21 17:18:07 -0800 (Tue, 21 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make ViewGestureController Obj-C++
https://bugs.webkit.org/show_bug.cgi?id=127385

Reviewed by Dean Jackson.

* UIProcess/mac/ViewGestureController.mm: Renamed from Source/WebKit2/UIProcess/mac/ViewGestureController.cpp.
* WebKit2.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllermm">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.mm</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllercpp">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (162484 => 162485)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-01-22 00:42:52 UTC (rev 162484)
+++ trunk/Source/WebKit2/ChangeLog        2014-01-22 01:18:07 UTC (rev 162485)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-01-21  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Make ViewGestureController Obj-C++
+        https://bugs.webkit.org/show_bug.cgi?id=127385
+
+        Reviewed by Dean Jackson.
+
+        * UIProcess/mac/ViewGestureController.mm: Renamed from Source/WebKit2/UIProcess/mac/ViewGestureController.cpp.
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2014-01-21  Roger Fong  &lt;roger_fong@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed. WebGLLoadPolicy::WebGLAsk is an unnecessary value.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp (162484 => 162485)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp        2014-01-22 00:42:52 UTC (rev 162484)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp        2014-01-22 01:18:07 UTC (rev 162485)
</span><span class="lines">@@ -1,217 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import &quot;config.h&quot;
-#import &quot;ViewGestureController.h&quot;
-
-#import &quot;ViewGestureControllerMessages.h&quot;
-#import &quot;ViewGestureGeometryCollectorMessages.h&quot;
-#import &quot;WebPageProxy.h&quot;
-#import &quot;WebProcessProxy.h&quot;
-
-using namespace WebCore;
-
-static const double minMagnification = 1;
-static const double maxMagnification = 3;
-
-static const double minElasticMagnification = 0.75;
-static const double maxElasticMagnification = 4;
-
-static const double zoomOutBoost = 1.6;
-static const double zoomOutResistance = 0.10;
-
-static const float smartMagnificationElementPadding = 0.05;
-static const float smartMagnificationPanScrollThreshold = 100;
-
-namespace WebKit {
-
-ViewGestureController::ViewGestureController(WebPageProxy&amp; webPageProxy)
-    : m_webPageProxy(webPageProxy)
-    , m_activeGestureType(ViewGestureType::None)
-    , m_visibleContentRectIsValid(false)
-    , m_frameHandlesMagnificationGesture(false)
-{
-    m_webPageProxy.process().addMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID(), *this);
-}
-
-ViewGestureController::~ViewGestureController()
-{
-    m_webPageProxy.process().removeMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID());
-}
-
-static double resistanceForDelta(double deltaScale, double currentScale)
-{
-    // Zoom out with slight acceleration, until we reach minimum scale.
-    if (deltaScale &lt; 0 &amp;&amp; currentScale &gt; minMagnification)
-        return zoomOutBoost;
-
-    // Zoom in with no acceleration, until we reach maximum scale.
-    if (deltaScale &gt; 0 &amp;&amp; currentScale &lt; maxMagnification)
-        return 1;
-
-    // Outside of the extremes, resist further scaling.
-    double limit = currentScale &lt; minMagnification ? minMagnification : maxMagnification;
-    double scaleDistance = abs(limit - currentScale);
-    double scalePercent = std::min(std::max(scaleDistance / limit, 0.), 1.);
-    double resistance = zoomOutResistance + scalePercent * (0.01 - zoomOutResistance);
-
-    return resistance;
-}
-
-FloatPoint ViewGestureController::scaledMagnificationOrigin(FloatPoint origin, double scale)
-{
-    FloatPoint scaledMagnificationOrigin(origin);
-    scaledMagnificationOrigin.moveBy(m_visibleContentRect.location());
-    float magnificationOriginScale = 1 - (scale / m_webPageProxy.pageScaleFactor());
-    scaledMagnificationOrigin.scale(magnificationOriginScale, magnificationOriginScale);
-    return scaledMagnificationOrigin;
-}
-
-void ViewGestureController::didCollectGeometryForMagnificationGesture(FloatRect visibleContentRect, bool frameHandlesMagnificationGesture)
-{
-    m_activeGestureType = ViewGestureType::Magnification;
-    m_visibleContentRect = visibleContentRect;
-    m_visibleContentRectIsValid = true;
-    m_frameHandlesMagnificationGesture = frameHandlesMagnificationGesture;
-}
-
-void ViewGestureController::handleMagnificationGesture(double scale, FloatPoint origin)
-{
-    ASSERT(m_activeGestureType == ViewGestureType::None || m_activeGestureType == ViewGestureType::Magnification);
-
-    if (m_activeGestureType == ViewGestureType::None) {
-        // FIXME: We drop the first frame of the gesture on the floor, because we don't have the visible content bounds yet.
-        m_magnification = m_webPageProxy.pageScaleFactor();
-        m_webPageProxy.process().send(Messages::ViewGestureGeometryCollector::CollectGeometryForMagnificationGesture(), m_webPageProxy.pageID());
-
-        return;
-    }
-
-    // We're still waiting for the DidCollectGeometry callback.
-    if (!m_visibleContentRectIsValid)
-        return;
-
-    m_activeGestureType = ViewGestureType::Magnification;
-
-    double scaleWithResistance = resistanceForDelta(scale, m_magnification) * scale;
-
-    m_magnification += m_magnification * scaleWithResistance;
-    m_magnification = std::min(std::max(m_magnification, minElasticMagnification), maxElasticMagnification);
-
-    m_magnificationOrigin = origin;
-
-    if (m_frameHandlesMagnificationGesture)
-        m_webPageProxy.scalePage(m_magnification, roundedIntPoint(origin));
-    else
-        m_webPageProxy.drawingArea()-&gt;adjustTransientZoom(m_magnification, scaledMagnificationOrigin(origin, m_magnification));
-}
-
-void ViewGestureController::endMagnificationGesture()
-{
-    ASSERT(m_activeGestureType == ViewGestureType::Magnification);
-
-    double newMagnification = std::min(std::max(m_magnification, minMagnification), maxMagnification);
-
-    if (m_frameHandlesMagnificationGesture)
-        m_webPageProxy.scalePage(newMagnification, roundedIntPoint(m_magnificationOrigin));
-    else
-        m_webPageProxy.drawingArea()-&gt;commitTransientZoom(newMagnification, scaledMagnificationOrigin(m_magnificationOrigin, newMagnification));
-}
-
-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, bool frameHandlesMagnificationGesture)
-{
-    if (frameHandlesMagnificationGesture)
-        return;
-
-    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;
-}
-
-void ViewGestureController::endActiveGesture()
-{
-    switch (m_activeGestureType) {
-    case ViewGestureType::None:
-    case ViewGestureType::SmartMagnification:
-        break;
-    case ViewGestureType::Magnification:
-        endMagnificationGesture();
-    }
-
-    m_visibleContentRectIsValid = false;
-    m_activeGestureType = ViewGestureType::None;
-}
-
-double ViewGestureController::magnification() const
-{
-    if (m_activeGestureType == ViewGestureType::Magnification)
-        return m_magnification;
-
-    return m_webPageProxy.pageScaleFactor();
-}
-
-} // namespace WebKit
</del></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllermmfromrev162482trunkSourceWebKit2UIProcessmacViewGestureControllercpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.mm (from rev 162482, trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.cpp) (0 => 162485)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.mm        2014-01-22 01:18:07 UTC (rev 162485)
</span><span class="lines">@@ -0,0 +1,217 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;ViewGestureController.h&quot;
+
+#import &quot;ViewGestureControllerMessages.h&quot;
+#import &quot;ViewGestureGeometryCollectorMessages.h&quot;
+#import &quot;WebPageProxy.h&quot;
+#import &quot;WebProcessProxy.h&quot;
+
+using namespace WebCore;
+
+static const double minMagnification = 1;
+static const double maxMagnification = 3;
+
+static const double minElasticMagnification = 0.75;
+static const double maxElasticMagnification = 4;
+
+static const double zoomOutBoost = 1.6;
+static const double zoomOutResistance = 0.10;
+
+static const float smartMagnificationElementPadding = 0.05;
+static const float smartMagnificationPanScrollThreshold = 100;
+
+namespace WebKit {
+
+ViewGestureController::ViewGestureController(WebPageProxy&amp; webPageProxy)
+    : m_webPageProxy(webPageProxy)
+    , m_activeGestureType(ViewGestureType::None)
+    , m_visibleContentRectIsValid(false)
+    , m_frameHandlesMagnificationGesture(false)
+{
+    m_webPageProxy.process().addMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID(), *this);
+}
+
+ViewGestureController::~ViewGestureController()
+{
+    m_webPageProxy.process().removeMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID());
+}
+
+static double resistanceForDelta(double deltaScale, double currentScale)
+{
+    // Zoom out with slight acceleration, until we reach minimum scale.
+    if (deltaScale &lt; 0 &amp;&amp; currentScale &gt; minMagnification)
+        return zoomOutBoost;
+
+    // Zoom in with no acceleration, until we reach maximum scale.
+    if (deltaScale &gt; 0 &amp;&amp; currentScale &lt; maxMagnification)
+        return 1;
+
+    // Outside of the extremes, resist further scaling.
+    double limit = currentScale &lt; minMagnification ? minMagnification : maxMagnification;
+    double scaleDistance = abs(limit - currentScale);
+    double scalePercent = std::min(std::max(scaleDistance / limit, 0.), 1.);
+    double resistance = zoomOutResistance + scalePercent * (0.01 - zoomOutResistance);
+
+    return resistance;
+}
+
+FloatPoint ViewGestureController::scaledMagnificationOrigin(FloatPoint origin, double scale)
+{
+    FloatPoint scaledMagnificationOrigin(origin);
+    scaledMagnificationOrigin.moveBy(m_visibleContentRect.location());
+    float magnificationOriginScale = 1 - (scale / m_webPageProxy.pageScaleFactor());
+    scaledMagnificationOrigin.scale(magnificationOriginScale, magnificationOriginScale);
+    return scaledMagnificationOrigin;
+}
+
+void ViewGestureController::didCollectGeometryForMagnificationGesture(FloatRect visibleContentRect, bool frameHandlesMagnificationGesture)
+{
+    m_activeGestureType = ViewGestureType::Magnification;
+    m_visibleContentRect = visibleContentRect;
+    m_visibleContentRectIsValid = true;
+    m_frameHandlesMagnificationGesture = frameHandlesMagnificationGesture;
+}
+
+void ViewGestureController::handleMagnificationGesture(double scale, FloatPoint origin)
+{
+    ASSERT(m_activeGestureType == ViewGestureType::None || m_activeGestureType == ViewGestureType::Magnification);
+
+    if (m_activeGestureType == ViewGestureType::None) {
+        // FIXME: We drop the first frame of the gesture on the floor, because we don't have the visible content bounds yet.
+        m_magnification = m_webPageProxy.pageScaleFactor();
+        m_webPageProxy.process().send(Messages::ViewGestureGeometryCollector::CollectGeometryForMagnificationGesture(), m_webPageProxy.pageID());
+
+        return;
+    }
+
+    // We're still waiting for the DidCollectGeometry callback.
+    if (!m_visibleContentRectIsValid)
+        return;
+
+    m_activeGestureType = ViewGestureType::Magnification;
+
+    double scaleWithResistance = resistanceForDelta(scale, m_magnification) * scale;
+
+    m_magnification += m_magnification * scaleWithResistance;
+    m_magnification = std::min(std::max(m_magnification, minElasticMagnification), maxElasticMagnification);
+
+    m_magnificationOrigin = origin;
+
+    if (m_frameHandlesMagnificationGesture)
+        m_webPageProxy.scalePage(m_magnification, roundedIntPoint(origin));
+    else
+        m_webPageProxy.drawingArea()-&gt;adjustTransientZoom(m_magnification, scaledMagnificationOrigin(origin, m_magnification));
+}
+
+void ViewGestureController::endMagnificationGesture()
+{
+    ASSERT(m_activeGestureType == ViewGestureType::Magnification);
+
+    double newMagnification = std::min(std::max(m_magnification, minMagnification), maxMagnification);
+
+    if (m_frameHandlesMagnificationGesture)
+        m_webPageProxy.scalePage(newMagnification, roundedIntPoint(m_magnificationOrigin));
+    else
+        m_webPageProxy.drawingArea()-&gt;commitTransientZoom(newMagnification, scaledMagnificationOrigin(m_magnificationOrigin, newMagnification));
+}
+
+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, bool frameHandlesMagnificationGesture)
+{
+    if (frameHandlesMagnificationGesture)
+        return;
+
+    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;
+}
+
+void ViewGestureController::endActiveGesture()
+{
+    switch (m_activeGestureType) {
+    case ViewGestureType::None:
+    case ViewGestureType::SmartMagnification:
+        break;
+    case ViewGestureType::Magnification:
+        endMagnificationGesture();
+    }
+
+    m_visibleContentRectIsValid = false;
+    m_activeGestureType = ViewGestureType::None;
+}
+
+double ViewGestureController::magnification() const
+{
+    if (m_activeGestureType == ViewGestureType::Magnification)
+        return m_magnification;
+
+    return m_webPageProxy.pageScaleFactor();
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (162484 => 162485)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-01-22 00:42:52 UTC (rev 162484)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-01-22 01:18:07 UTC (rev 162485)
</span><span class="lines">@@ -389,7 +389,7 @@
</span><span class="cx">                 29D55DF1161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29D55DEF161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp */; };
</span><span class="cx">                 29D55DF2161BF9F10031A2E3 /* WebPageGroupProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 29D55DF0161BF9F10031A2E3 /* WebPageGroupProxyMessages.h */; };
</span><span class="cx">                 2D125C5E1857EA05003BA3CB /* ViewGestureController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D125C5C1857EA05003BA3CB /* ViewGestureController.h */; };
</span><del>-                2D125C5F1857EA05003BA3CB /* ViewGestureController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D125C5D1857EA05003BA3CB /* ViewGestureController.cpp */; };
</del><ins>+                2D125C5F1857EA05003BA3CB /* ViewGestureController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D125C5D1857EA05003BA3CB /* ViewGestureController.mm */; };
</ins><span class="cx">                 2D1B5D5D185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D1B5D5B185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp */; };
</span><span class="cx">                 2D1B5D5E185869C8006C6596 /* ViewGestureControllerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D1B5D5C185869C8006C6596 /* ViewGestureControllerMessages.h */; };
</span><span class="cx">                 2D28F3E41885CCC1004B9EAE /* WebChromeClientIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D28F3E01885CCC1004B9EAE /* WebChromeClientIOS.mm */; };
</span><span class="lines">@@ -2027,7 +2027,7 @@
</span><span class="cx">                 29D55DEF161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPageGroupProxyMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 29D55DF0161BF9F10031A2E3 /* WebPageGroupProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageGroupProxyMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D125C5C1857EA05003BA3CB /* ViewGestureController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewGestureController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                2D125C5D1857EA05003BA3CB /* ViewGestureController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewGestureController.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                2D125C5D1857EA05003BA3CB /* ViewGestureController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewGestureController.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2D1B5D5A18586599006C6596 /* ViewGestureController.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = ViewGestureController.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D1B5D5B185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewGestureControllerMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D1B5D5C185869C8006C6596 /* ViewGestureControllerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewGestureControllerMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5659,7 +5659,7 @@
</span><span class="cx">                                 1AF05D8514688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h */,
</span><span class="cx">                                 1AF05D8414688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.mm */,
</span><span class="cx">                                 2D125C5C1857EA05003BA3CB /* ViewGestureController.h */,
</span><del>-                                2D125C5D1857EA05003BA3CB /* ViewGestureController.cpp */,
</del><ins>+                                2D125C5D1857EA05003BA3CB /* ViewGestureController.mm */,
</ins><span class="cx">                                 2D1B5D5A18586599006C6596 /* ViewGestureController.messages.in */,
</span><span class="cx">                                 728E86EF1795188C0087879E /* WebColorPickerMac.h */,
</span><span class="cx">                                 728E86F01795188C0087879E /* WebColorPickerMac.mm */,
</span><span class="lines">@@ -7723,7 +7723,7 @@
</span><span class="cx">                                 BCD3675C148C26C000447E87 /* WebConnectionToUIProcess.cpp in Sources */,
</span><span class="cx">                                 BC4A62A714744EC7006C681A /* WebConnectionToWebProcess.cpp in Sources */,
</span><span class="cx">                                 BC82836516B354F600A278FE /* WebContentProcessMain.mm in Sources */,
</span><del>-                                2D125C5F1857EA05003BA3CB /* ViewGestureController.cpp in Sources */,
</del><ins>+                                2D125C5F1857EA05003BA3CB /* ViewGestureController.mm in Sources */,
</ins><span class="cx">                                 BC82839916B48DC000A278FE /* WebContentServiceEntryPoint.mm in Sources */,
</span><span class="cx">                                 BCB9E2441120DACA00A137E0 /* WebContext.cpp in Sources */,
</span><span class="cx">                                 31A505F91680025500A930EB /* WebContextClient.cpp in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>