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
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
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
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
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
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
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
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
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
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
This patch was written entirely by the following script:
#!/bin/bash
if [ ! -d "./.hg" ]
then
echo "Not in a source tree." 1>&2
exit 1
fi
find . -regex '.*\(ref\|crash\)test.*\.list' | while read FILENAME
do
echo "Processing ${FILENAME}."
# The following has four substitutions:
# * The first one replaces the *first* argument to fuzzy() when it doesn't
# have a - in it, by replacing it with an explicit 0-N range.
# * The second one does the same for the *second* argument to fuzzy().
# * The third does the same for the *second* argument to fuzzy-if().
# * The fourth does the same for the *third* argument to fuzzy-if().
#
# Note that this is using perl rather than sed because perl doesn't
# support non-greedy matching, which is needed for the first argument to
# fuzzy-if.
perl -pi -e 's/(fuzzy\()([^ ,()-]*)(,[^ ,()]*\))/${1}0-${2}${3}/g;s/(fuzzy\([^ ,()]*,)([^ ,()-]*)(\))/${1}0-${2}${3}/g;s/(fuzzy-if\([^ ]*?,)([^ ,()-]*)(,[^ ,()]*\))/${1}0-${2}${3}/g;s/(fuzzy-if\([^ ]*?,[^ ,()]*,)([^ ,()-]*)(\))/${1}0-${2}${3}/g' "${FILENAME}"
done
Differential Revision: https://phabricator.services.mozilla.com/D2974
--HG--
extra : moz-landing-system : lando
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
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
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
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
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
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
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
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
For explaining what it does clearer, we should rename it and corresponding
member.
MozReview-Commit-ID: 6U8FgfHBbCL
--HG--
extra : rebase_source : 50bc3ce0d3b9900939c7e6e8a137abe2288cf727
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
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
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
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
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
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
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
DocShells are associated with outer DOM Windows, rather than Documents, so
having the getter on the document is a bit odd to begin with. But it's also
considerably less convenient, since most of the times when we want a docShell
from JS, we're dealing most directly with a window, and have to detour through
the document to get it.
MozReview-Commit-ID: LUj1H9nG3QL
--HG--
extra : source : fcfb99baa0f0fb60a7c420a712c6ae7c72576871
extra : histedit_source : 5be9b7b29a52a4b8376ee0bdfc5c08b12e3c775a
DocShells are associated with outer DOM Windows, rather than Documents, so
having the getter on the document is a bit odd to begin with. But it's also
considerably less convenient, since most of the times when we want a docShell
from JS, we're dealing most directly with a window, and have to detour through
the document to get it.
MozReview-Commit-ID: LUj1H9nG3QL
--HG--
extra : rebase_source : a13c59d1a5ed000187c7fd8e7339408ad6e2dee6
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
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
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
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
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
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
InsertTextWithQuotations() is called only by HTMLEditor::Rewrap(). So,
HTMLEditor::InsertTextWithQuotations() is always called. Therefore, we can
make it just return NS_ERROR_NOT_IMPLEMENTED.
MozReview-Commit-ID: FvmY2x3OOn7
--HG--
extra : rebase_source : be567c3882f81c83d2c07955c07202bb9ce2d797