flutter_flutter/shell/platform/embedder/platform_view_embedder.h
Chris Bracken abe9826a9d
Add accessibility semantics support to embedder (#7891)
Flutter's accessibility APIs consist of three main calls from the
embedder to the Dart application:

  1. FlutterEngineUpdateSemanticsEnabled: enables/disables semantics support.

  2. FlutterEngineUpdateAccessibilityFeatures: sets embedder-specific
     accessibility features.

  3. FlutterEngineDispatchSemanticsAction: dispatches an action (tap,
     long-press, scroll, etc.) to a semantics node.

and two main callbacks triggered by Dart code:

  1. FlutterUpdateSemanticsNodeCallback: notifies the embedder of
     updates to the properties of a given semantics node.

  2. FlutterUpdateSemanticsCustomActionCallback: notifies the embedder
     of updates to custom semantics actions registered in Dart code.

In the Flutter framework, when accessibility is first enabled, the
embedder will receive a stream of update callbacks notifying the
embedder of the full semantics tree. On further changes in the Dart
application, only updates will be sent.
2019-02-20 18:59:29 -08:00

77 lines
2.8 KiB
C++

// 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.
#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_
#include <functional>
#include "flutter/fml/macros.h"
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/embedder/embedder_surface.h"
#include "flutter/shell/platform/embedder/embedder_surface_gl.h"
#include "flutter/shell/platform/embedder/embedder_surface_software.h"
namespace shell {
class PlatformViewEmbedder final : public PlatformView {
public:
using UpdateSemanticsNodesCallback =
std::function<void(blink::SemanticsNodeUpdates update)>;
using UpdateSemanticsCustomActionsCallback =
std::function<void(blink::CustomAccessibilityActionUpdates actions)>;
using PlatformMessageResponseCallback =
std::function<void(fml::RefPtr<blink::PlatformMessage>)>;
struct PlatformDispatchTable {
UpdateSemanticsNodesCallback update_semantics_nodes_callback; // optional
UpdateSemanticsCustomActionsCallback
update_semantics_custom_actions_callback; // optional
PlatformMessageResponseCallback
platform_message_response_callback; // optional
};
// Creates a platform view that sets up an OpenGL rasterizer.
PlatformViewEmbedder(PlatformView::Delegate& delegate,
blink::TaskRunners task_runners,
EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table,
bool fbo_reset_after_present,
PlatformDispatchTable platform_dispatch_table);
// Create a platform view that sets up a software rasterizer.
PlatformViewEmbedder(
PlatformView::Delegate& delegate,
blink::TaskRunners task_runners,
EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table,
PlatformDispatchTable platform_dispatch_table);
~PlatformViewEmbedder() override;
// |shell::PlatformView|
void UpdateSemantics(
blink::SemanticsNodeUpdates update,
blink::CustomAccessibilityActionUpdates actions) override;
// |shell::PlatformView|
void HandlePlatformMessage(
fml::RefPtr<blink::PlatformMessage> message) override;
private:
std::unique_ptr<EmbedderSurface> embedder_surface_;
PlatformDispatchTable platform_dispatch_table_;
// |shell::PlatformView|
std::unique_ptr<Surface> CreateRenderingSurface() override;
// |shell::PlatformView|
sk_sp<GrContext> CreateResourceContext() const override;
FML_DISALLOW_COPY_AND_ASSIGN(PlatformViewEmbedder);
};
} // namespace shell
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_