Skip to content

Conversation

@goderbauer
Copy link
Member

Follow-up to #10305

@goderbauer
Copy link
Member Author

@Hixie @abarth How's this approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

s/left/previous

Copy link
Contributor

Choose a reason for hiding this comment

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

or "earlier"

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Member Author

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!

Copy link
Contributor

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

@goderbauer goderbauer changed the title [WIP] Adds a widgets that blocks all semantics of widgets below it in paint order within the same container Adds a widgets that blocks all semantics of widgets below it in paint order within the same container Jun 1, 2017
}) : super(renderObjectOwner: renderObjectOwner, dropSemanticsOfPreviousSiblings: dropSemanticsOfPreviousSiblings);

@override
Iterable<SemanticsNode> compile({ _SemanticsGeometry geometry, SemanticsNode currentSemantics, SemanticsNode parentSemantics }) sync* {}
Copy link
Contributor

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

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

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

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

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.

Copy link
Member Author

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

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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

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

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

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

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.

Copy link
Contributor

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

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!)

@Hixie
Copy link
Contributor

Hixie commented Jun 2, 2017

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Rephrased. PTAL.

@Hixie
Copy link
Contributor

Hixie commented Jun 3, 2017

LGTM

@goderbauer goderbauer merged commit 104725f into flutter:master Jun 3, 2017
@goderbauer goderbauer deleted the blockSemantics branch June 3, 2017 01:14
@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 13, 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