Commit Graph

9046 Commits

Author SHA1 Message Date
Csoregi Natalia
ce0127e7c1 Merge inbound to mozilla-central. a=merge 2018-11-07 18:17:51 +02:00
Masayuki Nakano
834ab00aaa Bug 1503231 - Make TextEditor::DeleteSelectionAsAction() removes removing range information from EditAction when Selection is NOT collapsed r=m_kato
When Selection is NOT collapsed, we remove selected content.  Therefore,
web apps don't need to know range information of user operation.  However, web
apps may want to know direction of the operation (backward or forward).  E.g.,
web apps may just mark selected range as "deleted" and move caret before or
after the range.

Therefore, when computed EditAction is eDeleteWordBackward or
eDeleteToBeginningOfSoftLine, we should use eDeleteBackward instead.  When it
is eDeleteWordForward or eDeleteToEndOfSoftLine, we should use eDeleteForward
instead.

Note that only on Windows, we follow behavior of richtext control (and Word).
That is, Ctrl + Backspace/Delete collapse from start of selected range to
start/end of current word.  I.e., collapsing Selection to start first and
removing to start or end of current word is Windows's standard behavior.
Currently, we do this in DeleteSelectionAsSubAction() but every caller
specifies eNone to aDirection except DeleteSelectionAsAction().  So, we can
move this before re-computing EditAction in DeleteSelectionAsAction().

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

--HG--
extra : moz-landing-system : lando
2018-11-07 08:38:15 +00:00
Dorel Luca
ea6a7e7d8d Backed out 2 changesets (bug 1504913) for build bustage in build/src/extensions/spellcheck/src/mozSpellChecker.cpp
Backed out changeset 89e02e0a1b77 (bug 1504913)
Backed out changeset ef65164fcac0 (bug 1504913)
2018-11-07 04:06:58 +02:00
Makoto Kato
d0181acf20 Bug 1504913 - Part 2. Get rid of nsISpellChecker. r=masayuki
No one uses nsISpellChecker, so let's get rid of nsISpellChecker.

Depends on D10993

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

--HG--
extra : moz-landing-system : lando
2018-11-06 09:18:05 +00:00
Makoto Kato
92cfcb047c Bug 1504913 - Part 1. Use mozSpellChecker directly instead of nsISpellChecker. r=masayuki
When creating an instance of nsISpellChecker, we always use
mozSpellChecker::Create.  So we should use mozSpellChecker directly instead of
nsISpellChecker.

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

--HG--
extra : moz-landing-system : lando
2018-11-06 09:15:56 +00:00
Gurzau Raul
8feb5a86ea Merge mozilla-central to autoland. a=merge CLOSED TREE 2018-11-06 12:03:05 +02:00
Ehsan Akhgari
6f7b03e600 Bug 1504574 - Remove the XPCOM registration for nsDocumentEncoder; r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D10856
2018-11-05 23:16:04 -05:00
Masayuki Nakano
93bb048158 Bug 1504131 - part 3: Remove editor/libeditor/HTMLEditorObjectResizerUtils.h r=m_kato
Now, the header file is not necessary.

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

--HG--
extra : moz-landing-system : lando
2018-11-06 06:10:01 +00:00
Masayuki Nakano
dbc466a1f7 Bug 1504131 - part 2: Remove ResizerMouseMotionListener r=m_kato
ResizerMouseMotionListener listens to "mousemove" events for resizers
or grabber to move absolutely position element and it calls only
HTMLEditor::MouseMove().  Fortunately, neither EditorEventListener not
HTMLEditorEventListener listens to "mousemove" events.  Therefore, we
can use HTMLEditorEventListener instead.

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

--HG--
extra : moz-landing-system : lando
2018-11-06 06:09:18 +00:00
Masayuki Nakano
b5f863bf51 Bug 1504131 - part 1: Remove DocumentResizeEventListener r=m_kato
DocumentResizeEventListener listens to only "resize" events of the window
and when it fired, it just calls HTMLEditor::RefreshResizers().  Fortunately,
neither EditorEventListener nor HTMLEditorEventListener listens to "resize"
events.  Therefore, we can move this implementation into
HTMLEditorEventListener.

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

--HG--
extra : moz-landing-system : lando
2018-11-06 04:58:29 +00:00
Masayuki Nakano
027abbffa5 Bug 1504379 - Add automated tests for nsIPlaintextEditor.insertLineBreak() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D10805

--HG--
extra : moz-landing-system : lando
2018-11-06 03:47:38 +00:00
Makoto Kato
b682338978 Bug 1504913 - Part 2. Get rid of nsISpellChecker. r=masayuki
No one uses nsISpellChecker, so let's get rid of nsISpellChecker.

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

--HG--
extra : rebase_source : 1caeba2edf7677258c0406f087eaa41e12cbb8a8
extra : histedit_source : 6a90572e8ecddf0f13fbe5b1abf1bedf1c84a4d9
2018-11-06 12:32:04 +09:00
Makoto Kato
a9fe8aa60c Bug 1504913 - Part 1. Use mozSpellChecker directly instead of nsISpellChecker. r=masayuki
When creating an instance of nsISpellChecker, we always use
mozSpellChecker::Create.  So we should use mozSpellChecker directly instead of
nsISpellChecker.

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

--HG--
extra : rebase_source : 0feffa60e6dc788904d212a77acbf416279af083
extra : histedit_source : b89cc8270c2df70ae414479f43ac30e8aa0a3d42
2018-11-06 12:31:36 +09:00
Masayuki Nakano
2bde324acf Bug 1501663 - part 7: HTMLEditor::GetSelectedElement() shouldn't return element node when Selection starts before the element node r=m_kato
This fixes odd case of this API.  GetSelectedElement() ignores non-element
nodes before an element node.  This must be intended to allow Selection to
start from in an element node.  However, current code allows to select starting
from previous text node.  This patch changes this behavior to stop looking
for element node if non-element node appears before an element node.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 11:38:10 +00:00
Masayuki Nakano
189f0a35de Bug 1501663 - part 6: Get rid of |foundElmentInRange| r=m_kato
The |for| loop in HTMLEditor::GetSelectedElement() does not allow to be
after an element node because if another element is found, returns nullptr,
and if another non-element node is found, lastElementInRange which is
result of the method is cleared.  So, we checking lastElementInRange at
first of the for loop (i.e., immediately after calling
nsIContentIterator::Next()), we can get rid of use ugly bool flag.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 11:16:20 +00:00
Masayuki Nakano
8442e9e0f6 Bug 1501663 - part 5: Rewrite the loop in HTMLEditor::GetSelectedElement() with |for| r=m_kato
HTMLEditor::GetSelectedElement() uses |while| and calls
nsIContentIterator::Next() at the last line.  Therefore, it cannot use
early-continue style.  Because nsIContentIterator::Next() is always called,
it should be rewrite with |for|.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 11:07:34 +00:00
Masayuki Nakano
db5abeb169 Bug 1501663 - part 4: Clean up first-half of HTMLEditor::GetSelectedElement() r=m_kato
HTMLEditor::GetSelectedElement() should use RangeBoundary to reduce auto
variables which are in large scope.  So, first optimization block can be
optimized with RangeBoundary.

Then, the second block, for handling nsGkAtoms::href, does not need to
retrieve AnchorRef() nor FocusRef() since this is exactly same as
StartRef() and EndRef() of the first range when there is only one selected
range.  So, the last |if| block in this block is not necessary since
this has already been handled by the first block.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 11:05:54 +00:00
Masayuki Nakano
82618136b1 Bug 1501663 - part 3: HTMLEditor::GetElementOrParentByTagNameInternal() shouldn't return <a> element when it's looking for nsGkAtoms::href or nsGkAtoms::anchor but found <a> element does not match with <a href="..."> or <a name="..."> r=m_kato
HTMLEditor::GetElementOrParentByTagNameInternal() may return <a> element
which does not match for nsGkAtoms::href or nsGkAtoms::anchor (in the former
case, it should return only an <a> element which has "href" attribute and
its value is not empty.  in the latter case, it should return only <a> element
which has "name" attribute and its value is not empty).

This patch makes it won't check found element's name when nsGkAtoms::href or
nsGkAtoms::anchor is specified.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 06:52:11 +00:00
Masayuki Nakano
2654031504 Bug 1501663 - part 2: HTMLEditor::GetSelectedElement() should return nullptr if 2 or more elements are in selected range r=m_kato
This is also regression of bug 1432944, but hidden by the optimization of
bug 1482019.

In bug 1482019, we removing the code clearing |found| flag when the loop
meets second element in selection range.
https://searchfox.org/mozilla-central/diff/0dd29e18302c5e6b07b88aac7164889d752acda7/editor/libeditor/HTMLEditor.cpp#2751-2753
because the flag won't be referred.

However, before the fix of bug 1432944, it's referred and the cleared flag
makes the method return nullptr.

Therefore, this patch makes it return nullptr when 2 or more elements are
in selected range.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 04:57:02 +00:00
Masayuki Nakano
fa95dc80c3 Bug 1501663 - part 1: HTMLEditor::GetSelectedElement() should return nullptr when first found element is not what the caller is looking for r=m_kato
This takes back old behavior, 59 or earlier version.

|selectedElement| may be set to an element which is not what the caller is
looking for.  Therefore, if the first element node in the selected range is
not what the caller is looking for, it should return nullptr.

This regression is caused by this changeset:
https://hg.mozilla.org/mozilla-central/rev/93c1d149d757 (bug 1432944)

Additionally, this patch modifies the automated test for conforming to
original idea of the API.  This API must not be intended to retrieve
usual inline elements like <b>, <i>, etc.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 03:52:10 +00:00
Masayuki Nakano
f6c59cabb6 Bug 1504093 - Make DocumentResizeEventListener::HandleEvent() call public methods of HTMLEditor r=m_kato
DocumentResizeEventListener::HandleEvent() calls protected method,
HTMLEditor::RefreshResizersInternal().  However, this method is an event
handler, i.e., called when the editor is not handling an edit action.

Therefore, for ensuring AutoEditActionDataSetter instance, it should call
public method, nsIHTMLEditor::RefereshResizers() instead.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 06:28:53 +00:00
Masayuki Nakano
9d4ed3f232 Bug 1503744 - Make HTMLEditor::SetHTMLBackgroundColorWithTransaction() not refer RefPtr after moving it r=m_kato
Simple fix of crash caused by referring nullptr.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 02:13:05 +00:00
Masayuki Nakano
dbbd5b9823 Bug 1503565 - Make HTMLEditor::BlobReader::OnResult() create AutoEditActionDataSetter r=m_kato
HTMLEditor::BlobReader::OnResult() is a callback method and it calls
non-public method of HTMLEditor, DoInsertHTMLWithContext().  So,
DoInsertHTMLWithContext() may need caller to have already created
AutoEditActionDataSetter instance.  Therefore, BlobReader should keep
EditAction which is the purpose of creating it and its OnResult() should
create AutoEditActionDataSetter instance with it.

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

--HG--
extra : moz-landing-system : lando
2018-11-05 02:12:27 +00:00
Masayuki Nakano
8e6dd0bc8a Bug 1503473 - part 5: Move InsertParagraphSeparator*() into HTMLEditor r=m_kato
Now, TextEditor needs only InsertLineBreak*() so that
InsertParagraphSeparator*() is necessary only in HTMLEditor.
With overriding nsIPlaintextEditor::InsertLineBreak() in HTMLEditor,
we can do it simply.

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

--HG--
extra : moz-landing-system : lando
2018-11-03 04:19:22 +00:00
Masayuki Nakano
9b49e5d514 Bug 1503473 - part 4: Create a new path to handle Enter key press in TextEditor r=m_kato
This patch creates new path to insert a line break in TextEditor.

Declares new EditSubAction::eInsertLineBreak and makes the path use
EditAction::eInsertLineBreak instead of EditAction::eInsertParagraphSeparator.

Unfortunately, this patch makes TextEditor::InsertLineBreakAsAction() as
a virtual method for keeping this change as small as possible.

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

--HG--
extra : moz-landing-system : lando
2018-11-03 11:22:13 +00:00
Masayuki Nakano
7c5fc30479 Bug 1503473 - part 3: Move inserting a line break code in TextEditor::InsertParagraphSeparatorAsSubAction() to TextEditRules::WillInsertLineBreak() r=m_kato
When TextEditRules::WillDoAction() and HTMLEditRules::WillDoAction() didn't
return error, didn't handle it, and didn't cancel it,
TextEditor::InsertParagraphSeparatorAsSubAction() inserts a line breaker.
However, this case is only when the instance is TextEditRules and
TextEditRules::WillInsertLineBreak() prepares to insert a line break without
any errors.  So, we can move the part into TextEditRules::WillInsertLineBreak()
simply.

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

--HG--
extra : moz-landing-system : lando
2018-11-03 11:21:15 +00:00
Masayuki Nakano
5787ea1b53 Bug 1503473 - part 2: Make TextEditRules::WillInsertBreak() and HTMLEditRules::WillInsertBreak() return EditActionResult r=m_kato
With this cleaning up, we can know when they return NS_OK with both
aCanceled is false and aHandled is false.  (Look for EditActionIgnored().)

Additionally, this patch renames HTMLEditRules::WillInsertBreak() to
WillInsertParagraphSeparator() and TextEditRules::WillInsertBreak() to
TextEditRules::WillInsertLineBreak().

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

--HG--
extra : moz-landing-system : lando
2018-11-03 11:20:06 +00:00
Masayuki Nakano
18ee481a2d Bug 1503473 - part 1: Rename TextEditor::OnInputParagraphSeparator() and HTMLEditor::OnInputLineBreak() r=m_kato
TextEditor::OnInputParagraphSeparator() and HTMLEditor::OnInputLineBreak() are
also used by command handlers.  Therefore, they should be renamed to
TextEditor::InsertParagraphSeparatorAsAction() and
HTMLEditor::InsertLineBreakAsAction().  Then, current
TextEditor::InsertParagraphSeparatorAsAction() should be renamed to
AsSubAction() and each caller of it should create AutoPlaceholderBatch
by themselves.

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

--HG--
extra : moz-landing-system : lando
2018-11-03 11:19:07 +00:00
Cosmin Sabou
7da86ef60f Backed out 5 changesets (bug 1503473) for crashes in Thunderbird on request of jorgk. a=backout
Backed out changeset a7f7d9f366b9 (bug 1503473)
Backed out changeset d067907793ef (bug 1503473)
Backed out changeset 130ba0de053f (bug 1503473)
Backed out changeset ec732243e9ad (bug 1503473)
Backed out changeset 13511cab2b41 (bug 1503473)
2018-11-03 02:08:42 +02:00
Masayuki Nakano
d481dba0c1 Bug 1503473 - part 5: Move InsertParagraphSeparator*() into HTMLEditor r=m_kato
Now, TextEditor needs only InsertLineBreak*() so that
InsertParagraphSeparator*() is necessary only in HTMLEditor.
With overriding nsIPlaintextEditor::InsertLineBreak() in HTMLEditor,
we can do it simply.

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

--HG--
extra : moz-landing-system : lando
2018-11-02 14:24:33 +00:00
Masayuki Nakano
b1587d8dd4 Bug 1503473 - part 4: Create a new path to handle Enter key press in TextEditor r=m_kato
This patch creates new path to insert a line break in TextEditor.

Declares new EditSubAction::eInsertLineBreak and makes the path use
EditAction::eInsertLineBreak instead of EditAction::eInsertParagraphSeparator.

Unfortunately, this patch makes TextEditor::InsertLineBreakAsAction() as
a virtual method for keeping this change as small as possible.

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

--HG--
extra : moz-landing-system : lando
2018-11-02 13:10:43 +00:00
Masayuki Nakano
4cd5738394 Bug 1503473 - part 3: Move inserting a line break code in TextEditor::InsertParagraphSeparatorAsSubAction() to TextEditRules::WillInsertLineBreak() r=m_kato
When TextEditRules::WillDoAction() and HTMLEditRules::WillDoAction() didn't
return error, didn't handle it, and didn't cancel it,
TextEditor::InsertParagraphSeparatorAsSubAction() inserts a line breaker.
However, this case is only when the instance is TextEditRules and
TextEditRules::WillInsertLineBreak() prepares to insert a line break without
any errors.  So, we can move the part into TextEditRules::WillInsertLineBreak()
simply.

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

