Chromium Code Reviews| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 m_innerViewportContainerLayer->setSize(m_size); | 84 m_innerViewportContainerLayer->setSize(m_size); |
| 85 | 85 |
| 86 // Make sure we clamp the offset to within the new bounds. | 86 // Make sure we clamp the offset to within the new bounds. |
| 87 setLocation(m_offset); | 87 setLocation(m_offset); |
| 88 | 88 |
| 89 // Need to re-compute sizes for the overlay scrollbars. | 89 // Need to re-compute sizes for the overlay scrollbars. |
| 90 setupScrollbar(WebScrollbar::Horizontal); | 90 setupScrollbar(WebScrollbar::Horizontal); |
| 91 setupScrollbar(WebScrollbar::Vertical); | 91 setupScrollbar(WebScrollbar::Vertical); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void PinchViewport::reset() | |
| 95 { | |
| 96 setLocation(FloatPoint(0, 0)); | |
| 97 setScale(1); | |
| 98 } | |
| 99 | |
| 94 void PinchViewport::mainFrameDidChangeSize() | 100 void PinchViewport::mainFrameDidChangeSize() |
| 95 { | 101 { |
| 96 // In unit tests we may not have initialized the layer tree. | 102 // In unit tests we may not have initialized the layer tree. |
| 97 if (m_innerViewportScrollLayer) | 103 if (m_innerViewportScrollLayer) |
| 98 m_innerViewportScrollLayer->setSize(contentsSize()); | 104 m_innerViewportScrollLayer->setSize(contentsSize()); |
| 99 | 105 |
| 100 // Make sure the viewport's offset is clamped within the newly sized main fr ame. | 106 // Make sure the viewport's offset is clamped within the newly sized main fr ame. |
| 101 setLocation(m_offset); | 107 setLocation(m_offset); |
| 102 } | 108 } |
| 103 | 109 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 117 | 123 |
| 118 m_offset = clampedOffset; | 124 m_offset = clampedOffset; |
| 119 | 125 |
| 120 ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordinator( ); | 126 ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordinator( ); |
| 121 ASSERT(coordinator); | 127 ASSERT(coordinator); |
| 122 coordinator->scrollableAreaScrollLayerDidChange(this); | 128 coordinator->scrollableAreaScrollLayerDidChange(this); |
| 123 } | 129 } |
| 124 | 130 |
| 125 void PinchViewport::setScale(float scale) | 131 void PinchViewport::setScale(float scale) |
| 126 { | 132 { |
| 133 if (scale == m_scale) | |
| 134 return; | |
| 135 | |
| 127 m_scale = scale; | 136 m_scale = scale; |
| 128 | 137 |
| 138 mainFrame()->loader().saveScrollState(); | |
| 139 | |
| 129 // Old-style pinch sets scale here but we shouldn't call into the | 140 // Old-style pinch sets scale here but we shouldn't call into the |
| 130 // clamping code below. | 141 // clamping code below. |
| 131 if (!m_innerViewportScrollLayer) | 142 if (!m_innerViewportScrollLayer) |
| 132 return; | 143 return; |
| 133 | 144 |
| 134 // Ensure we clamp so we remain within the bounds. | 145 // Ensure we clamp so we remain within the bounds. |
| 135 setLocation(visibleRect().location()); | 146 setLocation(visibleRect().location()); |
| 147 | |
| 148 // TODO: We should probably be calling scaleDidChange type functions here. | |
|
aelias_OOO_until_Jul13
2014/05/07 08:06:03
Separate from this patch, but the only thing in yo
| |
| 149 // see Page::setPageScaleFactor. | |
| 136 } | 150 } |
| 137 | 151 |
| 138 // Modifies the top of the graphics layer tree to add layers needed to support | 152 // Modifies the top of the graphics layer tree to add layers needed to support |
| 139 // the inner/outer viewport fixed-position model for pinch zoom. When finished, | 153 // the inner/outer viewport fixed-position model for pinch zoom. When finished, |
| 140 // the tree will look like this (with * denoting added layers): | 154 // the tree will look like this (with * denoting added layers): |
| 141 // | 155 // |
| 142 // *innerViewportContainerLayer (fixed pos container) | 156 // *innerViewportContainerLayer (fixed pos container) |
| 143 // +- *pageScaleLayer | 157 // +- *pageScaleLayer |
| 144 // | +- *innerViewportScrollLayer | 158 // | +- *innerViewportScrollLayer |
| 145 // | +-- overflowControlsHostLayer (root layer) | 159 // | +-- overflowControlsHostLayer (root layer) |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 | 331 |
| 318 void PinchViewport::invalidateScrollbarRect(Scrollbar*, const IntRect&) | 332 void PinchViewport::invalidateScrollbarRect(Scrollbar*, const IntRect&) |
| 319 { | 333 { |
| 320 // Do nothing. Pinch scrollbars live on the compositor thread and will | 334 // Do nothing. Pinch scrollbars live on the compositor thread and will |
| 321 // be updated when the viewport is synced to the CC. | 335 // be updated when the viewport is synced to the CC. |
| 322 } | 336 } |
| 323 | 337 |
| 324 void PinchViewport::setScrollOffset(const IntPoint& offset) | 338 void PinchViewport::setScrollOffset(const IntPoint& offset) |
| 325 { | 339 { |
| 326 setLocation(offset); | 340 setLocation(offset); |
| 341 | |
| 342 mainFrame()->loader().saveScrollState(); | |
| 327 } | 343 } |
| 328 | 344 |
| 329 GraphicsLayer* PinchViewport::layerForContainer() const | 345 GraphicsLayer* PinchViewport::layerForContainer() const |
| 330 { | 346 { |
| 331 return m_innerViewportContainerLayer.get(); | 347 return m_innerViewportContainerLayer.get(); |
| 332 } | 348 } |
| 333 | 349 |
| 334 GraphicsLayer* PinchViewport::layerForScrolling() const | 350 GraphicsLayer* PinchViewport::layerForScrolling() const |
| 335 { | 351 { |
| 336 return m_innerViewportScrollLayer.get(); | 352 return m_innerViewportScrollLayer.get(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { | 397 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { |
| 382 name = "Overlay Scrollbar Vertical Layer"; | 398 name = "Overlay Scrollbar Vertical Layer"; |
| 383 } else { | 399 } else { |
| 384 ASSERT_NOT_REACHED(); | 400 ASSERT_NOT_REACHED(); |
| 385 } | 401 } |
| 386 | 402 |
| 387 return name; | 403 return name; |
| 388 } | 404 } |
| 389 | 405 |
| 390 } // namespace WebCore | 406 } // namespace WebCore |
| OLD | NEW |