Flutter Engine
The Flutter Engine
string_attribute.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_LIB_UI_SEMANTICS_STRING_ATTRIBUTE_H_
6#define FLUTTER_LIB_UI_SEMANTICS_STRING_ATTRIBUTE_H_
7
8#include "flutter/lib/ui/dart_wrapper.h"
10
11namespace flutter {
12
13struct StringAttribute;
14
15using StringAttributePtr = std::shared_ptr<flutter::StringAttribute>;
16using StringAttributes = std::vector<StringAttributePtr>;
17
18// When adding a new StringAttributeType, the classes in these file must be
19// updated as well.
20// * engine/src/flutter/lib/ui/semantics.dart
21// * engine/src/flutter/lib/web_ui/lib/semantics.dart
22// * engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
23// * engine/src/flutter/shell/platform/embedder/embedder.h
24// * engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_api_test.dart
25// * engine/src/flutter/testing/dart/semantics_test.dart
26
27enum class StringAttributeType : int32_t {
29 kLocale,
30};
31
32//------------------------------------------------------------------------------
33/// The c++ representation of the StringAttribute, this struct serves as an
34/// abstract interface for the subclasses and should not be used directly.
36 virtual ~StringAttribute() = default;
37 int32_t start = -1;
38 int32_t end = -1;
40};
41
42//------------------------------------------------------------------------------
43/// Indicates the string needs to be spelled out character by character when the
44/// assistive technologies announce the string.
46
47//------------------------------------------------------------------------------
48/// Indicates the string needs to be treated as a specific language when the
49/// assistive technologies announce the string.
51 std::string locale;
52};
53
54//------------------------------------------------------------------------------
55/// The peer class for all of the StringAttribute subclasses in semantics.dart.
57 : public RefCountedDartWrappable<NativeStringAttribute> {
58 DEFINE_WRAPPERTYPEINFO();
59 FML_FRIEND_MAKE_REF_COUNTED(NativeStringAttribute);
60
61 public:
62 ~NativeStringAttribute() override;
63
64 //----------------------------------------------------------------------------
65 /// The init method for SpellOutStringAttribute constructor
66 static void initSpellOutStringAttribute(Dart_Handle string_attribute_handle,
67 int32_t start,
68 int32_t end);
69
70 //----------------------------------------------------------------------------
71 /// The init method for LocaleStringAttribute constructor
72 static void initLocaleStringAttribute(Dart_Handle string_attribute_handle,
73 int32_t start,
74 int32_t end,
75 std::string locale);
76
77 //----------------------------------------------------------------------------
78 /// Returns the c++ representataion of StringAttribute.
79 const StringAttributePtr GetAttribute() const;
80
81 private:
83 StringAttributePtr attribute_;
84};
85
86} // namespace flutter
87
88#endif // FLUTTER_LIB_UI_SEMANTICS_STRING_ATTRIBUTE_H_
The peer class for all of the StringAttribute subclasses in semantics.dart.
const StringAttributePtr GetAttribute() const
Returns the c++ representataion of StringAttribute.
static void initSpellOutStringAttribute(Dart_Handle string_attribute_handle, int32_t start, int32_t end)
The init method for SpellOutStringAttribute constructor.
static void initLocaleStringAttribute(Dart_Handle string_attribute_handle, int32_t start, int32_t end, std::string locale)
The init method for LocaleStringAttribute constructor.
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
@ kSpellOut
Definition: embedder.h:1202
@ kLocale
Definition: embedder.h:1204
glong glong end
StringAttribute
Definition: ax_enums.h:521
std::vector< StringAttributePtr > StringAttributes
std::shared_ptr< flutter::StringAttribute > StringAttributePtr
virtual ~StringAttribute()=default
StringAttributeType type