[SelectMenu] Extend HTMLOptionsCollection to support <selectmenu>. [chromium/src : main]

0 views
Skip to first unread message

Ionel Popescu (Gerrit)

unread,
Jul 26, 2021, 10:07:49 PM7/26/21
to Dan Clark, Mason Freed, blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org

Attention is currently required from: Dan Clark, Mason Freed.

Ionel Popescu would like Dan Clark and Mason Freed to review this change.

View Change

[SelectMenu] Extend HTMLOptionsCollection to support <selectmenu>.

Add support for a readonly 'options' attribute on <selectmenu>.

As we plan to remove support for part="option" and allow only <option>
elements to be used as options, the HTMLOptionsCollection is extended to
support <selectmenu>.

Since shadow tree traversal is needed to build selectmenu.options,
FlatTreeTraversal is extended to receive a matcher that is used to
filter the returned elements. Same approach is used for DOM tree
traversal[1].

[1]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/dom/element_traversal.h

Bug: 1191131
Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
---
M third_party/blink/renderer/core/dom/flat_tree_traversal.h
M third_party/blink/renderer/core/html/collection_type.h
M third_party/blink/renderer/core/html/forms/html_options_collection.cc
M third_party/blink/renderer/core/html/forms/html_options_collection.h
M third_party/blink/renderer/core/html/forms/html_select_menu_element.cc
M third_party/blink/renderer/core/html/forms/html_select_menu_element.h
M third_party/blink/renderer/core/html/forms/html_select_menu_element.idl
M third_party/blink/renderer/core/html/html_collection.cc
M third_party/blink/web_tests/external/wpt/html/semantics/forms/the-selectmenu-element/selectmenu-parts-structure.tentative.html
9 files changed, 178 insertions(+), 9 deletions(-)


To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
Gerrit-Change-Number: 3055671
Gerrit-PatchSet: 2
Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Dan Clark <dan...@microsoft.com>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-MessageType: newchange

Ionel Popescu (Gerrit)

unread,
Jul 26, 2021, 10:08:00 PM7/26/21
to blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Mason Freed, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Dan Clark, Mason Freed.

Patch set 2:Commit-Queue +1

View Change

1 comment:

To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
Gerrit-Change-Number: 3055671
Gerrit-PatchSet: 2
Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Dan Clark <dan...@microsoft.com>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Tue, 27 Jul 2021 02:07:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Blink WPT Bot (Gerrit)

unread,
Jul 26, 2021, 10:12:58 PM7/26/21
to Ionel Popescu, blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Mason Freed, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org

Attention is currently required from: Dan Clark, Mason Freed.

Exportable changes to web-platform-tests were detected in this CL and a pull request in the upstream repo has been made: https://github.com/web-platform-tests/wpt/pull/29797.

When this CL lands, the bot will automatically merge the PR on GitHub if the required GitHub checks pass; otherwise, ecosystem-infra@ team will triage the failures and may contact you.

WPT Export docs:
https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md#Automatic-export-process

