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
d2af1345
Unverified
Commit
d2af1345
authored
Nov 30, 2022
by
Casey Hillers
Committed by
GitHub
Nov 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix `Slider` semantic node size (#115285)" (#116294)
This reverts commit
8473da22
.
parent
29422d25
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
504 additions
and
233 deletions
+504
-233
slider.dart
packages/flutter/lib/src/material/slider.dart
+57
-75
slider_test.dart
packages/flutter/test/material/slider_test.dart
+442
-153
semantics_debugger_test.dart
packages/flutter/test/widgets/semantics_debugger_test.dart
+2
-2
controller_test.dart
packages/flutter_test/test/controller_test.dart
+3
-3
No files found.
packages/flutter/lib/src/material/slider.dart
View file @
d2af1345
...
...
@@ -821,11 +821,22 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
// in range_slider.dart.
Size
screenSize
()
=>
MediaQuery
.
of
(
context
).
size
;
void
handleDidGainAccessibilityFocus
()
{
VoidCallback
?
handleDidGainAccessibilityFocus
;
switch
(
theme
.
platform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
break
;
case
TargetPlatform
.
windows
:
handleDidGainAccessibilityFocus
=
()
{
// Automatically activate the slider when it receives a11y focus.
if
(!
focusNode
.
hasFocus
&&
focusNode
.
canRequestFocus
)
{
focusNode
.
requestFocus
();
}
};
break
;
}
final
Map
<
ShortcutActivator
,
Intent
>
shortcutMap
;
...
...
@@ -846,7 +857,11 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
?
math
.
min
(
MediaQuery
.
of
(
context
).
textScaleFactor
,
1.3
)
:
MediaQuery
.
of
(
context
).
textScaleFactor
;
return
FocusableActionDetector
(
return
Semantics
(
container:
true
,
slider:
true
,
onDidGainAccessibilityFocus:
handleDidGainAccessibilityFocus
,
child:
FocusableActionDetector
(
actions:
_actionMap
,
shortcuts:
shortcutMap
,
focusNode:
focusNode
,
...
...
@@ -855,7 +870,6 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
onShowFocusHighlight:
_handleFocusHighlightChanged
,
onShowHoverHighlight:
_handleHoverChanged
,
mouseCursor:
effectiveMouseCursor
,
includeFocusSemantics:
false
,
child:
CompositedTransformTarget
(
link:
_layerLink
,
child:
_SliderRenderObjectWidget
(
...
...
@@ -872,11 +886,11 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
onChangeEnd:
_handleDragEnd
,
state:
this
,
semanticFormatterCallback:
widget
.
semanticFormatterCallback
,
onDidGainAccessibilityFocus:
handleDidGainAccessibilityFocus
,
hasFocus:
_focused
,
hovering:
_hovering
,
),
),
),
);
}
...
...
@@ -935,7 +949,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
required
this
.
onChangeEnd
,
required
this
.
state
,
required
this
.
semanticFormatterCallback
,
required
this
.
onDidGainAccessibilityFocus
,
required
this
.
hasFocus
,
required
this
.
hovering
,
});
...
...
@@ -951,7 +964,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
final
ValueChanged
<
double
>?
onChangeStart
;
final
ValueChanged
<
double
>?
onChangeEnd
;
final
SemanticFormatterCallback
?
semanticFormatterCallback
;
final
VoidCallback
?
onDidGainAccessibilityFocus
;
final
_SliderState
state
;
final
bool
hasFocus
;
final
bool
hovering
;
...
...
@@ -972,7 +984,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
state:
state
,
textDirection:
Directionality
.
of
(
context
),
semanticFormatterCallback:
semanticFormatterCallback
,
onDidGainAccessibilityFocus:
onDidGainAccessibilityFocus
,
platform:
Theme
.
of
(
context
).
platform
,
hasFocus:
hasFocus
,
hovering:
hovering
,
...
...
@@ -997,7 +1008,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
..
onChangeEnd
=
onChangeEnd
..
textDirection
=
Directionality
.
of
(
context
)
..
semanticFormatterCallback
=
semanticFormatterCallback
..
onDidGainAccessibilityFocus
=
onDidGainAccessibilityFocus
..
platform
=
Theme
.
of
(
context
).
platform
..
hasFocus
=
hasFocus
..
hovering
=
hovering
...
...
@@ -1019,7 +1029,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
required
TargetPlatform
platform
,
required
ValueChanged
<
double
>?
onChanged
,
required
SemanticFormatterCallback
?
semanticFormatterCallback
,
required
this
.
onDidGainAccessibilityFocus
,
required
this
.
onChangeStart
,
required
this
.
onChangeEnd
,
required
_SliderState
state
,
...
...
@@ -1105,7 +1114,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
bool
_active
=
false
;
double
_currentDragValue
=
0.0
;
Rect
?
overlayRect
;
late
Offset
_thumbCenter
;
// This rect is used in gesture calculations, where the gesture coordinates
// are relative to the sliders origin. Therefore, the offset is passed as
...
...
@@ -1251,7 +1259,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
}
}
VoidCallback
?
onDidGainAccessibilityFocus
;
ValueChanged
<
double
>?
onChangeStart
;
ValueChanged
<
double
>?
onChangeEnd
;
...
...
@@ -1575,10 +1582,10 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
sliderTheme:
_sliderTheme
,
isDiscrete:
isDiscrete
,
);
_
thumbCenter
=
Offset
(
trackRect
.
left
+
visualPosition
*
trackRect
.
width
,
trackRect
.
center
.
dy
);
final
Offset
thumbCenter
=
Offset
(
trackRect
.
left
+
visualPosition
*
trackRect
.
width
,
trackRect
.
center
.
dy
);
if
(
isInteractive
)
{
final
Size
overlaySize
=
sliderTheme
.
overlayShape
!.
getPreferredSize
(
isInteractive
,
false
);
overlayRect
=
Rect
.
fromCircle
(
center:
_
thumbCenter
,
radius:
overlaySize
.
width
/
2.0
);
overlayRect
=
Rect
.
fromCircle
(
center:
thumbCenter
,
radius:
overlaySize
.
width
/
2.0
);
}
final
Offset
?
secondaryOffset
=
(
secondaryVisualPosition
!=
null
)
?
Offset
(
trackRect
.
left
+
secondaryVisualPosition
*
trackRect
.
width
,
trackRect
.
center
.
dy
)
:
null
;
...
...
@@ -1589,7 +1596,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
sliderTheme:
_sliderTheme
,
enableAnimation:
_enableAnimation
,
textDirection:
_textDirection
,
thumbCenter:
_
thumbCenter
,
thumbCenter:
thumbCenter
,
secondaryOffset:
secondaryOffset
,
isDiscrete:
isDiscrete
,
isEnabled:
isInteractive
,
...
...
@@ -1598,7 +1605,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
if
(!
_overlayAnimation
.
isDismissed
)
{
_sliderTheme
.
overlayShape
!.
paint
(
context
,
_
thumbCenter
,
thumbCenter
,
activationAnimation:
_overlayAnimation
,
enableAnimation:
_enableAnimation
,
isDiscrete:
isDiscrete
,
...
...
@@ -1635,7 +1642,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
sliderTheme:
_sliderTheme
,
enableAnimation:
_enableAnimation
,
textDirection:
_textDirection
,
thumbCenter:
_
thumbCenter
,
thumbCenter:
thumbCenter
,
isEnabled:
isInteractive
,
);
}
...
...
@@ -1648,7 +1655,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
if
(
attached
)
{
_sliderTheme
.
valueIndicatorShape
!.
paint
(
context
,
offset
+
_
thumbCenter
,
offset
+
thumbCenter
,
activationAnimation:
_valueIndicatorAnimation
,
enableAnimation:
_enableAnimation
,
isDiscrete:
isDiscrete
,
...
...
@@ -1667,7 +1674,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
_sliderTheme
.
thumbShape
!.
paint
(
context
,
_
thumbCenter
,
thumbCenter
,
activationAnimation:
_overlayAnimation
,
enableAnimation:
_enableAnimation
,
isDiscrete:
isDiscrete
,
...
...
@@ -1681,23 +1688,12 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
);
}
@override
void
assembleSemanticsNode
(
SemanticsNode
node
,
SemanticsConfiguration
config
,
Iterable
<
SemanticsNode
>
children
)
{
node
.
rect
=
Rect
.
fromCenter
(
center:
_thumbCenter
,
width:
kMinInteractiveDimension
,
height:
kMinInteractiveDimension
,
);
node
.
updateWith
(
config:
config
);
}
@override
void
describeSemanticsConfiguration
(
SemanticsConfiguration
config
)
{
super
.
describeSemanticsConfiguration
(
config
);
// The Slider widget has its own Focus widget with semantics information,
// and want that semantics node to collect the semantics information here
// and w
e w
ant that semantics node to collect the semantics information here
// so that it's all in the same node: otherwise Talkback sees that the node
// has focusable children, and it won't focus the Slider's Focus widget
// because it thinks the Focus widget's node doesn't have anything to say
...
...
@@ -1705,23 +1701,9 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
// information into one node means that Talkback will recognize that it has
// something to say and focus it when it receives keyboard focus.
// (See https://github.com/flutter/flutter/issues/57038 for context).
config
.
isSemanticBoundary
=
tru
e
;
config
.
isSemanticBoundary
=
fals
e
;
config
.
isEnabled
=
isInteractive
;
config
.
isSlider
=
true
;
config
.
isFocusable
=
isInteractive
;
config
.
isFocused
=
hasFocus
;
switch
(
_platform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
break
;
case
TargetPlatform
.
windows
:
config
.
onDidGainAccessibilityFocus
=
onDidGainAccessibilityFocus
;
break
;
}
config
.
textDirection
=
textDirection
;
if
(
isInteractive
)
{
config
.
onIncrease
=
increaseAction
;
...
...
packages/flutter/test/material/slider_test.dart
View file @
d2af1345
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/semantics_debugger_test.dart
View file @
d2af1345
...
...
@@ -290,7 +290,7 @@ void main() {
});
testWidgets
(
'SemanticsDebugger slider'
,
(
WidgetTester
tester
)
async
{
double
value
=
0.
50
;
double
value
=
0.
75
;
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -322,7 +322,7 @@ void main() {
// interpreted as a gesture by the semantics debugger and sent to the widget
// as a semantic action that always moves by 10% of the complete track.
await
tester
.
fling
(
find
.
byType
(
Slider
),
const
Offset
(-
100.0
,
0.0
),
2000.0
,
warnIfMissed:
false
);
// hitting the debugger
expect
(
value
,
equals
(
0.
45
));
expect
(
value
,
equals
(
0.
70
));
});
testWidgets
(
'SemanticsDebugger checkbox'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter_test/test/controller_test.dart
View file @
d2af1345
...
...
@@ -865,7 +865,7 @@ void main() {
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
_SemanticsTestWidget
()));
// We're expecting the traversal to start where the slider is.
final
List
<
Matcher
>
expectedMatchers
=
<
Matcher
>[...
fullTraversalMatchers
]..
removeRange
(
0
,
7
);
final
List
<
Matcher
>
expectedMatchers
=
<
Matcher
>[...
fullTraversalMatchers
]..
removeRange
(
0
,
8
);
expect
(
tester
.
semantics
.
simulatedAccessibilityTraversal
(
start:
find
.
byType
(
Slider
)),
...
...
@@ -887,7 +887,7 @@ void main() {
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
_SemanticsTestWidget
()));
// We're expecting the traversal to end where the slider is, inclusive.
final
Iterable
<
Matcher
>
expectedMatchers
=
<
Matcher
>[...
fullTraversalMatchers
].
getRange
(
0
,
8
);
final
Iterable
<
Matcher
>
expectedMatchers
=
<
Matcher
>[...
fullTraversalMatchers
].
getRange
(
0
,
9
);
expect
(
tester
.
semantics
.
simulatedAccessibilityTraversal
(
end:
find
.
byType
(
Slider
)),
...
...
@@ -909,7 +909,7 @@ void main() {
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
_SemanticsTestWidget
()));
// We're expecting the traversal to start at the text field and end at the slider.
final
Iterable
<
Matcher
>
expectedMatchers
=
<
Matcher
>[...
fullTraversalMatchers
].
getRange
(
1
,
8
);
final
Iterable
<
Matcher
>
expectedMatchers
=
<
Matcher
>[...
fullTraversalMatchers
].
getRange
(
1
,
9
);
expect
(
tester
.
semantics
.
simulatedAccessibilityTraversal
(
...
...
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