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

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: Added backward compatibility, tests 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
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 2653 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 float WebViewImpl::minimumPageScaleFactor() const 3033 float WebViewImpl::minimumPageScaleFactor() const
3035 { 3034 {
3036 return m_pageScaleConstraintsSet.finalConstraints().minimumScale; 3035 return m_pageScaleConstraintsSet.finalConstraints().minimumScale;
3037 } 3036 }
3038 3037
3039 float WebViewImpl::maximumPageScaleFactor() const 3038 float WebViewImpl::maximumPageScaleFactor() const
3040 { 3039 {
3041 return m_pageScaleConstraintsSet.finalConstraints().maximumScale; 3040 return m_pageScaleConstraintsSet.finalConstraints().maximumScale;
3042 } 3041 }
3043 3042
3044 void WebViewImpl::saveScrollAndScaleState()
3045 {
3046 m_savedPageScaleFactor = pageScaleFactor();
3047 m_savedScrollOffset = mainFrame()->scrollOffset();
3048 }
3049
3050 void WebViewImpl::restoreScrollAndScaleState()
3051 {
3052 if (!m_savedPageScaleFactor)
3053 return;
3054
3055 startPageScaleAnimation(IntPoint(m_savedScrollOffset), false, m_savedPageSca leFactor, scrollAndScaleAnimationDurationInSeconds);
3056 resetSavedScrollAndScaleState();
3057 }
3058
3059 void WebViewImpl::resetSavedScrollAndScaleState()
3060 {
3061 m_savedPageScaleFactor = 0;
3062 m_savedScrollOffset = IntSize();
3063 }
3064
3065 void WebViewImpl::resetScrollAndScaleState() 3043 void WebViewImpl::resetScrollAndScaleState()
3066 { 3044 {
3067 setPageScaleFactor(1, IntPoint()); 3045 // TODO: This is done by the pinchViewport().reset() call below and can be r emoved when
3046 // the new pinch path is the only one.
3047 setPageScaleFactor(1);
3048 updateMainFrameScrollPosition(IntPoint(), true);
3049 page()->frameHost().pinchViewport().reset();
3068 3050
3069 // Clear out the values for the current history item. This will prevent the history item from clobbering the 3051 // Clear out the values for the current history item. This will prevent the history item from clobbering the
3070 // value determined during page scale initialization, which may be less than 1. 3052 // value determined during page scale initialization, which may be less than 1.
3071 page()->mainFrame()->loader().clearScrollPositionAndViewState(); 3053 page()->mainFrame()->loader().clearScrollPositionAndViewState();
3072 m_pageScaleConstraintsSet.setNeedsReset(true); 3054 m_pageScaleConstraintsSet.setNeedsReset(true);
3073 3055
3074 // Clobber saved scales and scroll offsets. 3056 // Clobber saved scales and scroll offsets.
3075 if (FrameView* view = page()->mainFrame()->document()->view()) 3057 if (FrameView* view = page()->mainFrame()->document()->view())
3076 view->cacheCurrentScrollPosition(); 3058 view->cacheCurrentScrollPosition();
3077 resetSavedScrollAndScaleState();
3078 } 3059 }
3079 3060
3080 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize) 3061 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize)
3081 { 3062 {
3082 if (!page()) 3063 if (!page())
3083 return; 3064 return;
3084 3065
3085 LocalFrame* frame = page()->mainFrame(); 3066 LocalFrame* frame = page()->mainFrame();
3086 if (!frame) 3067 if (!frame)
3087 return; 3068 return;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
3567 } 3548 }
3568 3549
3569 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag e) 3550 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag e)
3570 { 3551 {
3571 if (isNewNavigation && !isNavigationWithinPage) 3552 if (isNewNavigation && !isNavigationWithinPage)
3572 m_pageScaleConstraintsSet.setNeedsReset(true); 3553 m_pageScaleConstraintsSet.setNeedsReset(true);
3573 3554
3574 // Make sure link highlight from previous page is cleared. 3555 // Make sure link highlight from previous page is cleared.
3575 m_linkHighlights.clear(); 3556 m_linkHighlights.clear();
3576 endActiveFlingAnimation(); 3557 endActiveFlingAnimation();
3577 resetSavedScrollAndScaleState();
3578 m_userGestureObserved = false; 3558 m_userGestureObserved = false;
3579 } 3559 }
3580 3560
3581 void WebViewImpl::willInsertBody(WebLocalFrameImpl* webframe) 3561 void WebViewImpl::willInsertBody(WebLocalFrameImpl* webframe)
3582 { 3562 {
3583 if (webframe != mainFrameImpl()) 3563 if (webframe != mainFrameImpl())
3584 return; 3564 return;
3585 3565
3586 // If we get to the <body> tag and we have no pending stylesheet and import load, we 3566 // If we get to the <body> tag and we have no pending stylesheet and import load, we
3587 // can be fairly confident we'll have something sensible to paint soon and 3567 // can be fairly confident we'll have something sensible to paint soon and
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
4109 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4089 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4110 4090
4111 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4091 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4112 return false; 4092 return false;
4113 4093
4114 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4094 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4115 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4095 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4116 } 4096 }
4117 4097
4118 } // namespace blink 4098 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698