Skip to content

Commit

Permalink
Revert "Add assistiveTechnologyEnabled flag to window" (flutter#5746)
Browse files Browse the repository at this point in the history
Reverts flutter#5740
  • Loading branch information
jonahwilliams authored and liyuqian committed Jul 13, 2018
1 parent a28c3e7 commit 9af920e
Show file tree
Hide file tree
Showing 17 changed files with 6 additions and 129 deletions.
5 changes: 0 additions & 5 deletions lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ void _updateSemanticsEnabled(bool enabled) {
_invoke(window.onSemanticsEnabledChanged, window._onSemanticsEnabledChangedZone);
}

void _updateAssistiveTechnologyEnabled(bool enabled) {
window._assistiveTechnologyEnabled = enabled;
_invoke(window._onAssistiveTechnologyEnabled, window._onAssistiveTechnologyEnabledZone);
}

void _dispatchPlatformMessage(String name, ByteData data, int responseId) {
if (window.onPlatformMessage != null) {
_invoke3<String, ByteData, PlatformMessageResponseCallback>(
Expand Down
24 changes: 0 additions & 24 deletions lib/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -637,30 +637,6 @@ class Window {
bool get semanticsEnabled => _semanticsEnabled;
bool _semanticsEnabled = false;

/// Whether the user is using assitive technologies to interact with the
/// application.
///
/// This includes screen readers such as TalkBack on Android and VoiceOVer
/// on iOS, as well as hardware switches, and more.
///
/// The [onAssistiveTechnologyEnabled] callback is called whenever this value
/// changes.
bool get assistiveTechnologyEnabled => _assistiveTechnologyEnabled;
bool _assistiveTechnologyEnabled = false;

/// A callback that is invoked when the value of [assistiveTechnologyEnabled]
/// changes.
///
/// The framework invokes this callback in the same zone in which the callback
/// was set.
VoidCallback get onAssistiveTechnologyEnabled => _onAssistiveTechnologyEnabled;
VoidCallback _onAssistiveTechnologyEnabled;
Zone _onAssistiveTechnologyEnabledZone;
set onAssistiveTechnologyEnabled(VoidCallback callback) {
_onAssistiveTechnologyEnabled = callback;
_onAssistiveTechnologyEnabledZone = Zone.current;
}

/// A callback that is invoked when the value of [semanticsEnabled] changes.
///
/// The framework invokes this callback in the same zone in which the
Expand Down
10 changes: 0 additions & 10 deletions lib/ui/window/window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,6 @@ void Window::UpdateSemanticsEnabled(bool enabled) {
{ToDart(enabled)});
}

void Window::UpdateAssistiveTechnologyEnabled(bool enabled) {
tonic::DartState* dart_state = library_.dart_state().get();
if (!dart_state)
return;
tonic::DartState::Scope scope(dart_state);

DartInvokeField(library_.value(), "_updateAssistiveTechnologyEnabled",
{ToDart(enabled)});
}

void Window::DispatchPlatformMessage(fxl::RefPtr<PlatformMessage> message) {
tonic::DartState* dart_state = library_.dart_state().get();
if (!dart_state)
Expand Down
1 change: 0 additions & 1 deletion lib/ui/window/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class Window final {
const std::string& country_code);
void UpdateUserSettingsData(const std::string& data);
void UpdateSemanticsEnabled(bool enabled);
void UpdateAssistiveTechnologyEnabled(bool enabled);
void DispatchPlatformMessage(fxl::RefPtr<PlatformMessage> message);
void DispatchPointerDataPacket(const PointerDataPacket& packet);
void DispatchSemanticsAction(int32_t id,
Expand Down
13 changes: 1 addition & 12 deletions runtime/runtime_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ std::unique_ptr<RuntimeController> RuntimeController::Clone() const {
bool RuntimeController::FlushRuntimeStateToIsolate() {
return SetViewportMetrics(window_data_.viewport_metrics) &&
SetLocale(window_data_.language_code, window_data_.country_code) &&
SetSemanticsEnabled(window_data_.semantics_enabled) &&
SetAssistiveTechnologyEnabled(window_data_.assistive_technology_enabled);
SetSemanticsEnabled(window_data_.semantics_enabled);
}

bool RuntimeController::SetViewportMetrics(const ViewportMetrics& metrics) {
Expand Down Expand Up @@ -171,16 +170,6 @@ bool RuntimeController::SetSemanticsEnabled(bool enabled) {
return false;
}

bool RuntimeController::SetAssistiveTechnologyEnabled(bool enabled) {
window_data_.assistive_technology_enabled = enabled;
if (auto window = GetWindowIfAvailable()) {
window->UpdateAssistiveTechnologyEnabled(window_data_.assistive_technology_enabled);
return true;
}

return false;
}

bool RuntimeController::BeginFrame(fxl::TimePoint frame_time) {
if (auto window = GetWindowIfAvailable()) {
window->BeginFrame(frame_time);
Expand Down
3 changes: 0 additions & 3 deletions runtime/runtime_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class RuntimeController final : public WindowClient {

bool SetSemanticsEnabled(bool enabled);

bool SetAssistiveTechnologyEnabled(bool enabled);

bool BeginFrame(fxl::TimePoint frame_time);

bool NotifyIdle(int64_t deadline);
Expand Down Expand Up @@ -82,7 +80,6 @@ class RuntimeController final : public WindowClient {
std::string country_code;
std::string user_settings_data = "{}";
bool semantics_enabled = false;
bool assistive_technology_enabled = false;
};

RuntimeDelegate& client_;
Expand Down
4 changes: 0 additions & 4 deletions shell/common/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,6 @@ void Engine::SetSemanticsEnabled(bool enabled) {
runtime_controller_->SetSemanticsEnabled(enabled);
}

void Engine::SetAssistiveTechnologyEnabled(bool enabled) {
runtime_controller_->SetAssistiveTechnologyEnabled(enabled);
}

void Engine::StopAnimator() {
animator_->Stop();
}
Expand Down
2 changes: 0 additions & 2 deletions shell/common/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class Engine final : public blink::RuntimeDelegate {

void SetSemanticsEnabled(bool enabled);

void SetAssistiveTechnologyEnabled(bool enabled);

void ScheduleFrame(bool regenerate_layer_tree = true) override;

// |blink::RuntimeDelegate|
Expand Down
4 changes: 0 additions & 4 deletions shell/common/platform_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ void PlatformView::SetSemanticsEnabled(bool enabled) {
delegate_.OnPlatformViewSetSemanticsEnabled(*this, enabled);
}

void PlatformView::SetAssistiveTechnologyEnabled(bool enabled) {
delegate_.OnPlatformViewSetAssistiveTechnologyEnabled(*this, enabled);
}

void PlatformView::SetViewportMetrics(const blink::ViewportMetrics& metrics) {
delegate_.OnPlatformViewSetViewportMetrics(*this, metrics);
}
Expand Down
5 changes: 0 additions & 5 deletions shell/common/platform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ class PlatformView {
virtual void OnPlatformViewSetSemanticsEnabled(const PlatformView& view,
bool enabled) = 0;

virtual void OnPlatformViewSetAssistiveTechnologyEnabled(const PlatformView& view,
bool enabled) = 0;

virtual void OnPlatformViewRegisterTexture(
const PlatformView& view,
std::shared_ptr<flow::Texture> texture) = 0;
Expand All @@ -87,8 +84,6 @@ class PlatformView {

virtual void SetSemanticsEnabled(bool enabled);

virtual void SetAssistiveTechnologyEnabled(bool enabled);

void SetViewportMetrics(const blink::ViewportMetrics& metrics);

void NotifyCreated();
Expand Down
14 changes: 0 additions & 14 deletions shell/common/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -574,20 +574,6 @@ void Shell::OnPlatformViewSetSemanticsEnabled(const PlatformView& view,
});
}

void Shell::OnPlatformViewSetAssistiveTechnologyEnabled(const PlatformView& view,
bool enabled) {
FXL_DCHECK(is_setup_);
FXL_DCHECK(&view == platform_view_.get());
FXL_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread());

task_runners_.GetUITaskRunner()->PostTask(
[engine = engine_->GetWeakPtr(), enabled] {
if (engine) {
engine->SetAssistiveTechnologyEnabled(enabled);
}
});
}

// |shell::PlatformView::Delegate|
void Shell::OnPlatformViewRegisterTexture(
const PlatformView& view,
Expand Down
4 changes: 0 additions & 4 deletions shell/common/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ class Shell final : public PlatformView::Delegate,
void OnPlatformViewSetSemanticsEnabled(const PlatformView& view,
bool enabled) override;

// |shell::PlatformView::Delegate|
void OnPlatformViewSetAssistiveTechnologyEnabled(const PlatformView& view,
bool enabled) override;

// |shell::PlatformView::Delegate|
void OnPlatformViewRegisterTexture(
const PlatformView& view,
Expand Down
5 changes: 0 additions & 5 deletions shell/platform/android/io/flutter/view/FlutterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,6 @@ private static native void nativeDispatchSemanticsAction(long nativePlatformView

private static native void nativeSetSemanticsEnabled(long nativePlatformViewAndroid,
boolean enabled);

private static native void nativeSetAssistiveTechnologyEnabled(long nativePlatformViewAndroid,
boolean enabled);

private static native boolean nativeGetIsSoftwareRenderingEnabled();

Expand Down Expand Up @@ -815,13 +812,11 @@ public void onTouchExplorationStateChanged(boolean enabled) {
if (enabled) {
mTouchExplorationEnabled = true;
ensureAccessibilityEnabled();
nativeSetAssistiveTechnologyEnabled(mNativeView.get(), true);
} else {
mTouchExplorationEnabled = false;
if (mAccessibilityNodeProvider != null) {
mAccessibilityNodeProvider.handleTouchExplorationExit();
}
nativeSetAssistiveTechnologyEnabled(mNativeView.get(), false);
}
resetWillNotDraw();
}
Expand Down
12 changes: 0 additions & 12 deletions shell/platform/android/platform_view_android_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,6 @@ static void SetSemanticsEnabled(JNIEnv* env,
ANDROID_SHELL_HOLDER->GetPlatformView()->SetSemanticsEnabled(enabled);
}

static void SetAssistiveTechnologyEnabled(JNIEnv* env,
jobject jcaller,
jlong shell_holder,
jboolean enabled) {
ANDROID_SHELL_HOLDER->GetPlatformView()->SetAssistiveTechnologyEnabled(enabled);
}

static jboolean GetIsSoftwareRendering(JNIEnv* env, jobject jcaller) {
return FlutterMain::Get().GetSettings().enable_software_rendering;
}
Expand Down Expand Up @@ -607,11 +600,6 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
.signature = "(JZ)V",
.fnPtr = reinterpret_cast<void*>(&shell::SetSemanticsEnabled),
},
{
.name = "nativeSetAssistiveTechnologyEnabled",
.signature = "(JZ)V",
.fnPtr = reinterpret_cast<void*>(&shell::SetAssistiveTechnologyEnabled),
},
{
.name = "nativeGetIsSoftwareRenderingEnabled",
.signature = "()Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,18 +792,16 @@ - (NSUInteger)supportedInterfaceOrientations {
#pragma mark - Accessibility

- (void)onAccessibilityStatusChanged:(NSNotification*)notification {
auto platformView = _shell->GetPlatformView();
#if TARGET_OS_SIMULATOR
// There doesn't appear to be any way to determine whether the accessibility
// inspector is enabled on the simulator. We conservatively always turn on the
// accessibility bridge in the simulator, but never assistive technology.
platformView->SetSemanticsEnabled(true);
platformView->SetAssistiveTechnologyEnabled(false);
// accessibility bridge in the simulator.
bool enabled = true;
#else
bool enabled = UIAccessibilityIsVoiceOverRunning() || UIAccessibilityIsSwitchControlRunning();
platformView->SetSemanticsEnabled(enabled || UIAccessibilityIsSpeakScreenEnabled());
platformView->SetAssistiveTechnologyEnabled(enabled);
bool enabled = UIAccessibilityIsVoiceOverRunning() || UIAccessibilityIsSwitchControlRunning() ||
UIAccessibilityIsSpeakScreenEnabled();
#endif
_shell->GetPlatformView()->SetSemanticsEnabled(enabled);
}

#pragma mark - Memory Notifications
Expand Down
6 changes: 0 additions & 6 deletions shell/platform/darwin/ios/platform_view_ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ class PlatformViewIOS final : public HeadlessPlatformViewIOS {
// |shell::PlatformView|
void SetSemanticsEnabled(bool enabled) override;

// |shell::PlatformView|
void SetAssistiveTechnologyEnabled(bool enabled) override;

// |shell::PlatformView|
void HandlePlatformMessage(
fxl::RefPtr<blink::PlatformMessage> message) override;

// |shell::PlatformView|
void UpdateSemantics(blink::SemanticsNodeUpdates update,
Expand Down
11 changes: 0 additions & 11 deletions shell/platform/darwin/ios/platform_view_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@
PlatformView::SetSemanticsEnabled(enabled);
}

// |shell:PlatformView|
void PlatformViewIOS::SetAssistiveTechnologyEnabled(bool enabled) {
if (enabled && !accessibility_bridge_) {
accessibility_bridge_ = std::make_unique<AccessibilityBridge>(owner_view_, this);
}
// Note: since the accessibility bridge is needed for both semantics and
// assistive technologies, but you cannot have the latter without the
// former, we only destroy the bridge in SetSemanticsEnabled and not here.
PlatformView::SetAssistiveTechnologyEnabled(enabled);
}

// |shell::PlatformView|
void PlatformViewIOS::UpdateSemantics(blink::SemanticsNodeUpdates update,
blink::CustomAccessibilityActionUpdates actions) {
Expand Down

0 comments on commit 9af920e

Please sign in to comment.