Commit 4dbcdad0 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Enable/disable TextZoom reset button based on reset state

Right now, only the zoom in/out buttons adjust based on whether zooming
in or out would change anything. The reset button should adjust the
same way.

Bug: 1053977
Change-Id: I83903b4a55953e4984a61f9ba6b7eaa8858d95fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063134
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742652}
parent 558f048b
......@@ -11,6 +11,8 @@
- (void)setZoomInEnabled:(BOOL)enabled;
// Tells the consumer that the user can currently zoom out.
- (void)setZoomOutEnabled:(BOOL)enabled;
// Tells the consumer that the user can currently reset the zoom level.
- (void)setResetZoomEnabled:(BOOL)enabled;
@end
......
......@@ -129,6 +129,8 @@
- (void)updateConsumerState {
[self.consumer setZoomInEnabled:self.fontSizeTabHelper->CanUserZoomIn()];
[self.consumer setZoomOutEnabled:self.fontSizeTabHelper->CanUserZoomOut()];
[self.consumer
setResetZoomEnabled:self.fontSizeTabHelper->CanUserResetZoom()];
}
#pragma mark - CRWWebStateObserver
......
......@@ -208,4 +208,8 @@ const CGFloat kDividerWidth = 1;
self.decrementButton.enabled = enabled;
}
- (void)setResetZoomEnabled:(BOOL)enabled {
self.resetButton.enabled = enabled;
}
@end
......@@ -43,6 +43,9 @@ class FontSizeTabHelper : public web::WebStateObserver,
// Returns whether the user can still zoom out. (I.e., They have not reached
// the min zoom level.).
bool CanUserZoomOut() const;
// Returns whether the user can reset the zoom level. (I.e., They are not at
// the default zoom level.)
bool CanUserResetZoom() const;
// Remove any stored zoom levels from the provided |PrefService|.
static void ClearUserZoomPrefs(PrefService* pref_service);
......
......@@ -192,6 +192,12 @@ bool FontSizeTabHelper::CanUserZoomOut() const {
return NewMultiplierAfterZoom(ZOOM_OUT).has_value();
}
bool FontSizeTabHelper::CanUserResetZoom() const {
base::Optional<double> new_multiplier = NewMultiplierAfterZoom(ZOOM_RESET);
return new_multiplier.has_value() &&
new_multiplier.value() != GetCurrentUserZoomMultiplier();
}
int FontSizeTabHelper::GetFontSize() const {
// Multiply by 100 as the web property needs a percentage.
return SystemSuggestedFontSizeMultiplier() * GetCurrentUserZoomMultiplier() *
......
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