diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index d7fd9ad9a..e9f2c8cde 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -60,6 +60,7 @@ import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement; import org.mozilla.vrbrowser.ui.widgets.WindowWidget; import org.mozilla.vrbrowser.ui.widgets.dialogs.CrashDialogWidget; +import org.mozilla.vrbrowser.utils.ServoUtils; import java.io.IOException; import java.net.URISyntaxException; @@ -121,6 +122,7 @@ public void run() { TrayWidget mTray; BookmarksView mBookmarksView; PermissionDelegate mPermissionDelegate; + long mExternalContext; LinkedList mWidgetUpdateListeners; LinkedList mPermissionListeners; LinkedList mFocusChangeListeners; @@ -601,6 +603,7 @@ void handleResize(final int aHandle, final float aWorldWidth, final float aWorld @Keep @SuppressWarnings("unused") void registerExternalContext(long aContext) { + ServoUtils.setExternalContext(aContext); GeckoVRManager.setExternalContext(aContext); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/utils/ServoUtils.java b/app/src/common/shared/org/mozilla/vrbrowser/utils/ServoUtils.java index 347f1ba28..7449aec61 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/utils/ServoUtils.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/utils/ServoUtils.java @@ -4,6 +4,8 @@ import android.util.Log; import org.mozilla.geckoview.GeckoSession; +import org.mozilla.vrbrowser.browser.SettingsStore; +import org.mozilla.vrbrowser.VRBrowserActivity; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -13,6 +15,7 @@ public class ServoUtils { private static final String WHITELIST_CLASSNAME = "org.mozilla.servo.ServoWhiteList"; private static final String LOGTAG = "ServoUtils"; private static Object mServoWhiteList = null; + private static long mVRContext; public static boolean isServoAvailable() { try { @@ -23,6 +26,10 @@ public static boolean isServoAvailable() { } } + public static void setExternalContext(long aContext) { + mVRContext = aContext; + } + public static boolean isInstanceOfServoSession(Object obj) { try { return Class.forName(SESSION_CLASSNAME).isInstance(obj); @@ -32,10 +39,11 @@ public static boolean isInstanceOfServoSession(Object obj) { } public static GeckoSession createServoSession(Context context) { + boolean layersEnabled = SettingsStore.getInstance(context).getLayersEnabled(); try { Class clazz = Class.forName(SESSION_CLASSNAME); - Constructor constructor = clazz.getConstructor(Context.class); - return (GeckoSession) constructor.newInstance(context); + Constructor constructor = clazz.getConstructor(Context.class, long.class, boolean.class); + return (GeckoSession) constructor.newInstance(context, mVRContext, layersEnabled); } catch (Exception e) { Log.e(LOGTAG, "Can't load or instanciate ServoSession: " + e); return null; diff --git a/servo/build.gradle b/servo/build.gradle index 4ffaaea21..3ce8da0d0 100644 --- a/servo/build.gradle +++ b/servo/build.gradle @@ -47,6 +47,6 @@ if (gradle.hasProperty('servoViewLocal')) { dependencies { // To see what the latest servoview version is go here: // https://download.servo.org/nightly/maven/org/mozilla/servoview/servoview-armv7/maven-metadata.xml - implementation 'org.mozilla.servoview:servoview-armv7:0.0.1.20190220.cc8a9fa' + implementation 'org.mozilla.servoview:servoview-armv7:0.0.1.20190401.31c0261' } } diff --git a/servo/src/main/java/org/mozilla/servo/ServoSession.java b/servo/src/main/java/org/mozilla/servo/ServoSession.java index d92f7e195..fdd31e607 100644 --- a/servo/src/main/java/org/mozilla/servo/ServoSession.java +++ b/servo/src/main/java/org/mozilla/servo/ServoSession.java @@ -6,10 +6,10 @@ import android.util.Log; import android.view.Surface; -import org.mozilla.gecko.GeckoVRManager; import org.mozilla.geckoview.GeckoDisplay; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoSession; +import org.mozilla.geckoview.GeckoVRManager; import org.mozilla.servoview.Servo; import org.mozilla.servoview.ServoSurface; @@ -25,13 +25,17 @@ public class ServoSession extends GeckoSession { private ServoPanZoomController mPanZoomController; private boolean mIsOpen = false; private String mUrl = "about:blank"; + private int mPadding; + private long mVRContext; private ProgressDelegate mProgressDelegate; private NavigationDelegate mNavigationDelegate; private ContentDelegate mContentDelegate; - public ServoSession(Context aContext) { + public ServoSession(Context aContext, long aVRContext, boolean aLayersEnabled) { Log.d(LOGTAG, "ServoSession()"); + mPadding = aLayersEnabled ? 1 : 0; + mVRContext = aVRContext; mActivity = (Activity) aContext; } @@ -40,10 +44,10 @@ public void onSurfaceChanged(Surface surface, int left, int top, int width, int mWidth = width; mHeight = height; mSurface = surface; - mServo = new ServoSurface(surface, width, height); + mServo = new ServoSurface(surface, width, height, mPadding); mServo.setClient(new ServoCallbacks()); mServo.setActivity(mActivity); - mServo.setVRExternalContext(GeckoVRManager.getExternalContext()); + mServo.setVRExternalContext(mVRContext); mServo.runLoop(); }