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

70 Коммитов

Автор SHA1 Сообщение Дата
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 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 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
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 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 ede88b49c1 Bug 1501180 - Make TextEditRules::Notify() hide input characters via editor instance r=m_kato
TextEditRules::Notify() is callback of the timer.  Therefore, this won't be
in the stack while editor handles an edit action.  Then, TextEditRules
cannot access edit action data which will be put on the stack after fixing
bug 1465702.  So, it should do it after once calling a method of editor
instance (and editor instance should call back proper TextEditRules method).

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

--HG--
extra : moz-landing-system : lando
2018-10-25 03:35:26 +00:00
Masayuki Nakano 9b40433ef6 Bug 1461708 - part 7: Make EventStateManager::HandleMiddleClickPaste() dispatch ePaste event by itself r=smaug
This is preparation of the last patch.  Even if no editor is clicked with
middle button, we need to do:
- collapse Selection at the clicked point.
- dispatch "paste" event.

Therefore, HandleMiddleClickPaste() should dispatch ePaste event by itself
and each editor methods should have a bool argument which the caller wants
ePaste event automatically.

Note that Chromium dispatches "paste" event and pastes clipboard content
into clicked editor even if preceding "auxclick" event is consumed.
However, our traditional behavior is not dispatching "paste" event nor
pasting clipboard content.  Unless Chromium developer keeps their odd
behavior, we should keep our traditional behavior since our behavior is
conforming to DOM event model.

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

--HG--
extra : moz-landing-system : lando
2018-10-10 12:05:39 +00:00
Masayuki Nakano d472d6f312 Bug 1461708 - part 4: Move implementation of UIEvent::GetRangeParent() and UIEvent::RangeOffset() to nsLayoutUtils r=smaug
We need to move EditorEventListener::HandleMiddleClickPaste() into
EventStateManager to handle middle click paste after all click events are
dispatched.  This is preparation of the change.

HandleMiddleClickPaste() uses UIEvent::GetRangeParent() and
UIEvent::RangeOffset() to collapse Selection at clicked point.  However,
EventStateManager cannot access them since EventStateManager can handle it
with WidgetMouseEvent.  Fortunately, only WidgetMouseEvent is necessary for
implementing them.  Therefore, we can move the implementation into
nsLayoutUtils and merge them.

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

--HG--
extra : moz-landing-system : lando
2018-10-10 12:03:34 +00:00
Masayuki Nakano c0e869978e Bug 1482012 - part 2: Create TextEditor::PasteAsAction() as non-virtual method for outer C++ code r=m_kato
User may paste a lot with pressing Accel+V for a while (i.e., with auto repeat).
So, calling nsIEditor::Paste() may be in a hot path and we can now make
non-virtual public method with AsHTMLEditor().

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

--HG--
extra : moz-landing-system : lando
2018-08-13 04:37:56 +00:00
Masayuki Nakano 0fadf6b9da Bug 1467796 - part 3: Make mozInlineSpellChecker::ReplaceWord() use TextEditor::ReplaceTextAsAction() r=m_kato,smaug
mozInlineSpellChecker::ReplaceWord() is used for replacing misspelled word
with a word.  So, this is necessary to be distinguished from insertText
command when we implement InputEvent.inputType.  So, we should make it
use TextEditor::ReplaceTextAsAction() instead (same as autocomplete).

This patch makes TextEditor::ReplaceTextAsAction() take optional argument
to make callers can specify replace range.  Then, the range is a spellchecker
selection range if the caller is mozInlineSpellChecker::ReplaceWord().
Prior to this patch, it clones the range for normal selection, but it's
expensive and we may be able to reuse cached range of Selection in this case.
So, this patch makes Selection::AddRangeInternal() checks if given range is
in another Selection and use mCachedRange as far as possible.

MozReview-Commit-ID: JIOTTsxlj4Q

--HG--
extra : rebase_source : 7c26b0255f08608ebe8c7045c9bcdca1dc70cadf
2018-07-04 22:51:55 +09:00
Masayuki Nakano 08f4c56c7e Bug 1467796 - part 2: Make autocomplete use new method TextEditor::ReplaceTextAsAction() which replaces all text with specified text r=m_kato
InputEvent.inputType needs to distinguish whether inserting text is caused
by insertText command or replaced by autocomplete or spellchecker.
Therefore, nsTextEditorState::SetValue() cannot use
TextEditor::InsertTextAsAction() nor TextEditor::DeleteSelectionAsAction().

This patch reuses TextEditor::SetText()'s slow path for the new method.

Note that the new method uses EditSubAction::eInsertText as top level edit sub-
action because specifying this improves undo/redo behavior.

And also this patch modifies test_bug1368544.html.  Oddly, only on Android,
we get different result.  After removing all text with setUserInput(""),
TextEditor::DeleteSelectionAsSubAction() removes both text node and non-bogus
<br> element from the anonymous-div element.  However, only on Android, new
<br> element is recreated.  I've not understood where this difference comes
from yet.

MozReview-Commit-ID: GKNksctGik

--HG--
rename : toolkit/content/tests/chrome/file_autocomplete_with_composition.js => toolkit/content/tests/chrome/file_editor_with_autocomplete.js
rename : toolkit/content/tests/chrome/test_autocomplete_with_composition_on_input.html => toolkit/content/tests/chrome/test_editor_for_input_with_autocomplete.html
rename : toolkit/content/tests/chrome/test_autocomplete_with_composition_on_textbox.xul => toolkit/content/tests/chrome/test_editor_for_textbox_with_autocomplete.xul
extra : rebase_source : b90419d9e5a01e86f6e6418f8df002c91416acae
2018-07-03 22:25:52 +09:00
Masayuki Nakano efd8891532 Bug 1467796 - part 1: Split TextEditor::InsertTextAsAction() to itself and TextEditor::InsertTextAsSubAction() for internal use r=m_kato
For bug 1465702, we need to split TextEditor::InsertTextAsAction() to 2 methods.
One is for root of handling an edit operation.  The other is for internal use,
e.g., handling as a part of an edit operation.  Therefore, this patch creates
InsertTextAsSubAction() for the internal use.

MozReview-Commit-ID: CIU5zdp0owP

--HG--
extra : rebase_source : 79b58fb01e48d1831bbdea01ed7b1a26dcd1821b
2018-07-02 20:12:22 +09:00
Masayuki Nakano 77fdd1508b Bug 1476897 - part 7: Drop nsIEditorMailSupport interface from TextEditor r=m_kato
Nobody uses nsIEditorMailSupport interface with TextEditor instances.
Therefore, stopping nsIEditorMailSupport interface support of TextEditor
saves memory of TextEditor which may be created a lot even in a document.

MozReview-Commit-ID: BJ4ucCaeYHl

--HG--
extra : rebase_source : 2c932df04d00a4453428dc3b7fd64d338c6963eb
2018-07-23 16:45:07 +09:00
Masayuki Nakano 5e98e38c30 Bug 1476897 - part 6: Move implementation of both TextEditor::PasteAsQuotation() and HTMLEditor::PasteAsQuotation() to new virtual methods r=m_kato
Neither TextEditor::PasteAsQuotation() nor HTMLEditor::PasteAsQuotation()
is used via nsIEditorMailSupport.  So, perhaps, we can remove this method
from the interface.  But for now, we should move each implementation to
new virtual methods and make only HTMLEditor::PasteAsQuotation() calls
new method since nobody uses nsIEditorMailSupport with TextEditor instances.

MozReview-Commit-ID: Eilxk74VHwT

--HG--
extra : rebase_source : 15abe305d9f332ecd521d9115a71443665a8c9fe
2018-07-23 16:34:03 +09:00
Masayuki Nakano a2ecad4a67 Bug 1476897 - part 5: Move implementation of TextEditor::InsertAsQuotation() to new method r=m_kato
TextEditor::InsertAsQuotation() is not used as a method of nsIEditorMailSupport,
however, this is used internally.  So, we need to keep this method's function
as a non-virtual method but we can make the method just return
NS_ERROR_NOT_IMPLEMENTED.

MozReview-Commit-ID: 2CcY4SZGwyr

--HG--
extra : rebase_source : d490145b571bea465be5379872b9ea01daa633cc
2018-07-23 16:05:30 +09:00
Masayuki Nakano 3a1344255b Bug 1467802 - part 4: Create TextEditor::ComputeValueInternal() for internal use of nsIPlaintextEditor::OutputToString() r=m_kato
For reducing virtual calls of nsIPlaintextEditor::OutputToString(),
TextEditor should have new non-virtual public method, ComputeTextValue() and
shared code between it and OutputToString() as ComputeValueInternal().

MozReview-Commit-ID: KFeovQ568bf

--HG--
extra : rebase_source : a5cfb24cefe44f7c60e649959ed49350ed00d4d6
2018-07-18 21:27:30 +09:00
Masayuki Nakano 85b94e287c Bug 1467802 - part 2: Mark TextEditor::GetAndInitDocEncoder() as const r=m_kato
TextEditor::GetAndInitDocEncoder() modifies only mCachedDocumentEncoder and
mCachedDocumentEncoderType which are cache of the method to save recreation
cost of document encoder when same type document encoder is requested.

So, with marking them mutable, we can change the method to a const method.

MozReview-Commit-ID: 80W0NtQhJOR

--HG--
extra : rebase_source : 84f4b49fe3a3124c0de99b39a2141a8cee553e54
2018-07-18 20:51:55 +09:00
Masayuki Nakano 9da3ea2d22 Bug 1467802 - part 1: Create TextEditor::WrapWidth() for internal use of nsIPlaintextEditor::GetWrapWidth() r=m_kato
Let's create non-virtual and simple accessor for TextEditor::mWrapColumn.

MozReview-Commit-ID: 97LhhOgkx4A

--HG--
extra : rebase_source : bd57d7fbcc8da5e00fe71b81a6a2a9ef2f92e939
2018-07-18 20:31:17 +09:00
Masayuki Nakano 0d09e1a26a Bug 1467799 - part 1: Remove implementation of EditorBase::GetDocumentIsEmpty() and rename TextEditor::DocumentIsEmpty() to TextEditor::IsEmpty() r=m_kato
EditorBase::GetDocumentIsEmpty() is never called since it's overridden by
TextEditor::GetDocumentIsEmtpy() and never called directly.  So, we can remove
its implementation.

Additionally, DocumentIsEmpty() is redundant. We can make it just IsEmpty().

MozReview-Commit-ID: CGsNzCHyVf

--HG--
extra : rebase_source : 3a8eeaf108bb387ea559e0643acfa96e26768577
2018-07-18 17:44:14 +09:00
Masayuki Nakano 98a833407e Bug 1467794 - Split TextEditor::DeleteSelectionAsAction() to itself and TextEditor::DeleteSelectionAsSubAction() r=m_kato
TextEditor::DeleteSelectionAsAction() is called even if it's a part of edit
action.  For example, it's called to prepare for inserting text.

For bug 1465702, editor itself and edit rules classes should not call
public DeleteSelectionAsAction() directly.  Therefore, this patch creates
DeleteSelectionAsSubAction() for internal use.

Note that this patch adds NS_ASSERTION() to detect wrong caller.  However,
it cannot distinguish if the call is valid, for example, it's allowed to
call DeleteSelectionAsSelection() even if it's handling an edit action but
the method is called via mutation event listener.  So, we need to allow
some assertions with some tests.  But unfortunately, 1405747.html uses
mutation event listener too many times (about 1,000 times) and the number
of assertion isn't stable.  Therefore, this patch makes the test stop using
the mutation event listener 2nd time since I can reproduce the crash with
ESR 52 at the 2nd time.

MozReview-Commit-ID: 1TWaypmnoCC

--HG--
extra : rebase_source : a6a4fb1cbcaf2ab6f10c5f3e7168a6bc0fcb02ed
2018-06-29 20:16:50 +09:00
Masayuki Nakano a6f0eec408 Bug 1467691 - Make some methods of EditorBase non-public r=m_kato
This moves NotifyEditorObservers() and GetInputEventTargetContent() into
protected member which should not be used by friends.

And also this moves IsModifiableNode() into protected member which can be
used by friends.

MozReview-Commit-ID: AxDBgTVED3V

--HG--
extra : rebase_source : 979c6cb0d075b3fd0106bd1c381aa3ef3b98ba78
2018-06-06 13:30:44 +09:00
Makoto Kato ef31f52f39 Bug 1467670 - Devirtualize InsertFromDrop. r=masayuki
InsertFromDrop is implemented on TextEditor only, so it can do devirtualize
this method.  Also, this method is only called by drop event handler of
EditorEventListener, so it should rename to better name (OnDrop).

Differential Revision: https://phabricator.services.mozilla.com/D1592
2018-06-08 05:19:51 +00:00
Masayuki Nakano 99341a9445 Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled.  However, currently, we call smaller
jobs as edit action.  For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed.  However, for the InputEvent.inputType,
we need inserText information.  So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.

And also this renames related stuff:

EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
  EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
  EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo

MozReview-Commit-ID: cvSkPUjFm1

--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 20:12:34 +09:00
Masayuki Nakano 11ae2207cf Bug 1463327 - part 4: Add comments to explain which kind of methods should be public methods r=m_kato
MozReview-Commit-ID: 6l8ZiMWEYCI

--HG--
extra : rebase_source : 024625012c917b17710016b91db10bfbaace2134
2018-05-22 20:15:05 +09:00
Masayuki Nakano f615160008 Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods.  One is true-public methods.  I.e.,
they should be able to be called by anybody.  E.g., command handlers, event
listeners, or JS via nsIEditor interface.  The other is semi-public methods.
 They are not called by the above examples but called by other classes which
are helper classes to handle edit actions.  E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.

When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData).  Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.

For preventing this issue, we should make TextEditor have only the true-public
methods as public.  The other public methods should be protected and their
users should be friend classes.  Then, we can protect such method from external
classes.

Note that this patch just moves the methods without any changes in TextEditor.h.

MozReview-Commit-ID: Db3H6d1V8IU

--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 16:40:44 +09:00
Masayuki Nakano 40ab33fe29 Bug 1463327 - part 1: Change scope of some methods of EditorBase which won't be called by non-helper classes of editing to protected r=m_kato
EditorBase (and other editor classes) have 2 type of public methods.  One is
true-public methods.  I.e., they should be able to be called by anybody.
E.g., command handlers, event listeners, or JS via nsIEditor interface.
The other is semi-public methods.  They are not called by the above examples
but called by other classes which are helper classes to handle edit actions.
E.g., TextEditRules, HTMLEditRules, HTMLEditUtils, CSSEditUtils and Transaction
classes.

When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData).  Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.

For preventing this issue, we should make EditorBase have only the true-public
methods as public.  The other public methods should be protected and their
users should be friend classes.  Then, we can protect such method from external
classes.

Note that this patch just moves the methods without any changes in EditorBase.h
(except removes GetName() since there is no body of this method and removes
IterDirection since it's unused).

MozReview-Commit-ID: HBseKLL6pxx

--HG--
extra : rebase_source : 2251ff659d831d01a6778d38f4e2714fcf2d6ef4
2018-05-22 16:08:43 +09:00
Makoto Kato 71b2579c1e Bug 1463330 - Move CanPasteTransferable and PreDestroy to out of nsIEditor. r=masayuki
CanPasteTransferable and PreDestroy aren't used from script (inc. comm-central
and bluegriffon), so we should move these to out of nsIEditor.

MozReview-Commit-ID: GRfBobAm2qi

--HG--
extra : rebase_source : 812792ff43da24bfd9cb99c4b3127e6acdc43ba1
2018-05-22 18:23:21 +09:00
Masayuki Nakano 552423e58f Bug 1456377 - Move composition event handlers from EditorBase to TextEditor r=m_kato
Currently, EditorBase handles most composition events.  However, only
eCompositionChange event handler is in TextEditor and it's the main event
of handling composition.  Therefore, we should make all composition event
handlers in one place for easier to read, and make them non-virtual.

MozReview-Commit-ID: BYDhiPyGKvo

--HG--
extra : rebase_source : ed9db0f49d7ae268c85359e48015e86584f9c999
2018-04-19 00:31:51 +09:00
Makoto Kato 3f513220d0 Bug 1455533 - Part 3. Remove unused nsIEditor.outputToStream. r=masayuki
No one uses outputToStream even if c-c and BlueGriffon.  We should remove this.

MozReview-Commit-ID: LEUtfc89DBe

--HG--
extra : rebase_source : f0c5aa918f577ca8a285afd2414fe3da6545fefc
2018-04-20 16:41:07 +09:00
Masayuki Nakano 043e93a8ba Bug 1451672 - part 21: Refine TextEditor::TypedText() r=m_kato
According to existing comments, TextEditor::TypedText() and
HTMLEditor::TypedText() are intentional bottleneck to debug.  However, only
for that purpose, it and its internal methods are made virtual.  This really
doesn't make sense.

So, this patch creates TextEditor::OnInputText() for callers of TypedText()
with non-empty string, TextEditor::OnInputParagraphSeparator() for callers
of TypedText() with eTypeBreak (Enter key or insertParagraphSeparator),
HTMLEditor::OnInputLineBreak() for callers of TypedText() with eTypeBR
(Shift + Enter or insertLineBreak).  Additionally, this creates internal
non-virtual methods for XPCOM methods which are used as internal methods of
TypedText().  One is InsertTextAsAction() for nsIPlatintextEditor.insertText().
the other is InsertParagraphSeparator() for nsIPlaintextEditor.insertLineBreak().

Although those new methods are not have "WithTransaction" postfix, they must
be clearer they'll use transactions since user input and actions should be
undo-able.

MozReview-Commit-ID: AmOkMqovIKA

--HG--
extra : rebase_source : 9c0f4b25fa2a36ad2f3394f72eb290824c31d82a
2018-04-16 23:43:36 +09:00
Masayuki Nakano a409fc4d17 Bug 1451672 - part 19: Remove TextEditor::CreateBR() and rename TextEditor::CreateBRImpl() to TextEditor::InsertBrElementWithTransaction() r=m_kato
TextEditor::CreateBR() is just a wrapper of TextEditor::CreateBRImpl() for
automatically retrieving Selection of the editor.

And TextEditor::CreateBRImpl() should be renamed to
TextEditor::InsertBrElementWithTransaction() for making it clearer what
it does.

MozReview-Commit-ID: D8sjVdLrVrd

--HG--
extra : rebase_source : f269f5c3ce598d221d7263c111475dab0dd5f19f
2018-04-16 19:21:29 +09:00
Masayuki Nakano c3efa1de72 Bug 1451672 - part 10: Rename TextEditor::DeleteSelectionImpl() to TextEditor::DeleteSelectionWithTransaction() r=m_kato
MozReview-Commit-ID: 8nypHV8X3js

--HG--
extra : rebase_source : 8ca989bd8d5b9e824ed48a0fafa76993a575d0d0
2018-04-11 19:11:15 +09:00
Masayuki Nakano 80c2ea82ed Bug 1451672 - part 9: Create TextEditor::DeleteSelectionAsAction() as implementation of nsIEditor::DeleteSelection() r=m_kato
First, EditorBase::DeleteSelection() is never used since
TextEditor::DeleteSelection() overrides it but does not call it.  So, this patch
makes EditorBase::DeleteSelection() only returns NS_ERROR_NOT_IMPLEMENTED.

Next, EditorBase::DeleteSelectionImpl() actually removes content for
TextEditor::DeleteSelection().  So, it should be named as
DeleteSelectionWithTransaction().  However, it'll be done in the following
patch.  On the other hand, its callers are EditorBase::HandleKeyPressEvent()
and EditorBase::DeleteSelectionAndPrepareToCreateNode().  Fortunately, they
can be moved to TextEditor simply.  Therefore this patch moves the methods
to TextEditor for making related methods in a place.

Then, we can make the implementation of nsIEditor::TextEditor() as a non-virtual
method, TextEditor::DeleteSelectionAsAction().

MozReview-Commit-ID: KXFDhW3G9lA

--HG--
extra : rebase_source : 15986979279b2cae3b61cda1bf6bf3d9e4987f3f
2018-04-11 17:37:49 +09:00
Boris Zbarsky 945feaec17 Bug 1455052 part 6. Stop using nsIDOMEvent in editor code. r=masayuki
MozReview-Commit-ID: JoP6kMuYQLQ
2018-04-20 12:53:17 -04:00
Makoto Kato 6c2bc77ccf Bug 1451972 - Remove more nsIDOMDocument usages from editor. r=masayuki
We should not use nsIDOMDocument if unnecessary. Because it needs QI to access
nsIDocument.

MozReview-Commit-ID: CMF3tmvBTB9

--HG--
extra : rebase_source : e832023be8d59a2c1e01bd423e6f058b0708dfe9
2018-04-06 14:53:05 +09:00
Makoto Kato 8c5d5f7c30 Bug 1449147 - Clean up more nsIDOMNode usages in editor. r=masayuki
To reduce QI, I would like to replace nsIDOMNode with nsINode.  And some
parameters in *DataTransder.cpp's methods is unused (it uses as nullptr),
so we should remove these parameters.

Also nsIDOMNodeList is unused now, so we should remove this including.

MozReview-Commit-ID: 1QTIkxDazjJ

--HG--
extra : rebase_source : 3961e897fcaa96975facc822821f1e223cab358d
2018-03-27 20:19:35 +09:00
Masayuki Nakano a1f13e5b38 Bug 1447924 - part 5: Merge TextEditor::Undo()/Redo() with EditorBase::Undo()/Redo() r=m_kato
EditorBase::Undo() and EditorBase::Redo() implement only undo/redo function.
TextEditor::Undo() and TextEditor::Redo() call them with calling some
notification methods.  However, this causes redundant AutoRules instance
creation and doesn't make sense to separate them under current design.

Therefore this patch merges them into TextEditor.  Unfortunately, they are
XPCOM methods but we cannot implement proper overloads of non-virtual since
they are already minimized design.  Fortunately, reducing only one virtual
call per undo/redo isn't so effective.  So, let's keep simpler design.

Additionally, this patch makes them stop committing composition because
Chrome does not commit composition even if "undo"/"redo" is requested with
execCommand() during composition and it doesn't make sense to try to
undo/redo after committing composition since first undoable transaction
becomes the committing composition and committing composition causes
removing all transactions from redo transaction queue.

MozReview-Commit-ID: 78qlV2I9Lzk

--HG--
extra : rebase_source : 545c787d47fe02bf7e085be9d3ae028816750e69
2018-03-23 01:21:17 +09:00
Masayuki Nakano 537b829474 Bug 1447213 - Change editor methods which take |const EditorRawDOMPoint&| but called with EditorDOMPoint.AsRaw() to template methods r=m_kato
A lot of methods take |const EditorRawDOMPoint&| as their argument.  However,
some of them are called with EditorDOMPoint::AsRaw(). This is not good for
performance because:
1. Needs to create temporary instance of EditorRawDOMPoint.
2. EditorRawDOMPoint::AsRaw() may be used by simple mistake.
3. Such methods may call EditorRawDOMPoint::Offset(), however, it's not copied
   to the original EditorDOMPoint instance.  So, callers may need to compute
   offset again.

So, such methods should be changed to template methods if they are not virtual
method and AsRaw() should be gotten rid of for prevent it looking not expensive.

MozReview-Commit-ID: DAqqW4a2EMS

--HG--
extra : rebase_source : 120b920477fe6e7231271411a00994325acdb842
2018-03-20 14:05:47 +09:00
Makoto Kato 250a70b6ca Bug 1446861 - Remove more nsIDOMElement usages from editor. r=masayuki
Except table access and XPCOM methods for c-c, tests and etc, we can remove
more nsIDOMElement usages to avoid QI.

MozReview-Commit-ID: HO5kAaZAs6Q

--HG--
extra : rebase_source : 41ede0bace33504ad852dc4e0016ea346cd7bdee
2018-03-19 14:14:45 +09:00
Boris Zbarsky 145e566cd8 Bug 1444686 part 10. Remove nsIDOMDragEvent::GetDataTransfer. r=mystor
MozReview-Commit-ID: LwKqWBGXVcN
2018-03-13 16:24:00 -04:00
Makoto Kato feb9be572d Bug 1439812 - Move noscript methods of nsIPlainTextEditor to TextEditor. r=masayuki
maxTextLength is unused from script, so I would like to move to TextEditor.
Also, there is no reason to keep setText on nsIPlainText.

MozReview-Commit-ID: CZ8pa9Pm8qt

--HG--
extra : rebase_source : ea58a20510b2211dcf440955ec8dc49d57337437
2018-02-21 13:21:57 +09:00
Makoto Kato 6e437ccf06 Bug 1436272 - Move noscript methods in nsIEditor to EditorBase. r=masayuki
Since We can use EditorBase/TextEditor/HTMLEditor directly,  we can
movei noscript methods in nsIEditor to each class.

Also, Init is unnecessary to use nsIDOMDocument and nsIContent since method
isn't in IDL.  And some methods are unused now.

MozReview-Commit-ID: D3B6oSlcT0L

--HG--
extra : rebase_source : 6cab2e6e7b4ba8cfb56d8320be24ca4afcbe55fb
extra : amend_source : 1d8c59086a9158a49dd270b64ecf8341ed4002ce
2018-02-07 15:28:04 +09:00
Masayuki Nakano b2a3e52b16 Bug 1430021 - part 1: Move |RefPtr<TextEditRules> mRules| from TextEditor to EditorBase r=m_kato
For calling some methods of mRules from EditorBase, let's move mRules member
from TextEditor to EditorBase.

Unfortunately, TextEditRules.h depends on EditAction which is declared in
EditorBase.h and that caused unnecessary include hell of EditorBase.h.  So,
let's move it to an independent header file.

MozReview-Commit-ID: 5HiSZLP9WHH

--HG--
extra : rebase_source : 3e2c40385a6f3d6d1e03ef4e213434383bb37d5f
2018-01-12 19:01:04 +09:00
Olli Pettay 3a7a79b6b8 Bug 1428747 - Make EditorBase::GetDOMEventTarget() to return EventTarget* and GetFocusedContent() return nsIContent* in order to optimize out some AddRef/Release calls, r=masayuki
--HG--
extra : rebase_source : 86be9af360438fcb1fa63f07994e41cf12d9c2e2
2018-01-09 15:41:42 +02:00
Masayuki Nakano 17f76b7cd6 Bug 1393337 - Get rid of nsIEditRules r=m_kato
nsIEditRules is a super class of only mozilla::TextEditRules and not scriptable.
So, we can get rid of it.

This patch merges RulesInfo with TextRulesInfo and name new class is RulesInfo
for minimizing the code change.

Additionally, adds two methods AsHTMLEditRules() and its const version.
They make existing cast code safer.

MozReview-Commit-ID: KwWH3ADj3Bv

--HG--
extra : rebase_source : 4517bdc95b530530e9756e07c4b6cce78c002073
2017-12-21 14:52:32 +09:00
Masayuki Nakano 315b823d03 Bug 1424676 - part 1: Make TextEditor::CreateBR() take |const EditorRawDOMPoint&| to specify the insertion point r=m_kato
TextEditor::CreateBR() should take |const EditorRawDOMPoint&| to specify the
insertion point instead of a set of container node and offset in it.

MozReview-Commit-ID: 4PrWzwmIgfD

--HG--
extra : rebase_source : c509907002693f3b77cd00bf77cfd0f26704fd65
2017-12-11 16:01:50 +09:00