--HG--
extra : moz-landing-system : lando
2018-11-02 08:58:29 +00:00
Masayuki Nakano
5ed27c4ca6 Bug 1503473 - part 2: Make TextEditRules::WillInsertBreak() and HTMLEditRules::WillInsertBreak() return EditActionResult r=m_kato
With this cleaning up, we can know when they return NS_OK with both
aCanceled is false and aHandled is false.  (Look for EditActionIgnored().)

Additionally, this patch renames HTMLEditRules::WillInsertBreak() to
WillInsertParagraphSeparator() and TextEditRules::WillInsertBreak() to
TextEditRules::WillInsertLineBreak().

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

--HG--
extra : moz-landing-system : lando
2018-11-02 07:48:25 +00:00
Masayuki Nakano
6ba637600b Bug 1503473 - part 1: Rename TextEditor::OnInputParagraphSeparator() and HTMLEditor::OnInputLineBreak() r=m_kato
TextEditor::OnInputParagraphSeparator() and HTMLEditor::OnInputLineBreak() are
also used by command handlers.  Therefore, they should be renamed to
TextEditor::InsertParagraphSeparatorAsAction() and
HTMLEditor::InsertLineBreakAsAction().  Then, current
TextEditor::InsertParagraphSeparatorAsAction() should be renamed to
AsSubAction() and each caller of it should create AutoPlaceholderBatch
by themselves.

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

--HG--
extra : moz-landing-system : lando
2018-11-02 03:36:36 +00:00
Ciure Andrei
83010e5db0 Merge inbound to mozilla-central. a=merge 2018-11-02 18:44:43 +02:00
Makoto Kato
2fe36cbaf4 Bug 1501376 - Part 2. Add mochitest. r=masayuki
Since reftest doesn't access clipboard, this test is implemented by mochitest
even if this compares with image.

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

--HG--
extra : rebase_source : ef7bd6cc081ee5b5b821fdcef24b1c20c5315f49
2018-11-02 19:48:55 +09:00
Makoto Kato
ad68faeb0f Bug 1501376 - Part 1. Pasting into GeckoView briefly displays text content in password field. r=masayuki
When inputting any character in password field, character isn't masked
immediately since echo password is turned on Android. But when pasting text,
the text is masked immediately on Blink and Android OS.

So we should adopt this behaviour on Gecko too.

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

--HG--
extra : rebase_source : b4bc026569e61fee697cb538719216fb258a11ae
2018-11-02 16:33:58 +09:00
Tom Schuster
8c1f89b6e5 Bug 1503588 - Remove aDataLen parameter from nsITransferable.getAnyTransferData. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D10441

--HG--
extra : moz-landing-system : lando
2018-11-02 11:02:25 +00:00
Masayuki Nakano
63f8b9a61d Bug 1503457 - Add some variation of EditAction values for composition r=m_kato
Input Events Level 2 declares "deleteByComposition" for empty composition
removes selected content and "deleteCompositionText" for canceling composition.
https://w3c.github.io/input-events/#interface-InputEvent-Attributes

Therefore, TextEditor::OnCompositionChange() should use a new EditAction for
the former only when new composition string is empty, there is no composition
string and there is non-collapsed Selection.

And also TextEditor::OnCompositionEnd() should use another new EditAction for
the latter when composition is canceled with empty string (we don't restore
selected content which is removed by the composition).

Additionally, due to bug 1305387, we don't dispatch "input" event when
we handle TextEditor::OnCompositionChange().  Instead, we dispatch it
when we handle TextEditor::OnCompositionEnd().  Therefore, we need to
use EditAction::eCommitComposition in TextEditor::OnCompositionEnd().

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

--HG--
extra : moz-landing-system : lando
2018-11-01 08:07:04 +00:00
Edgar Chen
81dcbf85e4 Bug 1497480 - Part 3: Add tests for spell-checking in ShadowDOM; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D9802

--HG--
extra : moz-landing-system : lando
2018-11-02 00:07:30 +00:00
Gabriele Svelto
266ef73c96 Bug 1503207 - Remove nsWeakPtr.h and cleanup all files including weak reference-related headers r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D10251

--HG--
extra : moz-landing-system : lando
2018-10-31 20:39:03 +00:00
Cosmin Sabou
223a549fe5 Backed out 3 changesets (bug 1497480) for causing Android mochitest failures on editor/libeditor/tests/test_bug. CLOSED TREE
Backed out changeset 6c2a5ce9fad8 (bug 1497480)
Backed out changeset cf74ff09b141 (bug 1497480)
Backed out changeset 31d9a680fb90 (bug 1497480)
2018-10-31 19:06:35 +02:00
Edgar Chen
4b3c7c5c9a Bug 1497480 - Part 3: Add tests for spell-checking in ShadowDOM; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D9802

--HG--
extra : moz-landing-system : lando
2018-10-31 14:44:53 +00:00
Masayuki Nakano
d97102c926 Bug 1465702 - part 7: Make protected/private methods of EditorBase/TextEditor/HTMLEditor use SelectionRefPtr() instead of GetSelection() r=m_kato
Now, any protected/private methods of editor classes can refer
SelectionRefPtr() safely.  So, we can cut the cost of calling GetSelection()
only once per edit action handling.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 10:04:08 +00:00
Masayuki Nakano
53578eb0db Bug 1465702 - part 6: Remove unnecessary Selection argument from TextEditRules and HTMLEditRules and rename/reimplement TextEditRules::SelectionRef() as TextEditRules::SelectionRefPtr() r=m_kato
When each method of TextEditRules and HTMLEditRules should be called only by
EditorBase/TextEditor/HTMLEditor while the editor instance has
AutoEditActionDataSetter instance.  Therefore, we can get rid of all
pointers/references of Selection from each method's argument.

Additionally, this reimplements TextEditRules::SelectionRef() with
EditorBase::SelectionRefPtr() and make it return |const RefPtr<Selection>&|
rather than |Selection&| since RefPtr reference is required when we call
methods which are marked as MOZ_CAN_RUN_SCRIPT.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 10:02:58 +00:00
Masayuki Nakano
f91716e775 Bug 1465702 - part 5: Remove unnecessary Selection argument from editor module r=m_kato
EditorBase::SelectionRefPtr() is now safe to use in editor and really fast to
retrieve Selection than EditorBase::GetSelection().  Therefore, we can get rid of
all Selection pointer/reference argument of each method which always take
normal Selection.

Note that this changes nsIHTMLEditor.checkSelectionStateForAnonymousButtons()
because its argument is only Selection.  So, BlueGriffon should work even
though it calls the method with nsIEditor.selection.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 10:01:38 +00:00
Masayuki Nakano
41166eca5f Bug 1465702 - part 4: Make public methods of HTMLEditor create AutoEditActionDataSetter if necessary r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D10008

--HG--
extra : moz-landing-system : lando
2018-10-30 10:00:17 +00:00
Masayuki Nakano
062a07e7b0 Bug 1465702 - part 3: Make public methods of TextEditor create AutoEditActionDataSetter if necessary r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D10007

--HG--
extra : moz-landing-system : lando
2018-10-30 09:59:33 +00:00
Masayuki Nakano
779965a889 Bug 1465702 - part 2: Make public methods of EditorBase create AutoEditActionDataSetter if necessary r=m_kato
This patch makes public methods of EditorBase create AutoEditActionDataSetter
as far as possible.  However, does not do so for some public methods if they are
not necessary to create it.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 09:57:52 +00:00
Masayuki Nakano
7f8df77fb6 Bug 1465702 - part 1: Add EditorBase::AutoEditActionDataSetter to store edit action and grab Selection instance while editor classes handle an edit action r=m_kato
Like TextEditRules, EditorBase should have a stack class which cache necessary
objects and current handling edit action.  The edit action will be necessary
when we implement InputEvent.inputType.

Different from TextEditRules, this adds |const RefPtr<Selection>&| instead
of |Selection&|.  The reason is, when I add MOZ_CAN_RUN_SCRIPT to some methods,
it's not allowed like this:

> foo->CanRunScriptMethod(SelectionRef());

I'll update TextEditRules for consistency in the following patches.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 09:56:41 +00:00