Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 255843004: Update trackpad pinch-zoom code for corrected scale semantics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 // at ..., -3*step, -2*step, -step, step, 2*step, 3*step, ... but not at 0) 1256 // at ..., -3*step, -2*step, -step, step, 2*step, 3*step, ... but not at 0)
1257 // so that it's easier to get back to your starting point than it is to 1257 // so that it's easier to get back to your starting point than it is to
1258 // overshoot. 1258 // overshoot.
1259 float nextStep = (abs(currentPinchZoomStepDelta_) + 1) * kZoomStepValue; 1259 float nextStep = (abs(currentPinchZoomStepDelta_) + 1) * kZoomStepValue;
1260 float backStep = abs(currentPinchZoomStepDelta_) * kZoomStepValue; 1260 float backStep = abs(currentPinchZoomStepDelta_) * kZoomStepValue;
1261 float zoomInThreshold = (currentPinchZoomStepDelta_ >= 0) ? nextStep 1261 float zoomInThreshold = (currentPinchZoomStepDelta_ >= 0) ? nextStep
1262 : -backStep; 1262 : -backStep;
1263 float zoomOutThreshold = (currentPinchZoomStepDelta_ <= 0) ? -nextStep 1263 float zoomOutThreshold = (currentPinchZoomStepDelta_ <= 0) ? -nextStep
1264 : backStep; 1264 : backStep;
1265 1265
1266 totalPinchGestureAmount_ += event.data.pinchUpdate.scale; 1266 totalPinchGestureAmount_ += (event.data.pinchUpdate.scale - 1.0);
1267 if (totalPinchGestureAmount_ > zoomInThreshold) { 1267 if (totalPinchGestureAmount_ > zoomInThreshold) {
1268 currentPinchZoomStepDelta_++; 1268 currentPinchZoomStepDelta_++;
1269 if (delegate_) 1269 if (delegate_)
1270 delegate_->ContentsZoomChange(true); 1270 delegate_->ContentsZoomChange(true);
1271 } else if (totalPinchGestureAmount_ < zoomOutThreshold) { 1271 } else if (totalPinchGestureAmount_ < zoomOutThreshold) {
1272 currentPinchZoomStepDelta_--; 1272 currentPinchZoomStepDelta_--;
1273 if (delegate_) 1273 if (delegate_)
1274 delegate_->ContentsZoomChange(false); 1274 delegate_->ContentsZoomChange(false);
1275 } 1275 }
1276 return true; 1276 return true;
(...skipping 2616 matching lines...) Expand 10 before | Expand all | Expand 10 after
3893 3893
3894 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 3894 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
3895 if (!delegate_) 3895 if (!delegate_)
3896 return; 3896 return;
3897 const gfx::Size new_size = GetPreferredSize(); 3897 const gfx::Size new_size = GetPreferredSize();
3898 if (new_size != old_size) 3898 if (new_size != old_size)
3899 delegate_->UpdatePreferredSize(this, new_size); 3899 delegate_->UpdatePreferredSize(this, new_size);
3900 } 3900 }
3901 3901
3902 } // namespace content 3902 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698