Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
91071f81
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
91071f81
编写于
10月 23, 2017
作者:
M
Michael Goderbauer
提交者:
GitHub
10月 23, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support for accessibility label and hint (#4264)
* Support for accessibility label and hint * review comments
上级
8e791567
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
67 addition
and
9 deletion
+67
-9
lib/ui/semantics.dart
lib/ui/semantics.dart
+10
-2
lib/ui/semantics/semantics_node.h
lib/ui/semantics/semantics_node.h
+2
-0
lib/ui/semantics/semantics_update_builder.cc
lib/ui/semantics/semantics_update_builder.cc
+4
-0
lib/ui/semantics/semantics_update_builder.h
lib/ui/semantics/semantics_update_builder.h
+2
-0
shell/platform/android/io/flutter/view/AccessibilityBridge.java
...platform/android/io/flutter/view/AccessibilityBridge.java
+24
-6
shell/platform/android/platform_view_android.cc
shell/platform/android/platform_view_android.cc
+13
-1
shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm
...tform/darwin/ios/framework/Source/accessibility_bridge.mm
+12
-0
未找到文件。
lib/ui/semantics.dart
浏览文件 @
91071f81
...
@@ -214,8 +214,10 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
...
@@ -214,8 +214,10 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
/// asynchronously, the [Window.onSemanticsAction] callback might be called
/// asynchronously, the [Window.onSemanticsAction] callback might be called
/// with an action that is no longer possible.
/// with an action that is no longer possible.
///
///
/// The `label` is a string that describes this node. Its reading direction is
/// The `label` is a string that describes this node. The `value` property
/// given by `textDirection`.
/// describes the current value of the node as a string. The `hint` string
/// describes what result an action performed on this node has. The reading
/// direction of all these strings is given by `textDirection`.
///
///
/// The `rect` is the region occupied by this node in its own coordinate
/// The `rect` is the region occupied by this node in its own coordinate
/// system.
/// system.
...
@@ -228,6 +230,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
...
@@ -228,6 +230,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
int
actions
,
int
actions
,
Rect
rect
,
Rect
rect
,
String
label
,
String
label
,
String
hint
,
String
value
,
TextDirection
textDirection
,
TextDirection
textDirection
,
Float64List
transform
,
Float64List
transform
,
Int32List
children
Int32List
children
...
@@ -242,6 +246,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
...
@@ -242,6 +246,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
rect
.
right
,
rect
.
right
,
rect
.
bottom
,
rect
.
bottom
,
label
,
label
,
hint
,
value
,
textDirection
!=
null
?
textDirection
.
index
+
1
:
0
,
textDirection
!=
null
?
textDirection
.
index
+
1
:
0
,
transform
,
transform
,
children
);
children
);
...
@@ -255,6 +261,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
...
@@ -255,6 +261,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
double
right
,
double
right
,
double
bottom
,
double
bottom
,
String
label
,
String
label
,
String
hint
,
String
value
,
int
textDirection
,
int
textDirection
,
Float64List
transform
,
Float64List
transform
,
Int32List
children
Int32List
children
...
...
lib/ui/semantics/semantics_node.h
浏览文件 @
91071f81
...
@@ -52,6 +52,8 @@ struct SemanticsNode {
...
@@ -52,6 +52,8 @@ struct SemanticsNode {
int32_t
flags
=
0
;
int32_t
flags
=
0
;
int32_t
actions
=
0
;
int32_t
actions
=
0
;
std
::
string
label
;
std
::
string
label
;
std
::
string
hint
;
std
::
string
value
;
int32_t
textDirection
=
0
;
// 0=unknown, 1=rtl, 2=ltr
int32_t
textDirection
=
0
;
// 0=unknown, 1=rtl, 2=ltr
SkRect
rect
=
SkRect
::
MakeEmpty
();
SkRect
rect
=
SkRect
::
MakeEmpty
();
...
...
lib/ui/semantics/semantics_update_builder.cc
浏览文件 @
91071f81
...
@@ -42,6 +42,8 @@ void SemanticsUpdateBuilder::updateNode(int id,
...
@@ -42,6 +42,8 @@ void SemanticsUpdateBuilder::updateNode(int id,
double
right
,
double
right
,
double
bottom
,
double
bottom
,
std
::
string
label
,
std
::
string
label
,
std
::
string
hint
,
std
::
string
value
,
int
textDirection
,
int
textDirection
,
const
tonic
::
Float64List
&
transform
,
const
tonic
::
Float64List
&
transform
,
const
tonic
::
Int32List
&
children
)
{
const
tonic
::
Int32List
&
children
)
{
...
@@ -51,6 +53,8 @@ void SemanticsUpdateBuilder::updateNode(int id,
...
@@ -51,6 +53,8 @@ void SemanticsUpdateBuilder::updateNode(int id,
node
.
actions
=
actions
;
node
.
actions
=
actions
;
node
.
rect
=
SkRect
::
MakeLTRB
(
left
,
top
,
right
,
bottom
);
node
.
rect
=
SkRect
::
MakeLTRB
(
left
,
top
,
right
,
bottom
);
node
.
label
=
label
;
node
.
label
=
label
;
node
.
hint
=
hint
;
node
.
value
=
value
;
node
.
textDirection
=
textDirection
;
node
.
textDirection
=
textDirection
;
node
.
transform
.
setColMajord
(
transform
.
data
());
node
.
transform
.
setColMajord
(
transform
.
data
());
node
.
children
=
std
::
vector
<
int32_t
>
(
node
.
children
=
std
::
vector
<
int32_t
>
(
...
...
lib/ui/semantics/semantics_update_builder.h
浏览文件 @
91071f81
...
@@ -33,6 +33,8 @@ class SemanticsUpdateBuilder
...
@@ -33,6 +33,8 @@ class SemanticsUpdateBuilder
double
right
,
double
right
,
double
bottom
,
double
bottom
,
std
::
string
label
,
std
::
string
label
,
std
::
string
hint
,
std
::
string
value
,
int
textDirection
,
int
textDirection
,
const
tonic
::
Float64List
&
transform
,
const
tonic
::
Float64List
&
transform
,
const
tonic
::
Int32List
&
children
);
const
tonic
::
Int32List
&
children
);
...
...
shell/platform/android/io/flutter/view/AccessibilityBridge.java
浏览文件 @
91071f81
...
@@ -158,7 +158,7 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
...
@@ -158,7 +158,7 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
result
.
setCheckable
((
object
.
flags
&
SEMANTICS_FLAG_HAS_CHECKED_STATE
)
!=
0
);
result
.
setCheckable
((
object
.
flags
&
SEMANTICS_FLAG_HAS_CHECKED_STATE
)
!=
0
);
result
.
setChecked
((
object
.
flags
&
SEMANTICS_FLAG_IS_CHECKED
)
!=
0
);
result
.
setChecked
((
object
.
flags
&
SEMANTICS_FLAG_IS_CHECKED
)
!=
0
);
result
.
setSelected
((
object
.
flags
&
SEMANTICS_FLAG_IS_SELECTED
)
!=
0
);
result
.
setSelected
((
object
.
flags
&
SEMANTICS_FLAG_IS_SELECTED
)
!=
0
);
result
.
setText
(
object
.
label
);
result
.
setText
(
object
.
getValueLabelHint
()
);
if
((
object
.
flags
&
SEMANTICS_FLAG_IS_BUTTON
)
!=
0
)
{
if
((
object
.
flags
&
SEMANTICS_FLAG_IS_BUTTON
)
!=
0
)
{
result
.
setClassName
(
"android.widget.Button"
);
result
.
setClassName
(
"android.widget.Button"
);
...
@@ -434,6 +434,8 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
...
@@ -434,6 +434,8 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
int
flags
;
int
flags
;
int
actions
;
int
actions
;
String
label
;
String
label
;
String
value
;
String
hint
;
TextDirection
textDirection
;
TextDirection
textDirection
;
private
float
left
;
private
float
left
;
...
@@ -468,11 +470,14 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
...
@@ -468,11 +470,14 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
flags
=
buffer
.
getInt
();
flags
=
buffer
.
getInt
();
actions
=
buffer
.
getInt
();
actions
=
buffer
.
getInt
();
final
int
stringIndex
=
buffer
.
getInt
();
int
stringIndex
=
buffer
.
getInt
();
if
(
stringIndex
==
-
1
)
label
=
stringIndex
==
-
1
?
null
:
strings
[
stringIndex
];
label
=
null
;
else
stringIndex
=
buffer
.
getInt
();
label
=
strings
[
stringIndex
];
value
=
stringIndex
==
-
1
?
null
:
strings
[
stringIndex
];
stringIndex
=
buffer
.
getInt
();
hint
=
stringIndex
==
-
1
?
null
:
strings
[
stringIndex
];
textDirection
=
TextDirection
.
fromInt
(
buffer
.
getInt
());
textDirection
=
TextDirection
.
fromInt
(
buffer
.
getInt
());
...
@@ -620,5 +625,18 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
...
@@ -620,5 +625,18 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
private
float
max
(
float
a
,
float
b
,
float
c
,
float
d
)
{
private
float
max
(
float
a
,
float
b
,
float
c
,
float
d
)
{
return
Math
.
max
(
a
,
Math
.
max
(
b
,
Math
.
max
(
c
,
d
)));
return
Math
.
max
(
a
,
Math
.
max
(
b
,
Math
.
max
(
c
,
d
)));
}
}
private
String
getValueLabelHint
()
{
StringBuilder
sb
=
new
StringBuilder
();
String
[]
array
=
{
value
,
label
,
hint
};
for
(
String
word:
array
)
{
if
(
word
!=
null
&&
(
word
=
word
.
trim
()).
length
()
>
0
)
{
if
(
sb
.
length
()
>
0
)
sb
.
append
(
", "
);
sb
.
append
(
word
);
}
}
return
sb
.
length
()
>
0
?
sb
.
toString
()
:
null
;
}
}
}
}
}
shell/platform/android/platform_view_android.cc
浏览文件 @
91071f81
...
@@ -431,7 +431,7 @@ bool PlatformViewAndroid::ResourceContextMakeCurrent() {
...
@@ -431,7 +431,7 @@ bool PlatformViewAndroid::ResourceContextMakeCurrent() {
void
PlatformViewAndroid
::
UpdateSemantics
(
void
PlatformViewAndroid
::
UpdateSemantics
(
std
::
vector
<
blink
::
SemanticsNode
>
update
)
{
std
::
vector
<
blink
::
SemanticsNode
>
update
)
{
constexpr
size_t
kBytesPerNode
=
2
6
*
sizeof
(
int32_t
);
constexpr
size_t
kBytesPerNode
=
2
8
*
sizeof
(
int32_t
);
constexpr
size_t
kBytesPerChild
=
sizeof
(
int32_t
);
constexpr
size_t
kBytesPerChild
=
sizeof
(
int32_t
);
JNIEnv
*
env
=
fml
::
jni
::
AttachCurrentThread
();
JNIEnv
*
env
=
fml
::
jni
::
AttachCurrentThread
();
...
@@ -464,6 +464,18 @@ void PlatformViewAndroid::UpdateSemantics(
...
@@ -464,6 +464,18 @@ void PlatformViewAndroid::UpdateSemantics(
buffer_int32
[
position
++
]
=
strings
.
size
();
buffer_int32
[
position
++
]
=
strings
.
size
();
strings
.
push_back
(
node
.
label
);
strings
.
push_back
(
node
.
label
);
}
}
if
(
node
.
value
.
empty
())
{
buffer_int32
[
position
++
]
=
-
1
;
}
else
{
buffer_int32
[
position
++
]
=
strings
.
size
();
strings
.
push_back
(
node
.
value
);
}
if
(
node
.
hint
.
empty
())
{
buffer_int32
[
position
++
]
=
-
1
;
}
else
{
buffer_int32
[
position
++
]
=
strings
.
size
();
strings
.
push_back
(
node
.
hint
);
}
buffer_int32
[
position
++
]
=
node
.
textDirection
;
buffer_int32
[
position
++
]
=
node
.
textDirection
;
buffer_float32
[
position
++
]
=
node
.
rect
.
left
();
buffer_float32
[
position
++
]
=
node
.
rect
.
left
();
buffer_float32
[
position
++
]
=
node
.
rect
.
top
();
buffer_float32
[
position
++
]
=
node
.
rect
.
top
();
...
...
shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm
浏览文件 @
91071f81
...
@@ -162,6 +162,18 @@ bool GeometryComparator(SemanticsObject* a, SemanticsObject* b) {
...
@@ -162,6 +162,18 @@ bool GeometryComparator(SemanticsObject* a, SemanticsObject* b) {
return
@
(
_node
.
label
.
data
());
return
@
(
_node
.
label
.
data
());
}
}
-
(
NSString
*
)
accessibilityHint
{
if
(
_node
.
hint
.
empty
())
return
nil
;
return
@
(
_node
.
hint
.
data
());
}
-
(
NSString
*
)
accessibilityValue
{
if
(
_node
.
value
.
empty
())
return
nil
;
return
@
(
_node
.
value
.
data
());
}
-
(
UIAccessibilityTraits
)
accessibilityTraits
{
-
(
UIAccessibilityTraits
)
accessibilityTraits
{
UIAccessibilityTraits
traits
=
UIAccessibilityTraitNone
;
UIAccessibilityTraits
traits
=
UIAccessibilityTraitNone
;
if
(
_node
.
HasAction
(
blink
::
SemanticsAction
::
kIncrease
)
||
if
(
_node
.
HasAction
(
blink
::
SemanticsAction
::
kIncrease
)
||
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录