Commit Graph

5525 Commits

Author SHA1 Message Date
Masayuki Nakano
f1cdc15e87 Bug 1482019 - part 4: Reduce the indent level of the last block in HTMLEditor::GetSelectedNode() r=m_kato
The first check of the last block of HTMLEditor::GetSelectedNode() can use
early-return style.  Additionally, |current| is not necessary since Selection
is not changed since the method retrieved first range.  So, we can get rid of
|current| and the |nullptr| case of it.
2018-08-10 17:46:33 +09:00
Masayuki Nakano
0dd29e1830 Bug 1482019 - part 3: Minimize some scope of auto varaiables in HTMLEditor::GetSelectedNode() r=m_kato
Some variables in HTMLEditor::GetSelectedNode() are declared very large block
they are not used and/or referred.  So, we can get rid of some variables or
move smaller block.
2018-08-10 17:41:58 +09:00
Masayuki Nakano
837bcd9d8e Bug 1482019 - part 2: Make HTMLEditor::GetSelectedNode() take nsAtom* for element name r=m_kato
Using nsAtom makes the method faster and simpler, although the caller needs
to atomize lower-cased string.
2018-08-10 17:30:04 +09:00
Masayuki Nakano
8e992098fa Bug 1482019 - part 1: Create non-virtual method HTMLEditor::GetSelectedNode() for implementing nsIHTMLEditor::GetSelectedElement() r=m_kato
For making each diff compact, this bug needs some patches.

First of all, this patch moves implementation of
nsIHTMLEditor::GetSelectedElement() to new non-virtual method
HTMLEditor::GetSelectedNode().
2018-08-10 16:51:52 +09:00
Masayuki Nakano
3b38503bf4 Bug 1482019 - part 0: Add automated tests for nsIHTMLEditor.getSelectedElement() r=m_kato
The HTMLEditor::GetSelectedElement() is ugly.  Probably, it's checked only with
expected simple cases since the result does not make sense in some cases.

For example, when Selection is collapsed, it returns an element only when
"href" is specified with the argument.  When Selection selects only one
element node (including its children), it quickly returns the node, however,
in the slow path, it returns second element node if first element node matches
with the argument.  Or returns first element ndoe if it does not match with
the argument.

For preventing regressions, new test is designed to keep current odd behavior.

The new test is disabled only debug build on Android because adding this test
causes permanent orange of non-related test,
dom/tests/mochitest/fetch/test_request.html, see bug 1480702.
2018-08-13 15:31:56 +09:00
Makoto Kato
d3b4ee4c97 Bug 1483434 - Allow nullptr parameter for PriorVisibleNode and NextVisibleNode. r=masayuki
Summary:
Sometimes the caller of PriorVisibleNode or NextVisibleNode doesn't use
outVisNode and/or outvisOffset. But both methods require all parameters and
it don't allow nullptr. It is complex whether parameter is used or unused.

So I would like to allow nullptr.

Also, this methods can change to const method, so I will change some methods
to const method too for this change.

Reviewers: masayuki

Tags: #secure-revision

Bug #: 1483434

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

--HG--
extra : rebase_source : 5bd9c87f05c8e88879268188a46a4a80126bd3e5
2018-08-14 18:26:46 +09:00
Masayuki Nakano
557a9e3c62 Bug 1482018 - Create non-virtual methods of nsIHTMLEditor::Indent() equivalents r=m_kato
nsIHTMLEditor::Indent() is used for handling Tab key in HandleKeyPressEvent()
and used for implementing indent/outdent commands.  Unfortunately, it takes
string argument to switch between indent or outdent.  So, it does not make
sense to use this in C++ code.

This patch creates IndentAsAction() and OutdentAsAction() as public methods
and the implementation is moved to IndentOrOutdentAsSubAction() which takes
EditSubAction to switch between indent and outdent.

Note that HandleKeyPressEvent() uses the new public methods.  However, this
is not problem for the future changes since HandleKeyPressEvent() is an
exception which may call other public methods.

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

--HG--
extra : moz-landing-system : lando
2018-08-14 08:30:09 +00:00
Masayuki Nakano
ecc94d2ee3 Bug 1482017 - part 1: Create HTMLEditor::CollapseSelectionAfter() for internal use of nsIHTMLEditor::SetCaretAfterElement() r=m_kato
We need to make it possible nsIHTMLEditor::SetCaretAfterElement() to distinguish
if it's called by outer class or editor itself.  Therefore, this patch creates
CollapseSelectionAfter() for internal use.

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

--HG--
extra : moz-landing-system : lando
2018-08-14 06:13:54 +00:00
Masayuki Nakano
bdc0aaa4af Bug 1482017 - part 0: Add automated tests for nsIHTMLEditor.setCaretAfterElement() r=m_kato
The new test is disabled only debug build on Android because adding this test
causes permanent orange of non-related test,
dom/tests/mochitest/fetch/test_request.html, see bug 1480702.

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

--HG--
extra : moz-landing-system : lando
2018-08-15 12:46:51 +00:00
Masayuki Nakano
5499f18c98 Bug 1482016 - part 1: Create HTMLEditor::SelectContentInternal() for internal use of HTMLEditor::SelectElement() r=m_kato
For making it possible HTMLEditor::SelectElement() to distinguish if it's
called by outer class or editor itself, this patch creates
HTMLEditor::SelectContentInternal().

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

--HG--
extra : moz-landing-system : lando
2018-08-15 08:59:40 +00:00
Masayuki Nakano
9eb55eb576 Bug 1482016 - part 0: Add automated tests for nsIHTMLEditor.selectElement() r=m_kato
The new test is disabled only debug build on Android because adding this test
causes permanent orange of non-related test,
dom/tests/mochitest/fetch/test_request.html, see bug 1480702.

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

--HG--
extra : moz-landing-system : lando
2018-08-15 08:49:25 +00:00
Cosmin Sabou
425b934989 Backed out changeset 419fd4edef4f (bug 1482016) for turning Bug 1480702 into permafail. a=backout 2018-08-15 04:29:48 +03:00
Cosmin Sabou
3a67fed29b Backed out changeset 302ce3cdb98f (bug 1482016) for turning bug 1480702 into permafail. a=backout 2018-08-15 04:17:26 +03:00
Andreea Pavel
5d75e43adc Merge mozilla-inbound to mozilla-central. a=merge 2018-08-14 19:15:33 +03:00
Henri Sivonen
3edc601325 Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj.
Correctness improvements:

 * UTF errors are handled safely per spec instead of dangerously truncating
   strings.

 * There are fewer converter implementations.

Performance improvements:

 * The old code did exact buffer length math, which meant doing UTF math twice
   on each input string (once for length calculation and another time for
   conversion). Exact length math is more complicated when handling errors
   properly, which the old code didn't do. The new code does UTF math on the
   string content only once (when converting) but risks allocating more than
   once. There are heuristics in place to lower the probability of
   reallocation in cases where the double math avoidance isn't enough of a
   saving to absorb an allocation and memcpy.

 * Previously, in UTF-16 <-> UTF-8 conversions, an ASCII prefix was optimized
   but a single non-ASCII code point pessimized the rest of the string. The
   new code tries to get back on the fast ASCII path.

 * UTF-16 to Latin1 conversion guarantees less about handling of out-of-range
   input to eliminate an operation from the inner loop on x86/x86_64.

 * When assigning to a pre-existing string, the new code tries to reuse the
   old buffer instead of first releasing the old buffer and then allocating a
   new one.

 * When reallocating from the new code, the memcpy covers only the data that
   is part of the logical length of the old string instead of memcpying the
   whole capacity. (For old callers old excess memcpy behavior is preserved
   due to bogus callers. See bug 1472113.)

 * UTF-8 strings in XPConnect that are in the Latin1 range are passed to
   SpiderMonkey as Latin1.

New features:

 * Conversion between UTF-8 and Latin1 is added in order to enable faster
   future interop between Rust code (or otherwise UTF-8-using code) and text
   node and SpiderMonkey code that uses Latin1.

MozReview-Commit-ID: JaJuExfILM9
2018-08-14 14:43:42 +03:00
Masayuki Nakano
fc9f86fabd Bug 1482016 - part 1: Create HTMLEditor::SelectContentInternal() for internal use of HTMLEditor::SelectElement() r=m_kato
For making it possible HTMLEditor::SelectElement() to distinguish if it's
called by outer class or editor itself, this patch creates
HTMLEditor::SelectContentInternal().

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

--HG--
extra : moz-landing-system : lando
2018-08-14 08:36:59 +00:00
Tiberius Oros
0930c2bbe1 Backed out changeset ec2b796f1af2 (bug 1482016) for build bustages on builds/worker/workspace/build/src/editor/libeditor/HTMLTableEditor on a CLOSED TREE 2018-08-14 09:17:44 +03:00
Masayuki Nakano
cbb0249edb Bug 1482016 - part 1: Create HTMLEditor::SelectContentInternal() for internal use of HTMLEditor::SelectElement() r=m_kato
For making it possible HTMLEditor::SelectElement() to distinguish if it's
called by outer class or editor itself, this patch creates
HTMLEditor::SelectContentInternal().

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

