-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Remove inactive elements from the semantic tree #10305
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
| /// | ||
| /// Gets called whenever the drawer's state switches from open to closed or | ||
| /// vice versa. | ||
| final VoidCallback onStateChanged; |
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 make this a ValueChanged<bool> callback and pass the value of isClosed?
| } | ||
|
|
||
| void _addIfNonNull(List<LayoutId> children, Widget child, Object childId) { | ||
| void _addChild(List<LayoutId> children, Widget child, Object childId, {bool excludeSemantics: 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.
nit: spaces around the named arguments
| new DrawerController( | ||
| key: _drawerKey, | ||
| onStateChanged: () { | ||
| // Rebuild Scaffold when drawer opens/closes to update semantics tree. |
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 would be slightly clearer if there was a local member field _drawerOpen which you used to determine the exclude semantics logic, and you just set it here inside the setState. it would avoid the empty callback.
if you prefer the current setup, then put this comment inside the setState callback's body.
| RenderExcludeSemantics({ RenderBox child }) : super(child); | ||
| RenderExcludeSemantics({ | ||
| RenderBox child, | ||
| bool excluding : true, |
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: extraneous space before colon
|
|
||
| @override | ||
| void visitChildrenForSemantics(RenderObjectVisitor visitor) { | ||
| if (excluding) { |
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: no braces
| }) : assert(excluding != null), | ||
| super(key: key, child: child); | ||
|
|
||
| /// Whether this widget is included in the semantics tree. |
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.
excluded, presumably
| /// call [State.setState], the user's battery will be drained unnecessarily. | ||
| /// | ||
| /// If this entry is declared to be a [semanticsBarrier], then entries below | ||
| /// this one will not be included in the semantic tree, e.i. those entries will |
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.
e.i. -> i.e.
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 actually, just "e.g." because it means other things too
| /// | ||
| /// If this entry is declared to be a [semanticsBarrier], then entries below | ||
| /// this one will not be included in the semantic tree, e.i. those entries will | ||
| /// be unreachable via accessibility means. |
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.
"via accessibility means" -> "to accessibility tools" or "via accessibility user agents" or some such.
| }) : _opaque = opaque, _maintainState = maintainState, _semanticsBarrier = semanticsBarrier { | ||
| assert(builder != null); | ||
| assert(opaque != null); | ||
| assert(maintainState != null); |
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.
assert
| /// Whether this entry is a semantics barrier for the entries below it. | ||
| /// | ||
| /// If `true`, entries below this entry will not be included in the semantic | ||
| /// tree. That means they are not reachable via accessibility means. |
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.
same comment here. "This means, for example, that they are not reachable using accessibility tools."
| return; | ||
| _semanticsBarrier = value; | ||
| assert(_overlay != null); | ||
| _overlay._didChangeEntryOpacity(); // TODO(goderbauer): rename? |
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.
yes, rename. :-)
| @override | ||
| Iterable<OverlayEntry> createOverlayEntries() sync* { | ||
| yield new OverlayEntry(builder: _buildModalBarrier); | ||
| yield new OverlayEntry(builder: _buildModalBarrier, semanticsBarrier: true); |
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.
looking at this it's sad that we can't have the modal barrier itself somehow occlude all the semantics below it rather than having it done in the overlay. but i don't see how we could sanely do that.
| } | ||
|
|
||
| /// Asserts that a node in the semantics tree of [SemanticsTester] has [label]. | ||
| Matcher includesNodeWithLabel(String label) => new _IncludesNodeWithLabel(label); |
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.
nice
|
This is fantastic. |
|
This patch introduces @abarth Do you have an idea for a clean solution to fix this? Hixie and I were out of ideas today. |
| final OverlayEntry entry = _entries[i]; | ||
| if (onstage) { | ||
| onstageChildren.add(new _OverlayEntry(entry)); | ||
| onstageChildren.add(new ExcludeSemantics( |
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 isn't going to work because part of the contract Overlay has with its entries is that they'll be contained in a Stack.
|
I'd try a different approach. Currently, we have RenderExcludeSemantics, which hides a subtree of render tree from the semantics compiler. I'd try adding a RenderSemanticsBarrier that prevents the semantics compiler from seeing anything before it in paint order. I'd then teach ModalBarrier to build a SemanticsBarrier. Essentially, you're trying to use a tree-order primitive to do a paint-order job. Instead, you might have more success if you invent a paint-order primitive to do a paint-order job. |
|
Yeah, that was the other approach we talked about, though we had dismissed it as impractical. Speaking with Adam this morning, Adam convinced me that we should take a look at that again. It certainly would be more idiomatic and would more closely match what we're really doing. |
|
@goderbauer I'm going to close this PR since we've concluded this approach isn't going to work. I hope that's ok. (I'm going through open PRs tidying things up.) |
In this PR:
includesNodeWithLabelmatcher for tests.