Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
5d08804d
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
5d08804d
编写于
8月 18, 2021
作者:
C
chunhtai
提交者:
GitHub
8月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Makes scrollable to use main screen if the flutter view is not attached to a screen (#28110)
上级
bf63412e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
2 deletion
+76
-2
shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
...l/platform/darwin/ios/framework/Source/SemanticsObject.mm
+6
-2
shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm
...atform/darwin/ios/framework/Source/SemanticsObjectTest.mm
+70
-0
未找到文件。
shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
浏览文件 @
5d08804d
...
...
@@ -54,7 +54,9 @@ CGPoint ConvertPointToGlobal(SemanticsObject* reference, CGPoint local_point) {
// `rect` is in the physical pixel coordinate system. iOS expects the accessibility frame in
// the logical pixel coordinate system. Therefore, we divide by the `scale` (pixel ratio) to
// convert.
CGFloat
scale
=
[[[
reference
bridge
]
->
view
()
window
]
screen
].
scale
;
UIScreen
*
screen
=
[[[
reference
bridge
]
->
view
()
window
]
screen
];
// Screen can be nil if the FlutterView is covered by another native view.
CGFloat
scale
=
screen
==
nil
?
[
UIScreen
mainScreen
].
scale
:
screen
.
scale
;
auto
result
=
CGPointMake
(
point
.
x
()
/
scale
,
point
.
y
()
/
scale
);
return
[[
reference
bridge
]
->
view
()
convertPoint
:
result
toView
:
nil
];
}
...
...
@@ -80,7 +82,9 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) {
// `rect` is in the physical pixel coordinate system. iOS expects the accessibility frame in
// the logical pixel coordinate system. Therefore, we divide by the `scale` (pixel ratio) to
// convert.
CGFloat
scale
=
[[[
reference
bridge
]
->
view
()
window
]
screen
].
scale
;
UIScreen
*
screen
=
[[[
reference
bridge
]
->
view
()
window
]
screen
];
// Screen can be nil if the FlutterView is covered by another native view.
CGFloat
scale
=
screen
==
nil
?
[
UIScreen
mainScreen
].
scale
:
screen
.
scale
;
auto
result
=
CGRectMake
(
rect
.
x
()
/
scale
,
rect
.
y
()
/
scale
,
rect
.
width
()
/
scale
,
rect
.
height
()
/
scale
);
return
UIAccessibilityConvertFrameToScreenCoordinates
(
result
,
[
reference
bridge
]
->
view
());
...
...
shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm
浏览文件 @
5d08804d
...
...
@@ -56,6 +56,36 @@ class MockAccessibilityBridge : public AccessibilityBridgeIos {
UIView
*
view_
;
UIWindow
*
window_
;
};
class
MockAccessibilityBridgeNoWindow
:
public
AccessibilityBridgeIos
{
public:
MockAccessibilityBridgeNoWindow
()
:
observations
({})
{
view_
=
[[
UIView
alloc
]
initWithFrame
:
kScreenSize
];
}
bool
isVoiceOverRunning
()
const
override
{
return
isVoiceOverRunningValue
;
}
UIView
*
view
()
const
override
{
return
view_
;
}
UIView
<
UITextInput
>*
textInputView
()
override
{
return
nil
;
}
void
DispatchSemanticsAction
(
int32_t
id
,
SemanticsAction
action
)
override
{
SemanticsActionObservation
observation
(
id
,
action
);
observations
.
push_back
(
observation
);
}
void
DispatchSemanticsAction
(
int32_t
id
,
SemanticsAction
action
,
fml
::
MallocMapping
args
)
override
{
SemanticsActionObservation
observation
(
id
,
action
);
observations
.
push_back
(
observation
);
}
void
AccessibilityObjectDidBecomeFocused
(
int32_t
id
)
override
{}
void
AccessibilityObjectDidLoseFocus
(
int32_t
id
)
override
{}
std
::
shared_ptr
<
FlutterPlatformViewsController
>
GetPlatformViewsController
()
const
override
{
return
nil
;
}
std
::
vector
<
SemanticsActionObservation
>
observations
;
bool
isVoiceOverRunningValue
;
private:
UIView
*
view_
;
};
}
// namespace
}
// namespace flutter
...
...
@@ -208,6 +238,46 @@ class MockAccessibilityBridge : public AccessibilityBridgeIos {
CGPointMake
(
0
,
scrollPosition
*
effectivelyScale
)));
}
-
(
void
)
testVerticalFlutterScrollableSemanticsObjectNoWindow
{
fml
::
WeakPtrFactory
<
flutter
::
AccessibilityBridgeIos
>
factory
(
new
flutter
::
MockAccessibilityBridgeNoWindow
());
fml
::
WeakPtr
<
flutter
::
AccessibilityBridgeIos
>
bridge
=
factory
.
GetWeakPtr
();
float
transformScale
=
0.5
f
;
float
screenScale
=
[
UIScreen
mainScreen
].
scale
;
// Flutter view without window uses [UIScreen mainScreen];
float
effectivelyScale
=
transformScale
/
screenScale
;
float
x
=
10
;
float
y
=
10
;
float
w
=
100
;
float
h
=
200
;
float
scrollExtentMax
=
500.0
;
float
scrollPosition
=
150.0
;
flutter
::
SemanticsNode
node
;
node
.
flags
=
static_cast
<
int32_t
>
(
flutter
::
SemanticsFlags
::
kHasImplicitScrolling
);
node
.
actions
=
flutter
::
kVerticalScrollSemanticsActions
;
node
.
rect
=
SkRect
::
MakeXYWH
(
x
,
y
,
w
,
h
);
node
.
scrollExtentMax
=
scrollExtentMax
;
node
.
scrollPosition
=
scrollPosition
;
node
.
transform
=
{
transformScale
,
0
,
0
,
0
,
0
,
transformScale
,
0
,
0
,
0
,
0
,
transformScale
,
0
,
0
,
0
,
0
,
1.0
};
FlutterSemanticsObject
*
delegate
=
[[
FlutterSemanticsObject
alloc
]
initWithBridge
:
bridge
uid
:
0
];
FlutterScrollableSemanticsObject
*
scrollable
=
[[
FlutterScrollableSemanticsObject
alloc
]
initWithSemanticsObject
:
delegate
];
SemanticsObject
*
scrollable_object
=
static_cast
<
SemanticsObject
*>
(
scrollable
);
[
scrollable_object
setSemanticsNode
:
&
node
];
[
scrollable_object
accessibilityBridgeDidFinishUpdate
];
XCTAssertTrue
(
CGRectEqualToRect
(
scrollable
.
frame
,
CGRectMake
(
x
*
effectivelyScale
,
y
*
effectivelyScale
,
w
*
effectivelyScale
,
h
*
effectivelyScale
)));
XCTAssertTrue
(
CGSizeEqualToSize
(
scrollable
.
contentSize
,
CGSizeMake
(
w
*
effectivelyScale
,
(
h
+
scrollExtentMax
)
*
effectivelyScale
)));
XCTAssertTrue
(
CGPointEqualToPoint
(
scrollable
.
contentOffset
,
CGPointMake
(
0
,
scrollPosition
*
effectivelyScale
)));
}
-
(
void
)
testHorizontalFlutterScrollableSemanticsObject
{
fml
::
WeakPtrFactory
<
flutter
::
AccessibilityBridgeIos
>
factory
(
new
flutter
::
MockAccessibilityBridge
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录