-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Adds a widgets that blocks all semantics of widgets below it in paint order within the same container #10425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/left/previous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or "earlier"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also maybe s/siblings/nodes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually its a better pattern to call a method on this rather than testing this against a specific subclass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we don't want to do it this way, because it would prevent you from applying the same logic to e.g. RenderSector or RenderSliver subclasses. This should be something that any class can do. Maybe something you call on the SemanticsNode in your annotator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this to use the same mechanism we use for isSemanticBoundary. No more testing this against a specific subclass and no more cyclic imports!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import creates a circular dependency. Although Dart can cope with circular dependencies, we avoid them because they tend to indicate a design flaw (e.g., the test against a specific subclass below).
52755cd to
838f5b7
Compare
| }) : super(renderObjectOwner: renderObjectOwner, dropSemanticsOfPreviousSiblings: dropSemanticsOfPreviousSiblings); | ||
|
|
||
| @override | ||
| Iterable<SemanticsNode> compile({ _SemanticsGeometry geometry, SemanticsNode currentSemantics, SemanticsNode parentSemantics }) sync* {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: { } for empty code blocks; {} for empty maps
| class _EmptySemanticsFragment extends _SemanticsFragment { | ||
| _EmptySemanticsFragment({ | ||
| @required RenderObject renderObjectOwner, | ||
| bool dropSemanticsOfPreviousSiblings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: trailing comma
| /// | ||
| /// If `true` is returned, the [SemanticsNode]s for all siblings and cousins | ||
| /// of this node, that were painted before this node, are dropped from the | ||
| /// semantics tree up until a semantic boundary is reached. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"earlier in a depth-first pre-order traversal"
| bool get isSemanticBoundary => false; | ||
|
|
||
| /// Whether this [RenderObject] makes other [RenderObject]s previously painted | ||
| /// in the same semantics container unreachable for accessibility purposes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semantics container should reference isSemanticsBoundary.
...and probably be phrased in terms of semantics boundaries rather than containers.
| /// | ||
| /// Paint order as established by [visitChildrenForSemantics] is used to | ||
| /// determine if a node is previous to this one. | ||
| bool get isBlockingSemanticsOfPreviouslyPaintedNodes => false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should define how it interacts when set on a node that is also a boundary.
I suspect the best behaviour is that it acts on the "outside" of the boundary, but I'm not sure that's what the code currently does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added documentation and changed the code to match that behavior.
| }); | ||
| if (isSemanticBoundary) { | ||
| // Don't propagate [dropSemanticsOfPreviousSiblings] past a semantic boundary. | ||
| dropSemanticsOfPreviousSiblings = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't understand this block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point when we walk up the tree we need to stop dropping children. The semantic boundary is that point where we stop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this is about propagating up. I somehow was confused and thought it was propagating down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add the word "up" to the description.
| description.add('layer: $_layer'); | ||
| if (_semantics != null) | ||
| description.add('semantics: $_semantics'); | ||
| description.add('isSemanticBoundary: $isSemanticBoundary'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than always including this (which will make the output verbose and repetitive), I would have:
if (isBlockingSemanticsOfPreviouslyPaintedNodes)
description.add('blocks semantics of earlier render objects below the common boundary');
if (isSemanticBoundary)
description.add('semantic boundary');|
|
||
| /// A widget that drops the semantics of all widget that were painted before it | ||
| /// in the same semantic container. | ||
| /// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add some more depth to this specific documentation, e.g. giving an example of where you'd use this
| /// See also: | ||
| /// | ||
| /// * [BlockSemantics] which drops semantics of previously painted sibling and | ||
| /// cousin widgets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/previously painted sibling and cousin widgets/widgets earlier in the tree/.
| @@ -0,0 +1,99 @@ | |||
| // Copyright 2017 The Chromium Authors. All rights reserved. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe rename basic_test to semantics_9_test?
| // Copyright 2016 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need a test of what happens if a render object is both a semantics boundary and has the new flag set.
| /// * [ExcludeSemantics] which drops all semantics of its descendants. | ||
| class BlockSemantics extends SingleChildRenderObjectWidget { | ||
| /// Creates a widget that excludes the semantics of all widgets painted before | ||
| /// it in the same semantic container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but leave this one the same, so that the reader can see different ways to describe this same behaviour and hopefully understand one of them!)
|
This seems pretty solid. Just some minor notes. |
| /// | ||
| /// If [isSemanticBoundary] and [isBlockingSemanticsOfPreviouslyPaintedNodes] | ||
| /// is set on the same node, all previously painted siblings and cousins | ||
| /// up until the next semantic boundary are dropped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph seems a bit ambiguous. What is the "next semantic boundary"? We're walking a multibranched tree in multiple directions...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rephrased. PTAL.
95b8396 to
1b09e61
Compare
Follow-up to #10305