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

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

Issue 1158673006: Replace various ScrollableArea scroll methods with setScrollPosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Build fix Created 5 years, 6 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/frame/RootFrameViewport.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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // Keep the center-of-pinch anchor in a stable position over the course 236 // Keep the center-of-pinch anchor in a stable position over the course
237 // of the magnify. 237 // of the magnify.
238 FloatPoint anchorAtOldScale = anchor.scaledBy(1.f / oldPageScale); 238 FloatPoint anchorAtOldScale = anchor.scaledBy(1.f / oldPageScale);
239 FloatPoint anchorAtNewScale = anchor.scaledBy(1.f / newPageScale); 239 FloatPoint anchorAtNewScale = anchor.scaledBy(1.f / newPageScale);
240 FloatSize anchorDelta = anchorAtOldScale - anchorAtNewScale; 240 FloatSize anchorDelta = anchorAtOldScale - anchorAtNewScale;
241 241
242 // First try to use the anchor's delta to scroll the FrameView. 242 // First try to use the anchor's delta to scroll the FrameView.
243 FloatSize anchorDeltaUnusedByScroll = anchorDelta; 243 FloatSize anchorDeltaUnusedByScroll = anchorDelta;
244 FrameView* view = mainFrame()->view(); 244 FrameView* view = mainFrame()->view();
245 DoublePoint oldPosition = view->scrollPositionDouble(); 245 DoublePoint oldPosition = view->scrollPositionDouble();
246 view->scrollBy(DoubleSize(anchorDelta.width(), anchorDelta.height())); 246 view->scrollBy(DoubleSize(anchorDelta.width(), anchorDelta.height()), UserSc roll);
247 DoublePoint newPosition = view->scrollPositionDouble(); 247 DoublePoint newPosition = view->scrollPositionDouble();
248 anchorDeltaUnusedByScroll = anchorDelta - toFloatSize(newPosition - oldPosit ion); 248 anchorDeltaUnusedByScroll = anchorDelta - toFloatSize(newPosition - oldPosit ion);
249 249
250 // Manually bubble any remaining anchor delta up to the pinch viewport. 250 // Manually bubble any remaining anchor delta up to the pinch viewport.
251 FloatPoint newLocation(location() + anchorDeltaUnusedByScroll); 251 FloatPoint newLocation(location() + anchorDeltaUnusedByScroll);
252 setScaleAndLocation(newPageScale, newLocation); 252 setScaleAndLocation(newPageScale, newLocation);
253 return true; 253 return true;
254 } 254 }
255 255
256 // Modifies the top of the graphics layer tree to add layers needed to support 256 // Modifies the top of the graphics layer tree to add layers needed to support
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 519
520 return frame->view()->visibleContentRect(IncludeScrollbars).size(); 520 return frame->view()->visibleContentRect(IncludeScrollbars).size();
521 } 521 }
522 522
523 void PinchViewport::invalidateScrollbarRect(Scrollbar*, const IntRect&) 523 void PinchViewport::invalidateScrollbarRect(Scrollbar*, const IntRect&)
524 { 524 {
525 // Do nothing. Pinch scrollbars live on the compositor thread and will 525 // Do nothing. Pinch scrollbars live on the compositor thread and will
526 // be updated when the viewport is synced to the CC. 526 // be updated when the viewport is synced to the CC.
527 } 527 }
528 528
529 void PinchViewport::setScrollOffset(const IntPoint& offset) 529 void PinchViewport::setScrollOffset(const IntPoint& offset, ScrollType scrollTyp e)
530 { 530 {
531 setScrollOffset(DoublePoint(offset)); 531 setScrollOffset(DoublePoint(offset), scrollType);
532 } 532 }
533 533
534 void PinchViewport::setScrollOffset(const DoublePoint& offset) 534 void PinchViewport::setScrollOffset(const DoublePoint& offset, ScrollType)
535 { 535 {
536 setLocation(toFloatPoint(offset)); 536 setLocation(toFloatPoint(offset));
537 } 537 }
538 538
539 GraphicsLayer* PinchViewport::layerForContainer() const 539 GraphicsLayer* PinchViewport::layerForContainer() const
540 { 540 {
541 return m_innerViewportContainerLayer.get(); 541 return m_innerViewportContainerLayer.get();
542 } 542 }
543 543
544 GraphicsLayer* PinchViewport::layerForScrolling() const 544 GraphicsLayer* PinchViewport::layerForScrolling() const
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } else if (graphicsLayer == m_rootTransformLayer) { 652 } else if (graphicsLayer == m_rootTransformLayer) {
653 name = "Root Transform Layer"; 653 name = "Root Transform Layer";
654 } else { 654 } else {
655 ASSERT_NOT_REACHED(); 655 ASSERT_NOT_REACHED();
656 } 656 }
657 657
658 return name; 658 return name;
659 } 659 }
660 660
661 } // namespace blink 661 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/core/frame/RootFrameViewport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698