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

Side by Side Diff: Source/core/frame/PinchViewport.cpp

Issue 889803004: Add touchpad pinch zoom support to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Incorporate review feedback Created 5 years, 10 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
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/core/page/ChromeClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 218
219 if (!valuesChanged) 219 if (!valuesChanged)
220 return; 220 return;
221 221
222 mainFrame()->loader().saveScrollState(); 222 mainFrame()->loader().saveScrollState();
223 223
224 clampToBoundaries(); 224 clampToBoundaries();
225 } 225 }
226 226
227 bool PinchViewport::magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoin t& anchor)
228 {
229 const float oldPageScale = scale();
230 const float newPageScale = frameHost().chrome().client().clampPageScaleFacto rToLimits(
231 magnifyDelta * oldPageScale);
232 if (newPageScale == oldPageScale)
233 return false;
234
235 // Keep the center-of-pinch anchor in a stable position over the course
236 // of the magnify.
237 FloatPoint anchorAtOldScale = anchor.scaledBy(1.f / oldPageScale);
238 FloatPoint anchorAtNewScale = anchor.scaledBy(1.f / newPageScale);
239 FloatSize anchorDelta = anchorAtOldScale - anchorAtNewScale;
240
241 // First try to use the anchor's delta to scroll the FrameView.
242 FloatSize anchorDeltaUnusedByScroll = anchorDelta;
243 FrameView* view = mainFrame()->view();
aelias_OOO_until_Jul13 2015/02/03 19:10:11 I'm not confident FrameView is guaranteed to exist
244 DoublePoint oldPosition = view->scrollPositionDouble();
245 view->scrollBy(DoubleSize(anchorDelta.width(), anchorDelta.height()));
246 DoublePoint newPosition = view->scrollPositionDouble();
247 anchorDeltaUnusedByScroll = anchorDelta - toFloatSize(newPosition - oldPosit ion);
248
249 // Manually bubble any remaining anchor delta up to the pinch viewport.
250 FloatPoint newLocation(location() + anchorDeltaUnusedByScroll);
251 setScaleAndLocation(newPageScale, newLocation);
252 return true;
253 }
254
227 // Modifies the top of the graphics layer tree to add layers needed to support 255 // Modifies the top of the graphics layer tree to add layers needed to support
228 // the inner/outer viewport fixed-position model for pinch zoom. When finished, 256 // the inner/outer viewport fixed-position model for pinch zoom. When finished,
229 // the tree will look like this (with * denoting added layers): 257 // the tree will look like this (with * denoting added layers):
230 // 258 //
231 // *rootTransformLayer 259 // *rootTransformLayer
232 // +- *innerViewportContainerLayer (fixed pos container) 260 // +- *innerViewportContainerLayer (fixed pos container)
233 // | +- *overscrollElasticityLayer 261 // | +- *overscrollElasticityLayer
234 // | +- *pageScaleLayer 262 // | +- *pageScaleLayer
235 // | +- *innerViewportScrollLayer 263 // | +- *innerViewportScrollLayer
236 // | +-- overflowControlsHostLayer (root layer) 264 // | +-- overflowControlsHostLayer (root layer)
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } else if (graphicsLayer == m_rootTransformLayer) { 575 } else if (graphicsLayer == m_rootTransformLayer) {
548 name = "Root Transform Layer"; 576 name = "Root Transform Layer";
549 } else { 577 } else {
550 ASSERT_NOT_REACHED(); 578 ASSERT_NOT_REACHED();
551 } 579 }
552 580
553 return name; 581 return name;
554 } 582 }
555 583
556 } // namespace blink 584 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/core/page/ChromeClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698