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
94515ba5
Unverified
Commit
94515ba5
authored
Oct 10, 2019
by
Tong Mu
Committed by
GitHub
Oct 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make MouseTracker.sendMouseNotifications private (#41879)
* Make sendMouseNotifications private
parent
10ddb7db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
23 deletions
+13
-23
mouse_tracking.dart
packages/flutter/lib/src/gestures/mouse_tracking.dart
+13
-17
mouse_tracking_test.dart
packages/flutter/test/gestures/mouse_tracking_test.dart
+0
-6
No files found.
packages/flutter/lib/src/gestures/mouse_tracking.dart
View file @
94515ba5
...
...
@@ -131,8 +131,8 @@ class MouseTracker extends ChangeNotifier {
/// Stops tracking an annotation, indicating that it has been removed from the
/// layer tree.
///
///
If the associated layer is not removed, and receives a hit, then
///
[sendMouseNotifications] will assert the next time it is called
.
///
An assertion error will be thrown if the associated layer is not removed
///
and receives another mouse hit
.
void
detachAnnotation
(
MouseTrackerAnnotation
annotation
)
{
final
_TrackedAnnotation
trackedAnnotation
=
_findAnnotation
(
annotation
);
for
(
int
deviceId
in
trackedAnnotation
.
activeDevices
)
{
...
...
@@ -155,7 +155,7 @@ class MouseTracker extends ChangeNotifier {
if
(
_trackedAnnotations
.
isNotEmpty
&&
!
_scheduledPostFramePositionCheck
)
{
_scheduledPostFramePositionCheck
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
duration
)
{
sendMouseNotifications
(
_lastMouseEvent
.
keys
);
_
sendMouseNotifications
(
_lastMouseEvent
.
keys
);
_scheduledPostFramePositionCheck
=
false
;
});
}
...
...
@@ -171,14 +171,14 @@ class MouseTracker extends ChangeNotifier {
// If we are adding the device again, then we're not removing it anymore.
_pendingRemovals
.
remove
(
deviceId
);
_addMouseEvent
(
deviceId
,
event
);
sendMouseNotifications
(<
int
>{
deviceId
});
_
sendMouseNotifications
(<
int
>{
deviceId
});
return
;
}
if
(
event
is
PointerRemovedEvent
)
{
_removeMouseEvent
(
deviceId
,
event
);
// If the mouse was removed, then we need to schedule one more check to
// exit any annotations that were active.
sendMouseNotifications
(<
int
>{
deviceId
});
_
sendMouseNotifications
(<
int
>{
deviceId
});
}
else
{
if
(
event
is
PointerMoveEvent
||
event
is
PointerHoverEvent
||
event
is
PointerDownEvent
)
{
final
PointerEvent
lastEvent
=
_lastMouseEvent
[
deviceId
];
...
...
@@ -187,7 +187,7 @@ class MouseTracker extends ChangeNotifier {
lastEvent
is
PointerAddedEvent
||
lastEvent
.
position
!=
event
.
position
)
{
// Only schedule a frame if we have our first event, or if the
// location of the mouse has changed, and only if there are tracked annotations.
sendMouseNotifications
(<
int
>{
deviceId
});
_
sendMouseNotifications
(<
int
>{
deviceId
});
}
}
}
...
...
@@ -212,17 +212,13 @@ class MouseTracker extends ChangeNotifier {
return
_trackedAnnotations
.
containsKey
(
annotation
);
}
/// Tells interested objects that a mouse has entered, exited, or moved, given
/// a callback to fetch the [MouseTrackerAnnotation] associated with a global
/// offset.
///
/// This is called from a post-frame callback when the layer tree has been
/// updated, right after rendering the frame.
///
/// This function is only public to allow for proper testing of the
/// MouseTracker. Do not call in other contexts.
@visibleForTesting
void
sendMouseNotifications
(
Iterable
<
int
>
deviceIds
)
{
// Tells interested objects that a mouse has entered, exited, or moved, given
// a callback to fetch the [MouseTrackerAnnotation] associated with a global
// offset.
//
// This is called from a post-frame callback when the layer tree has been
// updated, right after rendering the frame.
void
_sendMouseNotifications
(
Iterable
<
int
>
deviceIds
)
{
if
(
_trackedAnnotations
.
isEmpty
)
{
return
;
}
...
...
packages/flutter/test/gestures/mouse_tracking_test.dart
View file @
94515ba5
...
...
@@ -93,7 +93,6 @@ void main() {
_pointerData
(
PointerChange
.
hover
,
const
Offset
(
1.0
,
401.0
),
device:
1
),
]);
RendererBinding
.
instance
.
mouseTracker
.
attachAnnotation
(
annotation
);
RendererBinding
.
instance
.
mouseTracker
.
sendMouseNotifications
(<
int
>{
0
});
isInHitRegionOne
=
true
;
ui
.
window
.
onPointerDataPacket
(
packet1
);
expect
(
events
,
_equalToEventsOnCriticalFields
(<
PointerEvent
>[
...
...
@@ -124,11 +123,9 @@ void main() {
// add in a second mouse simultaneously.
clear
();
ui
.
window
.
onPointerDataPacket
(
packet5
);
RendererBinding
.
instance
.
mouseTracker
.
sendMouseNotifications
(<
int
>{
1
});
expect
(
events
,
_equalToEventsOnCriticalFields
(<
PointerEvent
>[
const
PointerEnterEvent
(
position:
Offset
(
1.0
,
401.0
),
device:
1
),
const
PointerHoverEvent
(
position:
Offset
(
1.0
,
401.0
),
device:
1
),
const
PointerHoverEvent
(
position:
Offset
(
1.0
,
401.0
),
device:
1
),
]));
});
...
...
@@ -142,7 +139,6 @@ void main() {
]);
isInHitRegionOne
=
true
;
RendererBinding
.
instance
.
mouseTracker
.
attachAnnotation
(
annotation
);
RendererBinding
.
instance
.
mouseTracker
.
sendMouseNotifications
(<
int
>{
0
});
ui
.
window
.
onPointerDataPacket
(
packet1
);
...
...
@@ -196,7 +192,6 @@ void main() {
]);
isInHitRegionOne
=
true
;
RendererBinding
.
instance
.
mouseTracker
.
attachAnnotation
(
annotation
);
RendererBinding
.
instance
.
mouseTracker
.
sendMouseNotifications
(<
int
>{
0
});
ui
.
window
.
onPointerDataPacket
(
packet1
);
ui
.
window
.
onPointerDataPacket
(
packet2
);
expect
(
events
,
_equalToEventsOnCriticalFields
(<
PointerEvent
>[
...
...
@@ -219,7 +214,6 @@ void main() {
]);
isInHitRegionOne
=
true
;
RendererBinding
.
instance
.
mouseTracker
.
attachAnnotation
(
annotation
);
RendererBinding
.
instance
.
mouseTracker
.
sendMouseNotifications
(<
int
>{
0
});
ui
.
window
.
onPointerDataPacket
(
packet1
);
ui
.
window
.
onPointerDataPacket
(
packet2
);
expect
(
events
,
_equalToEventsOnCriticalFields
(<
PointerEvent
>[
...
...
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