Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Update Servo #1053

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,6 +122,7 @@ public void run() {
TrayWidget mTray;
BookmarksView mBookmarksView;
PermissionDelegate mPermissionDelegate;
long mExternalContext;
LinkedList<UpdateListener> mWidgetUpdateListeners;
LinkedList<PermissionListener> mPermissionListeners;
LinkedList<FocusChangeListener> mFocusChangeListeners;
Expand Down Expand Up @@ -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);
}

Expand Down
12 changes: 10 additions & 2 deletions app/src/common/shared/org/mozilla/vrbrowser/utils/ServoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion servo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
12 changes: 8 additions & 4 deletions servo/src/main/java/org/mozilla/servo/ServoSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand All @@ -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();
}

Expand Down