--HG--
extra : moz-landing-system : lando
2018-08-13 07:21:28 +00:00
Masayuki Nakano
aa59ff8fc6 Bug 1482016 - part 0: Add automated tests for nsIHTMLEditor.selectElement() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D3186

--HG--
extra : moz-landing-system : lando
2018-08-14 05:56:24 +00:00
Adrian Wielgosik
be0c1a4f55 Bug 1481645 - Remove some redundant uses of do_QueryInterface. r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D2893

--HG--
extra : moz-landing-system : lando
2018-08-13 09:05:19 +00:00
Masayuki Nakano
e235a4e390 Bug 1482015 - Create HTMLEditor::RemoveInlinePropertyInternal() for internal use r=m_kato
For making it possible to distinguish if HTMLEditor::RemoveInlineProperty() is
called by outer class or editor itself, this patch creates
Create HTMLEditor::RemoveInlinePropertyInternal() and makes the internal
callers use this new method.

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

--HG--
extra : moz-landing-system : lando
2018-08-13 06:16:24 +00:00
Masayuki Nakano
205851fb7c Bug 1482013 - Create HTMLEditor::SetInlinePropertyInternal() for internal use r=m_kato
For making it possible to distinguish if SetInlineProperty() is called by outer
class or the editor itself, this patch creates SetInlinePropertyInternal().

Additionally, this makes the first argument of SetInlineProperty() from
nsAtom* to nsAtom& since it's not nullable.

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

--HG--
extra : moz-landing-system : lando
2018-08-13 05:16:10 +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
fa50ac3342 Bug 1482012 - part 1: Create HTMLEditor::PasteInternal() for internal use r=m_kato
HTMLEditor::Paste() is an override of nsIEditor.  So, it's virtual and public.
We should use protected method for internal use and should make it non-virtual
if possible.  This patch creates PasteInternal() which is a protected
non-virtual method.

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

--HG--
extra : moz-landing-system : lando
2018-08-13 04:15:34 +00:00
Makoto Kato
fef13a2f66 Bug 1464251 - SplitNodeDeepWithTransaction might create orphan node. r=masayuki
SplitStyleAbovePoint calls SplitNodeDeepWithTransaction repeatedly. If
SplitNodeDeepWithTransaction creates orphan node like this test case,
this crash occurs.  So we should check whether node becomes orphan node.

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

--HG--
extra : moz-landing-system : lando
2018-08-09 08:22:50 +00:00
Geoff Brown
11f0d46c60 Bug 1481587 - Skip a few mochitests on Android x86 7.0 only; r=snorp
Skip a few failing tests on Android 7, to enable green runs of mochitest-cl
and mochitest-gpu on packet.net.
2018-08-10 07:54:41 -06:00
Masayuki Nakano
5f872684af Bug 1467800 - Create HTMLEditor::InsertTextWithQuotationsInternal() for internal use of InsertTextWithQuotations() r=m_kato
HTMLEditor::InsertTextWithQuotations() is called by HTMLEditor::Rewrap() but
it's an XPCOM method, i.e., can be called by anybody.  For making possible to
distinguish whether it's called by outer or not, we should create non-virtual
method and Rewrap() should use it instead.

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

--HG--
extra : moz-landing-system : lando
2018-08-09 12:24:53 +00:00
Masayuki Nakano
bf98468b58 Bug 1482007 - part 2: Make all callers of EditorBase::BeginTransaction() use AutoTransactionBatch r=m_kato
This patch also removes LOCK_DOC() and UNLOCK_DOC() from TextServiceDocument.cpp
since they looks like we cannot use early-return style without call of
UNLOCK_DOC() even after removing EndTransaction() calls.  However, they
are defined as empty.  So, they do nothing even since first landing.
Therefore, there is no reason to keep them.

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

--HG--
extra : moz-landing-system : lando
2018-08-09 11:52:46 +00:00
Masayuki Nakano
89e5796790 Bug 1482007 - part 1: Create a helper class to guarantee to call nsIEditor::EndTransaction() after nsIEditor::BeginTransaction() call r=m_kato
This patch also creates non-virtual methods,
EditorBase::BeginTransactionInternal(), EditorBase::EndTransactionInternal(),
TransactionManager::BeginBatchInternal() and
TransactionManager::EndBatchInternal().

Although, this could be replaced with API to use PlaceholderTransaction,
we should investigate it when we have much time.

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

