Граф коммитов

38 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 58e73430fb Bug 1639161 - part 1: Create `ReplaceTextTransaction` class r=m_kato
Currently, when `HTMLEditor` replaces text in a text node, `HTMLEditor`
creates a set of `DeleteTextTransaction` and `InsertTextTransaction`.
However, this has bad impact for footprint and causes the callers messy.

This patch creates `ReplaceTextTransaction` instead and
`HTMLEditor::ReplaceTextWithTransaction()` as its wrapper.  Unfortunately,
this becomes not calling `nsIEditActionListener::DidDeleteText()`, however,
this is not used by mozilla-central, comm-central nor BlueGriffon.  IIRC,
it was not removed for some legacy addons of Thunderbird.  Therefore, it
must be okay to remove it.

Differential Revision: https://phabricator.services.mozilla.com/D76078
2020-05-21 02:30:09 +00:00
Masayuki Nakano 09160b3e7b Bug 1632021 - part 4: Get rid of IID of `InsertTextTransaction` and `CompositionTransaction` r=m_kato
`EditTransactionBase::GetAs*Transaction()` should be used instead.

Differential Revision: https://phabricator.services.mozilla.com/D71911
2020-04-23 12:28:39 +00:00
Masayuki Nakano 47acd7e8de Bug 1632021 - part 2: Add `nsITransaction::GetAsEditTransactionBase()` r=m_kato
In a lot of places in libeditor, we do nothing if given transaction is not
our edit transaction classes' instance.  Therefore, it's better to have
casting virtual method in `nsITransaction` for performance because QI cost
may not be cheap.

Differential Revision: https://phabricator.services.mozilla.com/D71908
2020-04-23 07:02:16 +00:00
Masayuki Nakano 8390d2e8bc Bug 1619914 - part 2: Mark transaction class methods and their caller methods as `MOZ_CAN_RUN_SCRIPT r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D69303

--HG--
extra : moz-landing-system : lando
2020-04-03 08:32:01 +00:00
Masayuki Nakano 3f95e60b07 Bug 1619914 - part 1: Make each transaction class grab their members with local variable before touching the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D69302

--HG--
extra : moz-landing-system : lando
2020-04-03 08:30:37 +00:00
Mihai Alexandru Michis 2f9f34de0e Backed out 2 changesets (bug 1619914) for causing gtest failures regarding TransactionManager.
CLOSED TREE

Backed out changeset d3816f82c0b9 (bug 1619914)
Backed out changeset 876b1031a6ae (bug 1619914)
2020-04-03 07:57:06 +03:00
Masayuki Nakano eb881aff87 Bug 1619914 - part 2: Mark transaction class methods and their caller methods as `MOZ_CAN_RUN_SCRIPT r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D69303

--HG--
extra : moz-landing-system : lando
2020-04-03 01:39:36 +00:00
Masayuki Nakano 5fb2cba97c Bug 1619914 - part 1: Make each transaction class grab their members with local variable before touching the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D69302

--HG--
extra : moz-landing-system : lando
2020-04-03 01:38:22 +00:00
Masayuki Nakano 0913d9141d Bug 1620504 - part 20: Clean up warnings in SelectionState and related classes r=m_kato
This changes a lot of arguments from pointer to reference.

Differential Revision: https://phabricator.services.mozilla.com/D66851

--HG--
extra : moz-landing-system : lando
2020-03-16 09:57:58 +00:00
Masayuki Nakano c1fc16a11b Bug 1620504 - part 3: Clean up warnings in CompositionTransaction r=m_kato
Depends on D65867

Differential Revision: https://phabricator.services.mozilla.com/D65869

--HG--
extra : moz-landing-system : lando
2020-03-09 07:14:19 +00:00
Masayuki Nakano 85a0bd9a61 Bug 1620135 - Clean up trivial constructor and destructor under libeditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D65448

--HG--
extra : moz-landing-system : lando
2020-03-06 04:38:25 +00:00
Masayuki Nakano c5eeb32fe1 Bug 1618089 - part 7: Make some related methods use `EditorDOMPointInText` for arguments or result r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D64338

--HG--
extra : moz-landing-system : lando
2020-03-03 01:15:38 +00:00
Masayuki Nakano ca49cc9d2d Bug 1548389 - part 0: Wrap modifying text node in editor with particular methods r=m_kato
In the next patch, we need to update unmasked range when anonymous text node
in `<input type="password">` is modified.  This patch makes editor manage it
easier to update the range.

