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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 263853008: Added pinch viewport offset to history item. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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/web/WebViewImpl.h ('k') | Source/web/tests/PinchViewportTest.cpp » ('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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 , m_editorClientImpl(this) 360 , m_editorClientImpl(this)
361 , m_inspectorClientImpl(this) 361 , m_inspectorClientImpl(this)
362 , m_backForwardClientImpl(this) 362 , m_backForwardClientImpl(this)
363 , m_spellCheckerClientImpl(this) 363 , m_spellCheckerClientImpl(this)
364 , m_storageClientImpl(this) 364 , m_storageClientImpl(this)
365 , m_fixedLayoutSizeLock(false) 365 , m_fixedLayoutSizeLock(false)
366 , m_shouldAutoResize(false) 366 , m_shouldAutoResize(false)
367 , m_zoomLevel(0) 367 , m_zoomLevel(0)
368 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) 368 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier))
369 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) 369 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier))
370 , m_savedPageScaleFactor(0)
371 , m_doubleTapZoomPageScaleFactor(0) 370 , m_doubleTapZoomPageScaleFactor(0)
372 , m_doubleTapZoomPending(false) 371 , m_doubleTapZoomPending(false)
373 , m_enableFakePageScaleAnimationForTesting(false) 372 , m_enableFakePageScaleAnimationForTesting(false)
374 , m_fakePageScaleAnimationPageScaleFactor(0) 373 , m_fakePageScaleAnimationPageScaleFactor(0)
375 , m_fakePageScaleAnimationUseAnchor(false) 374 , m_fakePageScaleAnimationUseAnchor(false)
376 , m_contextMenuAllowed(false) 375 , m_contextMenuAllowed(false)
377 , m_doingDragAndDrop(false) 376 , m_doingDragAndDrop(false)
378 , m_ignoreInputEvents(false) 377 , m_ignoreInputEvents(false)
379 , m_compositorDeviceScaleFactorOverride(0) 378 , m_compositorDeviceScaleFactorOverride(0)
380 , m_rootLayerScale(1) 379 , m_rootLayerScale(1)
(...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 float WebViewImpl::minimumPageScaleFactor() const 3040 float WebViewImpl::minimumPageScaleFactor() const
3042 { 3041 {
3043 return m_pageScaleConstraintsSet.finalConstraints().minimumScale; 3042 return m_pageScaleConstraintsSet.finalConstraints().minimumScale;
3044 } 3043 }
3045 3044
3046 float WebViewImpl::maximumPageScaleFactor() const 3045 float WebViewImpl::maximumPageScaleFactor() const
3047 { 3046 {
3048 return m_pageScaleConstraintsSet.finalConstraints().maximumScale; 3047 return m_pageScaleConstraintsSet.finalConstraints().maximumScale;
3049 } 3048 }
3050 3049
3051 void WebViewImpl::saveScrollAndScaleState()
3052 {
3053 m_savedPageScaleFactor = pageScaleFactor();
3054 m_savedScrollOffset = mainFrame()->scrollOffset();
3055 }
3056
3057 void WebViewImpl::restoreScrollAndScaleState()
3058 {
3059 if (!m_savedPageScaleFactor)
3060 return;
3061
3062 startPageScaleAnimation(IntPoint(m_savedScrollOffset), false, m_savedPageSca leFactor, scrollAndScaleAnimationDurationInSeconds);
3063 resetSavedScrollAndScaleState();
3064 }
3065
3066 void WebViewImpl::resetSavedScrollAndScaleState()
3067 {
3068 m_savedPageScaleFactor = 0;
3069 m_savedScrollOffset = IntSize();
3070 }
3071
3072 void WebViewImpl::resetScrollAndScaleState() 3050 void WebViewImpl::resetScrollAndScaleState()
3073 { 3051 {
3074 setPageScaleFactor(1, IntPoint()); 3052 // TODO: This is done by the pinchViewport().reset() call below and can be r emoved when
3053 // the new pinch path is the only one.
3054 setPageScaleFactor(1);
3055 updateMainFrameScrollPosition(IntPoint(), true);
3056 page()->frameHost().pinchViewport().reset();
3075 3057
3076 // Clear out the values for the current history item. This will prevent the history item from clobbering the 3058 // Clear out the values for the current history item. This will prevent the history item from clobbering the
3077 // value determined during page scale initialization, which may be less than 1. 3059 // value determined during page scale initialization, which may be less than 1.
3078 page()->mainFrame()->loader().clearScrollPositionAndViewState(); 3060 page()->mainFrame()->loader().clearScrollPositionAndViewState();
3079 m_pageScaleConstraintsSet.setNeedsReset(true); 3061 m_pageScaleConstraintsSet.setNeedsReset(true);
3080 3062
3081 // Clobber saved scales and scroll offsets. 3063 // Clobber saved scales and scroll offsets.
3082 if (FrameView* view = page()->mainFrame()->document()->view()) 3064 if (FrameView* view = page()->mainFrame()->document()->view())
3083 view->cacheCurrentScrollPosition(); 3065 view->cacheCurrentScrollPosition();
3084 resetSavedScrollAndScaleState();
3085 } 3066 }
3086 3067
3087 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize) 3068 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize)
3088 { 3069 {
3089 if (!page()) 3070 if (!page())
3090 return; 3071 return;
3091 3072
3092 LocalFrame* frame = page()->mainFrame(); 3073 LocalFrame* frame = page()->mainFrame();
3093 if (!frame) 3074 if (!frame)
3094 return; 3075 return;
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 } 3570 }
3590 3571
3591 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag e) 3572 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag e)
3592 { 3573 {
3593 if (isNewNavigation && !isNavigationWithinPage) 3574 if (isNewNavigation && !isNavigationWithinPage)
3594 m_pageScaleConstraintsSet.setNeedsReset(true); 3575 m_pageScaleConstraintsSet.setNeedsReset(true);
3595 3576
3596 // Make sure link highlight from previous page is cleared. 3577 // Make sure link highlight from previous page is cleared.
3597 m_linkHighlights.clear(); 3578 m_linkHighlights.clear();
3598 endActiveFlingAnimation(); 3579 endActiveFlingAnimation();
3599 resetSavedScrollAndScaleState();
3600 m_userGestureObserved = false; 3580 m_userGestureObserved = false;
3601 } 3581 }
3602 3582
3603 void WebViewImpl::willInsertBody(WebLocalFrameImpl* webframe) 3583 void WebViewImpl::willInsertBody(WebLocalFrameImpl* webframe)
3604 { 3584 {
3605 if (webframe != mainFrameImpl()) 3585 if (webframe != mainFrameImpl())
3606 return; 3586 return;
3607 3587
3608 // If we get to the <body> tag and we have no pending stylesheet and import load, we 3588 // If we get to the <body> tag and we have no pending stylesheet and import load, we
3609 // can be fairly confident we'll have something sensible to paint soon and 3589 // can be fairly confident we'll have something sensible to paint soon and
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
4132 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4112 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4133 4113
4134 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4114 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4135 return false; 4115 return false;
4136 4116
4137 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4117 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4138 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4118 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4139 } 4119 }
4140 4120
4141 } // namespace blink 4121 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/PinchViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698