forked from mirrors/gecko-dev
		
	Bug 1811575 - Make sure the swipe-to-navigation icon isn't rendered at zero progress gesture value. r=tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D167513
This commit is contained in:
		
							parent
							
								
									81c0d1dfea
								
							
						
					
					
						commit
						fb1dc455fa
					
				
					 2 changed files with 121 additions and 22 deletions
				
			
		|  | @ -736,6 +736,19 @@ var gHistorySwipeAnimation = { | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|  |   _willGoBack: function HSA_willGoBack(aVal) { | ||||||
|  |     return ( | ||||||
|  |       ((aVal > 0 && this.isLTR) || (aVal < 0 && !this.isLTR)) && this._canGoBack | ||||||
|  |     ); | ||||||
|  |   }, | ||||||
|  | 
 | ||||||
|  |   _willGoForward: function HSA_willGoForward(aVal) { | ||||||
|  |     return ( | ||||||
|  |       ((aVal > 0 && !this.isLTR) || (aVal < 0 && this.isLTR)) && | ||||||
|  |       this._canGoForward | ||||||
|  |     ); | ||||||
|  |   }, | ||||||
|  | 
 | ||||||
|   /** |   /** | ||||||
|    * Updates the animation between two pages in history. |    * Updates the animation between two pages in history. | ||||||
|    * |    * | ||||||
|  | @ -765,28 +778,25 @@ var gHistorySwipeAnimation = { | ||||||
|     // Compute the icon radius based on preferences.
 |     // Compute the icon radius based on preferences.
 | ||||||
|     const radius = |     const radius = | ||||||
|       this.minRadius + progress * (this.maxRadius - this.minRadius); |       this.minRadius + progress * (this.maxRadius - this.minRadius); | ||||||
|     if ((aVal >= 0 && this.isLTR) || (aVal <= 0 && !this.isLTR)) { |     if (this._willGoBack(aVal)) { | ||||||
|       // The intention is to go back.
 |       this._prevBox.collapsed = false; | ||||||
|       if (this._canGoBack) { |       this._nextBox.collapsed = true; | ||||||
|         this._prevBox.collapsed = false; |       this._prevBox.style.translate = `${translate}px 0px`; | ||||||
|         this._nextBox.collapsed = true; |       if (radius >= 0) { | ||||||
|         this._prevBox.style.translate = `${translate}px 0px`; |         this._prevBox | ||||||
|         if (radius >= 0) { |           .querySelectorAll("circle")[1] | ||||||
|           this._prevBox |           .setAttribute("r", `${radius}`); | ||||||
|             .querySelectorAll("circle")[1] |  | ||||||
|             .setAttribute("r", `${radius}`); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (Math.abs(aVal) >= 0.25) { |  | ||||||
|           // If `aVal` goes above 0.25, it means history navigation will be
 |  | ||||||
|           // triggered once after the user lifts their fingers, it's time to
 |  | ||||||
|           // trigger __indicator__ animations by adding `will-navigate` class.
 |  | ||||||
|           this._prevBox.querySelector("svg").classList.add("will-navigate"); |  | ||||||
|         } else { |  | ||||||
|           this._prevBox.querySelector("svg").classList.remove("will-navigate"); |  | ||||||
|         } |  | ||||||
|       } |       } | ||||||
|     } else if (this._canGoForward) { | 
 | ||||||
|  |       if (Math.abs(aVal) >= 0.25) { | ||||||
|  |         // If `aVal` goes above 0.25, it means history navigation will be
 | ||||||
|  |         // triggered once after the user lifts their fingers, it's time to
 | ||||||
|  |         // trigger __indicator__ animations by adding `will-navigate` class.
 | ||||||
|  |         this._prevBox.querySelector("svg").classList.add("will-navigate"); | ||||||
|  |       } else { | ||||||
|  |         this._prevBox.querySelector("svg").classList.remove("will-navigate"); | ||||||
|  |       } | ||||||
|  |     } else if (this._willGoForward(aVal)) { | ||||||
|       // The intention is to go forward.
 |       // The intention is to go forward.
 | ||||||
|       this._nextBox.collapsed = false; |       this._nextBox.collapsed = false; | ||||||
|       this._prevBox.collapsed = true; |       this._prevBox.collapsed = true; | ||||||
|  | @ -803,6 +813,11 @@ var gHistorySwipeAnimation = { | ||||||
|       } else { |       } else { | ||||||
|         this._nextBox.querySelector("svg").classList.remove("will-navigate"); |         this._nextBox.querySelector("svg").classList.remove("will-navigate"); | ||||||
|       } |       } | ||||||
|  |     } else { | ||||||
|  |       this._prevBox.collapsed = true; | ||||||
|  |       this._nextBox.collapsed = true; | ||||||
|  |       this._prevBox.style.translate = "none"; | ||||||
|  |       this._nextBox.style.translate = "none"; | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -830,7 +830,7 @@ add_task(async () => { | ||||||
|   await SpecialPowers.pushPrefEnv({ |   await SpecialPowers.pushPrefEnv({ | ||||||
|     set: [ |     set: [ | ||||||
|       ["browser.gesture.swipe.left", "Browser:BackOrBackDuplicate"], |       ["browser.gesture.swipe.left", "Browser:BackOrBackDuplicate"], | ||||||
|       ["browser.gesture.swipe.eight", "Browser:ForwardOrForwardDuplicate"], |       ["browser.gesture.swipe.right", "Browser:ForwardOrForwardDuplicate"], | ||||||
|       ["widget.disable-swipe-tracker", false], |       ["widget.disable-swipe-tracker", false], | ||||||
|       ["widget.swipe.velocity-twitch-tolerance", 0.0000001], |       ["widget.swipe.velocity-twitch-tolerance", 0.0000001], | ||||||
|       ["widget.swipe.success-velocity-contribution", 0.5], |       ["widget.swipe.success-velocity-contribution", 0.5], | ||||||
|  | @ -892,6 +892,90 @@ add_task(async () => { | ||||||
|   await SpecialPowers.popPrefEnv(); |   await SpecialPowers.popPrefEnv(); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | add_task(async () => { | ||||||
|  |   await SpecialPowers.pushPrefEnv({ | ||||||
|  |     set: [ | ||||||
|  |       ["browser.gesture.swipe.left", "Browser:BackOrBackDuplicate"], | ||||||
|  |       ["browser.gesture.swipe.right", "Browser:ForwardOrForwardDuplicate"], | ||||||
|  |       ["widget.disable-swipe-tracker", false], | ||||||
|  |       ["widget.swipe.velocity-twitch-tolerance", 0.0000001], | ||||||
|  |       ["widget.swipe.success-velocity-contribution", 0.5], | ||||||
|  |     ], | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   // Load three pages and go to the second page so that it can be navigated
 | ||||||
|  |   // to both back and forward.
 | ||||||
|  |   const tab = await BrowserTestUtils.openNewForegroundTab( | ||||||
|  |     gBrowser, | ||||||
|  |     "about:about", | ||||||
|  |     true /* waitForLoad */ | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   BrowserTestUtils.loadURIString(tab.linkedBrowser, "about:mozilla"); | ||||||
|  |   await BrowserTestUtils.browserLoaded( | ||||||
|  |     tab.linkedBrowser, | ||||||
|  |     false /* includeSubFrames */, | ||||||
|  |     "about:mozilla" | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   BrowserTestUtils.loadURIString(tab.linkedBrowser, "about:home"); | ||||||
|  |   await BrowserTestUtils.browserLoaded( | ||||||
|  |     tab.linkedBrowser, | ||||||
|  |     false /* includeSubFrames */, | ||||||
|  |     "about:home" | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   gBrowser.goBack(); | ||||||
|  |   await BrowserTestUtils.browserLoaded( | ||||||
|  |     tab.linkedBrowser, | ||||||
|  |     false /* includeSubFrames */, | ||||||
|  |     "about:mozilla" | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   // Make sure we can go back and go forward.
 | ||||||
|  |   ok(gBrowser.webNavigation.canGoBack); | ||||||
|  |   ok(gBrowser.webNavigation.canGoForward); | ||||||
|  | 
 | ||||||
|  |   // Start a history back pan gesture but keep touching.
 | ||||||
|  |   await panLeftToRightBegin(tab.linkedBrowser, 100, 100, 1); | ||||||
|  | 
 | ||||||
|  |   ok( | ||||||
|  |     !gHistorySwipeAnimation._prevBox.collapsed, | ||||||
|  |     "The icon box for the previous navigation should NOT be collapsed" | ||||||
|  |   ); | ||||||
|  |   ok( | ||||||
|  |     gHistorySwipeAnimation._nextBox.collapsed, | ||||||
|  |     "The icon box for the next navigation should be collapsed" | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   // Pan back to the opposite direction so that the gesture should be cancelled.
 | ||||||
|  |   // eslint-disable-next-line no-undef
 | ||||||
|  |   await NativePanHandler.promiseNativePanEvent( | ||||||
|  |     tab.linkedBrowser, | ||||||
|  |     100, | ||||||
|  |     100, | ||||||
|  |     // eslint-disable-next-line no-undef
 | ||||||
|  |     NativePanHandler.delta, | ||||||
|  |     0, | ||||||
|  |     // eslint-disable-next-line no-undef
 | ||||||
|  |     NativePanHandler.updatePhase | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   ok( | ||||||
|  |     gHistorySwipeAnimation._prevBox.collapsed, | ||||||
|  |     "The icon box for the previous navigation should be collapsed" | ||||||
|  |   ); | ||||||
|  |   ok( | ||||||
|  |     gHistorySwipeAnimation._nextBox.collapsed, | ||||||
|  |     "The icon box for the next navigation should be collapsed" | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   await panLeftToRightEnd(tab.linkedBrowser, 100, 100, 0); | ||||||
|  | 
 | ||||||
|  |   BrowserTestUtils.removeTab(tab); | ||||||
|  |   await SpecialPowers.popPrefEnv(); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
| // NOTE: This test listens wheel events so that it causes an overscroll issue
 | // NOTE: This test listens wheel events so that it causes an overscroll issue
 | ||||||
| // (bug 1800022). To avoid the bug, we need to run this test case at the end
 | // (bug 1800022). To avoid the bug, we need to run this test case at the end
 | ||||||
| // of this file.
 | // of this file.
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Hiroyuki Ikezoe
						Hiroyuki Ikezoe