Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@yaakovschectman
Copy link
Contributor

Flutter already supports tristate checkboxes that can have a mixed or half-checked state, but the semantics do not. Where the checked/unchecked state of a checkbox is passed to the Semantics node, a mixed state is not. This adds support for the mixed-state semantics flag to the engine. In conjunction with a PR to Flutter, we will be able to support the mixed state in semantics for checkboxes.

Addresses flutter/flutter#110107

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

Overall this approach lgtm. Adding @chunhtai for general a11y review.

@cbracken cbracken requested a review from chunhtai September 2, 2022 02:46
@yaakovschectman
Copy link
Contributor Author

I am going to need to push an interim PR to flutter/flutter to circumvent some tests that this change would break so that this change can be merged, which is necessary for those tests to be updated to be compatible with it.


/// Whether a tristate checkbox is in its mixed state.
///
/// Should only be true when the checkbox has [tristate] = true.
Copy link
Contributor

Choose a reason for hiding this comment

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

this can still be false if [tristate] = true?

Also this comment is too specific, people who reading this doc may not know what tristate is.

Maybe

If this is true, the check box this semantics node represents is in a mixed state. For example, a [Checkbox] with [Checkbox.tristate] set to true can have checked,  unchecked, or mixed state.

static const SemanticsFlag hasToggledState = SemanticsFlag._(_kHasToggledStateIndex);
static const SemanticsFlag isToggled = SemanticsFlag._(_kIsToggledIndex);
static const SemanticsFlag hasImplicitScrolling = SemanticsFlag._(_kHasImplicitScrollingIndex);
static const SemanticsFlag isMixedCheck = SemanticsFlag._(_kIsMixedCheckIndex);
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need a better name. maybe isCheckStateMixed

Copy link
Member

Choose a reason for hiding this comment

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

Maybe isMixedCheckState? But it's a bit at odds with existing naming convention typically hasFooState and isFoo.

@yaakovschectman yaakovschectman marked this pull request as ready for review September 2, 2022 21:02
/// can have checked, unchecked, or mixed state.
///
/// Should be false when the checkbox is either checked or unchecked.
///
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
///

EXPECT_FALSE(native_state.lVal & STATE_SYSTEM_CHECKED);
}

// Now check mixed state
Copy link
Member

Choose a reason for hiding this comment

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

Super pedantic nit: end with a period (here and below). Look like at least one comment above was already missing one :/

Ref: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-correct-grammar

Suggested change
// Now check mixed state
// Now check mixed state.

IAccessible* native_view = root_node->GetNativeViewAccessible();
ASSERT_TRUE(native_view != nullptr);

// Look up against the node itself (not one of its children)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Look up against the node itself (not one of its children)
// Look up against the node itself (not one of its children).

IAccessible* native_view = root_node->GetNativeViewAccessible();
ASSERT_TRUE(native_view != nullptr);

// Look up against the node itself (not one of its children)
Copy link
Member

Choose a reason for hiding this comment

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

Quick fix of existing comment:

Suggested change
// Look up against the node itself (not one of its children)
// Look up against the node itself (not one of its children).

EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_CHECKED);
}

// Test unchecked too
Copy link
Member

@cbracken cbracken Sep 2, 2022

Choose a reason for hiding this comment

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

Quick fix of existing comment. Sadly, github won't let me fix the one on line 653/654.

Suggested change
// Test unchecked too
// Test unchecked too.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

I imagine you'll need to rebase to tip-of-tree once your framework-side test changes have landed.

LGTM stamp from a Japanese personal seal

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

/// For example, a [Checkbox] with [Checkbox.tristate] set to true
/// can have checked, unchecked, or mixed state.
///
/// Should be false when the checkbox is either checked or unchecked.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Should be false when the checkbox is either checked or unchecked.
/// Must be false when the checkbox is either checked or unchecked.

@yaakovschectman yaakovschectman merged commit a5cc2b4 into flutter:main Sep 6, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 6, 2022
Oleh-Sv pushed a commit to Oleh-Sv/engine that referenced this pull request Sep 28, 2022
* Honor mixed state

* Add to unit test

* Add state enums

* Fix delimiter

* Add enums

* Scope subtests, rename enum

* Rename enums

* Comment specification

* Tidy up comments

* Rename java enum

* Trailing whitespace
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants