Commit e6402bf2 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Adjust ContentSuggestions accessibility scrolling

When the user scrolls with voice over activated, the scroll is done by
increasing the collection scroll by the height of the collection view.
As the collection is displaying the fake omnibox as an overlay, the
content hidden by the omnibox is not taken into account by the default
computation. This CL fixes it by taking it into account.

Bug: 763940
Change-Id: I3111037cbee73521096bbe9dbe264d809ac5088c
Reviewed-on: https://chromium-review.googlesource.com/660220Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501295}
parent d72e9b4a
......@@ -590,6 +590,35 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
ntp_home::FakeOmniboxAccessibilityID();
}
#pragma mark - UIAccessibilityAction
- (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction {
// The collection displays the fake omnibox on the top of the other elements.
// The default scrolling action scrolls for the full height of the collection,
// hiding elements behing the fake omnibox. This reduces the scrolling by the
// height of the fake omnibox.
if (direction == UIAccessibilityScrollDirectionDown) {
CGFloat newYOffset = self.collectionView.contentOffset.y +
self.collectionView.bounds.size.height -
ntp_header::kToolbarHeight;
newYOffset = MIN(self.collectionView.contentSize.height -
self.collectionView.bounds.size.height,
newYOffset);
self.collectionView.contentOffset =
CGPointMake(self.collectionView.contentOffset.x, newYOffset);
} else if (direction == UIAccessibilityScrollDirectionUp) {
CGFloat newYOffset = self.collectionView.contentOffset.y -
self.collectionView.bounds.size.height +
ntp_header::kToolbarHeight;
newYOffset = MAX(0, newYOffset);
self.collectionView.contentOffset =
CGPointMake(self.collectionView.contentOffset.x, newYOffset);
} else {
return NO;
}
return YES;
}
#pragma mark - Private
- (void)handleLongPress:(UILongPressGestureRecognizer*)gestureRecognizer {
......
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