mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove references to Fuchsia's ContextWriter (#9157)
This commit is contained in:
parent
153416e554
commit
69ebe5fb28
@ -839,8 +839,6 @@ FILE: ../../../flutter/shell/platform/fuchsia/flutter/component.cc
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/flutter/component.h
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/flutter/compositor_context.cc
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/flutter/compositor_context.h
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/flutter/context_writer_bridge.cc
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/flutter/context_writer_bridge.h
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/flutter/engine.cc
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/flutter/engine.h
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/flutter/fuchsia_font_manager.cc
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
"fuchsia.fonts.Provider",
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.modular.Clipboard",
|
||||
"fuchsia.modular.ContextWriter",
|
||||
"fuchsia.modular.ModuleContext",
|
||||
"fuchsia.netstack.Netstack",
|
||||
"fuchsia.sys.Environment",
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
"fuchsia.fonts.Provider",
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.modular.Clipboard",
|
||||
"fuchsia.modular.ContextWriter",
|
||||
"fuchsia.modular.ModuleContext",
|
||||
"fuchsia.netstack.Netstack",
|
||||
"fuchsia.sys.Environment",
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
"fuchsia.fonts.Provider",
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.modular.Clipboard",
|
||||
"fuchsia.modular.ContextWriter",
|
||||
"fuchsia.modular.ModuleContext",
|
||||
"fuchsia.netstack.Netstack",
|
||||
"fuchsia.sys.Environment",
|
||||
@ -18,4 +17,4 @@
|
||||
"fuchsia.wlan.service.Wlan"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,8 +15,6 @@ if (using_fuchsia_sdk) {
|
||||
"component.h",
|
||||
"compositor_context.cc",
|
||||
"compositor_context.h",
|
||||
"context_writer_bridge.cc",
|
||||
"context_writer_bridge.h",
|
||||
"engine.cc",
|
||||
"engine.h",
|
||||
"fuchsia_font_manager.cc",
|
||||
|
||||
@ -1,80 +0,0 @@
|
||||
// Copyright 2013 The Flutter 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 "context_writer_bridge.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/stringbuffer.h"
|
||||
#include "rapidjson/writer.h"
|
||||
|
||||
namespace flutter_runner {
|
||||
|
||||
ContextWriterBridge::ContextWriterBridge(
|
||||
fidl::InterfaceHandle<fuchsia::modular::ContextWriter> writer)
|
||||
: writer_(writer.Bind()) {}
|
||||
|
||||
ContextWriterBridge::~ContextWriterBridge() = default;
|
||||
|
||||
void ContextWriterBridge::UpdateSemantics(
|
||||
const flutter::SemanticsNodeUpdates& update) {
|
||||
for (const auto& update : update) {
|
||||
const auto& node = update.second;
|
||||
semantics_nodes_[node.id] = node;
|
||||
}
|
||||
std::vector<int> visited_nodes;
|
||||
UpdateVisitedForNodeAndChildren(0, &visited_nodes);
|
||||
EraseUnvisitedNodes(visited_nodes);
|
||||
|
||||
// The data sent to the Context Service is a JSON formatted list of labels
|
||||
// for all on screen widgets.
|
||||
rapidjson::Document nodes_json(rapidjson::kArrayType);
|
||||
for (const int node_index : visited_nodes) {
|
||||
const auto& node = semantics_nodes_[node_index];
|
||||
if (!node.label.empty()) {
|
||||
rapidjson::Value value;
|
||||
value.SetString(node.label.data(), node.label.size());
|
||||
nodes_json.PushBack(value, nodes_json.GetAllocator());
|
||||
}
|
||||
}
|
||||
|
||||
if (nodes_json.Size() > 0) {
|
||||
rapidjson::StringBuffer buffer;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||
nodes_json.Accept(writer);
|
||||
writer_->WriteEntityTopic("/inferred/accessibility_text",
|
||||
buffer.GetString());
|
||||
}
|
||||
}
|
||||
|
||||
void ContextWriterBridge::UpdateVisitedForNodeAndChildren(
|
||||
const int id,
|
||||
std::vector<int>* visited_nodes) {
|
||||
std::map<int, flutter::SemanticsNode>::const_iterator it =
|
||||
semantics_nodes_.find(id);
|
||||
if (it == semantics_nodes_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
visited_nodes->push_back(id);
|
||||
for (const int child : it->second.childrenInTraversalOrder) {
|
||||
UpdateVisitedForNodeAndChildren(child, visited_nodes);
|
||||
}
|
||||
}
|
||||
|
||||
void ContextWriterBridge::EraseUnvisitedNodes(
|
||||
const std::vector<int>& visited_nodes) {
|
||||
const std::unordered_set<int> visited_nodes_lookup(visited_nodes.begin(),
|
||||
visited_nodes.end());
|
||||
for (auto it = semantics_nodes_.begin(); it != semantics_nodes_.end();) {
|
||||
if (visited_nodes_lookup.find((*it).first) == visited_nodes_lookup.end()) {
|
||||
it = semantics_nodes_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace flutter_runner
|
||||
@ -1,45 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <fuchsia/modular/cpp/fidl.h>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/lib/ui/semantics/semantics_node.h"
|
||||
|
||||
namespace flutter_runner {
|
||||
|
||||
// Maintain an up-to-date list of SemanticsNodes on screen, and communicate
|
||||
// with the Context Service.
|
||||
class ContextWriterBridge final {
|
||||
public:
|
||||
ContextWriterBridge(
|
||||
fidl::InterfaceHandle<fuchsia::modular::ContextWriter> writer);
|
||||
|
||||
~ContextWriterBridge();
|
||||
|
||||
// Update the internal representation of the semantics nodes, and write the
|
||||
// semantics to Context Service.
|
||||
void UpdateSemantics(const flutter::SemanticsNodeUpdates& update);
|
||||
|
||||
private:
|
||||
fuchsia::modular::ContextWriterPtr writer_;
|
||||
std::map<int, flutter::SemanticsNode> semantics_nodes_;
|
||||
|
||||
// Walk the semantics node tree starting at |id|, and store the id of each
|
||||
// visited child in |visited_nodes|.
|
||||
void UpdateVisitedForNodeAndChildren(const int id,
|
||||
std::vector<int>* visited_nodes);
|
||||
|
||||
// Remove any node from |semantics_nodes_| that doesn't have an id in
|
||||
// |visited_nodes|.
|
||||
void EraseUnvisitedNodes(const std::vector<int>& visited_nodes);
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ContextWriterBridge);
|
||||
};
|
||||
|
||||
} // namespace flutter_runner
|
||||
@ -80,12 +80,6 @@ Engine::Engine(Delegate& delegate,
|
||||
environment->GetServices(parent_environment_service_provider.NewRequest());
|
||||
environment.Unbind();
|
||||
|
||||
// Grab the accessibility context writer that can understand the semantics
|
||||
// tree on the platform view.
|
||||
fidl::InterfaceHandle<fuchsia::modular::ContextWriter>
|
||||
accessibility_context_writer;
|
||||
svc->Connect(accessibility_context_writer.NewRequest());
|
||||
|
||||
// We need to manually schedule a frame when the session metrics change.
|
||||
OnMetricsUpdate on_session_metrics_change_callback = std::bind(
|
||||
&Engine::OnSessionMetricsDidChange, this, std::placeholders::_1);
|
||||
@ -120,8 +114,6 @@ Engine::Engine(Delegate& delegate,
|
||||
std::move(on_session_metrics_change_callback),
|
||||
on_session_size_change_hint_callback =
|
||||
std::move(on_session_size_change_hint_callback),
|
||||
accessibility_context_writer =
|
||||
std::move(accessibility_context_writer),
|
||||
vsync_handle = vsync_event_.get()](flutter::Shell& shell) mutable {
|
||||
return std::make_unique<flutter_runner::PlatformView>(
|
||||
shell, // delegate
|
||||
@ -132,9 +124,7 @@ Engine::Engine(Delegate& delegate,
|
||||
std::move(on_session_listener_error_callback),
|
||||
std::move(on_session_metrics_change_callback),
|
||||
std::move(on_session_size_change_hint_callback),
|
||||
std::move(accessibility_context_writer), // accessibility
|
||||
// context writer
|
||||
vsync_handle // vsync handle
|
||||
vsync_handle // vsync handle
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -86,8 +86,6 @@ PlatformView::PlatformView(
|
||||
fit::closure session_listener_error_callback,
|
||||
OnMetricsUpdate session_metrics_did_change_callback,
|
||||
OnSizeChangeHint session_size_change_hint_callback,
|
||||
fidl::InterfaceHandle<fuchsia::modular::ContextWriter>
|
||||
accessibility_context_writer,
|
||||
zx_handle_t vsync_event_handle)
|
||||
: flutter::PlatformView(delegate, std::move(task_runners)),
|
||||
debug_label_(std::move(debug_label)),
|
||||
@ -97,7 +95,6 @@ PlatformView::PlatformView(
|
||||
metrics_changed_callback_(std::move(session_metrics_did_change_callback)),
|
||||
size_change_hint_callback_(std::move(session_size_change_hint_callback)),
|
||||
ime_client_(this),
|
||||
context_writer_bridge_(std::move(accessibility_context_writer)),
|
||||
surface_(std::make_unique<Surface>(debug_label_)),
|
||||
vsync_event_handle_(vsync_event_handle) {
|
||||
// Register all error handlers.
|
||||
@ -595,9 +592,6 @@ void PlatformView::HandlePlatformMessage(
|
||||
void PlatformView::UpdateSemantics(
|
||||
flutter::SemanticsNodeUpdates update,
|
||||
flutter::CustomAccessibilityActionUpdates actions) {
|
||||
// TODO(MI4-1262): Figure out if the context_writer_bridge should be removed
|
||||
// as it is unused.
|
||||
// context_writer_bridge_.UpdateSemantics(update);
|
||||
// TODO(MIT-1539): Uncomment/Reimplement following code, to add A11y support.
|
||||
// semantics_bridge_.UpdateSemantics(update);
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#include "lib/fidl/cpp/binding.h"
|
||||
#include "lib/ui/scenic/cpp/id.h"
|
||||
|
||||
#include "context_writer_bridge.h"
|
||||
#include "surface.h"
|
||||
|
||||
namespace flutter_runner {
|
||||
@ -49,16 +48,12 @@ class PlatformView final : public flutter::PlatformView,
|
||||
fit::closure on_session_listener_error_callback,
|
||||
OnMetricsUpdate session_metrics_did_change_callback,
|
||||
OnSizeChangeHint session_size_change_hint_callback,
|
||||
fidl::InterfaceHandle<fuchsia::modular::ContextWriter>
|
||||
accessibility_context_writer,
|
||||
zx_handle_t vsync_event_handle);
|
||||
PlatformView(PlatformView::Delegate& delegate,
|
||||
std::string debug_label,
|
||||
flutter::TaskRunners task_runners,
|
||||
fidl::InterfaceHandle<fuchsia::sys::ServiceProvider>
|
||||
parent_environment_service_provider,
|
||||
fidl::InterfaceHandle<fuchsia::modular::ContextWriter>
|
||||
accessibility_context_writer,
|
||||
zx_handle_t vsync_event_handle);
|
||||
|
||||
~PlatformView();
|
||||
@ -80,7 +75,6 @@ class PlatformView final : public flutter::PlatformView,
|
||||
|
||||
fuchsia::sys::ServiceProviderPtr parent_environment_service_provider_;
|
||||
fuchsia::modular::ClipboardPtr clipboard_;
|
||||
ContextWriterBridge context_writer_bridge_;
|
||||
std::unique_ptr<Surface> surface_;
|
||||
flutter::LogicalMetrics metrics_;
|
||||
fuchsia::ui::gfx::Metrics scenic_metrics_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user