@@ -2479,6 +2479,13 @@ private void updateViewport() {
24792479 setupViewport (true );
24802480 }
24812481
2482+ static float getFixedDisplayDensity (Context context ) {
2483+ // We make bad assumptions about multiplying and dividing density by 100,
2484+ // force them to be true with this hack
2485+ float density = context .getResources ().getDisplayMetrics ().density ;
2486+ return ((int ) (density * 100 )) / 100.0f ;
2487+ }
2488+
24822489 private void setupViewport (boolean updateViewState ) {
24832490 if (mWebViewClassic == null || mSettings == null ) {
24842491 // We've been destroyed or are being destroyed, return early
@@ -2523,14 +2530,13 @@ private void setupViewport(boolean updateViewState) {
25232530 // adjust the default scale to match the densityDpi
25242531 float adjust = 1.0f ;
25252532 if (mViewportDensityDpi == -1 ) {
2526- adjust = mContext . getResources (). getDisplayMetrics (). density ;
2533+ adjust = getFixedDisplayDensity ( mContext ) ;
25272534 } else if (mViewportDensityDpi > 0 ) {
25282535 adjust = (float ) mContext .getResources ().getDisplayMetrics ().densityDpi
25292536 / mViewportDensityDpi ;
2537+ adjust = ((int ) (adjust * 100 )) / 100.0f ;
25302538 }
2531- // We make bad assumptions about multiplying and dividing by 100, force
2532- // them to be true with this hack
2533- adjust = ((int ) (adjust * 100 )) / 100.0f ;
2539+
25342540 // Remove any update density messages in flight.
25352541 // If the density is indeed different from WebView's default scale,
25362542 // a new message will be queued.
0 commit comments