Commit graph

158 commits

Author SHA1 Message Date
Iulian Moraru
51e39ebc5a Backed out changeset a00be88f3708 (bug 1877969) for causing multiple failures. CLOSED TREE 2024-06-04 16:49:11 +03:00
Oliver Medhurst
9fb1089f58 Bug 1877969 - Consume user activation when showing any picker r=dom-core,edgar
Consume transient user activation when showing file/color picker
at any time. Do not open if there is no transent user activation.

Spec PR: https://github.com/whatwg/html/pull/10344

Differential Revision: https://phabricator.services.mozilla.com/D201096
2024-06-04 11:33:36 +00:00
Neil Deakin
1515db9b71 Bug 1849122, allowing getting and modifying the autofill state directly within the input and select elements, and reset this state when its value changes, r=webidl,emilio
Resetting the state when the value is modified is bug 1359355.

Differential Revision: https://phabricator.services.mozilla.com/D210999
2024-05-28 23:39:59 +00:00
Emilio Cobos Álvarez
3b42787268 Bug 1895208 - Refactor IsFocusable checks to take flags rather than bool arguments. r=smaug
This doesn't change behavior on its own, but it's likely we want to make
the tab focusability more complicated in bug 1895184, and this will make
changes to this area less painful.

Differential Revision: https://phabricator.services.mozilla.com/D209525
2024-05-06 21:54:37 +00:00
Emilio Cobos Álvarez
8925ee2d3d Bug 1881011 - Refactor UnbindFromTree to take a context argument. r=smaug
Much like BindToTree.

This will be useful because I need to pass more information through
UnbindFromTree() to speed up dir=auto for bug 1874040.

Differential Revision: https://phabricator.services.mozilla.com/D202215
2024-02-20 15:05:40 +00:00
Emilio Cobos Álvarez
71838e2f11 Bug 1850295 - Update :user-{valid,invalid} to follow the spec. r=smaug
(Modulo open spec issues linked in comments)

Differential Revision: https://phabricator.services.mozilla.com/D196986
2024-01-16 11:09:01 +00:00
toe_head2001
2db1524240 Bug 1872457 - Improve performance of HTMLSelectElement::RemoveOptionsFromList r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D197442
2024-01-01 09:52:17 +00:00
Makoto Kato
291b796b27 Bug 1864030 - HTMLSelectElement.showPicker should show the picker on Android even if not combo box. r=dom-core,geckoview-reviewers,ohall,edgar
If not combo box, GeckoView shows the select picker. So `showPicker`
method should show it on mobile.

(This fix uses ANDROID define for KaiOS fork too)

Differential Revision: https://phabricator.services.mozilla.com/D194721
2023-12-13 06:53:37 +00:00
Tom Schuster
1ea05389b6 Bug 1865207 - HTMLSelectElement showPicker needs to check for being rendered. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D194409
2023-11-26 10:23:03 +00:00
Sandor Molnar
b7fe69a4ab Backed out changeset 4c7dab5cb50c (bug 1864291) for causing multiple failures on test_input_color_picker_popup.html / forms/browser_selectpopup_invoke.js CLOSED TREE 2023-11-15 19:44:05 +02:00
Luke Warlow
ed12e0d2d0 Bug 1864291 - Implements HandleInvokeInternal for select and input elements. r=smaug
Implements invoketarget defaults for select and input element, as specified in the open-ui "Invokers explainer".

