Commit Graph

316 Commits

Author SHA1 Message Date
Masayuki Nakano
daf79ccd1e Bug 1735446 - part 4: Make Selection::GetRangeAt() take uint32_t instead of int32_t r=smaug
It's an internal API corresponding to `Selection.getRangeAt` DOM API.
I think that it should use `uint32_t` rather than `size_t` because of the
consistency with the DOM API and `Selection::RangeCount()`.

This patch fixes all callers of `GetRangeAt()`, and rewrites it with ranged-
loops unless original ones do not refer `RangeCount()` every time and may run
script in the loop.

Differential Revision: https://phabricator.services.mozilla.com/D128848
2021-12-09 07:35:09 +00:00
Masayuki Nakano
3637714825 Bug 1735446 - part 3: Make Selection use size_t and Maybe<size_t> for handling index of array of the ranges r=smaug
Since it's the standard manner of `nsTArray`.

Differential Revision: https://phabricator.services.mozilla.com/D128846
2021-12-09 06:43:48 +00:00
Masayuki Nakano
fcf15637ac Bug 1735446 - part 2: Make Selection::SetAnchorFocusRange() take size_t for range index instead of int32_t r=mbrodesser
Since `size_t` is used by `nsTArray` as its index type, and it manages the array
of ranges.

Differential Revision: https://phabricator.services.mozilla.com/D128845
2021-12-09 06:16:56 +00:00
Masayuki Nakano
afee8ce4d7 Bug 1735446 - part 1: Make Selection use uint32_t for handling offset in DOM nodes r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D128844
2021-12-09 00:45:19 +00:00
Greg Tatum
69f3ddd0a8 Bug 1738057 - Split out BidiEmbeddingLevel into its own file; r=platform-i18n-reviewers,dminor
This should speed up re-compile times, as mozilla/intl/Bidi.h will only
be included in a few places.

Differential Revision: https://phabricator.services.mozilla.com/D129662
2021-11-16 15:11:58 +00:00
Greg Tatum
8eeb570d82 Bug 1719546 - Replace nsBidi with mozilla::intl::Bidi; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D128793
2021-10-20 14:01:21 +00:00
Butkovits Atila
b4ce43ec95 Backed out 3 changesets (bug 1719546) for causing SM bustages at Bidi.h. CLOSED TREE
Backed out changeset c4d6ffc7e445 (bug 1719546)
Backed out changeset a1f7ed6c4251 (bug 1719546)
Backed out changeset e69fc596f2c3 (bug 1719546)
2021-10-19 21:09:47 +03:00
Greg Tatum
c671a34e08 Bug 1719546 - Replace nsBidi with mozilla::intl::Bidi; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D128793
2021-10-19 16:55:36 +00:00
Masayuki Nakano
ffa5244e07 Bug 1732845 - Add nsINode::IsInDesignMode() to check whether the node is directly in design mode r=smaug
There are a lot of check of `Document`'s editable state **with** comments. This
means that it's unclear for developers that only `Document` node is editable in
design mode.

Additionally, there are some points which use composed document rather than
uncomposed document even though the raw API uses uncomposed document. Comparing
with the other browsers, checking uncomposed document is compatible behavior,
i.e., nodes in shadow trees are not editable unless `contenteditable`.

Therefore, `nsINode` should have a method to check whether it's in design mode
or not.

Note that it may be called with a node in UA widget.  Therefore, this patch
adds new checks if it's in UA widget subtree or native anonymous subtree,
checking whether it's in design mode with its host.

Differential Revision: https://phabricator.services.mozilla.com/D126764
2021-10-12 03:14:43 +00:00
Kagami Sascha Rosylight
c13d219483 Bug 1648944 - Part 1: Split select event flags into each event name r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D86700
2021-07-20 13:46:44 +00:00
Brindusan Cristian
0c4fbf4b49 Backed out 5 changesets (bug 1648944) for causing wpt failures in idlharness.window.html.
CLOSED TREE

Backed out changeset 598789cabb9f (bug 1648944)
Backed out changeset f464507bef57 (bug 1648944)
Backed out changeset fb2b9ceb7c69 (bug 1648944)
Backed out changeset a73cfada74cf (bug 1648944)
Backed out changeset 3f41877ffd14 (bug 1648944)
2021-07-20 13:29:49 +03:00
Kagami Sascha Rosylight
dff494f1a7 Bug 1648944 - Part 1: Split select event flags into each event name r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D86700
2021-07-20 08:59:47 +00:00
Kagami Sascha Rosylight
96a9b3d1e1 Bug 1717552 - Remove dom.select_events.enabled r=masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D118639
2021-06-24 12:30:35 +00:00
Kagami Sascha Rosylight
a2c61d2bfe Bug 1715819 - Select the text node if exists in TextEditor::SelectEntireDocument r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117444
2021-06-12 11:04:51 +00:00
Kagami Sascha Rosylight
cc180203f9 Bug 1713491 - Return std::pair from nsIFrame::GetOffsets r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D117520
2021-06-11 23:54:06 +00:00
Butkovits Atila
645878eef7 Backed out changeset aa6c7477c4d2 (bug 1713491) for causing build bustages on nsIFrame.cpp. CLOSED TREE 2021-06-12 00:12:06 +03:00
Kagami Sascha Rosylight
c15b9875ad Bug 1713491 - Return std::pair from nsIFrame::GetOffsets r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D117520
2021-06-11 18:53:28 +00:00
Dorel Luca
1406700f5f Backed out changeset 17e7b969b830 (bug 1713491) for Linux build bustage in gecko/dom/events/ContentEventHandler.cpp. CLOSED TREE 2021-06-11 17:52:10 +03:00
Kagami Sascha Rosylight
9b322e9f67 Bug 1713491 - Return std::pair from nsIFrame::GetOffsets r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D117520
2021-06-11 11:37:11 +00:00
Kagami Sascha Rosylight
6d0a641e94 Bug 1715882 - Return void from Selection::Clear and ::NotifySelectionListeners r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117469
2021-06-11 09:10:35 +00:00
Kagami Sascha Rosylight
3bd6c78fdc Bug 1714640 - Add AdjustFrameForLineStart call in Selection::ScrollIntoView r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D117009
2021-06-08 16:21:36 +00:00
Kartikaya Gupta
7c375a1189 Bug 1694847 - Remove the expired SCROLL_INPUT_METHODS telemetry probe. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D116320
2021-05-31 21:36:35 +00:00
Emilio Cobos Álvarez
79b783704d Bug 1708303 - Fix scroll-margin implementation. r=hiro
So that margin is not included in the rect for visibility calculations,
and padding and margin are accounted properly on them.

Differential Revision: https://phabricator.services.mozilla.com/D113853
2021-05-06 00:54:14 +00:00
Emilio Cobos Álvarez
79cfc09871 Bug 1701928 - Selection scrolling should not ignore scroll-{margin,padding}. r=hiro,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D110440
2021-04-02 12:14:19 +00:00
Ting-Yu Lin
5902370bb0 Bug 1696584 - Remove UnionRectEdges() and replace the callers with the equivalent UnionEdges(). r=emilio
UnionRectEdges() and UnionEdges() are equivalent, and the later has a
modern interface with a shorter name. Let's remove the former.

Differential Revision: https://phabricator.services.mozilla.com/D107315
2021-03-07 23:07:08 +00:00
Kagami Sascha Rosylight
7057dbdc56 Bug 1671768 - Part 4: Use MOZ_CAN_RUN_SCRIPT for Selection::RemoveAllRanges r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D103780
2021-02-03 21:52:48 +00:00
Kagami Sascha Rosylight
0c2cd22bb4 Bug 1671768 - Part 1: Use MOZ_CAN_RUN_SCRIPT for Selection::StyledRanges::MaybeFocusCommonEditingHost r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D103777
2021-02-03 21:52:02 +00:00
Kagami Sascha Rosylight
d0222ca683 Bug 1688090 - Prefer .Throw*Error with better error messages in Selection r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D102671
2021-01-22 12:00:08 +00:00
Masayuki Nakano
1a6ee46590 Bug 1357365 - part 5: Make TypeInState::OnSelectionChange stop keeping link style for new inserting content when selection is changed by JS r=m_kato,edgar
This is the most important situation.  If selection is collapsed to a edge of a
link, the other browsers does not insert new content into the link.  So, from
the point of view of web developers, this cause should work exactly same as
the other browsers.

Note that the new failures in `editing/run/inserttext.html` are passed only
on Gecko.  So, the test should be updated after fixing this bug.

Differential Revision: https://phabricator.services.mozilla.com/D101004
2021-01-13 01:55:40 +00:00
Mirko Brodesser
2747a25af6 Bug 1685303: part 4) Add logging to Selection::AddRangesForSelectableNodes. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D101354
2021-01-11 15:03:05 +00:00
Mirko Brodesser
6a7b4a7cfc Bug 1685303: part 2) Add debug logging for Selection::NotifySelectionListeners. r=smaug
Depends on D100984

Differential Revision: https://phabricator.services.mozilla.com/D100985
2021-01-07 22:51:13 +00:00
Kagami Sascha Rosylight
949c6feb7f Bug 1680167 - Part 3: MOZ_CAN_RUN_SCRIPT_BOUNDARY in dom/base r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D98626
2020-12-03 22:08:36 +00:00
Kagami Sascha Rosylight
be1d9a20b9 Bug 1615296 - Part 1: Remove MOZ_CAN_RUN_SCRIPT_BOUNDARY from Selection::Collapse r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D93598
2020-10-16 22:22:48 +00:00
Emilio Cobos Álvarez
f7cc4219e2 Bug 1670876 - Add support for printing selection in shadow dom. r=nordzilla
Recursive the things all :^)

The fix to the "corresponding node" bits in Document.cpp should be
pretty straight-forward. The fix in nsPrintJob is a bit more subtle:

