Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 2202123002: Make WebView respond to device scale change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combined two setSize methods again with question Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index f7f3ccedb74ef11394aca7df48d17a9b69874e5d..f6fe34efc886356b615bb1ab660f36d28edbd970 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -955,6 +955,15 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
}
/**
+ * Sets the device scale factor (maps DIP pixels to physical pixels).
+ */
+ public void setDeviceScaleFactor(float value) {
+ mRenderCoordinates.setDeviceScaleFactor(value);
+ if (mNativeContentViewCore == 0) return;
+ nativeSetDeviceScaleFactor(mNativeContentViewCore, value);
+ }
+
+ /**
* @return Current page scale factor (maps CSS pixels to DIP pixels).
*/
@VisibleForTesting
@@ -1471,6 +1480,28 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
}
}
+ /**
+ * Called when the underlying surface size and the viewport size are changed
+ * simultaneously. This may happen in WebView.
+ */
+ public void onPhysicalAndViewportSizeChanged(int wPix, int hPix) {
+ if (mPhysicalBackingWidthPix == wPix && mPhysicalBackingHeightPix == hPix
+ && getViewportWidthPix() == wPix && getViewportHeightPix() == hPix) {
+ return;
+ }
+
+ mPhysicalBackingWidthPix = wPix;
+ mPhysicalBackingHeightPix = hPix;
+ mViewportWidthPix = wPix;
+ mViewportHeightPix = hPix;
+
+ if (mNativeContentViewCore != 0) {
+ nativeWasResized(mNativeContentViewCore);
+ }
+
+ updateAfterSizeChanged();
+ }
+
private void updateAfterSizeChanged() {
mPopupZoomer.hide(false);
@@ -3321,6 +3352,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean focused);
+ private native void nativeSetDeviceScaleFactor(long nativeContentViewCoreImpl, float value);
+
private native void nativeSendOrientationChangeEvent(
long nativeContentViewCoreImpl, int orientation);

Powered by Google App Engine
This is Rietveld 408576698