[topaz] Delete old Semantics Bridge code in flutter.

This cl deletes, old semantics bridge code in flutter.

Testing:
  * Build: passed
  * Installed on device

MI4-1736 #comment

Change-Id: I1e224667266c2b097e6d027422cb861ca9d20c85
diff --git a/runtime/flutter_runner/BUILD.gn b/runtime/flutter_runner/BUILD.gn
index ea54651..9626c76 100644
--- a/runtime/flutter_runner/BUILD.gn
+++ b/runtime/flutter_runner/BUILD.gn
@@ -86,8 +86,6 @@
       "platform_view.h",
       "runner.cc",
       "runner.h",
-      "semantics_bridge.cc",
-      "semantics_bridge.h",
       "service_provider_dir.cc",
       "service_provider_dir.h",
       "session_connection.cc",
diff --git a/runtime/flutter_runner/platform_view.cc b/runtime/flutter_runner/platform_view.cc
index 851fd14..08464d9 100644
--- a/runtime/flutter_runner/platform_view.cc
+++ b/runtime/flutter_runner/platform_view.cc
@@ -100,7 +100,6 @@
       size_change_hint_callback_(std::move(session_size_change_hint_callback)),
       ime_client_(this),
       context_writer_bridge_(std::move(accessibility_context_writer)),
-      semantics_bridge_(this, &metrics_),
       surface_(std::make_unique<Surface>(debug_label_)),
       vsync_event_handle_(vsync_event_handle) {
   // Register all error handlers.
@@ -596,7 +595,8 @@
   // TODO(MI4-1262): Figure out if the context_writer_bridge should be removed
   // as it is unused.
   // context_writer_bridge_.UpdateSemantics(update);
-  semantics_bridge_.UpdateSemantics(update);
+  // TODO(MIT-1539): Uncomment/Reimplement following code, to add A11y support.
+  //semantics_bridge_.UpdateSemantics(update);
 }
 
 // Channel handler for kAccessibilityChannel
diff --git a/runtime/flutter_runner/platform_view.h b/runtime/flutter_runner/platform_view.h
index b4c1795..9a03d0a 100644
--- a/runtime/flutter_runner/platform_view.h
+++ b/runtime/flutter_runner/platform_view.h
@@ -22,7 +22,6 @@
 #include "lib/ui/scenic/cpp/id.h"
 
 #include "context_writer_bridge.h"
