Commit Graph

405 Commits

Author SHA1 Message Date
Ting-Yu Lin
5cd68a11de Bug 1896516 Part 9 - Remove nsIScrollableFrame usages under dom/. r=layout-reviewers,emilio
Also, in EventStateManager, convert `ComputeScrollTarget()` and
`ComputeScrollTargetAndMayAdjustWheelEvent()` to return `ScrollContainerFrame*`
so that we can drop more unnecessarily `do_QueryFrame`.

Due to removing `nsIScrollableFrame` forward declaration in DOM headers, we have
to add `nsIScrollableFrame` forward declaration temporarily in
nsMenuPopupFrame.h to make this patch compile, but we'll remove it once we
remove `nsIScrollableFrame` under layout/.

Differential Revision: https://phabricator.services.mozilla.com/D211496
2024-05-30 06:32:21 +00:00
Sebastian Hengst
bf4dfe53f8 Backed out 15 changesets (bug 1896516) for causing scrolling crashes on macOS. a=backout
Backed out changeset fd6904338812 (bug 1896516)
Backed out changeset 2977ff81a23e (bug 1896516)
Backed out changeset c8a6b0e526d6 (bug 1896516)
Backed out changeset 3c06f22da72b (bug 1896516)
Backed out changeset f63b0c4335fe (bug 1896516)
Backed out changeset 6f7ab8adfa6e (bug 1896516)
Backed out changeset 997c9249dbed (bug 1896516)
Backed out changeset c964fccd5180 (bug 1896516)
Backed out changeset 7b481b747b7a (bug 1896516)
Backed out changeset 42e1bbe0ecb6 (bug 1896516)
Backed out changeset 717dac08b607 (bug 1896516)
Backed out changeset 2f0817331dbe (bug 1896516)
Backed out changeset b765169a7a8f (bug 1896516)
Backed out changeset a2d37b98273c (bug 1896516)
Backed out changeset ea9ecb543e66 (bug 1896516)
2024-05-29 11:22:52 +02:00
Sean Feng
78f2554a95 Bug 1899020 - Make selection.direction returns none when the selection is collapsed r=jjaschke,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D211787
2024-05-28 18:44:25 +00:00
Ting-Yu Lin
5d5204f810 Bug 1896516 Part 9 - Remove nsIScrollableFrame usages under dom/. r=layout-reviewers,emilio
Also, in EventStateManager, convert `ComputeScrollTarget()` and
`ComputeScrollTargetAndMayAdjustWheelEvent()` to return `ScrollContainerFrame*`
so that we can drop more unnecessarily `do_QueryFrame`.

Due to removing `nsIScrollableFrame` forward declaration in DOM headers, we have
to add `nsIScrollableFrame` forward declaration temporarily in
nsMenuPopupFrame.h to make this patch compile, but we'll remove it once we
remove `nsIScrollableFrame` under layout/.

Differential Revision: https://phabricator.services.mozilla.com/D211496
2024-05-28 04:46:20 +00:00
Jan-Niklas Jaeschke
af935609c3 Bug 1894666 - Custom Highlight API: Call NotifySelectionListener() for the correct selection type. r=masayuki,dom-core
Before this patch, the `AutoFrameSelectionBatcher` helper class would always call `NotifySelectionListeners()` for `SelectionType::eNormal`, even if the selection may have originated from Custom Highlight.

This patch moves the information that a change has occurred during batching from `nsFrameSelection` into the `Selection` instance, thus keeping the information per instance instead of globally.
When batching ends, `Selection::NotifySelectionListeners()` is called for all `Selection` instances depending on the flag.

Additionally, `Selection::NotifySelectionListeners()` is updated so that some Listeners (AutoCopyListener, SelectionChangeEvent, AccessibleCaret) are only notified for `SelectionType::eNormal`.

Differential Revision: https://phabricator.services.mozilla.com/D210130
2024-05-15 12:35:39 +00:00
Emilio Cobos Álvarez
365fef8d03 Bug 1896051 - Try to improve Selection::NotifySelectionChanged(). r=masayuki
The current code doesn't make a lot of sense:

 * We should do no changes (certainly not move focus and co) when we're
   batching, since we'll reenter.

 * We forgot to pop the change reasons and schedule content visibility
   updates when there were no listeners. I think this is a no-op change
   tho since nowadays we ~always create an accessible caret, even on
   desktop...

Try to improve it.