--HG--
extra : moz-landing-system : lando
2018-08-09 11:45:41 +00:00
Emilio Cobos Álvarez
1a7f1a4dbf Bug 1478604 - Fix RepaintSelectionRunner so that it does something for non-presShell impls. r=masayuki
The regressing bug made RepaintSelectionRunner do nothing for any
nsISelectionListener that wasn't a PresShell.

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

--HG--
extra : moz-landing-system : lando
2018-08-07 12:55:21 +00:00
Masayuki Nakano
2413e81af0 Bug 1480666 - Make EditorBase::EndUpdateViewBatch() non-virtual r=m_kato
Although HTMLEditor::EndUpdateViewBatch() calls a method of nsIHTMLEditor,
the additional work after calling EditorBase::EndUpdateViewBatch() is enough
simple. So, we can move the implementation in HTMLEditor to EditorBase and
make it non-virtual.

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

--HG--
extra : moz-landing-system : lando
2018-08-06 04:42:39 +00:00
Masayuki Nakano
45a67c4b77 Bug 1480663 - Make EditorBase::IsModifiableNode() non-virtual r=m_kato
HTMLEditor::IsModifiableNode() is enough simple and can be checked in
EditorBase. So, we should make it non-virtual and check if instance is
HTMLEditor in EditorBase::IsModifiableNode().

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

--HG--
extra : moz-landing-system : lando
2018-08-03 11:10:46 +00:00
Masayuki Nakano
7484cc4573 Bug 1480055 - part 4: Make AutoTransactionsConserveSelection take reference of Editor rather than pointer r=m_kato
It's always created with non-nullptr.  So, making it treat reference of
EditorBase makes its implementation simpler.

Note that this changes comment in EditorBase::InsertTextWithTransaction() to
a MOZ_ASSERT() for detecting bugs.  However, the comment is wrong.  When
the insertion is for updating composition string, callers don't need to create
AutoTransactionsConserveSelection since it'll be ignored by
CompositionTransaction.  So, the new MOZ_ASSERT() checks whether it's
in composition or prevented transaction changing Selection.

MozReview-Commit-ID: 6jZ4LpksyoD

--HG--
extra : rebase_source : 61ca9272ddea165b3691cf1ce42dc6f4df099a36
2018-08-01 21:30:14 +09:00
Masayuki Nakano
4292293e8c Bug 1480055 - part 3: Create non-virtual method to set EditorBase::mAllowsTransactionsToChangeSelection r=m_kato
There is no non-virtual method to modify
EditorBase::mAllowsTransactionsToChangeSelection.  Therefore,
AutoTransactionsConserveSelection calls virtual method,
nsIEditor::SetShouldTxnSetSelection() twice (from both constructor and
destructor).  So, we should save this unnecessary cost.

MozReview-Commit-ID: B7TYGnGtuLB

--HG--
extra : rebase_source : 26ce77fb63a1967cca88b002cd65e1105477a63d
2018-08-01 21:11:44 +09:00
Masayuki Nakano
a9559a1d82 Bug 1480055 - part 2: Rename EditorBase::GetShouldTxnSetSelection() to EditorBase::AllowsTransactionsToChangeSelection() r=m_kato
For explaining what it does clearer, we should rename it and corresponding
member.

MozReview-Commit-ID: 6U8FgfHBbCL

--HG--
extra : rebase_source : 50bc3ce0d3b9900939c7e6e8a137abe2288cf727
2018-08-01 20:53:57 +09:00
Masayuki Nakano
470feacd31 Bug 1480055 - part 1: Remove nsIEditor::shouldTxnSetSelection() r=m_kato
nsIEditor::ShouldTxnSetSelection() is used only by DeleteRangeTransaction
(even if including comm-central and BlueGriffon) and there is a non-virtual
method EditorBase::GetShouldTxnSetSelection().  So, we can remove this.

MozReview-Commit-ID: JWSCw9k6lI0

--HG--
extra : rebase_source : 2509274216a1493134757a7d106464f06ea0ba57
2018-08-01 20:16:30 +09: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
Boris Zbarsky
754087a992 Bug 1446940 part 5. Stop getting docshells from windows via getInterface in dom/editor/etc code. r=kmag 2018-08-01 13:07:11 -04:00
Emilio Cobos Álvarez
8f34c12e14 Bug 1479860: Remove unused aCompileEventHandlers argument from BindToTree. r=bz
Mostly automatic via sed. Only parts which I touched manually (apart from a
couple ones where I fixed indentation or which had mispelled arguments) are the
callers. I may have removed a couple redundant `virtual` keywords as well when
I started to do it manually, I can revert those if wanted.