Note that the next patch also handles text node creation and destruction.

Differential Revision: https://phabricator.services.mozilla.com/D38003

--HG--
extra : moz-landing-system : lando
2019-07-22 03:53:29 +00:00
Mirko Brodesser 63b4627d28 Bug 1562876: rename `Selection::AddRange` to `Selection::AddRangeAndSelectFramesAndNotifyListeners`. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D36602
2019-07-03 13:26:13 +02:00
Masayuki Nakano 2a450c5196 Bug 1444847 - part 2: Sort out basic API of `nsRange` for consistency with coming `StaticRange` r=smaug
For avoiding confusion between API of `nsRange` and `StaticRange`, I'd like to
rename `nsRange::CreateRange()` to `nsRange::Create()` because
`StaticRange::CreateStaticRange()` is too long name and
`StaticRange::CreateRange()` sounds odd.  This patch renames it and changes
related methods to template methods to avoid runtime cost of temporary
`RawRangeBoundary` instance creation.

Differential Revision: https://phabricator.services.mozilla.com/D35141

--HG--
extra : moz-landing-system : lando
2019-06-28 07:47:29 +00:00
Masayuki Nakano 39daaa7db8 Bug 1534561 - Make editor use PresShell directly rather than nsIPresShell r=m_kato
`PresShell.h` is exposed as `mozilla/PresShell.h` and `PresShell` is the only
concrete class of `nsIPresShell`.  Therefore, we have no reason to access
`PresShell` via `nsIPresShell`.

Differential Revision: https://phabricator.services.mozilla.com/D23277

--HG--
extra : moz-landing-system : lando
2019-03-15 05:01:10 +00:00
Sylvestre Ledru 265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Kris Maglione 8340513b0c Bug 1463287: Add QueryInterface helper macro for concrete class types. r=bz
Using concrete class types with static IIDs in QueryInterface methods is a
pretty common pattern which isn't supported by any existing helper macros.
That's lead to separate ad-hoc implementations, with varying degrees of
dodginess, being scattered around the tree.

This patch adds a helper macro with a canonical (and safe) implementation, and
updates existing ad-hoc users to use it.

MozReview-Commit-ID: HaTGF7MN5Cv

--HG--
extra : rebase_source : ace930129d85960d22bc3048ca3bb19bbbd4a63e
extra : histedit_source : 03a87f746d957789d41381e4e1bfcc4fd7eebaf2%2C9c5bae9feeeef7721105db67be0f83e0ded66bb7
2018-05-21 16:33:18 -07:00
Boris Zbarsky 46cae9462a Bug 1387143 part 3. Stop using nsISelection in nsISelectionController. r=mats 2018-05-08 13:52:36 -04:00
Andrew McCreight 3f7472aec1 Bug 1449670, part 1 - Convert IsNodeOfType(nsINode::eTEXT) to IsText(). r=bz
This method is not a virtual call, and also looks nicer.

This patch was mostly generated by a Python script, but I manually
cleaned up the code in a few places where statements didn't need to be
split across multiple lines any more.

MozReview-Commit-ID: 8JExxqSRc59

--HG--
extra : rebase_source : df6330a89e8d65dfe7a6fda0c8cb9f9732302efc
2018-04-12 15:41:00 -07:00
Boris Zbarsky df07d2d834 Bug 1447890 part 5. Remove nsISelection::RemoveAllRanges. r=mystor
MozReview-Commit-ID: EeMje9KW6An
2018-03-27 00:35:23 -04:00
Boris Zbarsky 54d1f87ff4 Bug 1447890 part 1. Remove nsISelection::AddRange. r=mystor
MozReview-Commit-ID: 1JNLZp7tbII
2018-03-27 00:35:22 -04:00
Boris Zbarsky d243dbaa39 Bug 1446533 part 9. Remove nsIDOMCharacterData::ReplaceData. r=mystor
MozReview-Commit-ID: Lei6xZ2rw2K
2018-03-19 15:45:34 -04:00
Boris Zbarsky e7e7401bc3 Bug 1446533 part 8. Remove nsIDOMCharacterData::DeleteData. r=mystor
MozReview-Commit-ID: 7100YyU5jOG
2018-03-19 15:45:31 -04:00
Boris Zbarsky 5475554b91 Bug 1446533 part 7. Remove nsIDOMCharacterData::InsertData. r=mystor
MozReview-Commit-ID: 48XZ2J9ewHP
2018-03-19 15:38:04 -04:00
Adrian Wielgosik 3c2cc07d2d Bug 1379891 - remove nsPIEditorTransaction interface, GetTxnDescription methods. r=m_kato,masayuki
MozReview-Commit-ID: 4NLeMrrqIv5
2018-01-14 16:01:41 +01:00
Masayuki Nakano a5bd93a76e Bug 1425412 - part 4: Create CompositionTransaction::Create() and remove EditorBase::CreateTxnForComposition() r=m_kato
EditorBase::CreateTxnForComposition() just hides what it does.  For its caller,
creating a factory method, CompositionTransaction::Create(), is clearer what
it does.

