87 Commits
Author SHA1 Message Date
Sylvestre Ledru 2f632434a3 Bug 2036402 - Apply std::move in editor where values can be moved instead of copied r=dom-core,smaug
Differential Revision: https://phabricator.services.mozilla.com/D298107
2026-05-04 11:13:42 +00:00
Emilio Cobos Álvarez 1ddad57128 Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug
Make them concrete classes rather than interfaces, and make the
inheritance chain simpler.

Differential Revision: https://phabricator.services.mozilla.com/D296484
2026-04-28 07:38:27 +00:00
Silaghi ce61f876cc Revert "Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug" for causing wpt failures at BaseContentList
This reverts commit cde3e5607b.
2026-04-28 03:43:46 +00:00
Emilio Cobos Álvarez cde3e5607b Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug
Make them concrete classes rather than interfaces, and make the
inheritance chain simpler.

Differential Revision: https://phabricator.services.mozilla.com/D296484
2026-04-28 00:24:11 +00:00
Sylvestre Ledru 9f5cc05eee Bug 2023419 - Remove Emacs/Vim modelines from editor/ r=masayuki
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287844
2026-03-16 12:52:41 +00:00
Masayuki Nakano 8dd9d35fa1 Bug 1964011 - part 2: Make the editor classes log text input r=m_kato
Depends on D248368

Differential Revision: https://phabricator.services.mozilla.com/D248369
2025-05-09 06:49:28 +00:00
Masayuki Nakano 617c636f1f Bug 1717155 - part 1: Make TextEditor use GetTextNode() more r=m_kato
The anonymous `<div>` of `TextEditor` has only one `Text` as its first child.
Therefore, we can make `TextEditor` simpler to access the `Text` node.

Differential Revision: https://phabricator.services.mozilla.com/D240419
2025-03-13 05:25:45 +00:00
Masayuki Nakano 8bb457917b Bug 1949364 - Make EditorBase::HandleInsertText take further information of composition state r=m_kato
In bug 1940377, `HandleInsertText` will need to normalize surrounding
white-spaces after updating composition string at composition end.  To consider
it easier, it's nicer that it takes more detail for the purpose of inserting
text.

Differential Revision: https://phabricator.services.mozilla.com/D239077
2025-02-26 05:56:24 +00:00
Masayuki Nakano 6dec21102f Bug 1948527 - Get rid of EditorBase::DeleteSelectionWithTransaction because of used only by TextEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D238409
2025-02-18 22:34:41 +00:00
Masayuki Nakano ad9fbd6b1a Bug 1947099 - Get rid of unused aDocument parameter of EditorBase::InsertTextWithTransaction r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D237518
2025-02-11 23:42:53 +00:00
Masayuki Nakano 9fd27e7690 Bug 1937289 - Make AutoRangeArray::ExtendAnchorFocusRangeFor stop using nsFrameSelection r=m_kato,jjaschke,dom-core
`AutoRangeArray` is created for making some handlers of the editor classes free
from `Selection` and `nsFrameSelection` while handling the edit actions.
However, the method still depends on `nsFrameSelection` instance since its
callees are instance methods of `nsFrameSelection`.

However, `EditContext` requires completely free methods to compute target
ranges of `beforeinput`.  Therefore, we need to make it not depend on
`Selection` nor `nsFrameSelection`.

The common method, `nsFrameSelection::CreateRangeExtendedToSomewhere`, requires
`PresShell`, selection limiter which is set only when the selection is an
independent selection like in a selection for a text control, selection
ancestor limiter which is set only when an editing host has focus, caret
association hint to put caret to end of preceding line or start of following
line if selection range is collapsed at a line break and caret bidi level for
considering caret position around line break in bidi text.  They are now stored
by `nsFrameSelection` and modified when selection range is changed in some
cases.  Basically, the method is called without updating its ranges and if and
only if it's initialized with `Selection`.  So, simply caching the
`nsFrameSelection`'s values solves the issues in the most cases, but this
patch makes `AutoRangeArray` adjust the value only when its `Collapse` is
called because `Selection` automatically updates it and we can compute the
value without `Selection` nor `nsFrameSelection`.

