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

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

Issue 584833003: Made double-tap zoom work in pinch virtual viewport mode. (Blink-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 coordinator->scrollableAreaScrollLayerDidChange(this); 163 coordinator->scrollableAreaScrollLayerDidChange(this);
164 164
165 mainFrame()->loader().saveScrollState(); 165 mainFrame()->loader().saveScrollState();
166 } 166 }
167 167
168 void PinchViewport::move(const FloatPoint& delta) 168 void PinchViewport::move(const FloatPoint& delta)
169 { 169 {
170 setLocation(m_offset + delta); 170 setLocation(m_offset + delta);
171 } 171 }
172 172
173 void PinchViewport::setScale(float scale) 173 void PinchViewport::setScaleWithoutClampingViewportOffset(float scale)
174 { 174 {
175 if (scale == m_scale) 175 if (scale == m_scale)
176 return; 176 return;
177 177
178 m_scale = scale; 178 m_scale = scale;
179 179
180 if (mainFrame()) 180 if (mainFrame())
181 mainFrame()->loader().saveScrollState(); 181 mainFrame()->loader().saveScrollState();
182 182
183 // Old-style pinch sets scale here but we shouldn't call into the 183 // Old-style pinch sets scale here but we shouldn't call into the
184 // clamping code below. 184 // clamping code below.
185 if (!m_innerViewportScrollLayer) 185 if (!m_innerViewportScrollLayer)
186 return; 186 return;
187 187
188 // Ensure we clamp so we remain within the bounds.
189 setLocation(visibleRect().location());
190
191 // TODO: We should probably be calling scaleDidChange type functions here. 188 // TODO: We should probably be calling scaleDidChange type functions here.
192 // see Page::setPageScaleFactor. 189 // see Page::setPageScaleFactor.
193 } 190 }
194 191
192 void PinchViewport::setScale(float scale)
193 {
194 setScaleWithoutClampingViewportOffset(scale);
195
196 // Ensure we clamp so we remain within the bounds.
197 setLocation(visibleRect().location());
198 }
199
195 // Modifies the top of the graphics layer tree to add layers needed to support 200 // Modifies the top of the graphics layer tree to add layers needed to support
196 // the inner/outer viewport fixed-position model for pinch zoom. When finished, 201 // the inner/outer viewport fixed-position model for pinch zoom. When finished,
197 // the tree will look like this (with * denoting added layers): 202 // the tree will look like this (with * denoting added layers):
198 // 203 //
199 // *rootTransformLayer 204 // *rootTransformLayer
200 // +- *innerViewportContainerLayer (fixed pos container) 205 // +- *innerViewportContainerLayer (fixed pos container)
201 // +- *pageScaleLayer 206 // +- *pageScaleLayer
202 // | +- *innerViewportScrollLayer 207 // | +- *innerViewportScrollLayer
203 // | +-- overflowControlsHostLayer (root layer) 208 // | +-- overflowControlsHostLayer (root layer)
204 // | +-- outerViewportContainerLayer (fixed pos container) [frame container layer in RenderLayerCompositor] 209 // | +-- outerViewportContainerLayer (fixed pos container) [frame container layer in RenderLayerCompositor]
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 IntPoint PinchViewport::minimumScrollPosition() const 349 IntPoint PinchViewport::minimumScrollPosition() const
345 { 350 {
346 return IntPoint(); 351 return IntPoint();
347 } 352 }
348 353
349 IntPoint PinchViewport::maximumScrollPosition() const 354 IntPoint PinchViewport::maximumScrollPosition() const
350 { 355 {
351 return flooredIntPoint(FloatSize(contentsSize()) - visibleRect().size()); 356 return flooredIntPoint(FloatSize(contentsSize()) - visibleRect().size());
352 } 357 }
353 358
359 IntPoint PinchViewport::clampDocumentOffsetAtScale(const IntPoint& offset, float scale)
360 {
361 if (!mainFrame() || !mainFrame()->view())
362 return IntPoint();
363
364 FrameView* view = mainFrame()->view();
365
366 FloatSize scaledSize(m_size);
367 scaledSize.scale(1 / scale);
368
369 IntPoint pinchViewportMax = flooredIntPoint(FloatSize(contentsSize()) - scal edSize);
370 IntPoint max = view->maximumScrollPosition() + pinchViewportMax;
371 IntPoint min = view->minimumScrollPosition(); // PinchViewportMin should be (0, 0)
372
373 IntPoint clamped = offset;
374 clamped = clamped.shrunkTo(max);
375 clamped = clamped.expandedTo(min);
376 return clamped;
377 }
378
354 IntRect PinchViewport::scrollableAreaBoundingBox() const 379 IntRect PinchViewport::scrollableAreaBoundingBox() const
355 { 380 {
356 // This method should return the bounding box in the parent view's coordinat e 381 // This method should return the bounding box in the parent view's coordinat e
357 // space; however, PinchViewport technically isn't a child of any Frames. 382 // space; however, PinchViewport technically isn't a child of any Frames.
358 // Nonetheless, the PinchViewport always occupies the entire main frame so j ust 383 // Nonetheless, the PinchViewport always occupies the entire main frame so j ust
359 // return that. 384 // return that.
360 LocalFrame* frame = mainFrame(); 385 LocalFrame* frame = mainFrame();
361 386
362 if (!frame || !frame->view()) 387 if (!frame || !frame->view())
363 return IntRect(); 388 return IntRect();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { 467 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) {
443 name = "Overlay Scrollbar Vertical Layer"; 468 name = "Overlay Scrollbar Vertical Layer";
444 } else { 469 } else {
445 ASSERT_NOT_REACHED(); 470 ASSERT_NOT_REACHED();
446 } 471 }
447 472
448 return name; 473 return name;
449 } 474 }
450 475
451 } // namespace blink 476 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698