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
a9e27811
Unverified
Commit
a9e27811
authored
Mar 09, 2018
by
Michael Goderbauer
Committed by
GitHub
Mar 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not do semantics for detached objects (#15320)
parent
35c43ecc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
14 deletions
+74
-14
object.dart
packages/flutter/lib/src/rendering/object.dart
+3
-1
gesture_detector.dart
packages/flutter/lib/src/widgets/gesture_detector.dart
+28
-10
object_test.dart
packages/flutter/test/rendering/object_test.dart
+12
-0
scrollable_semantics_test.dart
packages/flutter/test/widgets/scrollable_semantics_test.dart
+29
-1
semantics_tester.dart
packages/flutter/test/widgets/semantics_tester.dart
+2
-2
No files found.
packages/flutter/lib/src/rendering/object.dart
View file @
a9e27811
...
...
@@ -2222,8 +2222,10 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
/// any way to update the semantics tree.
void
markNeedsSemanticsUpdate
()
{
assert
(!
attached
||
!
owner
.
_debugDoingSemantics
);
if
(
attached
&&
owner
.
_semanticsOwner
==
null
)
if
(!
attached
||
owner
.
_semanticsOwner
==
null
)
{
_cachedSemanticsConfiguration
=
null
;
return
;
}
// Dirty the semantics tree starting at `this` until we have reached a
// RenderObject that is a semantics boundary. All semantics past this
...
...
packages/flutter/lib/src/widgets/gesture_detector.dart
View file @
a9e27811
...
...
@@ -723,24 +723,42 @@ class _GestureSemantics extends SingleChildRenderObjectWidget {
@override
RenderSemanticsGestureHandler
createRenderObject
(
BuildContext
context
)
{
final
RenderSemanticsGestureHandler
renderObject
=
new
RenderSemanticsGestureHandler
();
_updateHandlers
(
renderObject
);
return
renderObject
;
return
new
RenderSemanticsGestureHandler
(
onTap:
_onTapHandler
,
onLongPress:
_onLongPressHandler
,
onHorizontalDragUpdate:
_onHorizontalDragUpdateHandler
,
onVerticalDragUpdate:
_onVerticalDragUpdateHandler
,
);
}
void
_updateHandlers
(
RenderSemanticsGestureHandler
renderObject
)
{
final
Map
<
Type
,
GestureRecognizer
>
recognizers
=
owner
.
_recognizers
;
renderObject
..
onTap
=
recognizers
.
containsKey
(
TapGestureRecognizer
)
?
owner
.
_handleSemanticsTap
:
null
..
onLongPress
=
recognizers
.
containsKey
(
LongPressGestureRecognizer
)
?
owner
.
_handleSemanticsLongPress
:
null
..
onHorizontalDragUpdate
=
recognizers
.
containsKey
(
HorizontalDragGestureRecognizer
)
||
recognizers
.
containsKey
(
PanGestureRecognizer
)
?
owner
.
_handleSemanticsHorizontalDragUpdate
:
null
..
onVerticalDragUpdate
=
recognizers
.
containsKey
(
VerticalDragGestureRecognizer
)
||
recognizers
.
containsKey
(
PanGestureRecognizer
)
?
owner
.
_handleSemanticsVerticalDragUpdate
:
null
;
..
onTap
=
_onTapHandler
..
onLongPress
=
_onLongPressHandler
..
onHorizontalDragUpdate
=
_onHorizontalDragUpdateHandler
..
onVerticalDragUpdate
=
_onVerticalDragUpdateHandler
;
}
@override
void
updateRenderObject
(
BuildContext
context
,
RenderSemanticsGestureHandler
renderObject
)
{
_updateHandlers
(
renderObject
);
}
GestureTapCallback
get
_onTapHandler
{
return
owner
.
_recognizers
.
containsKey
(
TapGestureRecognizer
)
?
owner
.
_handleSemanticsTap
:
null
;
}
GestureTapCallback
get
_onLongPressHandler
{
return
owner
.
_recognizers
.
containsKey
(
LongPressGestureRecognizer
)
?
owner
.
_handleSemanticsLongPress
:
null
;
}
GestureDragUpdateCallback
get
_onHorizontalDragUpdateHandler
{
return
owner
.
_recognizers
.
containsKey
(
HorizontalDragGestureRecognizer
)
||
owner
.
_recognizers
.
containsKey
(
PanGestureRecognizer
)
?
owner
.
_handleSemanticsHorizontalDragUpdate
:
null
;
}
GestureDragUpdateCallback
get
_onVerticalDragUpdateHandler
{
return
owner
.
_recognizers
.
containsKey
(
VerticalDragGestureRecognizer
)
||
owner
.
_recognizers
.
containsKey
(
PanGestureRecognizer
)
?
owner
.
_handleSemanticsVerticalDragUpdate
:
null
;
}
}
packages/flutter/test/rendering/object_test.dart
View file @
a9e27811
...
...
@@ -21,6 +21,15 @@ void main() {
renderObject
.
markNeedsSemanticsUpdate
();
expect
(
onNeedVisualUpdateCallCount
,
2
);
});
test
(
'detached RenderObject does not do semantics'
,
()
{
final
TestRenderObject
renderObject
=
new
TestRenderObject
();
expect
(
renderObject
.
attached
,
isFalse
);
expect
(
renderObject
.
describeSemanticsConfigurationCallCount
,
0
);
renderObject
.
markNeedsSemanticsUpdate
();
expect
(
renderObject
.
describeSemanticsConfigurationCallCount
,
0
);
});
}
class
TestRenderObject
extends
RenderObject
{
...
...
@@ -39,10 +48,13 @@ class TestRenderObject extends RenderObject {
@override
Rect
get
semanticBounds
=>
new
Rect
.
fromLTWH
(
0.0
,
0.0
,
10.0
,
20.0
);
int
describeSemanticsConfigurationCallCount
=
0
;
@override
void
describeSemanticsConfiguration
(
SemanticsConfiguration
config
)
{
super
.
describeSemanticsConfiguration
(
config
);
config
.
isSemanticBoundary
=
true
;
describeSemanticsConfigurationCallCount
++;
}
}
packages/flutter/test/widgets/scrollable_semantics_test.dart
View file @
a9e27811
...
...
@@ -12,6 +12,10 @@ import 'semantics_tester.dart';
void
main
(
)
{
SemanticsTester
semantics
;
setUp
(()
{
debugResetSemanticsIdCounter
();
});
tearDown
(()
{
semantics
?.
dispose
();
semantics
=
null
;
...
...
@@ -327,13 +331,35 @@ void main() {
children:
new
List
<
Widget
>.
generate
(
40
,
(
int
i
)
{
return
new
Container
(
child:
new
Text
(
'item
$i
'
),
height:
40.0
,
height:
40
0
.0
,
);
}),
),
),
);
final
TestSemantics
expectedSemantics
=
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
.
rootChild
(
children:
<
TestSemantics
>[
new
TestSemantics
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
scrollUp
],
children:
<
TestSemantics
>[
new
TestSemantics
(
label:
r'item 0'
,
textDirection:
TextDirection
.
ltr
,
),
new
TestSemantics
(
label:
r'item 1'
,
textDirection:
TextDirection
.
ltr
,
),
],
),
],
),
],
);
// Start with semantics off.
expect
(
tester
.
binding
.
pipelineOwner
.
semanticsOwner
,
isNull
);
...
...
@@ -341,6 +367,7 @@ void main() {
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
binding
.
pipelineOwner
.
semanticsOwner
,
isNotNull
);
expect
(
semantics
,
hasSemantics
(
expectedSemantics
,
ignoreId:
true
,
ignoreRect:
true
,
ignoreTransform:
true
));
// Semantics off
semantics
.
dispose
();
...
...
@@ -351,6 +378,7 @@ void main() {
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
binding
.
pipelineOwner
.
semanticsOwner
,
isNotNull
);
expect
(
semantics
,
hasSemantics
(
expectedSemantics
,
ignoreId:
true
,
ignoreRect:
true
,
ignoreTransform:
true
));
});
}
...
...
packages/flutter/test/widgets/semantics_tester.dart
View file @
a9e27811
...
...
@@ -265,9 +265,9 @@ class TestSemantics {
return
fail
(
'expected node id
$id
to have hint "
$hint
" but found hint "
${nodeData.hint}
".'
);
if
(
textDirection
!=
null
&&
textDirection
!=
nodeData
.
textDirection
)
return
fail
(
'expected node id
$id
to have textDirection "
$textDirection
" but found "
${nodeData.textDirection}
".'
);
if
(
nextNodeId
!=
null
&&
nextNodeId
!=
nodeData
.
nextNodeId
)
if
(
!
ignoreId
&&
nextNodeId
!=
null
&&
nextNodeId
!=
nodeData
.
nextNodeId
)
return
fail
(
'expected node id
$id
to have nextNodeId "
$nextNodeId
" but found "
${nodeData.nextNodeId}
".'
);
if
(
previousNodeId
!=
null
&&
previousNodeId
!=
nodeData
.
previousNodeId
)
if
(
!
ignoreId
&&
previousNodeId
!=
null
&&
previousNodeId
!=
nodeData
.
previousNodeId
)
return
fail
(
'expected node id
$id
to have previousNodeId "
$previousNodeId
" but found "
${nodeData.previousNodeId}
".'
);
if
((
nodeData
.
label
!=
''
||
nodeData
.
value
!=
''
||
nodeData
.
hint
!=
''
||
node
.
increasedValue
!=
''
||
node
.
decreasedValue
!=
''
)
&&
nodeData
.
textDirection
==
null
)
return
fail
(
'expected node id
$id
, which has a label, value, or hint, to have a textDirection, but it did not.'
);
...
...
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