(https://open-ui.org/components/invokers.explainer/)

Differential Revision: https://phabricator.services.mozilla.com/D193363
2023-11-15 14:20:48 +00:00
Tom Schuster
aafc425b7f Bug 1854112 - Add showPicker method to <select> elements. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D189675
2023-10-31 09:36:16 +00:00
Emilio Cobos Álvarez
c27a2129fd Bug 1850293 - Make validity states non-intrinsic. r=smaug
Add a RAII helper to notify of multiple state changes together for
these.

The UpdateState CustomElementInternals calls that are getting removed
are unnecessary (the state should be up-to-date by then, there's nothing
changing there particularly).

Same for the call in nsGenericHTMLFormElement::UnbindFromTree. ClearForm
already does an state update.

Differential Revision: https://phabricator.services.mozilla.com/D187033
2023-08-30 09:18:32 +00:00
Emilio Cobos Álvarez
4cc6758558 Bug 1839922 - Remove usage of {Has,Get}Attr(kNameSpaceID_None, ..). r=edgar
We have more readable and faster versions (that just omit the namespace
arg).

Mostly done via sed, with a couple helpers to use the faster lookups
where possible.

Differential Revision: https://phabricator.services.mozilla.com/D181795
2023-06-23 10:01:32 +00:00
Emilio Cobos Álvarez
7bddcf9e5a Bug 1839223 - Remove nsMappedAttributes. r=smaug
Instead, lazily schedule evaluation of them before styling, much like we
were doing for SVG.

A subtle tweak is that we only remain scheduled while in the document.
This allows us to use the "in document" bit plus the "mapped attributes
dirty" bit to know our scheduled status. It also prevents doing silly
work for disconnected elements, and having to do hashmap lookups on
adoption and node destruction.

Differential Revision: https://phabricator.services.mozilla.com/D181549
2023-06-22 17:22:03 +00:00
Cristian Tuns
6957543e5e Backed out changeset a3e55d5f9f13 (bug 1839223) for causing multiple failures in Document.cpp CLOSED TREE 2023-06-22 11:34:15 -04:00
Emilio Cobos Álvarez
2c6de5f038 Bug 1839223 - Remove nsMappedAttributes. r=smaug
Instead, lazily schedule evaluation of them before styling, much like we
were doing for SVG.

A subtle tweak is that we only remain scheduled while in the document.
This allows us to use the "in document" bit plus the "mapped attributes
dirty" bit to know our scheduled status. It also prevents doing silly
work for disconnected elements, and having to do hashmap lookups on
adoption and node destruction.

Differential Revision: https://phabricator.services.mozilla.com/D181549
2023-06-22 14:31:16 +00:00
Emilio Cobos Álvarez
9ac32645f7 Bug 1837382 - Remove nsIContent::IsDoneAddingChildren. r=smaug
It's only called once for a place where it knows it's a select element.

Differential Revision: https://phabricator.services.mozilla.com/D180312
2023-06-08 14:59:31 +00:00
Emilio Cobos Álvarez
25b79c7b15 Bug 1829225 - Make BeforeSetAttr take the parsed nsAttrValue. r=smaug
ParseAttribute ideally would be const (see bug 1829138), but the SVG and
SMIL code is rather messy. Still, now that BeforeSetAttr can't really
fail, swapping the order of ParseAttribute and BeforeSetAttr shouldn't
really change behavior.

Sorry for the extra `virtual` keyword removal and such. I had to do this
one by hand unlike the dependent bugs, and I went a bit drive-by, lmk if
you want me to split those changes.

Differential Revision: https://phabricator.services.mozilla.com/D176086
2023-04-21 09:25:17 +00:00
Emilio Cobos Álvarez
51758cfc9b Bug 1829189 - Make OnAttrSetButNotChanged and AfterSetAttr infallible. r=smaug
Same rg + sed shenanigans as the first patch.

There were two that could fail, both due to OOM:

 * HTMLInputElement::AfterSetAttr: If we fail (only in the type=range
   case) we end up with an old value without it being clamped by
   min/max/step.

 * HTMLBodyElement::AfterSetAttr: If we fail we won't peek up the
   DocShell's frame margins and styling could be incorrect.

That seems better than having to deal with broken states after we've
already set the attribute.

Depends on D176069

Differential Revision: https://phabricator.services.mozilla.com/D176070
2023-04-21 08:56:27 +00:00
Emilio Cobos Álvarez
ee4c38a50c Bug 1829189 - Make BeforeSetAttr infallible. r=smaug
rg BeforeSetAttr -l | xargs sed -i 's/nsresult BeforeSetAttr/void BeforeSetAttr/g'
  rg ::BeforeSetAttr -l | xargs sed -i 's/nsresult \(.*\)::BeforeSetAttr/void \1::BeforeSetAttr/g'

Plus trivial fixes, plus clang-format.

The only meaningful changes are in nsXULElement::BeforeSetAttr. Two
things could fail:

chromemargin: I removed it because we don't use the parsed attribute any
other place than here:

  https://searchfox.org/mozilla-central/rev/31f5847a4494b3646edabbdd7ea39cb88509afe2/dom/xul/ChromeObserver.cpp#136

And that deals just fine with it not being parsed.

usercontextid: We have a debug assertion that we don't dynamically change it.
I kept it but I don't think it's worth failing to set the attribute on release for that

Differential Revision: https://phabricator.services.mozilla.com/D176069
2023-04-21 08:56:27 +00:00
Alexander Surkov
7dfe52adaf Bug 1823757 - use parsed atoms for popovertarget attribute, r=emilio
Use parsed atoms to store popovertarget attributes as more effective mechanism to search for ID match in attr associated elements implementation. Followup from D173337.

Differential Revision: https://phabricator.services.mozilla.com/D174786
2023-04-11 18:35:51 +00:00
Natalia Csoregi
168555a743 Backed out changeset 96da9dcee2b0 (bug 1823757) for causing failures on popover-invoking-attribute.html. CLOSED TREE 2023-04-11 09:43:08 +03:00
Alexander Surkov
290fcc4061 Bug 1823757 - use parsed atoms for popovertarget attribute, r=emilio
Use parsed atoms to store popovertarget attributes as more effective mechanism to search for ID match in attr associated elements implementation. Followup from D173337.

Differential Revision: https://phabricator.services.mozilla.com/D174786
2023-04-11 00:53:28 +00:00
Ben Freist
2697fe89d4 Bug 1300405 - Fix insertion of already selected options r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D166955
2023-02-12 20:44:50 +00:00
Emilio Cobos Álvarez
30558e682e Bug 1797792 - Tweak HTMLOptionsCollection.length limit. r=smaug
As per the discussion in https://github.com/whatwg/html/pull/8347

Differential Revision: https://phabricator.services.mozilla.com/D160544
2022-10-28 12:29:09 +00:00
Emilio Cobos Álvarez
a857ee4d71 Bug 1793733 - Improve console warning for HTMLOptionsCollection.length. r=flod
There's the chance that the limit will change in the future per the spec
discussion, so make it also an argument.

Differential Revision: https://phabricator.services.mozilla.com/D158638
2022-10-05 06:08:14 +00:00
Robert Altner
28bcc313e9 Bug 344060 - Change behaviour of huge values for options.length. r=emilio
Setting options.length to a value greater than 10,000 will now not throw.

Differential Revision: https://phabricator.services.mozilla.com/D158457
2022-10-04 18:21:41 +00:00
Emilio Cobos Álvarez
47afabb81a Bug 1773070 - While at it use some better names for some bits. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D148538
2022-06-07 23:09:53 +00:00
Emilio Cobos Álvarez
255763ef57 Bug 1773070 - Unify Gecko and Servo EventState/ElementState bits. r=smaug
Add a dom/base/rust crate called just "dom" where we can share these.

Most of the changes are automatic:

  s/mozilla::EventStates/mozilla::dom::ElementState/
  s/EventStates/ElementState/
  s/NS_EVENT_STATE_/ElementState::/
  s/NS_DOCUMENT_STATE_/DocumentState::/

And so on. This requires a new cbindgen version to avoid ugly casts for
large shifts.

Differential Revision: https://phabricator.services.mozilla.com/D148537
2022-06-07 23:09:52 +00:00
Emilio Cobos Álvarez
505c0411c7 Bug 1771713 - Fix content state change notification when a selected option is inserted. r=edgar
This bug was revealed by the patch for bug 1381071, which caused
failures in dom/html/test/test_bug596511.html.

The test was not using the usual style invalidation machinery because it
was in a display: none subtree.

Tweak the test to check both the "raw" state (via matches()) and the
style, which should show invalidation issues more clearly.

Differential Revision: https://phabricator.services.mozilla.com/D147630
2022-05-30 11:06:21 +00:00
Kagami Sascha Rosylight
b1653a09c7 Bug 1767996 - Apply readability-make-member-function-const on dom/html r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D145627
2022-05-13 05:35:25 +00:00
Emilio Cobos Álvarez
ab3a92e515 Bug 1440506 - Do not destroy dropdowns on reframe. r=dholbert
We switch the open state storage to the element rather than the frame,
to be able to preserve it across reframes.

The code is loosely based on nsHideViewer in nsSubDocument.cpp, but it's
simpler because we don't need to do restoration shenanigans.

Differential Revision: https://phabricator.services.mozilla.com/D138689
2022-02-15 22:00:27 +00:00
Emilio Cobos Álvarez
b651bfe99a Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.

Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:

  <select>
    <option>ABC</option>
    <option style="font-size: 1px">Something long</option>
  </select>

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
2022-01-17 11:10:05 +00:00
Marian-Vasile Laza
35a88d897e Backed out 2 changesets (bug 1744009) for causing reftest failures on select-3.html.
Backed out changeset 3e44e31d3d12 (bug 1744009)
Backed out changeset 619389788775 (bug 1744009)
2022-01-17 11:14:27 +02:00
Emilio Cobos Álvarez
a8d469a8d0 Bug 1744009 - Simplify combobox <select> code. r=mconley,dholbert
With this patch on its own we get some a11y tests failures, but those
are fixed on a later patch.

Combobox select no longer creates frames for its <options>, nor an
nsListControlFrame. Instead, it computes its right intrinsic size using
the largest size of the options. This is better, because we render the
option text using the select style so if the select and option styles
are mismatched it'd cause changes in the size of the select when text
changes. See the following in a build without the patch, for example:

  <select>
    <option>ABC</option>
    <option style="font-size: 1px">Something long</option>
  </select>

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
2022-01-16 23:31:22 +00:00
Masayuki Nakano
3816ca9546 Bug 1741148 - part 3: Make users of nsINode::ComputeIndexOf_Deprecated() use nsINode::ComputeIndexOf() if the result is not set to int32_t nor return as int32_t r=smaug
This patch fixes only the cases if the result of `ComputeIndexOf_Deprecated()`
is used as unsigned integer with implicit or explicit cast.

Differential Revision: https://phabricator.services.mozilla.com/D131336
2021-12-09 11:55:36 +00:00
Masayuki Nakano
f2baf0d9ab Bug 1741148 - part 1: Rename nsINode::ComputeIndexOf to ComputeIndexOf_Deprecated r=smaug
It's hard to fix some callers.  Therefore, in this bug, we should fix only
simple cases.  Therefore, we should rename existing API first.

Differential Revision: https://phabricator.services.mozilla.com/D131334
2021-12-09 08:32:30 +00:00
Edgar Chen
531ef37175 Bug 1556364 - Part 2-1: Split nsGenericHTMLFormControlElement-only members from nsIConstraintValidation to a separated class; r=smaug
As ElementInternal has it own implmentation.

Differential Revision: https://phabricator.services.mozilla.com/D130259
2021-11-26 11:47:39 +00:00
Marian-Vasile Laza
807599b18f Backed out 5 changesets (bug 1556364) for causing web-platform test failures. CLOSED TREE
Backed out changeset dabffbe71a31 (bug 1556364)
Backed out changeset 76fc30f27c39 (bug 1556364)
Backed out changeset f6f7f949551f (bug 1556364)
Backed out changeset c77ef41d43d4 (bug 1556364)
Backed out changeset 2c8c74e99e47 (bug 1556364)
2021-11-26 05:01:08 +02:00
Edgar Chen
ab401654c2 Bug 1556364 - Part 2-1: Split nsGenericHTMLFormControlElement-only members from nsIConstraintValidation to a separated class; r=smaug
As ElementInternal has it own implmentation.

Differential Revision: https://phabricator.services.mozilla.com/D130259
2021-11-25 21:58:04 +00:00
Edgar Chen
ad06ef9d0a Bug 1737364 - Part 2: Elements should be barred from constraint validation if it has a datalist element ancestor; r=smaug
Add a new flag, ELEMENT_IS_DATALIST_OR_HAS_DATALIST_ANCESTOR, to indicate that
the element is a HTML datalist element or has a HTML datalist element ancestor.

Per https://html.spec.whatwg.org/multipage/form-elements.html#the-datalist-element:barred-from-constraint-validation

Differential Revision: https://phabricator.services.mozilla.com/D129717
2021-11-03 20:07:43 +00:00
Edgar Chen
36107cfddf Bug 1556363 - Part 1: Check disabled state for submission in a common place; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D129048
2021-10-25 20:43:10 +00:00
Edgar Chen
6c7f4da558 Bug 1556351 - Part 3: Rename nsGenericHTMLFormElementWithState to nsGenericHTMLFormControlElementWithState; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D124786
2021-10-04 20:51:26 +00:00
Edgar Chen
b946d3b81b Bug 1728537 - Part 2: Move RestoreState out of nsIFormControl; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D124180
2021-09-01 16:51:58 +00:00
Edgar Chen
7d1d31d3e9 Bug 1728537 - Part 1: Move SaveState out of nsIFormControl; r=smaug
And make it return void as the return value isn't used at callsites.

Differential Revision: https://phabricator.services.mozilla.com/D124179
2021-09-01 16:51:58 +00:00
Edgar Chen
bae585f79e Bug 1728081 - Part 3: Merge nsIForm into HTMLFormElement; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D123951
2021-08-30 18:44:51 +00:00
Olli Pettay
93b7f9edff Bug 1725293 - checkValidity() on <select required> returns true when <option value=> is moved in the dom, r=edgar
The new check should be still fast, since accessing selected index is trivial and Item() call is just accessing the element from an
nsTArray.

Differential Revision: https://phabricator.services.mozilla.com/D123371
2021-08-24 08:46:00 +00:00
Edgar Chen
af2f2867e6 Bug 1721349 - Move mSubmitter from HTMLFormSubmission to FormData and make it participate in cycle collection; r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D120334
2021-07-21 09:52:20 +00:00
Emilio Cobos Álvarez
2b0eae6061 Bug 1715134 - Make form control type an enum class. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117087
2021-06-08 09:43:59 +00:00