Skip to content

Commit 760bf7d

Browse files
mghiwareAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue# 5492404: Reading level check thread error."
2 parents 2b41c2f + bb99e28 commit 760bf7d

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

core/java/android/webkit/WebSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ public synchronized TextSize getTextSize() {
777777
public void setDoubleTapZoom(int doubleTapZoom) {
778778
if (mDoubleTapZoom != doubleTapZoom) {
779779
mDoubleTapZoom = doubleTapZoom;
780-
mWebView.updateDoubleTapZoom();
780+
mWebView.updateDoubleTapZoom(doubleTapZoom);
781781
}
782782
}
783783

core/java/android/webkit/WebView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,8 +2995,8 @@ boolean sendViewSizeZoom(boolean force) {
29952995
/**
29962996
* Update the double-tap zoom.
29972997
*/
2998-
/* package */ void updateDoubleTapZoom() {
2999-
mZoomManager.updateDoubleTapZoom();
2998+
/* package */ void updateDoubleTapZoom(int doubleTapZoom) {
2999+
mZoomManager.updateDoubleTapZoom(doubleTapZoom);
30003000
}
30013001

30023002
private int computeRealHorizontalScrollRange() {

core/java/android/webkit/ZoomManager.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ class ZoomManager {
151151
*/
152152
private float mDisplayDensity;
153153

154+
/*
155+
* The factor that is used to tweak the zoom scale on a double-tap,
156+
* and can be changed via WebSettings. Range is from 0.75f to 1.25f.
157+
*/
158+
private float mDoubleTapZoomFactor = 1.0f;
159+
154160
/*
155161
* The scale factor that is used as the minimum increment when going from
156162
* overview to reading level on a double tap.
@@ -314,10 +320,7 @@ public final float getDefaultScale() {
314320
* Returns the zoom scale used for reading text on a double-tap.
315321
*/
316322
public final float getReadingLevelScale() {
317-
WebSettings settings = mWebView.getSettings();
318-
final float doubleTapZoomFactor = settings != null
319-
? settings.getDoubleTapZoom() / 100.f : 1.0f;
320-
return mDisplayDensity * doubleTapZoomFactor;
323+
return mDisplayDensity * mDoubleTapZoomFactor;
321324
}
322325

323326
public final float getInvDefaultScale() {
@@ -516,8 +519,9 @@ public boolean isFixedLengthAnimationInProgress() {
516519
return mZoomScale != 0 || mInHWAcceleratedZoom;
517520
}
518521

519-
public void updateDoubleTapZoom() {
522+
public void updateDoubleTapZoom(int doubleTapZoom) {
520523
if (mInZoomOverview) {
524+
mDoubleTapZoomFactor = doubleTapZoom / 100.0f;
521525
mTextWrapScale = getReadingLevelScale();
522526
refreshZoomScale(true);
523527
}

0 commit comments

Comments
 (0)