Commit 093ee96f authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

Revert "[ios] Fix VoiceOver Issues in Tabgrid"

This reverts commit fbe67a95.

Reason for revert: Breaks TabSwitcherTransitionTestCase\testRotationsWhileSwitcherIsNotActive

Original change's description:
> [ios] Fix VoiceOver Issues in Tabgrid
> 
> - Updates _currentPage properly in response to 3-finger accessibility swipe. This will now properly read out the currently visible page if a user swipes to a different page.
> - Ensures that only the currently visible page's elements can be selected in the scroll view. This resolves an issue VoiceOver was having with what page to readout and to focus on. Oftentimes the visible page was not readout or selectable.
> 
> Video: https://drive.google.com/open?id=1Q62MUlrVcNlqnFIQOfw_YiGHinTKb_45
> 
> Bug: 880079
> Change-Id: I0696786292bec375af9d5326a790700000114559
> Reviewed-on: https://chromium-review.googlesource.com/1221474
> Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
> Reviewed-by: Mark Cogan <marq@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#592818}

TBR=marq@chromium.org,thegreenfrog@chromium.org

Change-Id: Idb378ca1c1a1405275975e47956ac94d09865ab1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 880079
Reviewed-on: https://chromium-review.googlesource.com/1237174Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592937}
parent 38a7b535
......@@ -277,30 +277,25 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
if (UseRTLLayout())
offset = 1.0 - offset;
self.topToolbar.pageControl.sliderPosition = offset;
}
// Update _currentPage if scroll view has moved to a new page. Important to
// note that changing pages with a 3-finger accessibiility swipe is not
// registered as dragging.
TabGridPage page = GetPageFromScrollView(scrollView);
if (page != _currentPage) {
_currentPage = page;
if (scrollView.dragging || scrollView.decelerating) {
TabGridPage page = GetPageFromScrollView(scrollView);
if (page != _currentPage) {
_currentPage = page;
[self broadcastIncognitoContentVisibility];
[self configureButtonsForActiveAndCurrentPage];
// Records when the user drags the scrollView to switch pages.
[self recordActionSwitchingToPage:_currentPage];
}
// TODO(crbug.com/872303) : This is a workaround because TabRestoreService
// does not notify observers when entries are removed. When close all tabs
// removes entries, the remote tabs page in the tab grid are not updated.
// This ensures that the table is updated whenever scrolling to it.
if (_currentPage == TabGridPageRemoteTabs) {
[self.remoteTabsViewController loadModel];
[self.remoteTabsViewController.tableView reloadData];
}
// TODO(crbug.com/872303) : This is a workaround because TabRestoreService
// does not notify observers when entries are removed. When close all tabs
// removes entries, the remote tabs page in the tab grid are not updated.
// This ensures that the table is updated whenever scrolling to it.
if (_currentPage == TabGridPageRemoteTabs) {
[self.remoteTabsViewController loadModel];
[self.remoteTabsViewController.tableView reloadData];
}
}
}
}
- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView {
......@@ -309,18 +304,21 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// scrolling.
self.topToolbar.pageControl.userInteractionEnabled = NO;
self.pageChangeInteraction = PageChangeInteractionScrollDrag;
[self updatePageViewAccessibilityVisibility];
}
- (void)scrollViewDidEndDragging:(UIScrollView*)scrollView
willDecelerate:(BOOL)decelerate {
// Re-enable the page control since the user isn't dragging anymore.
self.topToolbar.pageControl.userInteractionEnabled = YES;
[self updatePageViewAccessibilityVisibility];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView {
// Mark the interaction as ended, so that scrolls that don't change page don't
// cause other interactions to be mislabeled.
self.pageChangeInteraction = PageChangeInteractionNone;
[self updatePageViewAccessibilityVisibility];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView*)scrollView {
......@@ -533,15 +531,9 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// the ivar may have been set before the scroll view could be updated. Calling
// this method should always update the scroll view's offset if possible.
// Original current page is about to not be visible. Disable it from being
// focused by VoiceOver.
self.currentPageViewController.view.accessibilityElementsHidden = YES;
// If the view isn't loaded yet, just do bookkeeping on _currentPage.
if (!self.viewLoaded) {
_currentPage = currentPage;
// Allow VoiceOver to focus on the new current page's elements.
self.currentPageViewController.view.accessibilityElementsHidden = NO;
return;
}
CGFloat pageWidth = self.scrollView.frame.size.width;
......@@ -564,9 +556,6 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
_currentPage = currentPage;
}
}
// Allow VoiceOver to focus on the new current page's elements.
self.currentPageViewController.view.accessibilityElementsHidden = NO;
// TODO(crbug.com/872303) : This is a workaround because TabRestoreService
// does not notify observers when entries are removed. When close all tabs
// removes entries, the remote tabs page in the tab grid are not updated. This
......@@ -593,6 +582,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
if (_scrollViewAnimatingContentOffset == scrollViewAnimatingContentOffset)
return;
_scrollViewAnimatingContentOffset = scrollViewAnimatingContentOffset;
[self updatePageViewAccessibilityVisibility];
}
// Adds the scroll view and sets constraints.
......@@ -918,6 +908,19 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
kTabGridCloseAllButtonIdentifier;
}
// Updates the visibility of the pages' accessibility elements. When
// |scrollView| is scrolling, all pages should be visible. When stationary,
// however, the accessibility elements of off-screen pages should be hidden.
- (void)updatePageViewAccessibilityVisibility {
BOOL scrolling = self.scrollView.dragging || self.scrollView.decelerating ||
self.scrollViewAnimatingContentOffset;
UIViewController* currentPageViewController = self.currentPageViewController;
for (UIViewController* pageViewController in self.pageViewControllers) {
pageViewController.view.accessibilityElementsHidden =
!scrolling && pageViewController != currentPageViewController;
}
}
// Shows the two toolbars and the floating button. Suitable for use in
// animations.
- (void)showToolbars {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment