Commit graph

229 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
8bee16d175 Bug 1905743 - Tweak TextControlElement to be able to tell if column count is explicit or not. r=dholbert a=RyanVM
This is needed because we want implicit width of number and text
controls be the same, but explicit width be different to account for the
spinners. See:

  data:text/html,<input type="number"><br><input type="text"><br><input type="number" min="1" max="9"><br><input type="text" size="1">

For example. This patch on its own shouldn't change behavior.
2024-07-02 21:17:34 +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
Gregory Pappas
3ea20569e6 Bug 1881845 - Remove nsContentCID.h r=smaug,media-playback-reviewers,karlt
All of these components have been converted to static registration, making this
file unneeded.

Differential Revision: https://phabricator.services.mozilla.com/D202633
2024-03-04 23:41:05 +00:00
Emilio Cobos Álvarez
da249afc64 Bug 1881457 - Keep saving mFocusedValue. r=smaug
This deletion was an oversight of the regressing bug. Kind of
embarrassing we didn't have a test for it...

Differential Revision: https://phabricator.services.mozilla.com/D202449
2024-02-22 16:20:50 +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
Jonathan Kew
5741b2b190 Bug 1852478 - Convert CSS white-space into a shorthand that expands to white-space-collapse and text-wrap-mode longhands. r=firefox-style-system-reviewers,emilio
Note that although this builds, it would (by itself) result in some test breakage;
this is resolved in the following patches that build on this.

Differential Revision: https://phabricator.services.mozilla.com/D198790
2024-01-26 09:40:02 +00:00
Cristian Tuns
f0be219b00 Backed out 4 changesets (bug 1758391, bug 1852478) for causing build bustages in UseCounterMetrics.cpp CLOSED TREE
Backed out changeset fe673f87d86a (bug 1852478)
Backed out changeset d466ccbd1aad (bug 1852478)
Backed out changeset c0fa98fec39a (bug 1758391)
Backed out changeset 04d322f23fd0 (bug 1852478)
2024-01-25 18:29:39 -05:00
Jonathan Kew
2cd3b24544 Bug 1852478 - Convert CSS white-space into a shorthand that expands to white-space-collapse and text-wrap-mode longhands. r=firefox-style-system-reviewers,emilio
Note that although this builds, it would (by itself) result in some test breakage;
this is resolved in the following patches that build on this.

Differential Revision: https://phabricator.services.mozilla.com/D198790
2024-01-25 22:20:05 +00:00
Narcis Beleuzu
3b47d28f1e Backed out 4 changesets (bug 1758391, bug 1852478) for failures on test_animation-type-longhand.html . CLOSED TREE
Backed out changeset d6a8b0b97282 (bug 1852478)
Backed out changeset fef9fcec3afc (bug 1852478)
Backed out changeset 01711557e2bf (bug 1758391)
Backed out changeset 8c8a01dbca12 (bug 1852478)
2024-01-22 16:37:15 +02:00
Jonathan Kew
5f45c5f18d Bug 1852478 - Convert CSS white-space into a shorthand that expands to white-space-collapse and text-wrap-mode longhands. r=firefox-style-system-reviewers,emilio
Note that although this builds, it would (by itself) result in some test breakage;
this is resolved in the following patches that build on this.

Differential Revision: https://phabricator.services.mozilla.com/D198790
2024-01-22 12:57:54 +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
Masayuki Nakano
4bb761eb3e Bug 1863759 - Make IMEStateManager recreate IMEContentObserver if the active one is not observing editable content of focused element r=smaug,m_kato
The test case is a special case that changes focused element from a text control
to an editing host.  Therefore, without a focus change, focused editor is
changed from a `TextEditor` to `HTMLEditor`.  At this time, `IMEContentObserver`
needs to switch the observing target from the anonymous content if `<input>` to
children of it.

However, the editable content becomes completely changed without a focus change
in the DOM.  Therefore, `IMEStateManager` needs to synthesize a fake focus move
for IME.  Therefore, this patch make `IMEStateManager` recreate
`IMEContentObserver` if active one is not observing editable content for the
focused element under "current" conditions at checking it.  (When
`IMEContentObserver` is being destroyed, it sends "blur" notification to IME
and the new `IMEContentObserver` instance posts "focus" notification with
all editable content data.  I.e., recreating `IMEContentObserver` generates
a fake focus move from IME point of view.)

Additionally, there is the opposite case, that is, editing host of an `<input>`
whose type is not a text control may become a text control.  Therefore, this
adds new WPTs to check the handler is the text editor for the text control or
the HTML editor.  The tests passed on Firefox and Chrome at least.

FYI: I guess that in this case, we need to kick `focus` event listener of the
`HTMLEditor`, but anyway, users cannot change the content because it's the
case that an atomic content is the editing host.  Therefore, I don't touch
about that in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D193262
2023-12-05 02:33:18 +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
b1ad2fb6f3 Bug 1850293 - Make CHECKED/DEFAULT states not intrinsic. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D186933
2023-08-30 09:18:31 +00:00
Emilio Cobos Álvarez
33968f7c4e Bug 1850293 - Make editable states not intrinsic. r=smaug,masayuki
This one is tricky because form controls, though I think I got it right...

This fixes a pre-existing bug where we're not following the spec for readonly
inside content-editable.

I filed this as bug 1850390 but other browsers match the spec so add a test and
fix it while at it. This allows cheaper checks for readonlyness in a couple
places.

Differential Revision: https://phabricator.services.mozilla.com/D186896
2023-08-30 09:18:31 +00:00
Emilio Cobos Álvarez
71d548bcdf Bug 1850293 - Make PLACEHOLDER_SHOWN not an intrinsic state. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D186932
2023-08-29 00:32:41 +00:00
Markus Stange
3d20b7df6c Bug 1843484 - Use EventTarget* instead of nsISupports* for the event target parameter of the nsContentUtils::Dispatch methods. r=smaug
This saves a few queryInterface calls on the hot path.

Differential Revision: https://phabricator.services.mozilla.com/D186976
2023-08-28 23:38:42 +00:00
Emilio Cobos Álvarez
8510eba432 Bug 1842027 - Don't localize <input type=number>'s default value unless for display. r=masayuki
This avoids a lot of useless time on things like GetValueAsDecimal(),
where we get the default value as a string, parse it as a number for
sanitization reasons, localize it to a string, just to parse it back to
a number.

Differential Revision: https://phabricator.services.mozilla.com/D183284
2023-07-12 16:55:36 +00:00
Emilio Cobos Álvarez
945ed5ad06 Bug 1842027 - Remove nsTextControlFrame::TextEquals. r=masayuki
It is always called from TextControlState, and always ends up in
TextControlState::ValueEquals, so we can avoid some indirection and just
use that.

Depends on D183282

Differential Revision: https://phabricator.services.mozilla.com/D183283
2023-07-12 08:58:09 +00:00
Emilio Cobos Álvarez
035b0a67ec Bug 1842027 - Remove always-true aIgnoreWrap parameter from TextControlElement::GetTextEditorValue. r=masayuki
Depends on D183281

Differential Revision: https://phabricator.services.mozilla.com/D183282
2023-07-12 08:57:12 +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
cac40bd1b4 Bug 1837375 - HTMLTextArea::Clone has two codepaths for cloning the value. r=smaug
Unify them into one. The static document codepath also was setting
mValueChanged, so this seems fine.

Differential Revision: https://phabricator.services.mozilla.com/D180311
2023-06-08 15:14:41 +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
Vincent Hilla
ae0257ca20 Bug 675943 - Part 3: Clean up after implementing dirname. r=edgar
Depends on D178164

Differential Revision: https://phabricator.services.mozilla.com/D178278
2023-06-06 07:51:37 +00:00
Vincent Hilla
148e8efb7d Bug 675943 - Part 2: Implement dirname attr for textarea elements within forms. r=edgar
Depends on D175626

Differential Revision: https://phabricator.services.mozilla.com/D178164
2023-06-06 07:51:37 +00:00
Cosmin Sabou
50307024b4 Backed out 3 changesets (bug 675943) for causing wpt unexpected passes.
Backed out changeset 56d084bfc8b8 (bug 675943)
Backed out changeset 8f514549a81c (bug 675943)
Backed out changeset 33fabcece85d (bug 675943)
2023-05-24 14:43:06 +03:00
Vincent Hilla
f3ec29ff3d Bug 675943 - Part 3: Clean up after implementing dirname. r=edgar
Depends on D178164

Differential Revision: https://phabricator.services.mozilla.com/D178278
2023-05-24 08:04:52 +00:00
Vincent Hilla
1060b16a3b Bug 675943 - Part 2: Implement dirname attr for textarea elements within forms. r=edgar
Depends on D175626

Differential Revision: https://phabricator.services.mozilla.com/D178164
2023-05-24 08:04:52 +00:00
Vincent Hilla
400e875b6d Bug 1108425 - Fix dir=auto for textarea with rtl text. r=smaug
I copy-pasted all `SetDirectionFromValue`-related parts from HTMLInputElement to HTMLTextAreaElement

Differential Revision: https://phabricator.services.mozilla.com/D176999
2023-05-22 12:35:01 +00:00
Natalia Csoregi
b500f2692b Backed out changeset 2f394b22e31d (bug 1108425) for causing failures on bidi/726420-1.html. CLOSED TREE 2023-05-16 18:47:45 +03:00
Vincent Hilla
66bc5434e9 Bug 1108425 - Fix dir=auto for textarea with rtl text. r=smaug
I copy-pasted all `SetDirectionFromValue`-related parts from HTMLInputElement to HTMLTextAreaElement

Differential Revision: https://phabricator.services.mozilla.com/D176999
2023-05-16 13:49:07 +00:00
Emilio Cobos Álvarez
f37d9339a7 Bug 1833181 - Avoid attr lookups to check whether input value is empty. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D178078
2023-05-15 17:16:41 +00:00
Emilio Cobos Álvarez
407a5169d2 Bug 1833181 - Make SetValueChanged return void. r=smaug
Just a drive-by clean-up.

Differential Revision: https://phabricator.services.mozilla.com/D178077
2023-05-15 16:07:30 +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
Jan-Niklas Jaeschke
0ec5448edf Bug 1818686: Reset selection after replacing textarea content when no editor is present. r=masayuki
If the `.textContent` or `.defaultValue` attributes are used to change the content of a textarea,
according to the DOM Spec dictates first all children are removed and then a new child is added.
Removing all child elements must collapse the selection to 0.
However, the spec is not very precise on that matter,
see https://github.com/whatwg/html/issues/9028 .

This was currently not done (the selection was adjusted to the new length instead),
because the `Reset()` call was executed as a script runner,
therefore running (twice) after the new content has already been added.
With this change, the selection is adjusted to the new length explicitly
as soon as `ContentChanged()` is invoked, therefore updating it to 0
when content is removed.

Differential Revision: https://phabricator.services.mozilla.com/D172791
2023-03-17 12:52:46 +00:00
Masayuki Nakano
b754631550 Bug 822734 - Make HTMLTextAreaElement handle the mutation changes after all ranges handle them r=smaug
A mutation caused by a call of `Text::SplitText` is handled by 2 method calls,
`CharacterDataChanged` and `ContentInserted`, in `nsRange`.  Therefore,
`nsRange` stores some nodes for the later one, but
`HTMLTextAreaElement::ContentInserted` is called before it and that causes
another mutation which causes calling `nsRange::CharacterDataChanged` again.
Therefore, the assertion detects the recursive call.

For avoiding this issue, `HTMLTextAreaElement` needs to wait that all ranges
handle the mutation first.  Fortunately, `ContentInserted` is called with a
script blocker (*1).  Therefore, `HTMLTextAreaElement` can use script runner
to reset the anonymous subtree.

1. https://searchfox.org/mozilla-central/rev/f1dc2743777711c821d43f9911ee7c4447d60c8e/dom/base/nsINode.cpp#1566,1610

Differential Revision: https://phabricator.services.mozilla.com/D167766
2023-01-27 04:56:55 +00:00
Masayuki Nakano
ad4f56856b Bug 1800553 - part 2: Change HTMLAnchorElement::GetText to a const method r=smaug
This needs to change `nsContentUtils` methods because of used by the method.
Then, we can make some there callers are also `const` methods.

Depends on D162065

Differential Revision: https://phabricator.services.mozilla.com/D162066
2022-11-16 00:21:30 +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
Sylvestre Ledru
98949ee751 Bug 1754767 - Remove duplicate includes r=media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D138441
2022-02-11 10:01:15 +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