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

[WIP] Support for ServoSession - take 2 #585

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 11 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ android {
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled true
Expand Down Expand Up @@ -210,6 +214,12 @@ if (findProject(':geckoview-local')) {
}


if (findProject(':servoview-local')) {
dependencies {
implementation project(':servoview-local')
}
}

// -------------------------------------------------------------------------------------------------
// Dynamically set versionCode (See tools/build/versionCode.gradle
// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -245,4 +255,4 @@ android.applicationVariants.all { variant ->
println("Build type: " + buildType)
println("Flavor: " + variant.flavorName)
println("Version code: " + variant.mergedFlavor.versionCode)
}
}
13 changes: 13 additions & 0 deletions app/src/common/shared/org/mozilla/browser/BrowserDisplay.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.mozilla.browser;

import android.view.Surface;

import org.mozilla.geckoview.GeckoDisplay;

public interface BrowserDisplay {
void surfaceChanged(Surface mSurface, int aWidth, int aHeight);

void surfaceDestroyed();

GeckoDisplay gecko();
}
29 changes: 29 additions & 0 deletions app/src/common/shared/org/mozilla/browser/BrowserGeckoDisplay.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.mozilla.browser;

import android.view.Surface;

import org.mozilla.geckoview.GeckoDisplay;

class BrowserGeckoDisplay implements BrowserDisplay {

private final GeckoDisplay mDisplay;

public BrowserGeckoDisplay(GeckoDisplay geckoDisplay) {
mDisplay = geckoDisplay;
}

@Override
public void surfaceChanged(Surface surface, int aWidth, int aHeight) {
mDisplay.surfaceChanged(surface, aWidth, aHeight);
}

@Override
public void surfaceDestroyed() {
mDisplay.surfaceDestroyed();
}

@Override
public GeckoDisplay gecko() {
return mDisplay;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.mozilla.browser;

import android.view.MotionEvent;

import org.mozilla.gecko.gfx.PanZoomController;

class BrowserGeckoPanZoomController implements BrowserPanZoomController {
PanZoomController mPanZoomController;
public BrowserGeckoPanZoomController(PanZoomController panZoomController) {
mPanZoomController = panZoomController;
}

@Override
public boolean onTouchEvent(MotionEvent aEvent) {
return mPanZoomController.onTouchEvent(aEvent);
}

@Override
public boolean onMotionEvent(MotionEvent aEvent) {
return mPanZoomController.onMotionEvent(aEvent);
}
}
160 changes: 160 additions & 0 deletions app/src/common/shared/org/mozilla/browser/BrowserGeckoSession.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package org.mozilla.browser;

import android.graphics.Rect;
import android.net.Uri;

import org.mozilla.geckoview.GeckoRuntime;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.vrbrowser.SessionStore;

public class BrowserGeckoSession implements BrowserSession {

private final GeckoSession mSession;
private ProgressDelegate mProgressDelegate;
private NavigationDelegate mNavigationDelegate;
private ContentDelegate mContentDelegate;
private SessionStore mStore;
private BrowserGeckoPanZoomController mPanZoomController;

public BrowserGeckoSession(SessionStore store) {
mStore = store;
mSession = new GeckoSession();
}

@Override
public GeckoSession gecko() {
return mSession;
}

@Override
public boolean isGecko() {
return true;
}

@Override
public boolean isServo() {
return false;
}

@Override
public ProgressDelegate getProgressDelegate() {
return mProgressDelegate;
}

@Override
public void setProgressDelegate(ProgressDelegate delegate) {
mProgressDelegate = delegate;
mSession.setProgressDelegate(delegate.toGeckoProgress(mStore));
}

@Override
public NavigationDelegate getNavigationDelegate() {
return mNavigationDelegate;
}

@Override
public void setNavigationDelegate(NavigationDelegate delegate) {
mNavigationDelegate = delegate;
mSession.setNavigationDelegate(delegate.toGeckoNavigation(mStore));
}

@Override
public ContentDelegate getContentDelegate() {
return mContentDelegate;
}

@Override
public void setContentDelegate(ContentDelegate delegate) {
mContentDelegate = delegate;
mSession.setContentDelegate(delegate.toGeckoContent(mStore));
}

@Override
public void loadUri(Uri uri) {
mSession.loadUri(uri);
}

@Override
public void loadUri(String uri) {
mSession.loadUri(uri);
}

@Override
public boolean isOpen() {
return mSession.isOpen();
}

@Override
public void reload() {
mSession.reload();
}

@Override
public void stop() {
mSession.stop();
}

@Override
public void goBack() {
mSession.goBack();
}

@Override
public void goForward() {
mSession.goForward();
}

@Override
public void getSurfaceBounds(Rect rect) {
mSession.getSurfaceBounds(rect);
}

@Override
public GeckoSessionSettings getSettings() {
return mSession.getSettings();
}

@Override
public void setActive(boolean active) {
mSession.setActive(active);
}

@Override
public void open(GeckoRuntime runtime) {
mSession.open(runtime);
}

@Override
public void exitFullScreen() {
mSession.exitFullScreen();
}

@Override
public void loadData(byte[] data, String s) {
mSession.loadData(data, s);
}

@Override
public void close() {
mSession.close();
}

@Override
public BrowserDisplay acquireDisplay() {
return new BrowserGeckoDisplay(mSession.acquireDisplay());
}

@Override
public void releaseDisplay(BrowserDisplay mDisplay) {
mSession.releaseDisplay(mDisplay.gecko());
}

@Override
public BrowserPanZoomController getPanZoomController() {
if (mPanZoomController == null) {
mPanZoomController = new BrowserGeckoPanZoomController(mSession.getPanZoomController());
}
return mPanZoomController;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.mozilla.browser;

import android.view.MotionEvent;

public interface BrowserPanZoomController {
boolean onTouchEvent(MotionEvent aEvent);

boolean onMotionEvent(MotionEvent aEvent);
}
Loading