-#include "semantics_bridge.h"
 #include "surface.h"
 
 namespace flutter_runner {
@@ -81,9 +80,6 @@
   fuchsia::sys::ServiceProviderPtr parent_environment_service_provider_;
   fuchsia::modular::ClipboardPtr clipboard_;
   ContextWriterBridge context_writer_bridge_;
-  // The Semantics bridge is used to provide semantics data from this platform
-  // view to the accessibility manager.
-  SemanticsBridge semantics_bridge_;
   std::unique_ptr<Surface> surface_;
   flutter::LogicalMetrics metrics_;
   fuchsia::ui::gfx::Metrics scenic_metrics_;
diff --git a/runtime/flutter_runner/semantics_bridge.cc b/runtime/flutter_runner/semantics_bridge.cc
deleted file mode 100644
index 3848ef6..0000000
--- a/runtime/flutter_runner/semantics_bridge.cc
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/runtime/flutter_runner/semantics_bridge.h"
-
-#include <lib/syslog/global.h>
-
-#include "topaz/runtime/dart/utils/inlines.h"
-
-#include "topaz/runtime/flutter_runner/logging.h"
-
-namespace flutter_runner {
-
-// Helper function to convert SkRect, Flutter semantics node bounding box
-// format to fuchsia::ui::gfx::BoundingBox, the Fidl equivalent.
-fuchsia::ui::gfx::BoundingBox WrapBoundingBox(SkRect& rect) {
-  fuchsia::ui::gfx::BoundingBox box;
-  box.min.x = rect.fLeft;
-  box.min.y = rect.fTop;
-  box.min.z = 0;
-  box.max.x = rect.fRight;
-  box.max.y = rect.fBottom;
-  box.max.z = 0;
-  return box;
-}
-
-// Helper function to convert SkMatrix44, Flutter semantics node transform
-// format to fuchsia::ui::gfx::mat4, the Fidl equivalent.
-fuchsia::ui::gfx::mat4 WrapSkMatrix(SkMatrix44& args) {
-  fuchsia::ui::gfx::mat4 value;
-  DEBUG_CHECK(value.matrix.size() == 16, LOG_TAG, "");
-  float* m = value.matrix.data();
-  args.asColMajorf(m);
-  return value;
-}
-
-// Helper function to convert Flutter SemanticsNode to fuchsia Fidl
-// accessibility node format.
-fuchsia::accessibility::Node SerializeNode(flutter::SemanticsNode node,
-                                           float scale) {
-  fuchsia::accessibility::Node s_node = fuchsia::accessibility::Node();
-  s_node.node_id = node.id;
-  s_node.children_hit_test_order =
-      fidl::VectorPtr<int32_t>(node.childrenInHitTestOrder);
-  s_node.children_traversal_order =
-      fidl::VectorPtr<int32_t>(node.childrenInTraversalOrder);
-
-  s_node.data = fuchsia::accessibility::Data();
-  s_node.data.role = fuchsia::accessibility::Role::NONE;
-  s_node.data.label = node.label;
-
-  s_node.data.location = WrapBoundingBox(node.rect);
-  SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor);
-  node.transform.invert(&inverse);
-
-  if (s_node.node_id == 0) {
-    SkMatrix44 scaling(SkMatrix44::kIdentity_Constructor);
-    scaling.setScale(scale, scale, 1);
-    inverse = inverse * scaling;
-  }
-  s_node.data.transform = WrapSkMatrix(inverse);
-  return s_node;
-}
-
-SemanticsBridge::SemanticsBridge(flutter::PlatformView* platform_view,
-                                 flutter::LogicalMetrics* metrics)
-    : binding_(this), platform_view_(platform_view), metrics_(metrics) {
-  root_.set_error_handler([this](zx_status_t status) {
-    FX_LOG(INFO, LOG_TAG, "A11y bridge disconnected from a11y manager");
-    binding_.Unbind();
-    root_.Unbind();
-    platform_view_->SetSemanticsEnabled(false);
-  });
-
-  // Set up |a11y_toggle_| to listen for turning on/off a11y support.
-  // If this disconnects, we shut down all other connections and disable
-  // a11y support.
-  a11y_toggle_.events().OnAccessibilityToggle =
-      fit::bind_member(this, &SemanticsBridge::OnAccessibilityToggle);
-  a11y_toggle_.set_error_handler([this](zx_status_t status) {
-    FX_LOG(INFO, LOG_TAG, "Disconnected from a11y toggle broadcaster.");
-    binding_.Unbind();
-    root_.Unbind();
-    environment_set_ = false;
-    platform_view_->SetSemanticsEnabled(false);
-  });
-}
-
-void SemanticsBridge::SetupEnvironment(
-    uint32_t view_id,
-    fuchsia::sys::ServiceProvider* environment_service_provider) {
-  view_id_ = view_id;
-  environment_service_provider_ = environment_service_provider;
-  environment_service_provider->ConnectToService(
-      fuchsia::accessibility::ToggleBroadcaster::Name_,
-      a11y_toggle_.NewRequest().TakeChannel());
-  environment_set_ = true;
-  // Starts up accessibility support if accessibility was toggled before
-  // the environment was set.
-  if (enabled_) {
-    OnAccessibilityToggle(enabled_);
-  }
-}
-
-void SemanticsBridge::UpdateSemantics(
-    const flutter::SemanticsNodeUpdates& update) {
-  fidl::VectorPtr<int32_t> delete_nodes;
-  fidl::VectorPtr<fuchsia::accessibility::Node> update_nodes;
-  for (auto it = update.begin(); it != update.end(); ++it) {
-    flutter::SemanticsNode node = it->second;
-    // We delete nodes that are hidden from the screen.
-    if (node.HasFlag(flutter::SemanticsFlags::kIsHidden)) {
-      delete_nodes.push_back(node.id);
-    } else {
-      update_nodes.push_back(SerializeNode(node, (float)metrics_->scale));
-    }
-  }
-  // TODO(MI4-1539): re-enable after changes to semantics root API
-  /*
-  if (!delete_nodes.get().empty()) {
-    root_->DeleteSemanticNodes(view_id_, std::move(delete_nodes));
-  }
-  if (!update_nodes.get().empty()) {
-    root_->UpdateSemanticNodes(view_id_, std::move(update_nodes));
-  }
-  root_->Commit(view_id_);
-   */
-}
-
-void SemanticsBridge::PerformAccessibilityAction(
-    int32_t node_id, fuchsia::accessibility::Action action) {
-  std::vector<uint8_t> args = {};
-  switch (action) {
-    case fuchsia::accessibility::Action::GAIN_ACCESSIBILITY_FOCUS:
-      platform_view_->DispatchSemanticsAction(
-          node_id, flutter::SemanticsAction::kDidGainAccessibilityFocus, args);
-      break;
-    case fuchsia::accessibility::Action::LOSE_ACCESSIBILITY_FOCUS:
-      platform_view_->DispatchSemanticsAction(
-          node_id, flutter::SemanticsAction::kDidLoseAccessibilityFocus, args);
-      break;
-    case fuchsia::accessibility::Action::TAP:
-      platform_view_->DispatchSemanticsAction(
-          node_id, flutter::SemanticsAction::kTap, args);
-      break;
-    default:
-      FX_LOG(ERROR, LOG_TAG, "Accessibility action not supported");
-  }
-}
-
-void SemanticsBridge::OnAccessibilityToggle(bool enabled) {
-  if (enabled == enabled_ && root_.is_bound()) {
-    return;
-  }
-  enabled_ = enabled;
-  if (enabled && environment_set_) {
-    // Reconnect if the a11y manager connection is not bound.
-    if (!root_.is_bound()) {
-      environment_service_provider_->ConnectToService(
-          fuchsia::accessibility::SemanticsRoot::Name_,
-          root_.NewRequest().TakeChannel());
-    }
-    // TODO(MI4-1539): re-enable after changes to semantics root API
-    /*
-     if (root_.is_bound()) {
-          root_->RegisterSemanticsProvider(view_id_, binding_.NewBinding());
-          platform_view_->SetSemanticsEnabled(true);
-          return;
-        }
-        */
-  }
-  root_.Unbind();
-  // Disable if fall through to here.
-  platform_view_->SetSemanticsEnabled(false);
-}
-
-}  // namespace flutter_runner
diff --git a/runtime/flutter_runner/semantics_bridge.h b/runtime/flutter_runner/semantics_bridge.h
deleted file mode 100644
index fb34d07..0000000
--- a/runtime/flutter_runner/semantics_bridge.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_RUNTIME_FLUTTER_RUNNER_SEMANTICS_BRIDGE_H_
-#define TOPAZ_RUNTIME_FLUTTER_RUNNER_SEMANTICS_BRIDGE_H_
-
-#include <map>
-#include <unordered_set>
-
-#include <fuchsia/accessibility/cpp/fidl.h>
-#include <fuchsia/sys/cpp/fidl.h>
-#include <fuchsia/ui/input/cpp/fidl.h>
-
-#include "flutter/lib/ui/semantics/semantics_node.h"
-#include "flutter/lib/ui/window/viewport_metrics.h"
-#include "lib/fidl/cpp/binding_set.h"
-
-#include "flutter/shell/common/platform_view.h"
-
-namespace flutter_runner {
-
-// Connects the Flutter PlatformView to the Fuchsia accessibility manager and
-// provides a way to push semantic tree updates to the manager. Also provides
-// a SemanticsProvider implementation for the manager to call SemanticActions
-// on nodes on the screen.
-class SemanticsBridge final : public fuchsia::accessibility::SemanticsProvider {
- public:
-  SemanticsBridge(flutter::PlatformView* platform_view,
-                  flutter::LogicalMetrics* metrics);
-  ~SemanticsBridge() = default;
-
-  // Store the associated PlatformView's view_id and
-  // environment_service_provider to make necessary connections to |root_| and
-  // |a11y_toggle_|.
-  void SetupEnvironment(
-      uint32_t view_id,
-      fuchsia::sys::ServiceProvider* environment_service_provider);
-
-  // Converts the updated semantics nodes in |update| to Fidl accessibility
-  // node format to send to the accessibility manager. The update is split into
-  // three manager calls, one to send updated nodes, one to send deleted node
-  // ids, and one to finalize the update.
-  void UpdateSemantics(const flutter::SemanticsNodeUpdates& update);
-
- private:
-  // |fuchsia::accessibility::SemanticsProvider|
-  void PerformAccessibilityAction(
-      int32_t node_id, fuchsia::accessibility::Action action) override;
-
-  // On enabling, sets up a connection to the accessibility manager with
-  // the view id passed in from the PlatformView. In order for Flutter to
-  // start sending semantics updates, we must call SetSemanticsEnabled(true)
-  // in the associated |platform_view_|.
-  // On disabling, we disable Flutter from sending semantic updates and break
-  // the connection to the accessibility manager.
-  void OnAccessibilityToggle(bool enabled);
-
-  fidl::Binding<fuchsia::accessibility::SemanticsProvider> binding_;
-
-  // We keep a reference to the PlatformView's environment service provider
-  // to connect to the |fuchsia::accessibility::SemanticsRoot| service
-  // and the |fuchsia::accessibility::ToggleBroadcaster| service.
-  fuchsia::sys::ServiceProvider* environment_service_provider_;
-  fuchsia::accessibility::SemanticsRootPtr root_;
-  fuchsia::accessibility::ToggleBroadcasterPtr a11y_toggle_;
-  // We keep track of the current on/off state;
-  bool enabled_ = false;
-
-  // The associated Scenic view id for the associated PlatformView. This id
-  // must registered with the accessibility manager, and sent with every
-  // update, delete, and commit.
-  // TODO(SCN-847): Update the view_id system to initialize connections with
-  // event pair kernel objects.
-  uint32_t view_id_;
-  // We must make sure that we have a valid view id and environment service
-  // provider before registering with the a11y manager.
-  bool environment_set_ = false;
-  // We keep a reference to the associated PlatformView to call
-  // SemanticsActions.
-  flutter::PlatformView* platform_view_;
-  // Metrics is needed to scale Scenic view space into local
-  // Flutter space when performing hit-tests. This is converted into
-  // a transform matrix that is applied to this semantic tree's root node
-  // transform matrix when sent to the manager.
-  flutter::LogicalMetrics* metrics_;
-
-  // Disallow copy and assignment.
-  SemanticsBridge(const SemanticsBridge&) = delete;
-  SemanticsBridge& operator=(const SemanticsBridge&) = delete;
-};
-
-}  // namespace flutter_runner
-
-#endif  // TOPAZ_RUNTIME_FLUTTER_RUNNER_SEMANTICS_BRIDGE_H_