From a8d469a8d0564b390c59a1e22ccba0126d796a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 16 Jan 2022 23:31:22 +0000 Subject: [PATCH] Bug 1744009 - Simplify combobox This seems like a rather obscure case, but it's important to get it right, see bug 1741888. With this patch we use the same setup in content and parent processes (this needs bug 1596852 and bug 1744152). This means we can remove a bunch of the native view and popup code in nsListControlFrame. A couple browser_* tests are affected by this change and have been tweaked appropriately (the changes there are trivial). Not creating an nsListControlFrame for dropdown select means that we need to move a bunch of the event handling code from nsListControlFrame to a common place that nsComboboxControlFrame can also use. That place is HTMLSelectEventListener, and I think the setup is much nicer than having the code intertwined with nsListControlFrame. It should be relatively straight-forward to review, mostly moving code from one part to another. Another thing that we need to do in HTMLSelectEventListener that we didn't use to do is listening for DOM mutations on the dropdown. Before, we were relying on changes like text mutations triggering a reflow of the listcontrolframe, which also triggered a reflow of the comboboxcontrolframe, which in turn updated the text of the anonymous content. Now we need to trigger that reflow manually. There are some further simplifications that can be done after this lands (cleanup naming of openInParentProcess and so on, among others), but I'd rather land this first (after the merge of course) and work on them separately. Differential Revision: https://phabricator.services.mozilla.com/D132719 --- accessible/html/HTMLSelectAccessible.cpp | 22 +- accessible/html/HTMLSelectAccessible.h | 1 - browser/base/content/browser.xhtml | 1 + browser/base/content/main-popupset.inc.xhtml | 1 + .../content/test/forms/browser_selectpopup.js | 5 +- .../test/forms/browser_selectpopup_colors.js | 5 +- .../forms/browser_selectpopup_searchfocus.js | 5 +- .../test/tabdialogs/browser_subdialog_esc.js | 4 +- devtools/client/framework/toolbox-hosts.js | 1 + ...on_logic_adjust-time-with-playback-rate.js | 2 +- ..._animation_pause-resume-button_end-time.js | 2 +- ...rowser_animation_playback-rate-selector.js | 6 +- .../client/inspector/animation/test/head.js | 22 +- dom/events/EventStateManager.cpp | 11 - dom/html/HTMLSelectElement.cpp | 17 +- dom/html/HTMLSelectElement.h | 4 +- layout/base/nsCSSFrameConstructor.cpp | 51 +- layout/base/nsCSSFrameConstructor.h | 17 +- layout/base/nsLayoutUtils.cpp | 17 +- layout/build/nsLayoutStatics.cpp | 2 - layout/forms/HTMLSelectEventListener.cpp | 804 ++++++++++ layout/forms/HTMLSelectEventListener.h | 102 ++ layout/forms/moz.build | 1 + layout/forms/nsComboboxControlFrame.cpp | 844 ++--------- layout/forms/nsComboboxControlFrame.h | 111 +- layout/forms/nsListControlFrame.cpp | 1299 +---------------- layout/forms/nsListControlFrame.h | 154 +- layout/forms/nsSelectsAreaFrame.cpp | 20 +- layout/forms/test/bug665540_window.xhtml | 12 - layout/forms/test/chrome.ini | 4 - layout/forms/test/test_bug665540.html | 133 -- ...test_select_key_navigation_bug1498769.html | 9 +- layout/generic/nsFontInflationData.cpp | 4 +- layout/generic/nsGfxScrollFrame.cpp | 29 +- layout/generic/nsGfxScrollFrame.h | 14 - layout/generic/nsIScrollableFrame.h | 5 +- layout/generic/nsTextFrameUtils.cpp | 62 +- layout/generic/nsTextFrameUtils.h | 4 +- modules/libpref/init/all.js | 1 - ...select-intrinsic-option-font-size-ref.html | 5 + .../select-intrinsic-option-font-size.html | 6 + .../tests/browser_destination_change.js | 9 +- .../printing/tests/browser_print_duplex.js | 16 +- .../printing/tests/browser_print_margins.js | 89 +- .../tests/browser_print_page_range.js | 46 +- .../printing/tests/browser_sheet_count.js | 22 +- widget/windows/nsNativeThemeWin.cpp | 4 +- 47 files changed, 1357 insertions(+), 2648 deletions(-) create mode 100644 layout/forms/HTMLSelectEventListener.cpp create mode 100644 layout/forms/HTMLSelectEventListener.h delete mode 100644 layout/forms/test/bug665540_window.xhtml delete mode 100644 layout/forms/test/test_bug665540.html create mode 100644 testing/web-platform/tests/html/rendering/replaced-elements/the-select-element/select-intrinsic-option-font-size-ref.html create mode 100644 testing/web-platform/tests/html/rendering/replaced-elements/the-select-element/select-intrinsic-option-font-size.html diff --git a/accessible/html/HTMLSelectAccessible.cpp b/accessible/html/HTMLSelectAccessible.cpp index e8ef7294ce69..7c25f3c7b801 100644 --- a/accessible/html/HTMLSelectAccessible.cpp +++ b/accessible/html/HTMLSelectAccessible.cpp @@ -308,14 +308,10 @@ HTMLComboboxAccessible::HTMLComboboxAccessible(nsIContent* aContent, mGenericTypes |= eCombobox; mStateFlags |= eNoKidsFromDOM; - nsComboboxControlFrame* comboFrame = do_QueryFrame(GetFrame()); - if (comboFrame) { - nsIFrame* listFrame = comboFrame->GetDropDown(); - if (listFrame) { - mListAccessible = new HTMLComboboxListAccessible(mParent, mContent, mDoc); - Document()->BindToDocument(mListAccessible, nullptr); - AppendChild(mListAccessible); - } + if ((nsComboboxControlFrame*)do_QueryFrame(GetFrame())) { + mListAccessible = new HTMLComboboxListAccessible(mParent, mContent, mDoc); + Document()->BindToDocument(mListAccessible, nullptr); + AppendChild(mListAccessible); } } @@ -458,16 +454,6 @@ HTMLComboboxListAccessible::HTMLComboboxListAccessible(LocalAccessible* aParent, //////////////////////////////////////////////////////////////////////////////// // HTMLComboboxAccessible: LocalAccessible -nsIFrame* HTMLComboboxListAccessible::GetFrame() const { - nsIFrame* frame = HTMLSelectListAccessible::GetFrame(); - nsComboboxControlFrame* comboBox = do_QueryFrame(frame); - if (comboBox) { - return comboBox->GetDropDown(); - } - - return nullptr; -} - role HTMLComboboxListAccessible::NativeRole() const { return roles::COMBOBOX_LIST; } diff --git a/accessible/html/HTMLSelectAccessible.h b/accessible/html/HTMLSelectAccessible.h index 4e9f96d4708d..9ccf611259a6 100644 --- a/accessible/html/HTMLSelectAccessible.h +++ b/accessible/html/HTMLSelectAccessible.h @@ -205,7 +205,6 @@ class HTMLComboboxListAccessible : public HTMLSelectListAccessible { virtual ~HTMLComboboxListAccessible() {} // LocalAccessible - virtual nsIFrame* GetFrame() const override; virtual a11y::role NativeRole() const override; virtual uint64_t NativeState() const override; virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override; diff --git a/browser/base/content/browser.xhtml b/browser/base/content/browser.xhtml index 71480fc2f6d4..3c8f487a8f35 100644 --- a/browser/base/content/browser.xhtml +++ b/browser/base/content/browser.xhtml @@ -136,6 +136,7 @@ diff --git a/browser/base/content/main-popupset.inc.xhtml b/browser/base/content/main-popupset.inc.xhtml index 100c2f0eff02..c531d2b0ce10 100644 --- a/browser/base/content/main-popupset.inc.xhtml +++ b/browser/base/content/main-popupset.inc.xhtml @@ -283,6 +283,7 @@