After applying this patch, `AutoRangeArray` has two meanings, one is the
instance is a proxy for `Selection`.  The other is a container for a range to
call methods which take pointer or reference to it.  To make this differences
checked at build time, this patch creates a new subclass of it, and renamed to
`AutoClonedRangeArray` to make it clearer that what are stored in the array.

Oddly, `AutoRangeArray(nsRange&)` constructor has not been cloned.  Therefore,
I make it and its subclass version clone before storing into the array.  Then,
one caller needs to change which range should be tracked.

Differential Revision: https://phabricator.services.mozilla.com/D232174
2025-01-07 01:56:52 +00:00
Masayuki Nakano 6c98d18af0 Bug 1923251 - part 1: Make HTMLEditor clean up unnecessary padding line break when inserting something immediately before it r=m_kato
Both Chrome and Safari clean up unnecessary padding line breaks when they become
unnecessary.  Therefore, we should follow that.

Differential Revision: https://phabricator.services.mozilla.com/D225038
2024-12-13 01:18:53 +00:00
Butkovits Atila c97b034936 Backed out 6 changesets (bug 1923251, bug 1925635) for causing failures at test_editor.xhtml. CLOSED TREE
Backed out changeset 9cef3db4f874 (bug 1925635)
Backed out changeset 37e3129c7a6a (bug 1925635)
Backed out changeset b9ee5a52e135 (bug 1925635)
Backed out changeset 3433a2d6cbcd (bug 1925635)
Backed out changeset 5c700bed542e (bug 1923251)
Backed out changeset d11aeeb31a71 (bug 1923251)
2024-12-09 06:35:34 +02:00
Masayuki Nakano e1b31452df Bug 1923251 - part 1: Make HTMLEditor clean up unnecessary padding line break when inserting something immediately before it r=m_kato
Both Chrome and Safari clean up unnecessary padding line breaks when they become
unnecessary.  Therefore, we should follow that.

Differential Revision: https://phabricator.services.mozilla.com/D225038
2024-12-09 00:19:39 +00:00
Masayuki Nakano 89f7508482 Bug 1923251 - Backout almost all of D225038 except WPT part
The backed-out patch is Bug 1923251 (part 1).

This does not backout the changes in `EditorDOMPoint.h`, `WSRunObject.h` and
template method instantiation in `WSRunObject.cpp` to make some other my local
changes keep working.  (They won't affect to any behavior.)

Depends on D226631

Differential Revision: https://phabricator.services.mozilla.com/D226632
2024-10-23 18:07:53 +00:00
Masayuki Nakano a5dd21ba62 Bug 1923251 - part 1: Make HTMLEditor clean up unnecessary padding line break when inserting something immediately before it r=m_kato
Both Chrome and Safari clean up unnecessary padding line breaks when they become
unnecessary.  Therefore, we should follow that.

Differential Revision: https://phabricator.services.mozilla.com/D225038
2024-10-16 05:59:50 +00:00
Stanca Serban 1234a535b1 Backed out 2 changesets (bug 1923251) for causing build bustages in HTMLEditor.cpp. CLOSED TREE
Backed out changeset 526e6dccb137 (bug 1923251)
Backed out changeset b61267a75e51 (bug 1923251)
2024-10-16 02:55:14 +03:00
Masayuki Nakano 23bb197be6 Bug 1923251 - part 1: Make HTMLEditor clean up unnecessary padding line break when inserting something immediately before it r=m_kato
Both Chrome and Safari clean up unnecessary padding line breaks when they become
unnecessary.  Therefore, we should follow that.

Differential Revision: https://phabricator.services.mozilla.com/D225038
2024-10-15 23:14:58 +00:00
Masayuki Nakano 544f45533f Bug 1893351 - part 1: Add an option to make EditorBase::InsertTextWithTransaction always create a Text node r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D211697
2024-05-30 00:42:41 +00:00
Masayuki Nakano a96712fcc3 Bug 1858590 - Make TextEditor::HandleInsertText stop handling the command for empty string after deleting selection r=m_kato
The handler has an early-return block for the case inserting empty text.
However, it's done before deleting selection, but it should be done after that.

Differential Revision: https://phabricator.services.mozilla.com/D190904
2023-10-19 03:16:08 +00:00
Masayuki Nakano f84a751fe1 Bug 1839793 - Move EditorBase::FindBetterInsertionPoint into TextEditor r=m_kato
Currently it runs if the instance is a `TextEditor` or it's in the plaintext
mode of `HTMLEditor`.  However, it does not make sense to run it only in
specific mode of `HTMLEditor`, and most part does not make sense for
`HTMLEditor`.

This patch moves the method to `TextEditor`, and for
`EditorBase::InsertTextWithTransaction()` and
`AutoRangeArray::ExtendAnchorFocusRangeFor()`, adds new method to
`EditorDOMPointBase` to get a text node position if it points around
a text node.

Differential Revision: https://phabricator.services.mozilla.com/D181835
2023-06-27 04:23:09 +00:00
Masayuki Nakano 3e05a5438f Bug 1815383 - part 1: Make InsertTextTransaction::DoTransaction stop updating Selection directly r=m_kato
And also this patch makes its only user,
`EditorBase::InsertTextIntoTextNodeWithTransaction`, and its only caller,
`EditorBase::InsertTextWithTransaction`, return `InsertTextResult` for
returning both end of inserted text and caret point suggestion.  Note that
if it's for IME composition, `CompositionTransaction` needs to update
`Selection` directly.  Therefore, caret point may be unset under composition
to updating `Selection` to wrong point (it seems that
`TextEditor::HandleInsertText` can be simplified later because of this change).

Depends on D169044

Differential Revision: https://phabricator.services.mozilla.com/D169744
2023-02-17 08:25:24 +00:00
Masayuki Nakano 599e32db5d Bug 1797247 - part 4: Make EditorBase::DeleteRangesWithTransaction not touch Selection directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D169041
2023-02-15 22:40:14 +00:00
Andrew McCreight 3f5dddd6cd Bug 1794811, part 1 - Include nsISupports.h instead of nsISupportsBase.h. r=necko-reviewers,nika,valentin
nsISupports.h includes nsISupportsBase.h, so it should be equivalent.

In the next patch, I'm changing things so that nsISupports is defined in
nsISupports.h instead of nsISupportsBase.h, and deleting the latter, so
this change will be needed anyways. I'm guessing people were using IWYU
or something like that.

Differential Revision: https://phabricator.services.mozilla.com/D159169
2022-10-17 16:09:22 +00:00
Masayuki Nakano 767307c38d Bug 1791501 - Use EditActionResult as ok type of mozilla::Result r=m_kato
Any callers do not refer "ignored", "handled" and "cancel" state without
checking whether the method returns error or not.  Therefore, error state
can be (and should be) managed by `mozilla::Result`'s error state.

Perhaps, it should store a caret position later because deletion handlers
of `HTMLEditor` use it, but update `Selection` immediately.

Differential Revision: https://phabricator.services.mozilla.com/D158080
2022-09-28 07:21:37 +00:00
Masayuki Nakano 4d67291c6c Bug 1789967 - part 2: Make TextEditor and HTMLEditor implement EditorBase::CollapseSelectionToEndOfLastLeafNode by themselves r=m_kato
It does different thing for `TextEditor` and `HTMLEditor`, and used almost
internally.  Therefore, it should be implemented in the sub classes and
we should name them better.

Differential Revision: https://phabricator.services.mozilla.com/D157407
2022-09-22 06:17:36 +00:00
Iulian Moraru fd8c1d81c9 Backed out 2 changesets (bug 1789967) for causing wd failures on content_editable.py. CLOSED TREE
Backed out changeset f2f431ee78a3 (bug 1789967)
Backed out changeset edac234f1eba (bug 1789967)
2022-09-21 04:40:46 +03:00
Masayuki Nakano d4c735e5e4 Bug 1789967 - part 2: Make TextEditor and HTMLEditor implement EditorBase::CollapseSelectionToEndOfLastLeafNode by themselves r=m_kato
It does different thing for `TextEditor` and `HTMLEditor`, and used almost
internally.  Therefore, it should be implemented in the sub classes and
we should name them better.

Differential Revision: https://phabricator.services.mozilla.com/D157407
2022-09-21 00:38:23 +00:00
Masayuki Nakano 276855fa75 Bug 1775381 - Move AutoRangeArray from EditorUtils.h to its own header and cpp file r=m_kato
Depends on D152982

Differential Revision: https://phabricator.services.mozilla.com/D153063
2022-08-04 05:39:16 +00:00
Masayuki Nakano c56be53f24 Bug 1765018 - part 4: Make EditorBase::InsertTextWithTransaction treat only EditorDOMPoint r=m_kato
In theory, methods which touch the DOM tree should take `EditorDOMPoint` rather
than `EditorRawDOMPoint`.  And now, we can return meaningful value if it
succeeded, with `Result`.

Therefore, this patch makes it return `Result<EditorDOMPoint, nsresult>` instead
of taking an out argument, and take only `EditorDOMPoint` rather than taking any
type of `EditorDOMPointBase` since it's always converted to `EditorDOMPoint`.

Differential Revision: https://phabricator.services.mozilla.com/D143881
2022-04-20 23:46:19 +00:00
Masayuki Nakano 90a36f5bcc Bug 1765018 - part 3: Make EditorBase::FindBetterInsertionPoint be a template method r=m_kato
To avoid the unnecessary conversion between `EditorDOMPoint` and
`EditorRawDOMPoint`, it should be a template method which can take/return either
`EditorDOMPoint` or `EditorRawDOMPoint`.

Differential Revision: https://phabricator.services.mozilla.com/D143880
2022-04-20 23:41:28 +00:00
Masayuki Nakano 083c6837d0 Bug 1765018 - part 2: Make EditorBase::Get(Start|End)Point return EditorDOMPoint or EditorRawDOMPoint r=m_kato
This avoids unnecessary conversion at the callers' side, although they should be
omitted by the complier.

Differential Revision: https://phabricator.services.mozilla.com/D143879
2022-04-20 23:35:18 +00:00
Masayuki Nakano 57ba857907 Bug 1764684 - part 2: Make editor use methods of EditorBase to collapse Selection r=m_kato
First, move methods of `HTMLEditor` which collapse `Selection` to `EditorBase`.
Then, make editor stop accessing `Selection::CollapseInLimiter` directly.

Differential Revision: https://phabricator.services.mozilla.com/D143814
2022-04-20 14:36:52 +00:00
Masayuki Nakano 320035af5a Bug 1764679 - Make GetInterlinePosition and SetInterlinePosition work with new enum class r=smaug
It's hard to remember what the `bool` value of them means.  Therefore, there
are a lot of comment around the API users to explain what they do.  For making
it clearer and reducing the risk of specifying opposite value, they should work
with an `enum class`.

Differential Revision: https://phabricator.services.mozilla.com/D143812
2022-04-20 14:24:55 +00:00
Masayuki Nakano b40b9a49d9 Bug 1758420 - part 3: Rename TextComposition::GetStartRef() and TextComposition::GetEndRef() r=m_kato
They return IME selection range rather than composition string range.  I.e.,
when the composition does not have IME selections anymore, e.g., at committing,
they return non-set `RawRangeBoundary`.

For making the result meaning clearer, they should be
`FirstIMESelectionStartRef` and `LastIMESelectionEndRef`.

Depends on D141194

Differential Revision: https://phabricator.services.mozilla.com/D141195
2022-03-18 06:34:47 +00:00
Masayuki Nakano 22aa786ab3 Bug 1753508 - Add logger of selection batch r=smaug
This was required for debugging the bug.

Differential Revision: https://phabricator.services.mozilla.com/D139350
2022-03-11 02:24:24 +00:00
Masayuki Nakano ba7e54426e Bug 1734507 - Make TextEditor guarantee that ranges to delete are in the text node r=saschanaz
Our internal code can touch internal `Selection` object of `<input>` and
`<textarea>`, thus, selection ranges in them may be not in the text node.
Therefore, we should make `TextEditor` instance try to shrink the deleting
ranges into the text node first.

In a followup bug (perhaps, bug 1734846), we should split the deletion code into
`TextEditor` and `HTMLEditor` for making the code simpler and never regressed.

Differential Revision: https://phabricator.services.mozilla.com/D133181
2021-12-08 21:37:22 +00:00
Masayuki Nakano c468fdfd2e Bug 1720809 - part 2: Make insertLineBreak command handler in HTMLEditor insert a linefeed character instead of <br> element in same condition as Blink/WebKit r=m_kato
Similar to the previous patch, this patch makes `insertLineBreak` command
handler of `HTMLEditor` may insert a linefeed character instead of `<br>`
element for compatibility with Blink/WebKit.

Note that for making same name rules as `insertParagraphSeparator` command
handlers, this patch renames
`HTMLEditor::InsertBRElementAtSelectionWithTransaction()` to
`InsertLineBreakAsSubAction()` and moves
`EditorBase::InsertLineBreakAsSubAction()` to `TextEditor` since it's
used only by `TextEditor` instance.

Depends on D124731

Differential Revision: https://phabricator.services.mozilla.com/D124732
2021-09-10 21:45:47 +00:00
Masayuki Nakano c3500e3f66 Bug 1723125 - Ignore normal selection when updating composition string r=m_kato
Web apps can modify normal selection even during IME composition and no
browsers stop composition by it.  However, our editor tries to delete
non-collapsed selected range before updating composition.  Therefore,
we need additional state at handling inserting text whether selection
should be deleted or ignored.

Depends on D121371

Differential Revision: https://phabricator.services.mozilla.com/D121372
2021-08-02 08:23:50 +00:00
Masayuki Nakano 780fbf11f8 Bug 1714914 - Make editor classes treat offset in parent node as uint32_t r=m_kato
It should be treated as `uint32_t` since DOM API does so.  However, there are
some exceptions:

* Result of `nsINode::ComputeIndexOf()`
* Result of `nsAString` methods

They return `-1` as not found, and anyway, they cannot treat large integer
than `INT32_MAX`.  Therefore, this patch does not touch around them.

Differential Revision: https://phabricator.services.mozilla.com/D118933
2021-06-30 07:07:28 +00:00
Masayuki Nakano 569104c02d Bug 1717156 - part 6: Get rid of nsIEditor::eEditorDontEchoPassword r=m_kato
It's used only by password field, i.e., only by `TextEditor`, and used
temporarily.  Additionally, there is some space in `TextEditor`.  So, we
can get rid of it, and make `TextEditor` store it directly.

Note that this allows to skip expensive `nsIEditor::SetFlags()` calls by
`AutoRestoreEditorState`.  This may improve setting `<input>.value` performance.

Differential Revision: https://phabricator.services.mozilla.com/D118266
2021-06-22 00:18:08 +00:00
Kagami Sascha Rosylight af92858a0c Bug 1716728 - Part 4: Remove EnsureNoPaddingBRElementForEmptyEditor call for TextEditor r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118066
2021-06-21 01:49:00 +00:00
Kagami Sascha Rosylight 78338bca9d Bug 1716728 - Part 2: Remove TextEditor::EnsurePaddingBRElementForEmptyEditor() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118064
2021-06-21 01:48:59 +00:00
Kagami Sascha Rosylight 43d0279953 Bug 1713334 - Part 5: Allow caret to be at the end of text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117024
2021-06-18 00:36:55 +00:00
Kagami Sascha Rosylight 9d95e1b696 Bug 1713334 - Part 3: Assume TextEditor always have a text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117023
2021-06-18 00:36:54 +00:00
Kagami Sascha Rosylight fb2f3c5848 Bug 1713334 - Part 1: Keep a text node inside text controls even if empty r=masayuki,Jamie
Doing so prevents confusion when detecting selection change.

Differential Revision: https://phabricator.services.mozilla.com/D116303
2021-06-18 00:36:53 +00:00
Ryan VanderMeulen ef8c1a221c Backed out 5 changesets (bug 1713334) for causing bug 1716714.
Backed out changeset bd1c37ce2c61 (bug 1713334)
Backed out changeset 876ed18c5126 (bug 1713334)
Backed out changeset 5a4f4514d99a (bug 1713334)
Backed out changeset 7d7feef654c7 (bug 1713334)
Backed out changeset 61e15374e617 (bug 1713334)
2021-06-17 10:57:32 -04:00
Kagami Sascha Rosylight 17ca97d96a Bug 1716350 - Remove redundant editor type checks r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117662
2021-06-15 10:45:20 +00:00
Kagami Sascha Rosylight 03f911eb4d Bug 1713334 - Part 5: Allow caret to be at the end of text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117024
2021-06-14 19:56:24 +00:00
Kagami Sascha Rosylight bcbe5c3fcb Bug 1713334 - Part 3: Assume TextEditor always have a text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117023
2021-06-14 19:56:23 +00:00