Skip to content

Conversation

@goderbauer
Copy link
Member

In this PR:

  • OverlayEntries can be a semantic barriers meaning that everything below that entry is no longer included in the semantics tree (used for e.g. Dialogs).
  • When the Drawer in a Scaffold is open all elements outside of the drawer are no longer part of the semantics tree.
  • A new includesNodeWithLabel matcher for tests.

@goderbauer goderbauer requested a review from Hixie May 24, 2017 23:52
///
/// Gets called whenever the drawer's state switches from open to closed or
/// vice versa.
final VoidCallback onStateChanged;
Copy link
Contributor

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}) {
Copy link
Contributor

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.
Copy link
Contributor

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,
Copy link
Contributor

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) {
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.i. -> i.e.

Copy link
Contributor

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.
Copy link
Contributor

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);
Copy link
Contributor

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.
Copy link
Contributor

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?
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@Hixie
Copy link
Contributor

Hixie commented May 25, 2017

This is fantastic.

@Hixie
Copy link
Contributor

Hixie commented May 25, 2017

LGTM

@goderbauer
Copy link
Member Author

This patch introducesExcludeSemantics widgets between Stack and its children (which can be ParentDataWidgets). This causes asserts to be thrown (see https://travis-ci.org/flutter/flutter/jobs/235859177#L549).

@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(
Copy link
Contributor

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.

@abarth
Copy link
Contributor

abarth commented May 25, 2017

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.

@Hixie
Copy link
Contributor

Hixie commented May 25, 2017

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.

@Hixie
Copy link
Contributor

Hixie commented May 26, 2017

@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.)

@Hixie Hixie closed this May 26, 2017
@goderbauer goderbauer deleted the excludeSematnics branch September 25, 2017 22:19
@goderbauer goderbauer added the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Oct 17, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants