Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
9b299f2c
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
未验证
提交
9b299f2c
编写于
12月 20, 2019
作者:
Y
Yegor
提交者:
GitHub
12月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix editable placement in a11y mode (#14581)
上级
cce5afd4
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
443 addition
and
282 deletion
+443
-282
lib/web_ui/lib/src/engine/semantics/text_field.dart
lib/web_ui/lib/src/engine/semantics/text_field.dart
+70
-5
lib/web_ui/lib/src/engine/text_editing/text_editing.dart
lib/web_ui/lib/src/engine/text_editing/text_editing.dart
+252
-214
lib/web_ui/lib/src/engine/window.dart
lib/web_ui/lib/src/engine/window.dart
+1
-1
lib/web_ui/test/text_editing_test.dart
lib/web_ui/test/text_editing_test.dart
+120
-62
未找到文件。
lib/web_ui/lib/src/engine/semantics/text_field.dart
浏览文件 @
9b299f2c
...
...
@@ -4,6 +4,70 @@
part of
engine
;
/// Text editing used by accesibility mode.
///
/// [SemanticsTextEditingStrategy] assumes the caller will own the creation,
/// insertion and disposal of the DOM element. Due to this
/// [initializeElementPlacement], [initializeTextEditing] and
/// [disable] strategies are handled differently.
///
/// This class is still responsible for hooking up the DOM element with the
/// [HybridTextEditing] instance so that changes are communicated to Flutter.
class
SemanticsTextEditingStrategy
extends
DefaultTextEditingStrategy
{
/// Creates a [SemanticsTextEditingStrategy] that eagerly instantiates
/// [domElement] so the caller can insert it before calling
/// [SemanticsTextEditingStrategy.enable].
SemanticsTextEditingStrategy
(
HybridTextEditing
owner
,
html
.
HtmlElement
domElement
)
:
super
(
owner
)
{
// Make sure the DOM element is of a type that we support for text editing.
// TODO(yjbanov): move into initializer list when https://github.com/dart-lang/sdk/issues/37881 is fixed.
assert
((
domElement
is
html
.
InputElement
)
||
(
domElement
is
html
.
TextAreaElement
));
super
.
domElement
=
domElement
;
}
@override
void
disable
()
{
// We don't want to remove the DOM element because the caller is responsible
// for that.
//
// Remove focus from the editable element to cause the keyboard to hide.
// Otherwise, the keyboard stays on screen even when the user navigates to
// a different screen (e.g. by hitting the "back" button).
domElement
.
blur
();
}
@override
void
initializeElementPlacement
()
{
// Element placement is done by [TextField].
}
@override
void
initializeTextEditing
(
InputConfiguration
inputConfig
,
{
_OnChangeCallback
onChange
,
_OnActionCallback
onAction
})
{
// In accesibilty mode, the user of this class is supposed to insert the
// [domElement] on their own. Let's make sure they did.
assert
(
domElement
!=
null
);
assert
(
html
.
document
.
body
.
contains
(
domElement
));
isEnabled
=
true
;
_inputConfiguration
=
inputConfig
;
_onChange
=
onChange
;
_onAction
=
onAction
;
domElement
.
focus
();
}
@override
void
setEditingState
(
EditingState
editingState
)
{
super
.
setEditingState
(
editingState
);
// Refocus after setting editing state.
domElement
.
focus
();
}
}
/// Manages semantics objects that represent editable text fields.
///
/// This role is implemented via a content-editable HTML element. This role does
...
...
@@ -19,15 +83,15 @@ class TextField extends RoleManager {
semanticsObject
.
hasFlag
(
ui
.
SemanticsFlag
.
isMultiline
)
?
html
.
TextAreaElement
()
:
html
.
InputElement
();
persistentTextEditingElement
=
PersistentTextEditingElement
(
textEditingElement
=
SemanticsTextEditingStrategy
(
textEditing
,
editableDomElement
,
);
_setupDomElement
();
}
PersistentTextEditingElement
persistentT
extEditingElement
;
html
.
Element
get
_textFieldElement
=>
persistentT
extEditingElement
.
domElement
;
SemanticsTextEditingStrategy
t
extEditingElement
;
html
.
Element
get
_textFieldElement
=>
t
extEditingElement
.
domElement
;
void
_setupDomElement
()
{
// On iOS, even though the semantic text field is transparent, the cursor
...
...
@@ -61,6 +125,7 @@ class TextField extends RoleManager {
switch
(
browserEngine
)
{
case
BrowserEngine
.
blink
:
case
BrowserEngine
.
edge
:
case
BrowserEngine
.
ie11
:
case
BrowserEngine
.
firefox
:
case
BrowserEngine
.
ie11
:
case
BrowserEngine
.
unknown
:
...
...
@@ -82,7 +147,7 @@ class TextField extends RoleManager {
return
;
}
textEditing
.
useCustomEditableElement
(
persistentT
extEditingElement
);
textEditing
.
useCustomEditableElement
(
t
extEditingElement
);
ui
.
window
.
onSemanticsAction
(
semanticsObject
.
id
,
ui
.
SemanticsAction
.
tap
,
null
);
});
...
...
@@ -98,7 +163,7 @@ class TextField extends RoleManager {
num
lastTouchStartOffsetY
;
_textFieldElement
.
addEventListener
(
'touchstart'
,
(
html
.
Event
event
)
{
textEditing
.
useCustomEditableElement
(
persistentT
extEditingElement
);
textEditing
.
useCustomEditableElement
(
t
extEditingElement
);
final
html
.
TouchEvent
touchEvent
=
event
;
lastTouchStartOffsetX
=
touchEvent
.
changedTouches
.
last
.
client
.
x
;
lastTouchStartOffsetY
=
touchEvent
.
changedTouches
.
last
.
client
.
y
;
...
...
lib/web_ui/lib/src/engine/text_editing/text_editing.dart
浏览文件 @
9b299f2c
此差异已折叠。
点击以展开。
lib/web_ui/lib/src/engine/window.dart
浏览文件 @
9b299f2c
...
...
@@ -155,7 +155,7 @@ class EngineWindow extends ui.Window {
break
;
case
'flutter/textinput'
:
textEditing
.
handleTextInput
(
data
);
textEditing
.
channel
.
handleTextInput
(
data
);
return
;
case
'flutter/platform_views'
:
...
...
lib/web_ui/test/text_editing_test.dart
浏览文件 @
9b299f2c
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录