View Change

    To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
    Gerrit-Change-Number: 3055671
    Gerrit-PatchSet: 2
    Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Blink WPT Bot <blink-w3c-te...@chromium.org>
    Gerrit-Attention: Dan Clark <dan...@microsoft.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Tue, 27 Jul 2021 02:12:48 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Dan Clark (Gerrit)

    unread,
    Jul 27, 2021, 7:39:06 PM7/27/21
    to Ionel Popescu, blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Blink WPT Bot, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org

    Attention is currently required from: Ionel Popescu, Mason Freed.

    View Change

    1 comment:

    • File third_party/blink/renderer/core/dom/flat_tree_traversal.h:

      • Patch Set #4, Line 289:

          while (node && !is_match(*node))
        node = FlatTreeTraversal::Next(*node, stay_within);

        I'm not sure that this approach is going to be sufficient for all cases where we need to skip over nested <selectmenu>/<select>s in the parts search.

        Consider cases like this:
        <selectmenu>
        <selectmenu>
        <option>one</option>
        </selectmenu>
        <option>two</option>
        </selectmenu>

        The outer <selectmenu> should only see <option> "two" as a valid option part, because "one" is in a nested <selectmenu>. But this function won't do so; it will continue into the subtree of elements that don't pass the is_match() check.

        This is in contrast to SelectMenuPartTraversal in https://chromium-review.googlesource.com/c/chromium/src/+/3053078, which skips over subtrees of nested <selectmenu>/<select>.

        I don't see a good way to handle this with the MatchFunc pattern, so we might need something like SelectMenuPartTraversal after all. We make FlatTreeTraversal use MatchFunc differently from ElementTraversal, but that seems potentially confusing.

    To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
    Gerrit-Change-Number: 3055671
    Gerrit-PatchSet: 4
    Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Blink WPT Bot <blink-w3c-te...@chromium.org>
    Gerrit-Attention: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Tue, 27 Jul 2021 23:38:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Ionel Popescu (Gerrit)

    unread,
    Jul 28, 2021, 2:07:54 PM7/28/21
    to blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Blink WPT Bot, Mason Freed, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org

    Attention is currently required from: Dan Clark, Mason Freed.

    View Change

    1 comment:

    • File third_party/blink/renderer/core/dom/flat_tree_traversal.h:

      • I'm not sure that this approach is going to be sufficient for all cases where we need to skip over n […]

        Indeed, there a different behavior where the FlatTreeTraversal / ElementTraversal traverse the entire tree and uses the MatchFunc to filter the elements, as opposed to SelectMenuPartTraversal that skips over subtrees.

        I think there are 2 solutions here:
        1. adjust the MatchFunc to ensure that the parts are not part of a nested <selectmenu/select>.
        2. keep SelectMenuPartTraversal and add a comment on why it is needed.

        I think we may find that (1) has a slightly higher complexity due to many corner cases so we should probably pursue (2).

    To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
    Gerrit-Change-Number: 3055671
    Gerrit-PatchSet: 4
    Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Blink WPT Bot <blink-w3c-te...@chromium.org>
    Gerrit-Attention: Dan Clark <dan...@microsoft.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Wed, 28 Jul 2021 18:07:42 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Dan Clark <dan...@microsoft.com>
    Gerrit-MessageType: comment

    Dan Clark (Gerrit)

    unread,
    Jul 30, 2021, 5:25:01 PM7/30/21
    to Ionel Popescu, blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Blink WPT Bot, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org

    Attention is currently required from: Ionel Popescu, Mason Freed.

    View Change

    1 comment:

    • File third_party/blink/renderer/core/html/forms/html_select_menu_element.cc:

      • Patch Set #4, Line 470: EnsureCachedCollection<HTMLOptionsCollection>(kSelectMenuOptions);

        I've been thinking about this change some more, and it's a little suspicious that HTMLSelectMenuElement is going to have two separate collections of its options: the HTMLOptionsCollection created here, and HTMLSelectMenuElement::option_parts_.

        It would be great if we could just get rid of HTMLSelectMenuElement::option_parts_ and use this HTMLOptionsCollection instead. However we've been using in OptionPartInserted/OptionPartRemoved in order to keep track of whether we've already registered the OptionPartEventListener option_part_listener_ once on each option part. We might also need to keep track of similar things for options in the future, that need to be set when an option is registered as a part and unset when it stops being a part.

        I don't know how to make that work with HTMLCollection collections, since they are Ensured on-demand. I don't see a good way to know whether a given element in the HTMLOptionsCollection has already been processed in OptionPartInserted or not.

        But, HTMLOptionElement already has is_descendant_of_select_menu_, so could we check that, instead of checking whether an option is present in option_parts_? (Although we might need to upgrade from a bool to a HTMLSelectMenuElement pointer, since there might be bugs when an <option> is moved directly from one <selectmenu> to another).

        Or alternatively, could we instead invent a new class that exposes HTMLSelectMenuElement::option_parts_ with the HTMLOptionsCollection IDL interface, instead of using the EnsureCachedCollection stuff?

    To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
    Gerrit-Change-Number: 3055671
    Gerrit-PatchSet: 4
    Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Blink WPT Bot <blink-w3c-te...@chromium.org>
    Gerrit-Attention: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Fri, 30 Jul 2021 21:24:52 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Domenic Denicola (Gerrit)

    unread,
    Aug 1, 2021, 3:04:56 PM8/1/21
    to Ionel Popescu, blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Blink WPT Bot, Mason Freed, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org

    Attention is currently required from: Ionel Popescu, Mason Freed.

    View Change

    1 comment:

    • Patchset:

      • Patch Set #4:

        Hey, just popping in after seeing this exported to WPT: Can I suggest not doing this, or perhaps having a standards discussion first? HTMLOptionsCollection is a legacy "fake array" and I don't think we would accept any HTML Standard PRs that continue spreading it throughout the platform. New features should use ObservableArray, if anything. (Although IMO I don't think an options property is needed at all.)

    To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
    Gerrit-Change-Number: 3055671
    Gerrit-PatchSet: 4
    Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Blink WPT Bot <blink-w3c-te...@chromium.org>
    Gerrit-CC: Domenic Denicola <dom...@chromium.org>
    Gerrit-Attention: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Sun, 01 Aug 2021 19:04:44 +0000

    Mason Freed (Gerrit)

    unread,
    Aug 2, 2021, 2:54:53 PM8/2/21
    to Ionel Popescu, blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Domenic Denicola, Blink WPT Bot, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org

    Attention is currently required from: Ionel Popescu.

    View Change

    1 comment:

    To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
    Gerrit-Change-Number: 3055671
    Gerrit-PatchSet: 4
    Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Blink WPT Bot <blink-w3c-te...@chromium.org>
    Gerrit-CC: Domenic Denicola <dom...@chromium.org>
    Gerrit-Attention: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Comment-Date: Mon, 02 Aug 2021 18:54:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Domenic Denicola <dom...@chromium.org>
    Gerrit-MessageType: comment

    Ionel Popescu (Gerrit)

    unread,
    Aug 2, 2021, 4:19:06 PM8/2/21
    to blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Domenic Denicola, Blink WPT Bot, Mason Freed, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org

    View Change

    1 comment:

    To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
    Gerrit-Change-Number: 3055671
    Gerrit-PatchSet: 4
    Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Blink WPT Bot <blink-w3c-te...@chromium.org>
    Gerrit-CC: Domenic Denicola <dom...@chromium.org>
    Gerrit-Comment-Date: Mon, 02 Aug 2021 20:18:54 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Domenic Denicola <dom...@chromium.org>
    Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
    Gerrit-MessageType: comment

    Ionel Popescu (Gerrit)

    unread,
    Sep 23, 2021, 12:20:06 PM9/23/21
    to blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, Domenic Denicola, Blink WPT Bot, Mason Freed, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org

    Ionel Popescu abandoned this change.

    View Change

    Abandoned

    To view, visit change 3055671. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If2730faaf8ea117fa01fcc148fdd56b2e8146d85
    Gerrit-Change-Number: 3055671
    Gerrit-PatchSet: 4
    Gerrit-Owner: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Ionel Popescu <iopo...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Blink WPT Bot <blink-w3c-te...@chromium.org>
    Gerrit-CC: Domenic Denicola <dom...@chromium.org>
    Gerrit-MessageType: abandon
    Reply all
    Reply to author
    Forward
    0 new messages