Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0347c533
Unverified
Commit
0347c533
authored
Jun 11, 2021
by
xubaolin
Committed by
GitHub
Jun 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a PlatformView gesture bug (#84257)
parent
f43a282f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
8 deletions
+67
-8
platform_views.dart
packages/flutter/lib/src/services/platform_views.dart
+12
-8
platform_view_test.dart
packages/flutter/test/rendering/platform_view_test.dart
+55
-0
No files found.
packages/flutter/lib/src/services/platform_views.dart
View file @
0347c533
...
...
@@ -540,20 +540,24 @@ class _AndroidMotionEventConverter {
);
}
void
handlePointerUpEvent
(
PointerUpEvent
event
)
{
pointerPositions
.
remove
(
event
.
pointer
);
usedAndroidPointerIds
.
remove
(
pointerProperties
[
event
.
pointer
]!.
id
);
pointerProperties
.
remove
(
event
.
pointer
);
void
_remove
(
int
pointer
)
{
pointerPositions
.
remove
(
pointer
);
usedAndroidPointerIds
.
remove
(
pointerProperties
[
pointer
]!.
id
);
pointerProperties
.
remove
(
pointer
);
if
(
pointerProperties
.
isEmpty
)
{
downTimeMillis
=
null
;
}
}
void
handlePointerUpEvent
(
PointerUpEvent
event
)
{
_remove
(
event
.
pointer
);
}
void
handlePointerCancelEvent
(
PointerCancelEvent
event
)
{
pointerPositions
.
clear
();
pointerProperties
.
clear
();
usedAndroidPointerIds
.
clear
();
downTimeMillis
=
null
;
// The pointer cancel event is handled like pointer up. Normally,
// the difference is that pointer cancel doesn't perform any action,
// but in this case neither up or cancel perform any action.
_remove
(
event
.
pointer
)
;
}
AndroidMotionEvent
?
toAndroidMotionEvent
(
PointerEvent
event
)
{
...
...
packages/flutter/test/rendering/platform_view_test.dart
View file @
0347c533
...
...
@@ -4,9 +4,11 @@
import
'dart:ui'
as
ui
;
import
'package:fake_async/fake_async.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../services/fake_platform_views.dart'
;
import
'rendering_tester.dart'
;
...
...
@@ -98,6 +100,56 @@ void main() {
});
},
skip:
isBrowser
);
// TODO(yjbanov): fails on Web with obscured stack trace: https://github.com/flutter/flutter/issues/42770
// Regression test for https://github.com/flutter/flutter/issues/69431
test
(
'multi-finger touch test'
,
()
{
renderer
;
// Initialize bindings.
final
FakeAndroidPlatformViewsController
viewsController
=
FakeAndroidPlatformViewsController
();
viewsController
.
registerViewType
(
'webview'
);
final
AndroidViewController
viewController
=
PlatformViewsService
.
initAndroidView
(
id:
0
,
viewType:
'webview'
,
layoutDirection:
TextDirection
.
rtl
);
final
PlatformViewRenderBox
platformViewRenderBox
=
PlatformViewRenderBox
(
controller:
viewController
,
hitTestBehavior:
PlatformViewHitTestBehavior
.
opaque
,
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
VerticalDragGestureRecognizer
>(
()
=>
VerticalDragGestureRecognizer
(),
),
},
);
layout
(
platformViewRenderBox
);
pumpFrame
(
phase:
EnginePhase
.
flushSemantics
);
viewController
.
pointTransformer
=
(
Offset
offset
)
=>
platformViewRenderBox
.
globalToLocal
(
offset
);
FakeAsync
().
run
((
FakeAsync
async
)
{
// Put one pointer down.
ui
.
window
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
ui
.
PointerChange
.
add
,
Offset
.
zero
,
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
down
,
const
Offset
(
10
,
10
),
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
remove
,
const
Offset
(
10
,
10
),
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
]));
async
.
flushMicrotasks
();
// Put another pointer down and then cancel it.
ui
.
window
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
ui
.
PointerChange
.
add
,
Offset
.
zero
,
pointer:
2
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
down
,
const
Offset
(
20
,
10
),
pointer:
2
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
cancel
,
const
Offset
(
20
,
10
),
pointer:
2
,
kind:
PointerDeviceKind
.
touch
),
]));
async
.
flushMicrotasks
();
// The first pointer can still moving without crashing.
ui
.
window
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
ui
.
PointerChange
.
add
,
Offset
.
zero
,
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
move
,
const
Offset
(
10
,
10
),
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
remove
,
const
Offset
(
10
,
10
),
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
]));
async
.
flushMicrotasks
();
});
// Passes if no crashes.
});
}
ui
.
PointerData
_pointerData
(
...
...
@@ -105,8 +157,11 @@ ui.PointerData _pointerData(
Offset
logicalPosition
,
{
int
device
=
0
,
PointerDeviceKind
kind
=
PointerDeviceKind
.
mouse
,
int
pointer
=
0
,
})
{
return
ui
.
PointerData
(
pointerIdentifier:
pointer
,
embedderId:
pointer
,
change:
change
,
physicalX:
logicalPosition
.
dx
*
ui
.
window
.
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
ui
.
window
.
devicePixelRatio
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment