| OLD | NEW |
| 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 Loading... |
| 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 if (!mainFrame() || !mainFrame()->view()) |
| 235 return false; |
| 236 |
| 237 // Keep the center-of-pinch anchor in a stable position over the course |
| 238 // of the magnify. |
| 239 FloatPoint anchorAtOldScale = anchor.scaledBy(1.f / oldPageScale); |
| 240 FloatPoint anchorAtNewScale = anchor.scaledBy(1.f / newPageScale); |
| 241 FloatSize anchorDelta = anchorAtOldScale - anchorAtNewScale; |
| 242 |
| 243 // First try to use the anchor's delta to scroll the FrameView. |
| 244 FloatSize anchorDeltaUnusedByScroll = anchorDelta; |
| 245 FrameView* view = mainFrame()->view(); |
| 246 DoublePoint oldPosition = view->scrollPositionDouble(); |
| 247 view->scrollBy(DoubleSize(anchorDelta.width(), anchorDelta.height())); |
| 248 DoublePoint newPosition = view->scrollPositionDouble(); |
| 249 anchorDeltaUnusedByScroll = anchorDelta - toFloatSize(newPosition - oldPosit
ion); |
| 250 |
| 251 // Manually bubble any remaining anchor delta up to the pinch viewport. |
| 252 FloatPoint newLocation(location() + anchorDeltaUnusedByScroll); |
| 253 setScaleAndLocation(newPageScale, newLocation); |
| 254 return true; |
| 255 } |
| 256 |
| 227 // Modifies the top of the graphics layer tree to add layers needed to support | 257 // 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, | 258 // the inner/outer viewport fixed-position model for pinch zoom. When finished, |
| 229 // the tree will look like this (with * denoting added layers): | 259 // the tree will look like this (with * denoting added layers): |
| 230 // | 260 // |
| 231 // *rootTransformLayer | 261 // *rootTransformLayer |
| 232 // +- *innerViewportContainerLayer (fixed pos container) | 262 // +- *innerViewportContainerLayer (fixed pos container) |
| 233 // | +- *overscrollElasticityLayer | 263 // | +- *overscrollElasticityLayer |
| 234 // | +- *pageScaleLayer | 264 // | +- *pageScaleLayer |
| 235 // | +- *innerViewportScrollLayer | 265 // | +- *innerViewportScrollLayer |
| 236 // | +-- overflowControlsHostLayer (root layer) | 266 // | +-- overflowControlsHostLayer (root layer) |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 } else if (graphicsLayer == m_rootTransformLayer) { | 577 } else if (graphicsLayer == m_rootTransformLayer) { |
| 548 name = "Root Transform Layer"; | 578 name = "Root Transform Layer"; |
| 549 } else { | 579 } else { |
| 550 ASSERT_NOT_REACHED(); | 580 ASSERT_NOT_REACHED(); |
| 551 } | 581 } |
| 552 | 582 |
| 553 return name; | 583 return name; |
| 554 } | 584 } |
| 555 | 585 |
| 556 } // namespace blink | 586 } // namespace blink |
| OLD | NEW |