Differential Revision: https://phabricator.services.mozilla.com/D210051
2024-05-13 08:44:31 +00:00
Sean Feng
b910bf7165 Bug 1867058 - Part 12: Fix a bug in ShadowDOM selection where existing ranges get removed unexpectedly r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D203968
2024-03-25 13:41:00 +00:00
Sean Feng
0d24f21cae Bug 1867058 - Part 11: Ensure nsIFrame::SelectionStateChanged is called for frames in shadow tree. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D202317
2024-03-25 13:41:00 +00:00
Sean Feng
4a776dbb51 Bug 1867058 - Part 8: Update Selection to support across shadow dom selection r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D195310
2024-03-25 13:40:59 +00:00
Sean Feng
dafeea0a23 Bug 1867058 - Part 3: Implement Selection.GetComposedRanges r=jjaschke,dom-core
Spec: https://www.w3.org/TR/selection-api/#ref-for-dom-selection-getcomposedranges-1

Differential Revision: https://phabricator.services.mozilla.com/D195303
2024-03-25 13:40:56 +00:00
Sean Feng
69b0eb74ee Bug 1867058 - Part 1: Implement Selection.direction r=jjaschke,dom-core
This patch implements the .direction attribute

Spec: https://www.w3.org/TR/selection-api/#dom-selection-direction

Differential Revision: https://phabricator.services.mozilla.com/D195301
2024-03-25 13:40:56 +00:00
pstanciu
bcc6e01718 Backed out 12 changesets (bug 1867058) for causing bustages on AbstractRange.cpp
Backed out changeset 6254c9c51033 (bug 1867058)
Backed out changeset 2ad556d56736 (bug 1867058)
Backed out changeset a8bc41291ab3 (bug 1867058)
Backed out changeset c30869c03a70 (bug 1867058)
Backed out changeset 39c5816dff6b (bug 1867058)
Backed out changeset 42e226158dc9 (bug 1867058)
Backed out changeset 67bb7158a09f (bug 1867058)
Backed out changeset 7b5a689dc7fd (bug 1867058)
Backed out changeset 3cf108eb13a6 (bug 1867058)
Backed out changeset 8efda4cce80c (bug 1867058)
Backed out changeset 0837e15babab (bug 1867058)
Backed out changeset 8ce7972ea4df (bug 1867058)
2024-03-23 02:24:26 +02:00
Sean Feng
2eaaa6af8c Bug 1867058 - Part 12: Fix a bug in ShadowDOM selection where existing ranges get removed unexpectedly r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D203968
2024-03-22 17:05:52 +00:00
Sean Feng
1cf2fdc670 Bug 1867058 - Part 11: Ensure nsIFrame::SelectionStateChanged is called for frames in shadow tree. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D202317
2024-03-22 17:05:52 +00:00
Sean Feng
e71c2c9c02 Bug 1867058 - Part 8: Update Selection to support across shadow dom selection r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D195310
2024-03-22 17:05:51 +00:00
Sean Feng
f0a79fc086 Bug 1867058 - Part 3: Implement Selection.GetComposedRanges r=jjaschke,dom-core
Spec: https://www.w3.org/TR/selection-api/#ref-for-dom-selection-getcomposedranges-1

Differential Revision: https://phabricator.services.mozilla.com/D195303
2024-03-22 17:05:49 +00:00
Sean Feng
4aa13f1825 Bug 1867058 - Part 1: Implement Selection.direction r=jjaschke,dom-core
This patch implements the .direction attribute

Spec: https://www.w3.org/TR/selection-api/#dom-selection-direction

Differential Revision: https://phabricator.services.mozilla.com/D195301
2024-03-22 17:05:48 +00:00
Emilio Cobos Álvarez
95b8f63b04 Bug 1860328 - Track nsCaret position at the DOM level. r=sefeng,masayuki
This should avoid a bunch of paint invalidation issues with our caret
code (and seems simpler anyways).

Differential Revision: https://phabricator.services.mozilla.com/D204434
2024-03-18 09:12:57 +00:00
Jan-Niklas Jaeschke
f48048966b Bug 1881695: Implemented a new Cache to store the index of a node in a parent. r=smaug
This new cache implementation keeps the last N node/index combos in a stack-allocated array, which will be queried before calling nsINode::ComputeIndexOf().

Differential Revision: https://phabricator.services.mozilla.com/D203900
2024-03-11 19:02:11 +00:00
Natalia Csoregi
bda037520e Backed out changeset 37af5c6d011a (bug 1881695) for causing Bug 1884602 and Bug 1884601. CLOSED TREE 2024-03-11 10:47:07 +02:00
Jan-Niklas Jaeschke
9542d9c0d0 Bug 1881695: Implemented a new Cache to store the index of a node in a parent. r=smaug
This new cache implementation keeps the last N node/index combos in a stack-allocated array, which will be queried before calling nsINode::ComputeIndexOf().

Differential Revision: https://phabricator.services.mozilla.com/D203900
2024-03-09 11:13:55 +00:00
Cristina Horotan
a77498aaf0 Backed out changeset e72815765675 (bug 1881695) for causing Hazard failure at nsContentUtils.h 2024-03-07 23:47:13 +02:00
Jan-Niklas Jaeschke
4bc4c58c44 Bug 1881695: Implemented a new Cache to store the index of a node in a parent. r=smaug
This new cache implementation keeps the last N node/index combos in a stack-allocated array, which will be queried before calling nsINode::ComputeIndexOf().

Differential Revision: https://phabricator.services.mozilla.com/D203900
2024-03-07 16:57:16 +00:00
Narcis Beleuzu
0acdaa9355 Backed out changeset cc11e54ef4b1 (bug 1881695) for bustages on nsContentUtils.h 2024-03-07 18:01:44 +02:00
Jan-Niklas Jaeschke
7b6a9412e4 Bug 1881695: Implemented a new Cache to store the index of a node in a parent. r=smaug
This new cache implementation keeps the last N node/index combos in a stack-allocated array, which will be queried before calling nsINode::ComputeIndexOf().

Differential Revision: https://phabricator.services.mozilla.com/D203900
2024-03-07 15:14:06 +00:00
Gregory Pappas
48834b756d 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
Masayuki Nakano
0f8ffe6344 Bug 1878191 - Fix 2 iterating loops of selection ranges r=smaug,Jamie
These loops may run script.

In  `HyperTextAccessible`, it calls
`RemoveRangeAndUnselectFramesAndNotifyListeners`. So, chrome script which is not
directly related to this module may run in each call.  I think that using
`RemoveAllRanges` is better for here.  Before bug 1735446, this loop tried
to keep first range, but accidentally, I changed this loop delete all ranges.
However, `SetSelectionBoundsAt` will add a range if it's required and there is
no bug reports.  Therefore, I think keep the new behavior is better.

In `nsRange::DeleteFromDocument`, the loop may run mutation events too.
Therefore, it needs to store all ranges first.  Then, the preceding patch
changes the behavior here if a selection range is moved to different root.
Previously, it was deleted, but now, they are not touched.

Depends on D200606

Differential Revision: https://phabricator.services.mozilla.com/D200607
2024-02-07 04:34:38 +00:00
Peter Van der Beken
51ddf6034a Bug 1878631 - Remove some unused selection code. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D200620
2024-02-06 09:31:43 +00:00
Jan-Niklas Jaeschke
e95ad689e8 Bug 1878504: Don't trigger range reordering when a range is added. r=smaug
Ranges stored in Selection::StyledRanges are expected to be sorted by their start point.
In Bug 1872535 a range reordering was introduced which makes sure that static ranges are at the right spot after a DOM mutation has happened.
Reordering is necessary in two conditions:
- The document generation has changed (=There are changes to the DOM tree)
- A selection has changed (which would call NotfySelectionListeners())
However, when a range is added, it is not necessary to reorder, since the AddRange...() method inserts the new range at the correct spot (and reorders beforehand if necessary).

Differential Revision: https://phabricator.services.mozilla.com/D200592
2024-02-05 08:28:00 +00:00
Jan-Niklas Jaeschke
61332bd880 Bug 1872535: Deal with invalid StaticRanges and DOM mutations in Selection. r=smaug
Ranges inside of a `Selection` are expected to be sorted by their start point by the painting algorithms. Also, `StaticRange`s, which previously were not part of `Selection`, need to be considered for painting based on their `IsValid()` status.

This is now added by introducing a second array for invalid static ranges and an additional re-ordering method which needs to be called before paint that moves ranges in between.
 A potential change in range endpoints can be determined by observing the `Document`s generation and by adding a flag that's set to true in `Selection::NotifySelectionObservers()`.

Differential Revision: https://phabricator.services.mozilla.com/D198943
2024-01-23 13:27:41 +00:00
Masayuki Nakano
441e111542 Bug 1816581 - part 6: Move the static methods used for moving caret or considering caret geometry into new utility class r=emilio
The methods are in `nsCaret`, `nsFrameSelection` and `dom::Selection`.  That
makes harder to read, and they are called each other, so, they are reused for
different purpose.  Therefore, it must be better to move them into a new class.
Then, the name differences may become more unclear.  If you think so, feel free
to request renaming some methods of them.

Differential Revision: https://phabricator.services.mozilla.com/D197288
2023-12-27 04:42:12 +00:00
Masayuki Nakano
7d741ea0a2 Bug 1816581 - part 5: Make nsFrameSelection::PeekOffsetForCaretMove implement without members r=emilio
A caller of it should be independent from `nsFrameSelection` instance.
Therefore, I'd like to separate it to static method part and instance method
part.

Differential Revision: https://phabricator.services.mozilla.com/D197287
2023-12-27 04:42:11 +00:00
Masayuki Nakano
4b885ead17 Bug 1816581 - part 4: Make Selection::GetPrimaryFrameForFocusNode stop updating the caret association hint of nsFrameSelection r=emilio
Its name sounds a getter, but it updates the caret association hint of
`nsFrameSelection`, but at least, one of its callers,
`nsFrameSelection::PeekOffsetForCaretMove` shouldn't update it because it
just scans the previous or next position for caret.

Then, `Selection::GetPrimaryFrameForFocusNode` can be implemented with a
new static method which is useful for `PeekOffsetForCaretMove` when it becomes
a static method.

Differential Revision: https://phabricator.services.mozilla.com/D197286
2023-12-27 04:42:11 +00:00
Masayuki Nakano
119f1ae17d Bug 1816581 - part 3: Make Selection::GetPrimaryOrCaretFrameForNodeOffset static r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D197285
2023-12-27 04:42:10 +00:00
Masayuki Nakano
3e5aacdcfa Bug 1816581 - part 2: Make nsCaret::GetCaretFrameForNodeOffset static r=emilio
Oddly, it updates `nsFrameSelection` instance and some root callers may depend
on that. Therefore, this patch keep updating `nsFrameSelection` in the callers.

Differential Revision: https://phabricator.services.mozilla.com/D197284
2023-12-27 04:42:10 +00:00
Masayuki Nakano
d5a890bd62 Bug 1816581 - part 1: Make CaretAssociationHint an enum class r=emilio
For forward-decl-able.

Differential Revision: https://phabricator.services.mozilla.com/D197283
2023-12-27 04:42:09 +00:00
Masayuki Nakano
c8a6b93627 Bug 1612076 - Make AdjustCaretFrameForLineEnd stop scanning text node if first node is editable but reached non-editable one r=emilio
When pressing `ArrowLeft` key at:
```
<p>abc</p><p><span contenteditable=false>def</span>{}<br></p>
```
, caret is moved into the non-editable text because
`nsCaret::GetCaretFrameForNodeOffset` looks for a preceding text node from
the `BRFrame`. This is required if the preceding text node ends with a
collapsible white-space but followed by a `<br>` because the text frame
should not contain the white-space rect and `BRFrame` frame should be next
to it, i.e., the white-space looks like a overflown content.

So, for rendering a caret, the method needs to return non-editable text frame
even in the case, but for considering new caret position in the DOM tree, it
should not return non-editable text frame.

Therefore, this patch adds a param to `nsCaret::GetCaretFrameForNodeOffset()`
which forcibly return editable content frame or not and makes
`Selection::GetPrimaryOrCaretFrameForNodeOffset` call it with the new option
because its callers are the handler of caret navigation.

Differential Revision: https://phabricator.services.mozilla.com/D196259
2023-12-19 01:58:07 +00:00
Emilio Cobos Álvarez
d02e297b2d Bug 1624819 - Remove TaskCategory and other quantum dom remnants. r=smaug,media-playback-reviewers,credential-management-reviewers,cookie-reviewers,places-reviewers,win-reviewers,valentin,mhowell,sgalich,alwu
Sorry this is not a particularly easy patch to review. But it should be
mostly straight-forward.

I kept Document::Dispatch mostly for convenience, but could be
cleaned-up too / changed by SchedulerGroup::Dispatch. Similarly maybe
that can just be NS_DispatchToMainThread if we add an NS_IsMainThread
check there or something (to preserve shutdown semantics).