Additionally, capsuling the creation in CompositionTransaction class can make
the text node information in TextComposition updated automatically.  So, now,
it might be better to update them in DoTransaction() because there is a lag
between creating the transaction and calling DoTransaction().  However, this
patch doesn't want to change any existing behavior.  So, this doesn't fix this
issue.

MozReview-Commit-ID: K8ci7ytwh1u

--HG--
extra : rebase_source : d468a0fc997c99f78f7eb46451082e7f1e052890
2017-12-15 18:26:37 +09:00
Masayuki Nakano 59ff865ade Bug 1425390 - part 2: Make the constructor of CompositionTransaction take TextComposition to reduce its arguments r=m_kato
Most arguments of the constructor of CompositionTransaction are now stored by
EditorBase::mComposition.  So, making it take TextComposition reduces the
number of its arguments.

Note that this patch doesn't make it retrieve TextComposition with
EditorBase::GetComposition() for guaranteeing that the editor has non-nullptr
mComposition.

MozReview-Commit-ID: 3O5wL52UBUy

--HG--
extra : rebase_source : 7f48465ef3f2f040e8c526fb7837060ecb6c9147
2017-12-15 16:45:41 +09:00
Makoto Kato 5bd44e5cfd Bug 1393355 - Move SetTextRangeStyle from nsISelectionPrivate to Selection. r=masayuki
There is no reason that SetTextRangeStyle is defined at nsISelectionPrivate.  Also, SetTextRangeStyle isn't scriptable, and is called from CompositionTransaction::SetIMESelection only.  So we should move this to Selection.

MozReview-Commit-ID: FCOA6wVhvYZ

--HG--
extra : rebase_source : 64eb9e5fb973195b2c87ab4eb296685c8a4d0319
2017-08-24 16:56:12 +09:00
Makoto Kato b04d5091db Bug 1388638 - Use RAII class for StartBatchChanges/EndBatchChanges. r=masayuki
CompositionTransaction forgets to call EndBatchChanges when GetSelectionController returns error, so we should use RAII class instead.

MozReview-Commit-ID: HI9kutRVzx6

--HG--
extra : rebase_source : d276f4349c5a64d4610581ae1a76d160841f7d7b
2017-08-09 18:06:36 +09:00
Masayuki Nakano e877ded333 Bug 1349138 Edit transactions should store their editor instance with strong reference r=smaug
Edit transactions should store their editor instance with strong reference and they should be released at destroying the editor.

MozReview-Commit-ID: D67KU8WFxyo

--HG--
extra : rebase_source : 28c8a37498cad9f2e308eb4416cef76cf395bb9c
2017-03-21 19:00:36 +09:00
Makoto Kato 272781396f Bug 1310912 - Part 4. RangeUpdater should be called on DoTransaction. r=masayuki
Although PlaceholderTransaction will use the selection on Merge, it is too late to use UpdateRange.  Because RangeUpdater will be used after DoTransaction is finished.  So we should update selection on DoTransaction.

Also, part 1 fix doesn't update selection correctly via RangeUpdater when IME composition is multiple node.

MozReview-Commit-ID: 9so9tR8uQ6t

--HG--
extra : rebase_source : 02a8bebe6c89ceb023bd598b77b40c5817cd4007
extra : histedit_source : d114420552779d3352637c5554bf9e90e6e9cd40
2016-11-12 14:56:33 +09:00
Makoto Kato 65c64fee1d Bug 1310912 - Part 1. CompositionTransaction should support multiple text nodes. r=masayuki
Google Keep uses range.insertNode on input event.  So, text node will be inserted into current caret position.

Microsoft IME's caret is after composition string, but ATOK's caret is before it.  So when using ATOK, this issue occurs.  By range.insertNode, text nodes that have IME attribute becomes multiple text nodes.  But CompositionTransanction doesn't consider that IME range isn't single text node.  Although it replaces current composition string with new string on first text node, it doesn't delete composition string on other text node.

MozReview-Commit-ID: 9uRx0A9mppx

--HG--
extra : rebase_source : fe0754cee2197822ca6ac9ebed13013a8f13b606
2016-11-08 16:14:57 +09:00
Masayuki Nakano 2773c4d0ef Bug 1310618 Replace nsresult variables |res| with |rv| under editor/ r=Ehsan
In our coding rules, variable names of nsresult should be rv.  Indeed, when you see |rv| in the code, you must assume that its type if nsresult.

However, a lot of code under editor/ uses |res| for the variables of nsresult.  Let's replace |res| with |rv|.

And this patch improves following points:

1. When |rv| is set in both |if| and |else| block and they are check outside of them, this moves the check into each |if| and |else| block because even if the failure is notified with warning, you cannot see which case was performed and failed.  This change makes it clear.

2. When |return rv;| returns non-error code because |rv| is checked with NS_ENSURE_SUCCESS() immediately before, setting replacing it with |return NS_OK;| is clearer.

3. Move declaration of |nsresult rv| into smaller scope as far as possible.  This prevents setting rv to unexpected value and easier to check its value at reading the code.

MozReview-Commit-ID: 9MAqj7sFey3

--HG--
extra : rebase_source : 0fd316b851ea616b3a95d8c1afc111ff55e11993
2016-10-19 18:09:33 +09:00
Ou Shinjo 2e390f8812 Bug 1266165 - CompositionTransaction::SetIMESelection() should not hide caret when redo r=masayuki
CompositionTransaction::SetIMESelection() is also called when user redos the committed composition.  In such case, it doesn't have ranges, but DoTransaction() tries to restore selection ranges with no ranges.  That causes hiding caret because when there is no caret range in the ranges, SetIMESelection() hides the caret as IME requested.

So, for redo, SetIMESelection() shouldn't hide caret when there are no ranges (i.e., the composition was already committed).
2016-08-27 13:26:42 +09:00
Masayuki Nakano f382711dc3 Bug 1260651 part.59 Rename nsEditor to mozilla::EditorBase (and also their file names) r=mccr8
This patch also renames:

EditorInputEventDispatcher -> mozilla::EditorInputEventDispatcher

And some variable names are renamed from aEditor or mEditor to aEditorBase or mEditorBase for making their types clearer.

MozReview-Commit-ID: 2FCXWpLMn8e

--HG--
rename : editor/libeditor/nsEditor.cpp => editor/libeditor/EditorBase.cpp
rename : editor/libeditor/nsEditor.h => editor/libeditor/EditorBase.h
2016-07-08 13:10:13 +09:00
Masayuki Nakano 5fb3db78b5 Bug 1260651 part.32 Rename EditTxn to mozilla::EditTransactionBase r=mccr8
This patch also renames NS_DECL_EDITTXN to NS_DECL_EDIT_TRANSACTION_BASE.

MozReview-Commit-ID: 29TQbKBBEhD

--HG--
rename : editor/libeditor/EditTxn.cpp => editor/libeditor/EditTransactionBase.cpp
rename : editor/libeditor/EditTxn.h => editor/libeditor/EditTransactionBase.h
2016-07-08 09:48:34 +09:00
Masayuki Nakano f6a83f89e0 Bug 1260651 part.23 Rename mozilla::dom::IMETextTxn to mozilla::CompositionTransaction (and their files too) r=mccr8
This patch renames IMETextTxn to CompositionTransaction.  "Composition" is now used in some web standard specs, e.g., CompositionEvent defined by UI Events.

This patch also renames nsEditor::CreateTxnForIMEText() to nsEditor::CreateTxnForComposition().

MozReview-Commit-ID: JN0GgGdpAWG

--HG--
rename : editor/libeditor/IMETextTxn.cpp => editor/libeditor/CompositionTransaction.cpp
rename : editor/libeditor/IMETextTxn.h => editor/libeditor/CompositionTransaction.h
2016-07-07 15:42:08 +09:00