Skip to content
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

Remove remaining uses of childToSlot #64273

Merged
merged 1 commit into from Aug 21, 2020
Merged

Conversation

tvolkert
Copy link
Contributor

Description

The remaining uses of this pattern were all due to wanting to have
the child's slot when Element.forgetChild() was called. However,
when that method is called, the child's slot value is still valid
in the context of the parent, so the uses can just use child.slot.

Related Issues

This is the final round of cleanup from the fallout of #63269

Tests

Test exemption: this PR just removes code (and renames a few variables) - the existing tests passing validates the change.

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read [Handling breaking changes].

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.

@flutter-dashboard flutter-dashboard bot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Aug 20, 2020
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@tvolkert
Copy link
Contributor Author

Adding @goderbauer for context of the change (since he reviewed the earlier changes)

Adding @HansMuller and @justinmc for the specific Material changes.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -747,8 +747,7 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
) : super(widget);

List<Element> _children;
final Map<_CupertinoTextSelectionToolbarItemsSlot, Element> slotToChild = <_CupertinoTextSelectionToolbarItemsSlot, Element>{};
final Map<Element, _CupertinoTextSelectionToolbarItemsSlot> childToSlot = <Element, _CupertinoTextSelectionToolbarItemsSlot>{};
final Map<_CupertinoTextSelectionToolbarItemsSlot, Element> slottedChildren = <_CupertinoTextSelectionToolbarItemsSlot, Element>{};
Copy link
Contributor

Choose a reason for hiding this comment

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

This name sounds like a list rather than a map (slotToChild sounds like a map)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update it back.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM modulo (my humble opinion) renaming the slotToChild properties.

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM, just a naming question 👍

@@ -2066,8 +2066,7 @@ enum _ChipSlot {
class _RenderChipElement extends RenderObjectElement {
_RenderChipElement(_ChipRenderWidget chip) : super(chip);

final Map<_ChipSlot, Element> slotToChild = <_ChipSlot, Element>{};
final Map<Element, _ChipSlot> childToSlot = <Element, _ChipSlot>{};
final Map<_ChipSlot, Element> children = <_ChipSlot, Element>{};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this children here but slottedChildren in the cupertino file above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the Cupertino file above, the element contains both an indexed list of children and a map of what it was referring to as "slotted children", so I made the map name match what it was referred to in the comments. However, it sounds like it's more confusing, so I'll rename all occurrences back to slotToChild

final _ChipSlot slot = childToSlot[child];
childToSlot.remove(child);
slotToChild.remove(slot);
assert(children.values.contains(child));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I know you're just changing the variable name, but couldn't this be:

Suggested change
assert(children.values.contains(child));
assert(children.containsValue(child));

Here and in a couple other places below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep - I'll update them all. I'm not used to having a containsValue() function on a map 🙂

The remaining uses of this pattern were all due to wanting to have
the child's slot when `Element.forgetChild()` was called. However,
when that method is called, the child's `slot` value is still valid
in the context of the parent, so the uses can just use `child.slot`.

This is the final round of cleanup from the fallout of flutter#63269
@tvolkert tvolkert merged commit dae720b into flutter:master Aug 21, 2020
@tvolkert tvolkert deleted the childToSlot branch August 21, 2020 17:41
smadey pushed a commit to smadey/flutter that referenced this pull request Aug 27, 2020
The remaining uses of this pattern were all due to wanting to have
the child's slot when `Element.forgetChild()` was called. However,
when that method is called, the child's `slot` value is still valid
in the context of the parent, so the uses can just use `child.slot`.

This is the final round of cleanup from the fallout of flutter#63269
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
The remaining uses of this pattern were all due to wanting to have
the child's slot when `Element.forgetChild()` was called. However,
when that method is called, the child's `slot` value is still valid
in the context of the parent, so the uses can just use `child.slot`.

This is the final round of cleanup from the fallout of flutter#63269
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants