Unverified Commit 496ef4f7 authored by chunhtai's avatar chunhtai Committed by GitHub

prevents sliver app bar from changing semantics tree when it is not necesaary (#61012)

parent 06b301cd
...@@ -258,26 +258,9 @@ abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObje ...@@ -258,26 +258,9 @@ abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObje
} }
} }
/// Whether the [SemanticsNode]s associated with this [RenderSliver] should
/// be excluded from the semantic scrolling area.
///
/// [RenderSliver]s that stay on the screen even though the user has scrolled
/// past them (e.g. a pinned app bar) should set this to true.
@protected
bool get excludeFromSemanticsScrolling => _excludeFromSemanticsScrolling;
bool _excludeFromSemanticsScrolling = false;
set excludeFromSemanticsScrolling(bool value) {
if (_excludeFromSemanticsScrolling == value)
return;
_excludeFromSemanticsScrolling = value;
markNeedsSemanticsUpdate();
}
@override @override
void describeSemanticsConfiguration(SemanticsConfiguration config) { void describeSemanticsConfiguration(SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config); super.describeSemanticsConfiguration(config);
if (_excludeFromSemanticsScrolling)
config.addTagForChildren(RenderViewport.excludeFromScrolling); config.addTagForChildren(RenderViewport.excludeFromScrolling);
} }
...@@ -375,7 +358,6 @@ abstract class RenderSliverPinnedPersistentHeader extends RenderSliverPersistent ...@@ -375,7 +358,6 @@ abstract class RenderSliverPinnedPersistentHeader extends RenderSliverPersistent
final SliverConstraints constraints = this.constraints; final SliverConstraints constraints = this.constraints;
final double maxExtent = this.maxExtent; final double maxExtent = this.maxExtent;
final bool overlapsContent = constraints.overlap > 0.0; final bool overlapsContent = constraints.overlap > 0.0;
excludeFromSemanticsScrolling = overlapsContent || (constraints.scrollOffset > maxExtent - minExtent);
layoutChild(constraints.scrollOffset, maxExtent, overlapsContent: overlapsContent); layoutChild(constraints.scrollOffset, maxExtent, overlapsContent: overlapsContent);
final double effectiveRemainingPaintExtent = math.max(0, constraints.remainingPaintExtent - constraints.overlap); final double effectiveRemainingPaintExtent = math.max(0, constraints.remainingPaintExtent - constraints.overlap);
final double layoutExtent = (maxExtent - constraints.scrollOffset).clamp(0.0, effectiveRemainingPaintExtent) as double; final double layoutExtent = (maxExtent - constraints.scrollOffset).clamp(0.0, effectiveRemainingPaintExtent) as double;
...@@ -575,7 +557,6 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste ...@@ -575,7 +557,6 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste
} else { } else {
_effectiveScrollOffset = constraints.scrollOffset; _effectiveScrollOffset = constraints.scrollOffset;
} }
excludeFromSemanticsScrolling = _effectiveScrollOffset <= constraints.scrollOffset;
final bool overlapsContent = _effectiveScrollOffset < constraints.scrollOffset; final bool overlapsContent = _effectiveScrollOffset < constraints.scrollOffset;
layoutChild( layoutChild(
......
...@@ -1645,9 +1645,6 @@ void main() { ...@@ -1645,9 +1645,6 @@ void main() {
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
children: <TestSemantics>[ children: <TestSemantics>[
...@@ -1661,7 +1658,8 @@ void main() { ...@@ -1661,7 +1658,8 @@ void main() {
), ),
], ],
), ),
], TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
), ),
], ],
), ),
......
...@@ -78,13 +78,6 @@ void _tests() { ...@@ -78,13 +78,6 @@ void _tests() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
children: <TestSemantics>[
TestSemantics(
id: 9,
flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling,
],
actions: <SemanticsAction>[SemanticsAction.scrollUp],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 7, id: 7,
...@@ -100,6 +93,13 @@ void _tests() { ...@@ -100,6 +93,13 @@ void _tests() {
), ),
], ],
), ),
TestSemantics(
id: 9,
flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling,
],
actions: <SemanticsAction>[SemanticsAction.scrollUp],
children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
label: 'Item 0', label: 'Item 0',
...@@ -225,16 +225,6 @@ void _tests() { ...@@ -225,16 +225,6 @@ void _tests() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
children: <TestSemantics>[
TestSemantics(
id: 9,
flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling,
],
actions: <SemanticsAction>[
SemanticsAction.scrollUp,
SemanticsAction.scrollDown,
],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 7, id: 7,
...@@ -250,6 +240,16 @@ void _tests() { ...@@ -250,6 +240,16 @@ void _tests() {
), ),
], ],
), ),
TestSemantics(
id: 9,
flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling,
],
actions: <SemanticsAction>[
SemanticsAction.scrollUp,
SemanticsAction.scrollDown,
],
children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
label: 'Item 0', label: 'Item 0',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment