Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7bfb2df authored by Steve Block's avatar Steve Block Committed by Android (Google) Code Review
Browse files

Merge "Update DeviceOrientationManager to be specific to a WebViewCore"

parents c9facccc f4a705f0
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.webkit;

import android.util.Log;

/**
 * This class is simply a container for the methods used to configure WebKit's
 * mock DeviceOrientationClient for use in LayoutTests.
@@ -27,23 +25,28 @@ import android.util.Log;
 * @hide
 */
public final class DeviceOrientationManager {
    private WebViewCore mWebViewCore;

    public DeviceOrientationManager(WebViewCore webViewCore) {
        mWebViewCore = webViewCore;
    }

    /**
     * Sets whether the Page for the specified WebViewCore should use a mock DeviceOrientation
     * Sets whether the Page for this WebViewCore should use a mock DeviceOrientation
     * client.
     */
    public static void useMock(WebViewCore webViewCore) {
    public void useMock() {
        assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
        nativeUseMock(webViewCore);
        nativeUseMock(mWebViewCore);
    }

    /**
     * Set the position for the mock DeviceOrientation service for the supplied WebViewCore.
     * Set the position for the mock DeviceOrientation service for this WebViewCore.
     */
    public static void setMockOrientation(WebViewCore webViewCore, boolean canProvideAlpha,
            double alpha, boolean canProvideBeta, double beta, boolean canProvideGamma,
            double gamma) {
    public void setMockOrientation(boolean canProvideAlpha, double alpha, boolean canProvideBeta,
            double beta, boolean canProvideGamma, double gamma) {
        assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
        nativeSetMockOrientation(webViewCore, canProvideAlpha, alpha, canProvideBeta, beta,
        nativeSetMockOrientation(mWebViewCore, canProvideAlpha, alpha, canProvideBeta, beta,
                canProvideGamma, gamma);
    }

+2 −3
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.webkit.DeviceOrientationManager;
import android.webkit.WebTextView.AutoCompleteAdapter;
import android.webkit.WebViewCore.EventHub;
import android.webkit.WebViewCore.TouchEventData;
@@ -3763,8 +3762,8 @@ public class WebView extends AbsoluteLayout
     */
    public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha,
            boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) {
        DeviceOrientationManager.setMockOrientation(mWebViewCore, canProvideAlpha, alpha,
                canProvideBeta, beta, canProvideGamma, gamma);
        mWebViewCore.setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta,
                canProvideGamma, gamma);
    }

    /**
+9 −1
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@ final class WebViewCore {
    private int mWebkitScrollX = 0;
    private int mWebkitScrollY = 0;

    private DeviceOrientationManager mDeviceOrientationManager = new DeviceOrientationManager(this);

    // The thread name used to identify the WebCore thread and for use in
    // debugging other classes that require operation within the WebCore thread.
    /* package */ static final String THREAD_NAME = "WebViewCoreThread";
@@ -2489,7 +2491,13 @@ final class WebViewCore {
    }

    private void useMockDeviceOrientation() {
        DeviceOrientationManager.useMock(this);
        mDeviceOrientationManager.useMock();
    }

    public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha,
            boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) {
        mDeviceOrientationManager.setMockOrientation(canProvideAlpha, alpha, canProvideBeta, beta,
                canProvideGamma, gamma);
    }

    private native void nativePause();