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
f73c358e
Unverified
Commit
f73c358e
authored
Mar 10, 2023
by
Michael Goderbauer
Committed by
GitHub
Mar 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce the PipelineOwner tree (#122231)
Introduce the PipelineOwner tree
parent
b4019f98
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1341 additions
and
34 deletions
+1341
-34
binding.dart
packages/flutter/lib/src/rendering/binding.dart
+26
-14
object.dart
packages/flutter/lib/src/rendering/object.dart
+239
-19
binding_pipeline_manifold_init_test.dart
...r/test/rendering/binding_pipeline_manifold_init_test.dart
+25
-0
binding_pipeline_manifold_test.dart
...lutter/test/rendering/binding_pipeline_manifold_test.dart
+98
-0
pipeline_owner_tree_test.dart
...ages/flutter/test/rendering/pipeline_owner_tree_test.dart
+952
-0
widget_tester.dart
packages/flutter_test/lib/src/widget_tester.dart
+1
-1
No files found.
packages/flutter/lib/src/rendering/binding.dart
View file @
f73c358e
...
...
@@ -30,7 +30,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
super
.
initInstances
();
_instance
=
this
;
_pipelineOwner
=
PipelineOwner
(
onNeedVisualUpdate:
ensureVisualUpdate
,
onSemanticsOwnerCreated:
_handleSemanticsOwnerCreated
,
onSemanticsUpdate:
_handleSemanticsUpdate
,
onSemanticsOwnerDisposed:
_handleSemanticsOwnerDisposed
,
...
...
@@ -45,8 +44,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
if
(
kIsWeb
)
{
addPostFrameCallback
(
_handleWebFirstFrame
);
}
addSemanticsEnabledListener
(
_handleSemanticsEnabledChanged
);
_handleSemanticsEnabledChanged
();
_pipelineOwner
.
attach
(
_manifold
);
}
/// The current [RendererBinding], if one has been created.
...
...
@@ -201,6 +199,8 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
}
}
late
final
PipelineManifold
_manifold
=
_BindingPipelineManifold
(
this
);
/// Creates a [RenderView] object to be the root of the
/// [RenderObject] rendering tree, and initializes it so that it
/// will be rendered when the next frame is requested.
...
...
@@ -330,17 +330,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
super
.
dispatchEvent
(
event
,
hitTestResult
);
}
SemanticsHandle
?
_semanticsHandle
;
void
_handleSemanticsEnabledChanged
()
{
if
(
semanticsEnabled
)
{
_semanticsHandle
??=
_pipelineOwner
.
ensureSemantics
();
}
else
{
_semanticsHandle
?.
dispose
();
_semanticsHandle
=
null
;
}
}
@override
void
performSemanticsAction
(
SemanticsActionEvent
action
)
{
_pipelineOwner
.
semanticsOwner
?.
performAction
(
action
.
nodeId
,
action
.
type
,
action
.
arguments
);
...
...
@@ -621,3 +610,26 @@ class RenderingFlutterBinding extends BindingBase with GestureBinding, Scheduler
return
RendererBinding
.
instance
;
}
}
/// A [PipelineManifold] implementation that is backed by the [RendererBinding].
class
_BindingPipelineManifold
extends
ChangeNotifier
implements
PipelineManifold
{
_BindingPipelineManifold
(
this
.
_binding
)
{
_binding
.
addSemanticsEnabledListener
(
notifyListeners
);
}
final
RendererBinding
_binding
;
@override
void
requestVisualUpdate
()
{
_binding
.
ensureVisualUpdate
();
}
@override
bool
get
semanticsEnabled
=>
_binding
.
semanticsEnabled
;
@override
void
dispose
()
{
_binding
.
removeSemanticsEnabledListener
(
notifyListeners
);
super
.
dispose
();
}
}
packages/flutter/lib/src/rendering/object.dart
View file @
f73c358e
This diff is collapsed.
Click to expand it.
packages/flutter/test/rendering/binding_pipeline_manifold_init_test.dart
0 → 100644
View file @
f73c358e
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'Initializing the RendererBinding does not crash when semantics is enabled'
,
()
{
try
{
MyRenderingFlutterBinding
();
}
catch
(
e
)
{
fail
(
'Initializing the RenderingBinding threw an unexpected error:
\n
$e
'
);
}
expect
(
RendererBinding
.
instance
,
isA
<
MyRenderingFlutterBinding
>());
expect
(
SemanticsBinding
.
instance
.
semanticsEnabled
,
isTrue
);
});
}
// Binding that pretends the platform had semantics enabled before the binding
// is initialized.
class
MyRenderingFlutterBinding
extends
RenderingFlutterBinding
{
@override
bool
get
semanticsEnabled
=>
true
;
}
packages/flutter/test/rendering/binding_pipeline_manifold_test.dart
0 → 100644
View file @
f73c358e
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'rendering_tester.dart'
;
void
main
(
)
{
MyTestRenderingFlutterBinding
.
ensureInitialized
();
tearDown
(()
{
final
List
<
PipelineOwner
>
children
=
<
PipelineOwner
>[];
RendererBinding
.
instance
.
pipelineOwner
.
visitChildren
((
PipelineOwner
child
)
{
children
.
add
(
child
);
});
children
.
forEach
(
RendererBinding
.
instance
.
pipelineOwner
.
dropChild
);
});
test
(
"BindingPipelineManifold notifies binding if render object managed by binding's PipelineOwner tree needs visual update"
,
()
{
final
PipelineOwner
child
=
PipelineOwner
();
RendererBinding
.
instance
.
pipelineOwner
.
adoptChild
(
child
);
final
RenderObject
renderObject
=
TestRenderObject
();
child
.
rootNode
=
renderObject
;
renderObject
.
scheduleInitialLayout
();
RendererBinding
.
instance
.
pipelineOwner
.
flushLayout
();
MyTestRenderingFlutterBinding
.
instance
.
ensureVisualUpdateCount
=
0
;
renderObject
.
markNeedsLayout
();
expect
(
MyTestRenderingFlutterBinding
.
instance
.
ensureVisualUpdateCount
,
1
);
});
test
(
'Turning global semantics on/off creates semantics owners in PipelineOwner tree'
,
()
{
final
PipelineOwner
child
=
PipelineOwner
(
onSemanticsUpdate:
(
_
)
{
},
);
RendererBinding
.
instance
.
pipelineOwner
.
adoptChild
(
child
);
expect
(
child
.
semanticsOwner
,
isNull
);
expect
(
RendererBinding
.
instance
.
pipelineOwner
.
semanticsOwner
,
isNull
);
final
SemanticsHandle
handle
=
SemanticsBinding
.
instance
.
ensureSemantics
();
expect
(
child
.
semanticsOwner
,
isNotNull
);
expect
(
RendererBinding
.
instance
.
pipelineOwner
.
semanticsOwner
,
isNotNull
);
handle
.
dispose
();
expect
(
child
.
semanticsOwner
,
isNull
);
expect
(
RendererBinding
.
instance
.
pipelineOwner
.
semanticsOwner
,
isNull
);
});
}
class
MyTestRenderingFlutterBinding
extends
TestRenderingFlutterBinding
{
static
MyTestRenderingFlutterBinding
get
instance
=>
BindingBase
.
checkInstance
(
_instance
);
static
MyTestRenderingFlutterBinding
?
_instance
;
static
MyTestRenderingFlutterBinding
ensureInitialized
()
{
if
(
_instance
!=
null
)
{
return
_instance
!;
}
return
MyTestRenderingFlutterBinding
();
}
@override
void
initInstances
()
{
super
.
initInstances
();
_instance
=
this
;
}
int
ensureVisualUpdateCount
=
0
;
@override
void
ensureVisualUpdate
()
{
super
.
ensureVisualUpdate
();
ensureVisualUpdateCount
++;
}
}
class
TestRenderObject
extends
RenderObject
{
@override
void
debugAssertDoesMeetConstraints
()
{
}
@override
Rect
get
paintBounds
=>
Rect
.
zero
;
@override
void
performLayout
()
{
}
@override
void
performResize
()
{
}
@override
Rect
get
semanticBounds
=>
Rect
.
zero
;
}
packages/flutter/test/rendering/pipeline_owner_tree_test.dart
0 → 100644
View file @
f73c358e
This diff is collapsed.
Click to expand it.
packages/flutter_test/lib/src/widget_tester.dart
View file @
f73c358e
...
...
@@ -1045,7 +1045,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
void
_verifySemanticsHandlesWereDisposed
()
{
assert
(
_lastRecordedSemanticsHandles
!=
null
);
// TODO(goderbauer): Fix known leak in web engine when running integration tests and remove this "correction", https://github.com/flutter/flutter/issues/121640.
final
int
knownWebEngineLeakForLiveTestsCorrection
=
kIsWeb
&&
binding
is
LiveTestWidgetsFlutterBinding
?
2
:
0
;
final
int
knownWebEngineLeakForLiveTestsCorrection
=
kIsWeb
&&
binding
is
LiveTestWidgetsFlutterBinding
?
1
:
0
;
if
(
_currentSemanticsHandles
-
knownWebEngineLeakForLiveTestsCorrection
>
_lastRecordedSemanticsHandles
!)
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
...
...
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