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

Commit 40edfc97 authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Reload page when A11y is on and the JavaScript state changes." into jb-mr1-dev

parents 5b3652cc c98b3460
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -279,6 +279,7 @@ class AccessibilityInjector {
        }

        if (!shouldInjectJavaScript(url)) {
            mAccessibilityScriptInjected = false;
            toggleFallbackAccessibilityInjector(true);
            return;
        }
@@ -291,6 +292,23 @@ class AccessibilityInjector {
        mAccessibilityScriptInjected = true;
    }

    /**
     * Adjusts the accessibility injection state to reflect changes in the
     * JavaScript enabled state.
     *
     * @param enabled Whether JavaScript is enabled.
     */
    public void updateJavaScriptEnabled(boolean enabled) {
        if (enabled) {
            addAccessibilityApisIfNecessary();
        } else {
            removeAccessibilityApisIfNecessary();
        }

        // We have to reload the page after adding or removing APIs.
        mWebView.reload();
    }

    /**
     * Toggles the non-JavaScript method for handling accessibility.
     *
+1 −0
Original line number Diff line number Diff line
@@ -1122,6 +1122,7 @@ public class WebSettingsClassic extends WebSettings {
        if (mJavaScriptEnabled != flag) {
            mJavaScriptEnabled = flag;
            postSync();
            mWebView.updateJavaScriptEnabled(flag);
        }
    }

+6 −0
Original line number Diff line number Diff line
@@ -1633,6 +1633,12 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        mZoomManager.updateMultiTouchSupport(context);
    }

    void updateJavaScriptEnabled(boolean enabled) {
        if (isAccessibilityInjectionEnabled()) {
            getAccessibilityInjector().updateJavaScriptEnabled(enabled);
        }
    }

    private void init() {
        OnTrimMemoryListener.init(mContext);
        mWebView.setWillNotDraw(false);