Differential Revision: https://phabricator.services.mozilla.com/D190450
2023-10-10 08:51:12 +00:00
Jan Varga
272327b326 Bug 1855134 - Move existing MOZ_TRY macros to a dedicated header file; r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D189226
2023-09-28 20:46:07 +00:00
Olli Pettay
c8c800a6a6 Bug 1843477, remove main thread only CC macros, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D187146
2023-09-26 12:36:20 +00:00
Cosmin Sabou
1483b97d75 Backed out 6 changesets (bug 1843477) for causing hazards failures. CLOSED TREE
Backed out changeset 64b093aa12a9 (bug 1843477)
Backed out changeset bdcd84c938d1 (bug 1843477)
Backed out changeset 05c882dd0d9a (bug 1843477)
Backed out changeset 1de814e5820d (bug 1843477)
Backed out changeset 6a0e19a60a5d (bug 1843477)
Backed out changeset 48942aff586f (bug 1843477)
2023-09-26 05:32:28 +03:00
Olli Pettay
c1089623d8 Bug 1843477, remove main thread only CC macros, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D187146
2023-09-25 21:09:00 +00:00
Cosmin Sabou
af07ece97f Backed out 3 changesets (bug 1843477) for causing hazards failures on TelemetryFixture.cpp. CLOSED TREE
Backed out changeset 4dd5d8ac600c (bug 1843477)
Backed out changeset e7bc0b63286a (bug 1843477)
Backed out changeset 4f45f40beaf7 (bug 1843477)
2023-09-08 20:21:46 +03:00
Olli Pettay
26df9a59fc Bug 1843477, remove main thread only CC macros, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D187146
2023-09-08 14:51:48 +00:00
Daniel Holbert
623c585bf9 Bug 1802466 part 2: Change GetSelectionEndPointGeometry to handle vertical-writing-mode text nodes. r=emilio
This function had some code that we hadn't yet updated to support vertical
writing modes.  This patch makes it more generic so that it can properly handle
vertical-writing-mode text nodes (so that we can e.g. properly keep the caret
scrolled into view, in a vertical-writing-mode textfield).

I'm just focusing on vertical vs. horizontal generification for now.  I'm not
entirely sure if it makes sense to make it even-more-generic-still to support
reversed-inline-direction writing modes as well. I wasn't able to trigger any
issues with those in some brief testing, so I think this patch is sufficient
as-is, but I left a TODO(dholbert) code-comment to call out that ambiguity
that's still present in the code.

Differential Revision: https://phabricator.services.mozilla.com/D187160
2023-09-07 08:22:27 +00:00
Daniel Holbert
e7c77fa2d0 Bug 1802466 part 1: Refactor computation of outparam rect in GetSelectionEndPointGeometry. r=emilio
This patch doesn't change behavior. It's just laying the groundwork for the
next patch which adds vertical-writing-mode support.

(This patch adds some documentation in terms of logical axes, though, which
will become accurate as of the next patch in this series.)

Differential Revision: https://phabricator.services.mozilla.com/D187161
2023-09-07 08:22:26 +00:00
Narcis Beleuzu
e3ab2fae7b Backed out 3 changesets (bug 1802466) for mochitest failure on test_composition_text_querycontent.xhtml . CLOSED TREE
Backed out changeset 1af6a9b30e2c (bug 1802466)
Backed out changeset 9461b0e136d3 (bug 1802466)
Backed out changeset 59c6e8943e53 (bug 1802466)
2023-09-06 21:24:32 +03:00
Daniel Holbert
7e7b8a50bc Bug 1802466 part 2: Change GetSelectionEndPointGeometry to handle vertical-writing-mode text nodes. r=emilio
This function had some code that we hadn't yet updated to support vertical
writing modes.  This patch makes it more generic so that it can properly handle
vertical-writing-mode text nodes (so that we can e.g. properly keep the caret
scrolled into view, in a vertical-writing-mode textfield).

I'm just focusing on vertical vs. horizontal generification for now.  I'm not
entirely sure if it makes sense to make it even-more-generic-still to support
reversed-inline-direction writing modes as well. I wasn't able to trigger any
issues with those in some brief testing, so I think this patch is sufficient
as-is, but I left a TODO(dholbert) code-comment to call out that ambiguity
that's still present in the code.

Differential Revision: https://phabricator.services.mozilla.com/D187160
2023-09-06 17:16:46 +00:00
Daniel Holbert
392722c59e Bug 1802466 part 1: Refactor computation of outparam rect in GetSelectionEndPointGeometry. r=emilio
This patch doesn't change behavior. It's just laying the groundwork for the
next patch which adds vertical-writing-mode support.

(This patch adds some documentation in terms of logical axes, though, which
will become accurate as of the next patch in this series.)

Differential Revision: https://phabricator.services.mozilla.com/D187161
2023-09-06 17:16:46 +00:00
Masayuki Nakano
de5abd5945 Bug 1840700 - Make Selection::AddRangeAndSelectFramesAndNotifyListenersInternal() update interline position even if it does nothing r=jjaschke
It always set to "start of next line" when new range was added.  However,
after bug 1815802, it does nothing when adding range is one of its ranges.
Therefore, if interline position is set to "end of line" by our internal
code, like editor, `getSelection().addRange(getSelection().getRangeAt(0))`
keeps the last interline position.

Differential Revision: https://phabricator.services.mozilla.com/D182300
2023-06-28 07:59:13 +00:00