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