Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
a6b71ac4
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,发现更多精彩内容 >>
未验证
提交
a6b71ac4
编写于
4月 27, 2021
作者:
M
Matej Knopp
提交者:
GitHub
4月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix accent popup position (#25524)
上级
2db8af2d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
91 addition
and
6 deletion
+91
-6
shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.h
...rm/darwin/macos/framework/Source/FlutterTextInputPlugin.h
+1
-0
shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm
...m/darwin/macos/framework/Source/FlutterTextInputPlugin.mm
+12
-6
shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm
...rwin/macos/framework/Source/FlutterTextInputPluginTest.mm
+78
-0
未找到文件。
shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.h
浏览文件 @
a6b71ac4
...
...
@@ -29,4 +29,5 @@
// Private methods made visible for testing
@interface
FlutterTextInputPlugin
(
TestMethods
)
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
;
-
(
NSRect
)
firstRectForCharacterRange
:(
NSRange
)
range
actualRange
:(
NSRangePointer
)
actualRange
;
@end
shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm
浏览文件 @
a6b71ac4
...
...
@@ -21,6 +21,8 @@ static NSString* const kShowMethod = @"TextInput.show";
static
NSString
*
const
kHideMethod
=
@"TextInput.hide"
;
static
NSString
*
const
kClearClientMethod
=
@"TextInput.clearClient"
;
static
NSString
*
const
kSetEditingStateMethod
=
@"TextInput.setEditingState"
;
static
NSString
*
const
kSetEditableSizeAndTransform
=
@"TextInput.setEditableSizeAndTransform"
;
static
NSString
*
const
kSetCaretRect
=
@"TextInput.setCaretRect"
;
static
NSString
*
const
kUpdateEditStateResponseMethod
=
@"TextInputClient.updateEditingState"
;
static
NSString
*
const
kPerformAction
=
@"TextInputClient.performAction"
;
static
NSString
*
const
kMultilineInputType
=
@"TextInputType.multiline"
;
...
...
@@ -39,6 +41,7 @@ static NSString* const kSelectionIsDirectionalKey = @"selectionIsDirectional";
static
NSString
*
const
kComposingBaseKey
=
@"composingBase"
;
static
NSString
*
const
kComposingExtentKey
=
@"composingExtent"
;
static
NSString
*
const
kTextKey
=
@"text"
;
static
NSString
*
const
kTransformKey
=
@"transform"
;
/**
* The affinity of the current cursor position. If the cursor is at a position representing
...
...
@@ -163,6 +166,8 @@ static flutter::TextRange RangeFromBaseExtent(NSNumber* base,
_textInputContext
=
[[
NSTextInputContext
alloc
]
initWithClient
:
self
];
_previouslyPressedFlags
=
0
;
_flutterViewController
=
viewController
;
// Initialize with the zero matrix which is not
// an affine transform.
_editableTransform
=
CATransform3D
();
...
...
@@ -215,10 +220,10 @@ static flutter::TextRange RangeFromBaseExtent(NSNumber* base,
// engine since it sent this update, and needs to now be made to match the
// engine's version of the state.
[
self
updateEditState
];
}
else
if
([
method
isEqualToString
:
@"TextInput.setEditableSizeAndTransform"
])
{
}
else
if
([
method
isEqualToString
:
kSetEditableSizeAndTransform
])
{
NSDictionary
*
state
=
call
.
arguments
;
[
self
setEditableTransform
:
state
[
@"transform"
]];
}
else
if
([
method
isEqualToString
:
@"TextInput.setCaretRect"
])
{
[
self
setEditableTransform
:
state
[
kTransformKey
]];
}
else
if
([
method
isEqualToString
:
kSetCaretRect
])
{
NSDictionary
*
rect
=
call
.
arguments
;
[
self
updateCaretRect
:
rect
];
}
else
{
...
...
@@ -462,9 +467,10 @@ static flutter::TextRange RangeFromBaseExtent(NSNumber* base,
CGRect
rect
=
CGRectApplyAffineTransform
(
_caretRect
,
CATransform3DGetAffineTransform
(
_editableTransform
));
// flip and convert to screen coordinates
double
viewHeight
=
self
.
flutterViewController
.
view
.
bounds
.
size
.
height
;
rect
.
origin
.
y
=
viewHeight
-
rect
.
origin
.
y
;
// convert to window coordinates
rect
=
[
self
.
flutterViewController
.
view
convertRect
:
rect
toView
:
nil
];
// convert to screen coordinates
return
[
self
.
flutterViewController
.
view
.
window
convertRectToScreen
:
rect
];
}
else
{
return
CGRectZero
;
...
...
shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm
浏览文件 @
a6b71ac4
...
...
@@ -81,6 +81,80 @@
return
true
;
}
-
(
bool
)
testFirstRectForCharacterRange
{
id
engineMock
=
OCMClassMock
([
FlutterEngine
class
]);
id
binaryMessengerMock
=
OCMProtocolMock
(
@protocol
(
FlutterBinaryMessenger
));
OCMStub
(
// NOLINT(google-objc-avoid-throwing-exception)
[
engineMock
binaryMessenger
])
.
andReturn
(
binaryMessengerMock
);
id
controllerMock
=
OCMClassMock
([
FlutterViewController
class
]);
OCMStub
(
// NOLINT(google-objc-avoid-throwing-exception)
[
controllerMock
engine
])
.
andReturn
(
engineMock
);
id
viewMock
=
OCMClassMock
([
NSView
class
]);
OCMStub
(
// NOLINT(google-objc-avoid-throwing-exception)
[
viewMock
bounds
])
.
andReturn
(
NSMakeRect
(
0
,
0
,
200
,
200
));
OCMStub
(
// NOLINT(google-objc-avoid-throwing-exception)
[
controllerMock
view
])
.
andReturn
(
viewMock
);
id
windowMock
=
OCMClassMock
([
NSWindow
class
]);
OCMStub
(
// NOLINT(google-objc-avoid-throwing-exception)
[
viewMock
window
])
.
andReturn
(
windowMock
);
OCMExpect
(
// NOLINT(google-objc-avoid-throwing-exception)
[
viewMock
convertRect
:
NSMakeRect
(
28
,
10
,
2
,
19
)
toView
:
nil
])
.
andReturn
(
NSMakeRect
(
28
,
10
,
2
,
19
));
OCMExpect
(
// NOLINT(google-objc-avoid-throwing-exception)
[
windowMock
convertRectToScreen
:
NSMakeRect
(
28
,
10
,
2
,
19
)])
.
andReturn
(
NSMakeRect
(
38
,
20
,
2
,
19
));
FlutterTextInputPlugin
*
plugin
=
[[
FlutterTextInputPlugin
alloc
]
initWithViewController
:
controllerMock
];
FlutterMethodCall
*
call
=
[
FlutterMethodCall
methodCallWithMethodName:
@"TextInput.setEditableSizeAndTransform"
arguments:
@{
@"height"
:
@
(
20.0
),
@"transform"
:
@[
@
(
1.0
),
@
(
0.0
),
@
(
0.0
),
@
(
0.0
),
@
(
0.0
),
@
(
1.0
),
@
(
0.0
),
@
(
0.0
),
@
(
0.0
),
@
(
0.0
),
@
(
1.0
),
@
(
0.0
),
@
(
20.0
),
@
(
10.0
),
@
(
0.0
),
@
(
1.0
)
],
@"width"
:
@
(
400.0
),
}];
[
plugin
handleMethodCall
:
call
result:
^
(
id
){
}];
call
=
[
FlutterMethodCall
methodCallWithMethodName
:
@"TextInput.setCaretRect"
arguments:
@{
@"height"
:
@
(
19.0
),
@"width"
:
@
(
2.0
),
@"x"
:
@
(
8.0
),
@"y"
:
@
(
0.0
),
}];
[
plugin
handleMethodCall
:
call
result:
^
(
id
){
}];
NSRect
rect
=
[
plugin
firstRectForCharacterRange
:
NSMakeRange
(
0
,
0
)
actualRange
:
nullptr
];
@try
{
OCMVerify
(
// NOLINT(google-objc-avoid-throwing-exception)
[
windowMock
convertRectToScreen
:
NSMakeRect
(
28
,
10
,
2
,
19
)]);
}
@catch
(...)
{
return
false
;
}
return
NSEqualRects
(
rect
,
NSMakeRect
(
38
,
20
,
2
,
19
));
}
@end
namespace
flutter
::
testing
{
...
...
@@ -89,4 +163,8 @@ TEST(FlutterTextInputPluginTest, TestEmptyCompositionRange) {
ASSERT_TRUE
([[
FlutterInputPluginTestObjc
alloc
]
testEmptyCompositionRange
]);
}
TEST
(
FlutterTextInputPluginTest
,
TestFirstRectForCharacterRange
)
{
ASSERT_TRUE
([[
FlutterInputPluginTestObjc
alloc
]
testFirstRectForCharacterRange
]);
}
}
// namespace flutter::testing
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录