Most of them are just removing the argument, but in Element.cpp I also added an
assertion for GetBindingParent when binding the ShadowRoot's kids (the binding
parent is set from the ShadowRoot constructor, and I don't think we bind a
shadow tree during unlink or what not which could cause a behavior difference).

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

MozReview-Commit-ID: 2oIgatty2HU
2018-08-01 10:42:54 +02:00
Bogdan Tara
b95ba78360 Merge inbound to mozilla-central. a=merge 2018-07-31 21:30:12 +03:00
Emilio Cobos Álvarez
2996813963 Bug 1479450: Implement nsCSSProps::LookupProperty using Rust. r=xidorn
Always assume allowed-for-all-content. There are a couple callers which weren't
doing that:

 * A unit test -> removed.

 * ComputeAnimationDistance: Used for testing (in transitions_per_property), and
   for the animation inspector. The animation inspector shouldn't show
   non-enabled properties. The transitions_per_property test already relies on
   getComputedStyle stuff which only uses eForAllContent.

 * GetCSSImageURLs: I added this API for the context menu page and such. It
   doesn't rely on non-enabled-everywhere properties, it was only using
   eInChrome because it was a ChromeOnly API, but it doesn't really need this.

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

MozReview-Commit-ID: 4VOi5Su3Bos
2018-07-31 12:00:15 +02:00
Makoto Kato
a8ca18700d Bug 1479383 - Use const method for some GetEditorRoot methods. r=masayuki
Some methods to get editor root etc has unnecessary refcounting and it isn't
const method.  So we should remove unnecessary refcounting and change to
const method.

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

--HG--
extra : moz-landing-system : lando
2018-07-30 10:35:43 +00:00
Masayuki Nakano
a9d57dd8a8 Bug 1478564 - part 1: Optimize TextEditRules::HandleNewLines() r=m_kato
TextEditRules::HandleNewLines() is expensive since it may scan all of given
string twice and more.  On the other hand, in most cases, given string does
not contain \n, \r nor \r\n.

First, for avoid using nsTString::FindCharInSet(), HandleNewLine() should
receive string which never contains \r nor \r\n.  Then, it always can use
nsTSubstring::FindChar() instead.

Next, HandleNewLines() should do nothing if given string does not contain \n.

Finally, because of unused, this removes unnecessary HandleNewLines() argument
which can specify the way to handle new lines.

MozReview-Commit-ID: 8WSfxfkuFgN

--HG--
extra : rebase_source : 1c05721162a30288929d030c0a15fe83a50fe9d2
2018-07-24 17:46:12 +09:00
Masayuki Nakano
58cbd9a01e Bug 1478564 - part 0: Add automated tests for TextEditRules::HandleNewLines() r=m_kato
MozReview-Commit-ID: L55zBuflDBP

--HG--
extra : rebase_source : 1df602adddf15534198b12191c41197d14ed045b
2018-07-26 22:27:47 +09:00
Masayuki Nakano
4619306c40 Bug 1478268 - Fix condition of MOZ_ASSERT() in TextEditor::InsertWithQuotationsAsSubAction() r=jorgk+176914
As explained in the comment of TextEditor::InsertWithQuotationsAsSubAction(),
it excepts that TextEditRules::WillDoAction() won't handle it.  So, the
MOZ_ASSERT() should check |!handled|, not |handled|.

Caused this regression means that we do not have test to paste text into
<textarea>.  Therefore, this patch adds the tests.

MozReview-Commit-ID: 2UUSVrmmNVK

--HG--
extra : rebase_source : 912d5428aeed83a7a46ec7e4a49c73c33dd7b295
2018-07-26 17:01:15 +09:00
Masayuki Nakano
b590219ca3 Bug 1478605 - HTMLEditRules::SplitMailCites() should check if split left node has a primary frame before accessing it r=jorgk+176914
The crash at this point may be caused by unexpected behavior change.  However,
it's difficult to investigate what causes the crash.  So, let's just avoid
the crash to investigate what unexpected behavior occurs.

MozReview-Commit-ID: P6YZTqP7zI

--HG--
extra : rebase_source : 24620884511aa3f1bc9fddb6049fcf6554150439
2018-07-26 19:38:33 +09:00
Boris Zbarsky
75abc43e0d Bug 1476145 part 8. Stop using getInterface(nsIDOMWindowUtils) in various test code. r=kmag 2018-07-24 19:47:43 -04: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