The way printing selection works is literally "select everything else,
then call Selection.deleteFromDocument on that". We need to do the same
with shadow DOM, which involves skipping over shadow trees, and dealing
with selecting bits in ancestor trees as needed.

Note that for multi-range-selection case this technically relies on the
order of the ranges being shadow-tree-inclusive. We don't support
multi-range selection in shadow dom well, afaict, but I've added a
comment to the code to that effect.

Differential Revision: https://phabricator.services.mozilla.com/D93357
2020-10-16 17:36:37 +00:00
Kartikaya Gupta
d143abb49d Bug 1670003 - Add back the scroll input methods telemetry. r=botond
This is mostly a revert of the patch in bug 1425686 that removed the old
probe, but rebased to new code locations and clang-formatted. The histogram
entry is also updated with new bug numbers and fields.

The next patch will refine some of these telemetry recording points; the patch
is split into two for easier reviewing as this part is basically what landed
originally.

Differential Revision: https://phabricator.services.mozilla.com/D92995
2020-10-10 17:41:47 +00:00
Botond Ballo
1074cb3575 Bug 1667594 - Move nsLayoutUtils::RectCallback to namespace scope. r=emilio,jgilbert
This allows it to be forward-declared (while a nested class cannot be),
such that headers files that use RectCallback by pointer or reference
do not need to include nsLayoutUtils.h.

This avoids including nsLayoutUtils.h in nsRange.h.

Differential Revision: https://phabricator.services.mozilla.com/D91685
2020-09-30 21:06:47 +00:00
Kagami Sascha Rosylight
22e72f0233 Bug 1666537 - Peek logical line end in bidi context r=emilio,jfkthame
Previously it peeked to the visually leftmost/rightmost position, while such position can actually be a middle of the line in mixed bidi context and thus incorrectly skip some frame when a selection extends. This patch corrects the behavior.

Differential Revision: https://phabricator.services.mozilla.com/D91274
2020-09-25 13:36:50 +00:00
Kagami Sascha Rosylight
42d833f6b3 Bug 1623413 - Part 3: Skip limiter check in CollapseToStart/End r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88992
2020-09-03 03:45:24 +00:00
Kagami Sascha Rosylight
a20339adb5 Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
Depends on D88702

Differential Revision: https://phabricator.services.mozilla.com/D88920
2020-09-03 03:45:26 +00:00
Kagami Sascha Rosylight
a3c3191e52 Bug 1623413 - Part 1: Skip selection point check when called from JS r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88702
2020-09-03 11:55:22 +00:00
Mihai Alexandru Michis
d775b8dd6d Backed out 3 changesets (bug 1623413) for causing failures in Selection_collapse.html
CLOSED TREE

Backed out changeset d3d67293f115 (bug 1623413)
Backed out changeset 75ed1b8a5c67 (bug 1623413)
Backed out changeset 0eef32d6a454 (bug 1623413)
2020-09-03 05:37:49 +03:00
Kagami Sascha Rosylight
73dd0877c0 Bug 1623413 - Part 3: Skip limiter check in CollapseToStart/End r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88992
2020-09-02 23:42:27 +00:00
Kagami Sascha Rosylight
3eab64fd31 Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
Depends on D88702

Differential Revision: https://phabricator.services.mozilla.com/D88920
2020-09-02 23:42:27 +00:00
Kagami Sascha Rosylight
96b5aec4f8 Bug 1623413 - Part 1: Skip selection point check when called from JS r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88702
2020-09-01 09:28:26 +00:00
Simon Giesecke
d2e71d5859 Bug 1648010 - Remove NS_NAMED_LITERAL_CSTRING and NS_NAMED_LITERAL_STRING macros. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80631
2020-07-01 08:42:31 +00:00
Simon Giesecke
a69d79b6db Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
Kagami Sascha Rosylight
b31045dcce Bug 1645003 - Return pointer from GetPrimaryOrCaretFrameForNodeOffset and its deps r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D80063
2020-06-18 10:26:47 +00:00
Kagami Sascha Rosylight
fbef1cfbce Bug 1644868 - Return pointer from GetPrimaryFrameFor* r=jfkthame
Those methods have two sources to check after call: the return value and the pointer. This can be confusing as a caller may think they should check both when they don't need to. Since the two always behaves together (a valid pointer + NS_OK, or nullptr + NS_ERROR_FAILURE), this replaces the return value with the pointer.

Differential Revision: https://phabricator.services.mozilla.com/D79196
2020-06-11 10:56:11 +00:00
Emilio Cobos Álvarez
30cc71cb06 Bug 312971 - Unprefix -moz-read-write / -moz-read-only. r=edgar
And remove some duplicated tests from WPT.

Differential Revision: https://phabricator.services.mozilla.com/D75231
2020-05-14 16:46:08 +00:00
Mirko Brodesser
3bbda64677 Bug 1635709: part 18) Correct assignment to aDidAddRange in Selection::MaybeAddTableCellRange. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D75100
2020-05-14 10:08:55 +00:00