Commit Graph

9261 Commits

Author SHA1 Message Date
Masayuki Nakano
448571fd81 Bug 1533293 - part 2: Rewrite EditorBase::SelectEntireDocument() and its overrides r=m_kato
`EditorBase::SelectEntierDocument()` uses `Selection::Extend()` but it's too
slow.  It should use `Selection::SetStartAndEndInLimiter()` instead.

Additionally, `TextEditor::SelectEntierDocument()` shrink the result of
`EditorBase::SelectEntierDocument()` with `Selection::Extend()` if there is
a `moz-<br>` element.  So, `TextEditor::SelectEntinerDocument()` should set
its expected selection with a call for saving the runtime cost.

Then, we don't need to make `EditorBase::SelectEntierDocument()` as non-pure
virtual method.  So, this patch makes each its callers call
`Selection->SelectAllChildren()` directly.

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

--HG--
extra : moz-landing-system : lando
2019-03-18 01:51:53 +00:00
Masayuki Nakano
d4cbc09db8 Bug 1533293 - part 1: Create Selection::SetStartAndEnd() to set new range as far as faster r=smaug
`Selection::Extend()` is too slow because:
- it may create some `nsRange` instances.
- it users `nsContentUtils::ComparePoints()` multiple times.

Therefore, we can improve the performance if we can stop using it in some
places.  First, this patch creates `Selection::SetStartAndEnd()` and
`Selection::SetStartAndEndInLimiter()` for internal use.  They remove
current ranges, reuse `nsRange` instance as far as possible and add new
range which is set by their arguments.  Then, this patch makes
`Selection::SelectAllChildren()` stop using `Selection::Extend()`.  At this
time, this fixes a web-compat issue.  `Selection::Expand()` cannot cross the
selection limiter boundary when there is a limiter (e.g., when an editing host
has focus).  But we can now fix this with using the new internal API.

Note that methods in editor shouldn't move selection to outside of active
editing host.  Therefore, this patch adds `Selection::SetStartAndEndInLimiter()`
and `Selection::SetBaseAndExtentInLimiter()` for them.

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

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

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

--HG--
extra : moz-landing-system : lando
2019-03-15 05:01:10 +00:00
Boris Zbarsky
4ff91d4938 Bug 1506439 part 2. Stop creating a useless nsCOMPtr in DispatchInputEvent. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D23068

--HG--
extra : moz-landing-system : lando
2019-03-13 02:34:48 +00:00
Boris Zbarsky
f9a32ca8b1 Bug 1534370 part 4. Remove some simple MOZ_CAN_RUN_SCRIPT_BOUNDARY annotations from editor. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D23044

--HG--
extra : moz-landing-system : lando
2019-03-12 01:50:41 +00:00
Boris Zbarsky
9a4ba73134 Bug 1534370 part 3. Mark InsertFromTransferable as MOZ_CAN_RUN_SCRIPT. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D23042

--HG--
extra : moz-landing-system : lando
2019-03-12 01:55:03 +00:00
Boris Zbarsky
6d1f77b386 Bug 1534370 part 2. Annotate doCommand as MOZ_CAN_RUN_SCRIPT. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D23041

--HG--
extra : moz-landing-system : lando
2019-03-12 01:57:42 +00:00
Boris Zbarsky
358e378b63 Bug 1505029. Teach our static analysis about nsCOMPtr<nsISupports> being a strong ref. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D23021

--HG--
extra : moz-landing-system : lando
2019-03-12 21:04:07 +00:00
Makoto Kato
ae43a8cf0a Bug 676268 - Part 1. Support text/html on Android clipboard backend. r=geckoview-reviewers,snorp
Summary: Actually, we only support `text/unicode` mime type on Android clipboard backend.  But Android API 16+ supports `text/html`, so we should support this type since Chrome/Blink already supports it.

Reviewers: #geckoview-reviewers, snorp

Reviewed By: #geckoview-reviewers, snorp

Bug #: 676268

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

--HG--
extra : rebase_source : 17ef0aa06b83b812bb9bccfab93a72e0b37f9652
2019-03-20 14:47:19 +09:00
Makoto Kato
ba8662db5b Bug 1533250 - Remove *JSAndPlugins* methods from nsIEditingSession. r=masayuki
Firefox, comm-central and bluegriffon don't use `*JSAndPlugin*` methods of
`nsIEditingSession` from script. Let's remove or move to `nsEditingSession`.

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

--HG--
extra : rebase_source : 256fb4025fe8c6f5a61d5b015af942ff65759c23
2019-02-10 19:41:43 +09:00
Masayuki Nakano
49207fb1b7 Bug 1532890 - Get rid of CachedWeakPtr due to unused r=m_kato
The class was created for Quantum Flow, but now, nobody uses it.

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

--HG--
extra : moz-landing-system : lando
2019-03-07 04:25:40 +00:00
Masayuki Nakano
8763d4dcac Bug 1532527 - Support "insertFromPasteAsQuotation" inputType value r=smaug
Only Firefox has an operation to paste clipboard data as quoted text
(Control + middle button paste).  Input Events Level 1 and Level 2 declared
new inputType value for this operation.  Therefore, we should support it.

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

--HG--
extra : moz-landing-system : lando
2019-03-05 14:35:43 +00:00
Tim Nguyen
fa021187df Bug 1513343 - Remove textarea binding and replace usages with html:textarea. r=bgrins,dao
Differential Revision: https://phabricator.services.mozilla.com/D15001

--HG--
extra : moz-landing-system : lando
2019-03-05 11:41:42 +00:00
Josef Citrine
dde7723c68 Bug 1485264 - Removed dom.event.highrestimestamp.enabled pref r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D21580

--HG--
extra : moz-landing-system : lando
2019-03-01 18:49:44 +00:00
Marco Bonardo
5c4e44ce0a Bug 1528751 - Add a custom eslint rule to check "consistent" if bracing. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D20753

--HG--
extra : moz-landing-system : lando
2019-02-28 08:39:33 +00:00
James Willcox
61ca9441b1 Bug 1525959 - Skip some mochitests tests under GeckoView r=geckoview-reviewers,esawin
There are few things that are either Fennec-specific or don't work
currently under GeckoView w/ e10s under TestRunnerActivity. Disable
these so we can get some testing going in automation.

This also replaces 'isFennec' with the more correct 'is_fennec'.

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

--HG--
extra : moz-landing-system : lando
2019-02-27 15:01:43 +00:00
Masayuki Nakano
995e03c1d3 Bug 1530250 - Make InsertTagCommand::DoCommandParams() check result of nsCommandParams::GetString() r=m_kato
Accidentally, I removed the check in the previous landing (bug 1529190).  This
patch restores it.

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

--HG--
extra : moz-landing-system : lando
2019-02-27 00:44:18 +00:00
Masayuki Nakano
9609df9a73 Bug 1525481 - part 3: Make editor not expose internal errors to the web r=m_kato
As far as I've tested, Chrome does not throw exception even when editor is
destroyed or editor content is modified unexpectedly.  So, we should return
`NS_OK` from most public methods of editor when internal methods return
`NS_ERROR_EDITOR_DESTROYED` or `NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE`.

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

--HG--
extra : moz-landing-system : lando
2019-02-25 09:07:54 +00:00
Masayuki Nakano
0b16be82cb Bug 1525481 - part 2: Make EditorBase::DoSplitNode() return error if split nodes are moved/removed unexpectedly r=m_kato
We should stop handling splitting nodes if mutation event listeners move or
remove the split nodes unexpectedly because the post processors may not be
able to keep handling the nodes.  For example, if a node is moved to outside
of editing host, we shouldn't touch it anymore due to non-editable.

This patch makes `EditorBase::DoSplitNode()` return new error for making
any parent callers stop their job, but note that the following patch makes
any public methods expose the new error as exception for compatibility with
Chrome.

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

--HG--
extra : moz-landing-system : lando
2019-02-25 08:29:38 +00:00
Masayuki Nakano
dc541393db Bug 1525481 - part 1: Make SplitNodeTransaction::DoTransaction() always check the result of EditorBase::DoSplitNode() r=m_kato
Oddly, `SplitNodeTransaction::DoTransaction()` checks the result of
`EditorBase::DoSplitNode()` only when it's not allowed to change `Selection`.
We should make it always check the result.

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

--HG--
extra : moz-landing-system : lando
2019-02-25 05:00:27 +00:00
Masayuki Nakano
e4a493a90c Bug 1529190 - Make execCommand("createLink") and execCommand("insertImage") aware of URL including non-ASCII characters r=m_kato
`InsertTagCommand::DoCommandParams()` inserts given URL to `href` of `<a>` or
`src` of `<img>`.  However, it treats the given URL includes only ASCII
characters.  Therefore, we cannot insert URL including non-ASCII characters
with `execCommand("createLink")` nor `execCommand("insertImage")`.

This patch makes `nsHTMLDocument::ExecCommand()` set the param as `nsString`
and makes `InsertTagCommand::DoCommandParams()` retrieve it with `GetString()`.

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

--HG--
extra : moz-landing-system : lando
2019-02-25 03:30:50 +00:00
Masayuki Nakano
d926c78b43 Bug 1529177 - Make InsertTagCommand::DoCommandParams() use nsGkAtoms to set attribute r=m_kato
`InsertTagCommand::DoCommandParams()` uses `Element::SetAttribute()` which takes
`nsAString` as attribute name.  For avoiding unnecessary copy of attribute name,
we should make it use `Element::SetAttr()` which takes `nsAtom` instead.

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

--HG--
extra : moz-landing-system : lando
2019-02-22 08:19:37 +00:00
Masayuki Nakano
6e11a1ab32 Bug 1505668 - part 3: Stop supporting "cmd_copyAndCollapseToEnd" since only CopyPasteAssistent refers it but nobody uses it r=m_kato,TYLin
"cmd_copyAndCollapseToEnd" is referred only by CopyPasteAssistent (even
including comm-central and BlueGriffon), but CopyPasteAssistent won't receive
"copy" command to send it.

So, it seems that we can get rid of a lot around CopyPasteAssistent but this
patch just changes the mapping in it ("copy" is mapped to "cmd_copy") and
removes command handlers of "cmd_copyAndCollapseToEnd" completely.

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

--HG--
extra : moz-landing-system : lando
2019-02-22 01:39:14 +00:00
Masayuki Nakano
a0806ef68a Bug 1505668 - part 2: Stop supporting "cmd_setDocumentOptions" since nobody uses it r=m_kato
"cmd_setDocumentOptions" is never used now (even including comm-central and
BlueGriffon).  So, we can stop supporting this command and we can get rid of
the command handler, SetDocumentOptionsCommand.

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

--HG--
extra : moz-landing-system : lando
2019-02-21 11:16:27 +00:00
Masayuki Nakano
4c828577c0 Bug 1505668 - part 1: Stop supporting "cmd_clearUndo" since nobody uses it r=m_kato
"cmd_clearUndo" is never used now (even including comm-central and BlueGriffon).
So, we can stop supporting this command and we can get rid of the command
handler, ClearUndoCommand.

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

--HG--
extra : moz-landing-system : lando
2019-02-21 11:14:11 +00:00
Masayuki Nakano
f4e8c4a068 Bug 1528676 - Remove telemetry probes for HTMLEditors which have shown Gecko build-in editing UIs and if they are operated r=m_kato,Ehsan
Those probes are now expired and we got enough data:

- Almost no user uses the grip to move absolute positioned element
- There were over one thousand users using the inline table editor and the object resizers.
- Such users keep using even after we disabled the UIs by default.

Perhaps, such small number of users keep using the UIs, i.e., I guess the
number won't become smaller in short term.  Therefore, this patch removes the
telemetry probes and members of HTMLEditor which are necessary to call
Telemetry API.

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

--HG--
extra : moz-landing-system : lando
2019-02-22 02:17:27 +00:00
Emilio Cobos Álvarez
f8ecce61ec Bug 1470926 - Null-check mBoundFrame after calling SetSelectionRange on it. r=TYLin
This code was already handling the world going away, but did not handle the case
of just getting unbound, which can happen if some selection listener (e.g.,
AccessibleCaret) flushes layout.

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

--HG--
extra : moz-landing-system : lando
2019-02-21 00:18:15 +00:00
Ting-Yu Lin
d373ed0def Bug 1526097 - Remove nsIFrame::eBlockFrame flag. r=dholbert
Only nsBlockFrame and its subclasses recognize the nsIFrame::eBlockFrame
flag, so we can replace the usage of the flag with either
nsIFrame::IsBlockFrameOrSubclass() or a do_QueryFrame().

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

--HG--
extra : moz-landing-system : lando
2019-02-20 21:18:14 +00:00
Emilio Cobos Álvarez
39d3da7fd5 Bug 1528644 - Internal value changes shouldn't change validity state. r=masayuki
Even less so on reframe, where it's just unsound to do so. I had to give a value
to eSetValue_Internal, since otherwise I cannot check for its presence. I can
further special-case the reframe case if you prefer.

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

--HG--
extra : moz-landing-system : lando
2019-02-19 09:25:55 +00:00
Masayuki Nakano
f8a317eb9a Bug 998941 - part 2-3: Create new constructors of DataTransfer to set only plain text or nsITransferable r=smaug
DataTransfer should have more 2 constructors.  One takes |const nsAString&| and
sets its data to the string.  The other takes |nsITransferable*| and stores only
its data with DataTransferItem.

If given data is external resource like the case of `HTMLEditor::PasteTransferable()`,
we should copy its data to each DataTransferItem because nsITransferable is not
cycle-collectable, but DataTransfer may be grabbed by JS.  Unfortunately, adding
new path to initialize DataTransfer with nsITransferable instance is too risky
because DataTransfer and DataTransferItem work together to initialize each of
them if DataTransfer is in external mode. Therefore, this patch makes the
new constructor temporarily sets it to in external mode, then, cache usable types
first, then, call `FillAllExternalData()` to  make each DataTransferItem initializes
its data by itself, finally, make the constructor set it to internal mode and release
nsITransferable instance.  This is ugly implementation but the most reasonable
way for now because:

- We don't need to change DataTransfer nor DataTransferItem a lot in this bug.
- We don't need to duplicate any code like a loop in `CacheExternalData()`.

In another bug, we should redesign DataTransfer and DataTransferItem to
make DataTransferable easier to be added new constructors.

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

--HG--
extra : moz-landing-system : lando
2019-02-19 07:13:20 +00:00
Masayuki Nakano
474225038e Bug 998941 - part 2-2: Make HTMLEditor set InputEvent.dataTransfer when InputEvent.inputType is "insertFromPaste", "insertFromDrop" or "insertReplacementText" r=smaug,m_kato
InputEvent.dataTransfer should be set to non-null when InputEvent.inputType
is "insertFromPaste", "insertFromDrop" or "insertReplacementText" and
editor is an HTMLEditor instance:
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data

("insertTranspose" and "insertFromYank" are not currently supported on Gecko.)

This patch makes nsContentUtils::DispatchInputEvent() take dataTransfer value
and EditorBase set it via AutoEditActionDataSetter like data value.

However, we need to create other constructors of DataTransfer to create its
read-only instances initialized with nsITransferable or nsAString.  This will
be implemented by the following patch.

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

--HG--
extra : moz-landing-system : lando
2019-02-19 06:33:42 +00:00
Masayuki Nakano
551de121c1 Bug 998941 - part 1-7: Make HTMLEditor set InputEvent.data to serialized color value when InputEvent.inputType is "formatBackColor" or "formatForeColor" r=smaug,m_kato,emilio
Although neither Chrome nor Safari does not set InputEvent.data when the event
is caused by `document.execCommand()` with `backColor`, `foreColor` nor
`hiliteColor`, Safari supports styling color with touchbar and in that case,
Safari sets it (*1).

Additionally, currently Safari uses `rgb()` to represents a color value and
using same rule to serializing color value for CSS OM matches Safari's behavior
and can represent any valid color values.

This patch makes given color value parsed and then serialized with same code
in style system.  If the value is `currentcolor`, `inherit`, `initial` or `reset`, sets
the value as-is for now.  Additionally, when given value is invalid, sets the value
as-is for forward compatibility.

Note that automated tests will be added into input-events-exec-command.html
by the last patch.

1. https://github.com/w3c/input-events/issues/94#issuecomment-461061517

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

--HG--
extra : moz-landing-system : lando
2019-02-19 06:31:28 +00:00
Masayuki Nakano
135f048bdf Bug 998941 - part 1-6: Make HTMLEditor set InputEvent.data when InputEvent.inputType is "fontName" r=smaug,m_kato
Although neither Chrome nor Safari does not set InputEvent.data value when
InputEvent.inputType is "fontName", but it's easy to implement. Therefore, this
patch implements it as declaration of Input Events.

This patch uses given value as-is.  Perhaps, this shouldn't cause any problems
because such value can be set to Element.style.fontFamily without any changes.

Note that automated test will be added into WPT later.

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

--HG--
extra : moz-landing-system : lando
2019-02-19 06:30:50 +00:00
Masayuki Nakano
0d571915df Bug 998941 - part 1-5: Make HTMLEditor set InputEvent.data when InputEvent.inputType is "insertLink" r=smaug,m_kato
Although neither Chrome nor Safari does not set InputEvent.data value when
InputEvent.inputType is "insertLink", but it's easy to implement.  Therefore,
this patch implements it as declaration of Input Events.

This patch sets the value to raw href attribute value because we create
<a> element without absolute URI when web apps call execCommand("createLink")
with relative URI.

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

--HG--
extra : moz-landing-system : lando
2019-02-19 06:30:12 +00:00
Masayuki Nakano
122ab2691a Bug 998941 - part 1-4: Make editor set InputEvent.data to "ltr" or "rtl" when InputEvent.inputType is "formatSetBlockTextDirection" r=smaug,m_kato
When InputEvent.inputType is "formatSetBlockTextDirection" or
"formatSetInlineTextDirection", InputEvent.data value should be one of
"ltr", "rtl", "auto" or "null".
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data

We only supports "ltr" and "rtl" when user switches the direction with
Accel + Shift + X.  Therefore this patch makes EditorBase set the data
to "ltr" or "rtl".

Oddly, with synthesizing the shortcut keys, the command is not executed
properly in the automated test.  Therefore, this patch dispatches the
command directly.

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

--HG--
extra : moz-landing-system : lando
2019-02-19 06:29:38 +00:00
Masayuki Nakano
2eaf64e594 Bug 998941 - part 1-3: Make TextEditor (only when not HTMLEditor instance) set InputEvent.data to inserting string when InputEvent.inputType is "insertFromPaste", "insertFromDrop" or "insertReplacementText" r=smaug,m_kato
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data

Both Input Events Level 1 and Level 2 declare that InputEvent.data should be
set to inserting string only on TextEditor when InputEvent.inputType is
"insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop",
"insertTranspose", "insertReplacementText" or "insertFromYank".

Currently, we support only "insertFromPaste", "insertFromDrop",
"insertReplacementText".  Therefore, this patch makes TextEditor set
EditorBase::mEditActionData::mData only for them (and the instance is not
HTMLEditor's).

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

--HG--
extra : moz-landing-system : lando
2019-02-19 06:28:57 +00:00
Masayuki Nakano
a3484e40c0 Bug 998941 - part 1-2: Make editor set InputEvent.data to inserting text when it sets InputEvent.inputType to "insertText" or "insertCompositionText" r=smaug,m_kato
This patch makes nsContentUtils::DispatchInputEvent() support to set
InputEvent.data.  Whether the its value should be null or DOMString depends
on InputEvent.inputType value.

- https://rawgit.com/w3c/input-events/v1/index.html#overview
- https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
- https://w3c.github.io/input-events/#overview
- https://w3c.github.io/input-events/#dfn-data

According to the draft specs, InputEvent.data should be always inserting text
when inputType is "insertText" or "insertCompositionText" (or
"insertFromCompoition" if Level 2 support is enabled).

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

--HG--
extra : moz-landing-system : lando
2019-02-19 06:28:19 +00:00
Andreea Pavel
7b1605af56 Backed out 3 changesets (bug 1525959, bug 1526002) for failing android
Backed out changeset de0efca1118e (bug 1526002)
Backed out changeset 503cbc86e442 (bug 1525959)
Backed out changeset 33ea61c54aea (bug 1525959)
2019-02-12 23:53:05 +02:00
James Willcox
c7a8bf9699 Bug 1526002 - Replace 'isFennec' with 'is_fennec' in mochitest.ini r=gbrown
Differential Revision: https://phabricator.services.mozilla.com/D19038

--HG--
extra : moz-landing-system : lando
2019-02-10 19:07:57 +00:00
James Willcox
228b5844d5 Bug 1525959 - Skip some mochitests tests under GeckoView r=geckoview-reviewers,esawin
There are few things that are either Fennec-specific or don't work
currently under GeckoView w/ e10s under TestRunnerActivity. Disable
these so we can get some testing going in automation.

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

--HG--
extra : moz-landing-system : lando
2019-02-12 15:15:28 +00:00
Makoto Kato
c1917e9616 Bug 1503491 - Part 1. Remove CheckCurrentWordNoSuggest. r=masayuki
No one uses CheckCurrentWordNoSuggest. So I would like to get a rid of this
method. And this method is only user of mozSpellChecker::CheckWord. So
mozSpellChecker::CheckWord shouldn't allow that aSuggestions is nullptr on
content process since we already have async API as mozSpellChecker::CheckWords.

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

--HG--
extra : moz-landing-system : lando
2019-02-10 22:03:53 +00:00
Makoto Kato
03c4d17822 Bug 1496118 - Clean up caret when destroying editor. r=masayuki
Summary:
Editor changes caret visibility during drag and drop.  But when destroying
editor, we don't restore caret state.  So we should restore it when destroying
editor.

Tags: #secure-revision

Bug #: 1496118

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

--HG--
extra : rebase_source : 157f2c9e69857c7f7adb916af2a319392c4d125a
2019-02-06 19:26:35 +09:00
Myk Melez
25349d2601 Bug 1518283 - prohibit blank lines at the beginning and end of blocks (eslint padded-blocks) r=mossop,Standard8
Differential Revision: https://phabricator.services.mozilla.com/D17526

--HG--
extra : moz-landing-system : lando
2019-01-30 17:26:25 +00:00
Kris Maglione
e930b89c34 Bug 1514594: Part 3 - Change ChromeUtils.import API.
***
Bug 1514594: Part 3a - Change ChromeUtils.import to return an exports object; not pollute global. r=mccr8

This changes the behavior of ChromeUtils.import() to return an exports object,
rather than a module global, in all cases except when `null` is passed as a
second argument, and changes the default behavior not to pollute the global
scope with the module's exports. Thus, the following code written for the old
model:

  ChromeUtils.import("resource://gre/modules/Services.jsm");

is approximately the same as the following, in the new model:

  var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");

Since the two behaviors are mutually incompatible, this patch will land with a
scripted rewrite to update all existing callers to use the new model rather
than the old.
***
Bug 1514594: Part 3b - Mass rewrite all JS code to use the new ChromeUtils.import API. rs=Gijs

This was done using the followng script:

https://bitbucket.org/kmaglione/m-c-rewrites/src/tip/processors/cu-import-exports.jsm
***
Bug 1514594: Part 3c - Update ESLint plugin for ChromeUtils.import API changes. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D16747
***
Bug 1514594: Part 3d - Remove/fix hundreds of duplicate imports from sync tests. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16748
***
Bug 1514594: Part 3e - Remove no-op ChromeUtils.import() calls. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16749
***
Bug 1514594: Part 3f.1 - Cleanup various test corner cases after mass rewrite. r=Gijs
***
Bug 1514594: Part 3f.2 - Cleanup various non-test corner cases after mass rewrite. r=Gijs

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

--HG--
extra : rebase_source : 359574ee3064c90f33bf36c2ebe3159a24cc8895
extra : histedit_source : b93c8f42808b1599f9122d7842d2c0b3e656a594%2C64a3a4e3359dc889e2ab2b49461bab9e27fc10a7
2019-01-17 10:18:31 -08:00
Randell Jesup
76bd9e73cc Bug 1522150: Add a DeferredTimers queue ahead of the normal Idle EventQueue r=froyd
* * *
Bug 1522150: Rename NS_IdleDispatch* functions since they take queue identifiers r=froyd
2019-01-26 12:18:05 -05:00
Ehsan Akhgari
4137a92662 Bug 1514340 - Part 2: Break out the content blocking related notifications into nsIWebProgressListener.onContentBlockingEvent(); r=baku,johannh
Differential Revision: https://phabricator.services.mozilla.com/D16052
2019-01-21 09:58:50 -05:00
Cosmin Sabou
7ccc9d8b0b Merge mozilla-inbound to mozilla-central. a=merge 2019-01-19 11:57:49 +02:00
Makoto Kato
c7936919a5 Bug 1518002 - Update selection cache when initializing editor. r=masayuki
GitLab's comment calls scrollTop on input event handler. The scollTop may cause
reflow.  When causing reflow, editor is destroyed and initialized again. Then
nsTextEditorState will set current value to editor.  But this is failure.

By bug 1465702, selection is cached in edit action. When initializing editor,
selection controller is updated, so selection into cache becomes invalid. It
means that all selection methods will return error since document is different.

So we should update selection cache when initializing editor.

Also, I cannot create test case for this situation since we have to cause reflow
in input and/or composition event. Do you have any idea?

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

--HG--
extra : moz-landing-system : lando
2019-01-18 10:00:23 +00:00
Ehsan Akhgari
e5e885ae31 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
# ignore-this-changeset

--HG--
extra : amend_source : 7221c8d15a765df71171099468e7c7faa648f37c
extra : histedit_source : a0cce6015636202bff09e35a13f72e03257a7695
2019-01-18 10:16:18 +01:00
Makoto Kato
7bc8f8b726 Bug 1502661 - Part 2. Add async method to check word by spellchecker. r=masayuki
For mozInlineSpellChecker, I would like to add promse-based method to check
word. But this method is

- On content process, it works by async.
- On chrome process, it works by sync.

Some reftests with non-e10s don't wait that spellchecker is finished correctly
due to race condition of spellchecker dictionary update.  So it uses sync'd
promise on chrome.

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

--HG--
extra : rebase_source : 63d8fb1b3a6f8754f5b7604ea920c1a26bcd4f5b
2018-12-18 20:23:44 +09:00
Sylvestre Ledru
47a5dd1fb8 Bug 1519636 - Reformat everything to the Google coding style r=Ehsan
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2019-01-16 08:50:07 +00:00
Razvan Maries
642dd2cc11 Merge mozilla-central to autoland. a=merge on a CLOSED TREE 2019-01-11 17:33:16 +02:00
Christoph Kerschbaumer
fbb4bafd5c Bug 1513241: Update loadURI interface and pass a loadURIOptions dictionary from frontend to docshell loads. r=bz 2019-01-11 12:43:39 +01:00
Masayuki Nakano
f421d7b889 Bug 181137 - part 8: Make ContentIteratorBase and its subclasses non-refcountable r=smaug
This patch makes ContentIteratorBase, PostContentIterator, PreContentIterator
and ContentSubtreeIterator classes non-refcountable because most users can
create their instances in stack and such users may be in a hot path.  So,
we can save a lot of cost of instantiation.

Unfortunately, only ScriptableContentIterator creates one of the concrete
classes and needs to destroy it properly.  Therefore, its
EnsureContentIterator(), destructor, traverse and unlink code becomes messy.
However, ScriptableContentIterator was designed for automated tests and we
need to maintain it not so many times.  Therefore, improvement of other
users must be worthwhiler than this demerit.

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

--HG--
extra : moz-landing-system : lando
2019-01-11 01:52:26 +00:00
Masayuki Nakano
a6ef59a998 Bug 181137 - part 6: Make nsFilteredContentIterator not derived from nsIContentIterator r=smaug
nsFilteredContentIterator is used only by TextServicesDocument and there is
no reason that it should be derived from nsIContentIterator except consistency.
Additionally, it's now only class which is derived from nsIContentIterator
except ContentIteratorBase.  So, after this change, we can get rid of
nsIContentIterator completely.

This patch moves nsFilteredContentIterator into mozilla namespace and
makes TextServicesDocument treat FilteredContentIterator directly instead of
nsIContentIterator interface.

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

--HG--
rename : editor/spellchecker/nsFilteredContentIterator.cpp => editor/spellchecker/FilteredContentIterator.cpp
rename : editor/spellchecker/nsFilteredContentIterator.h => editor/spellchecker/FilteredContentIterator.h
extra : moz-landing-system : lando
2019-01-11 01:51:35 +00:00
Masayuki Nakano
da38fe53bc Bug 181137 - part 5: Make all users of PostContentIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of PostContentIterator can access it directly.  This patch
makes them use the concrete class directly.

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

--HG--
extra : moz-landing-system : lando
2019-01-11 01:50:19 +00:00
Masayuki Nakano
f5602b96ab Bug 181137 - part 4: Make all users of PreContentIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of PreContentIterator can access it directly.  This patch makes
them use the concrete class directly.

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

--HG--
extra : moz-landing-system : lando
2019-01-11 01:49:36 +00:00
Masayuki Nakano
3b6d4adf2d Bug 181137 - part 3: Make all users of ContentSutreeIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of ContentSubtreeIterator can access it directly.  This patch
makes them use the concrete class directly.

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

--HG--
extra : moz-landing-system : lando
2019-01-11 01:49:00 +00:00
Csoregi Natalia
13506c036a Backed out 8 changesets (bug 181137) for bustage on FragmentOrElement.cpp:1751. CLOSED TREE
Backed out changeset 99a977d519a0 (bug 181137)
Backed out changeset 65a4b245e851 (bug 181137)
Backed out changeset 5385d5fd9b8b (bug 181137)
Backed out changeset 83bec02c21d9 (bug 181137)
Backed out changeset b7ab59bf545e (bug 181137)
Backed out changeset b6fc7a332db7 (bug 181137)
Backed out changeset 654fdbad67db (bug 181137)
Backed out changeset 90a1ff49b6b1 (bug 181137)

--HG--
rename : dom/base/ContentIterator.h => dom/base/nsContentIterator.cpp
rename : editor/spellchecker/FilteredContentIterator.cpp => editor/spellchecker/nsFilteredContentIterator.cpp
rename : editor/spellchecker/FilteredContentIterator.h => editor/spellchecker/nsFilteredContentIterator.h
2019-01-10 11:42:27 +02:00
Masayuki Nakano
796ceb094f Bug 181137 - part 8: Make ContentIteratorBase and its subclasses non-refcountable r=smaug
This patch makes ContentIteratorBase, PostContentIterator, PreContentIterator
and ContentSubtreeIterator classes non-refcountable because most users can
create their instances in stack and such users may be in a hot path.  So,
we can save a lot of cost of instantiation.

Unfortunately, only ScriptableContentIterator creates one of the concrete
classes and needs to destroy it properly.  Therefore, its
EnsureContentIterator(), destructor, traverse and unlink code becomes messy.
However, ScriptableContentIterator was designed for automated tests and we
need to maintain it not so many times.  Therefore, improvement of other
users must be worthwhiler than this demerit.

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

--HG--
extra : moz-landing-system : lando
2019-01-10 08:50:41 +00:00
Masayuki Nakano
d15a70b2c2 Bug 181137 - part 6: Make nsFilteredContentIterator not derived from nsIContentIterator r=smaug
nsFilteredContentIterator is used only by TextServicesDocument and there is
no reason that it should be derived from nsIContentIterator except consistency.
Additionally, it's now only class which is derived from nsIContentIterator
except ContentIteratorBase.  So, after this change, we can get rid of
nsIContentIterator completely.

This patch moves nsFilteredContentIterator into mozilla namespace and
makes TextServicesDocument treat FilteredContentIterator directly instead of
nsIContentIterator interface.

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

--HG--
rename : editor/spellchecker/nsFilteredContentIterator.cpp => editor/spellchecker/FilteredContentIterator.cpp
rename : editor/spellchecker/nsFilteredContentIterator.h => editor/spellchecker/FilteredContentIterator.h
extra : moz-landing-system : lando
2019-01-10 08:47:11 +00:00
Masayuki Nakano
bdc602b92f Bug 181137 - part 5: Make all users of PostContentIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of PostContentIterator can access it directly.  This patch
makes them use the concrete class directly.

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

--HG--
extra : moz-landing-system : lando
2019-01-10 08:46:32 +00:00
Masayuki Nakano
6f5a9fb98a Bug 181137 - part 4: Make all users of PreContentIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of PreContentIterator can access it directly.  This patch makes
them use the concrete class directly.

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

--HG--
extra : moz-landing-system : lando
2019-01-10 08:46:25 +00:00
Masayuki Nakano
e4fd546fbd Bug 181137 - part 3: Make all users of ContentSutreeIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of ContentSubtreeIterator can access it directly.  This patch
makes them use the concrete class directly.

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

--HG--
extra : moz-landing-system : lando
2019-01-10 08:45:07 +00:00
Tim Nguyen
34cebfc0b6 Bug 1437641 - Remove numberbox binding and convert usages to input[type=number]. r=bgrins,dao
Differential Revision: https://phabricator.services.mozilla.com/D15882

--HG--
rename : toolkit/themes/shared/numberbox.css => toolkit/themes/shared/numberinput.css
extra : moz-landing-system : lando
2019-01-09 08:51:32 +00:00
Makoto Kato
abc90adfa8 Bug 1450055 - Part 1. Add focus event to system group to initialize editor. r=masayuki
Editor initializes selection and input context (via IMEStateManager) on focus
event. But if content script calls stopImmediatePropagation on focus event,
editor cannot initialize these since editor cannot receive focus event.

It means that Android widget doesn't open virtual keyboard since
GeckoEditableSupport::SetInputContext isn't called.  Also, Firefox desktop
doesn't show caret in this situation since selection isn't initialized in
editor.

So the event listener of focus and blur event should use system group.

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

--HG--
extra : rebase_source : 71ab7e4aa043bac43e307dd6dfe4e84073d5154f
2019-01-08 14:51:41 +09:00
Masayuki Nakano
ed2040ac16 Bug 1447239 - Implement InputEvent.inputType r=smaug
This patch implements InputType.inputType which is declared by Input Events.
The attribute has already been implemented by Chrome and Safari.  Chrome
implements Input Events Level 1, but Safari implements Input Events Level 2.
 Difference between them is only whether it supports "insertFromComposition",
"deleteByComposition" and "deleteCompositionText".  This patch makes the
level switchable with pref and takes Level 1 by default because Level 2 is
still unstable around event order with composition events.

For reducing string copy cost at dispatching "input" event, this patch
makes EditorInternalInputEvent store valid input-type as enum class,
EditorInputType and resolves it to string value when
dom::InputEvent::GetInputType() is called.  Note that the reason why
this patch names the enum class as EditorInputType is, there is InputType
enum class already for avoiding conflict the name, this appends "Editor"
prefix because "input" and "beforeinput" events are fired only when an
editor has focus.

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

--HG--
extra : moz-landing-system : lando
2019-01-07 10:10:57 +00:00
Timothy Guan-tin Chien
bd38b39f8a Bug 1512048 - Convert tabmodalprompt binding to JSM module r=Gijs
This converts the tabmodalprompt binding to a class, to be constructed along side with the element
by TabModalPromptBox.

TabModalPromptBox will keep the instances in a map and pass it to the callers, instead of the element.
The tests and callers can access the class instance by passing the element reference to the map.

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

--HG--
rename : toolkit/components/prompts/content/tabprompts.xml => toolkit/components/prompts/content/tabprompts.jsm
extra : moz-landing-system : lando
2019-01-04 19:29:34 +00:00
Tom Schuster
79d3c5244b Bug 571074 - Mark nsITransferable.getTransferData as [must_use]. r=mats
Differential Revision: https://phabricator.services.mozilla.com/D13454

--HG--
extra : moz-landing-system : lando
2019-01-04 16:16:59 +00:00
Emilio Cobos Álvarez
d2ed260822 Bug 1517241 - Rename nsIDocument to mozilla::dom::Document. r=smaug
Summary: Really sorry for the size of the patch. It's mostly automatic
s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to
add the right namespacing and such.

Overall it's not a very interesting patch I think.

nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and
nsIDocumentInlines.h into DocumentInlines.h.

I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it.

While fixing up some of the bits I also removed some unneeded OwnerDoc() null
checks and such, but I didn't do anything riskier than that.
2019-01-03 17:48:33 +01:00
Emilio Cobos Álvarez
63814207cb Bug 1516853 - Merge nsIDocument and nsDocument. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D15498

--HG--
extra : moz-landing-system : lando
2018-12-31 14:10:19 +00:00
Makoto Kato
1c2f8f57a2 Bug 1441619 - Add crashtest. r=masayuki
Summary:
The latest version of Gecko doesn't crash by this HTML, but I would like to add
this for the future.

Bug #: 1441619

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

--HG--
extra : rebase_source : 5633e508d1c1f405465857a71f7c544fbb3782e8
2018-12-18 15:09:52 +09:00
Bogdan Tara
dcf5ea092c Merge mozilla-central to mozilla-inbound. a=merge CLOSED TREE 2018-12-03 23:53:09 +02:00
Ehsan Akhgari
0dcf936804 Bug 1510911 - Part 2: Backout changeset f8849239da42 (bug 1493563 - Part 5) for regressing performance 2018-12-03 14:27:53 -05:00
Edgar Chen
30d48a6150 Bug 1507543 - Spellchecker for contenteditable/design-mode should not run without focus; r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D12875

--HG--
rename : editor/reftests/spellcheck-contenteditable-nofocus.html => editor/reftests/spellcheck-contenteditable-nofocus-1.html
extra : moz-landing-system : lando
2018-12-03 11:20:09 +00:00
Benjamin Bouvier
a7f1d173a0 Bug 1511383: Update vim modelines after clang-format; r=sylvestre
- modify line wrap up to 80 chars; (tw=80)
- modify size of tab to 2 chars everywhere; (sts=2, sw=2)

--HG--
extra : rebase_source : 7eedce0311b340c9a5a1265dc42d3121cc0f32a0
extra : amend_source : 9cb4ffdd5005f5c4c14172390dd00b04b2066cd7
2018-11-30 16:39:55 +01:00
Sylvestre Ledru
265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Razvan Maries
77d87d9972 Merge mozilla-central to autoland. a=merge on a CLOSED TREE 2018-11-30 05:13:14 +02:00
Masayuki Nakano
7348477018 Bug 1510183 - Make HTMLEditor treat empty string attribute of style as nullptr of nsAtom rather than nsGkAtoms::_empty r=m_kato
After fixing bug 1427060, HTMLEditor treats attribute of style as nullptr.
However, if empty string is used to call NS_Atomize(), it returns
nsGkAtoms::_empty.  Therefore, HTMLEditor fails to check whether attribute is
specified or not with nullptr check since some root callers sets
nsGkAtoms::_empty instead of nullptr.

This patch makes HTMLEditor always use nullptr for empty string of attribute
of style with wrapping NS_Atomize() with AtomzieAttribute().  Additionally,
for safer change, this patch makes PropItem and TypeInState treat
nsGkAtom::_empty as nullptr.

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

--HG--
extra : moz-landing-system : lando
2018-11-30 01:21:59 +00:00
Jan Varga
be167c5e0b Bug 1286798 - Part 10: Support for storage events; r=asuth,janv
Storage events are fired either directly after getting response from synchronous SetItem call or through observers. When a new onstorage event listener is added, we sycnhronously register an observer in the parent process. There's always only one observer actor per content process.
PBackgroundLSDatabase is now managed by a new PBackgroundLSObject protocol. PBackgroundLSObject is needed to eliminate the need to pass the principal info and document URI everytime a write operation occurs.
Preparation of an observer shares some states with preparation of a datastore, so common stuff now lives in LSRequestBase and preparation of a datastore now implements a nested state machine.

This patch was enhanced by asuth to drop observers only when the last storage listener is removed.
EventListenerRemoved is invoked on any removal, not just the final removal, so we need to make sure it's the final removal before dropping observer.
2018-11-29 21:47:45 +01:00
Jan Varga
60831f2e38 Bug 1286798 - Part 3: New basic (memory only) implementation of LocalStorage; r=asuth,mccr8
The implementation is based on a cache (datastore) living in the parent process and sync IPC calls initiated from content processes.
IPC communication is done using per principal/origin database actors which connect to the datastore.
The synchronous blocking of the main thread is done by creating a nested event target and spinning the event loop.
2018-11-29 21:47:20 +01:00
Geoff Brown
1ec332e1cb Bug 1511101 - Enable a few android 7.0 x86 mochitest; r=me,a=test-only 2018-11-29 11:03:05 -07:00
Kyle Machulis
c241567f0f Bug 1505601 - Turn nsIDocShell XPIDL const lists into cenums; r=bzbarsky
Turn all const lists and related attributes into cenums, to provide a
vague sense of type safety.

Depends on D11715

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

--HG--
extra : moz-landing-system : lando
2018-11-28 03:30:56 +00:00
Ehsan Akhgari
2febd96e7e Bug 1508472 - Part 2: Second batch of comment fix-ups in preparation for the tree reformat r=sylvestre
This is a best effort attempt at ensuring that the adverse impact of
reformatting the entire tree over the comments would be minimal.  I've used a
combination of strategies including disabling of formatting, some manual
formatting and some changes to formatting to work around some clang-format
limitations.

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

--HG--
extra : moz-landing-system : lando
2018-11-28 00:54:56 +00:00
Cosmin Sabou
0afa5aa670 Backed out 2 changesets (bug 1508472) for causing build bustages on JobScheduler_posix.cpp. CLOSED TREE
Backed out changeset af951294cf96 (bug 1508472)
Backed out changeset 2320933cb7bc (bug 1508472)
2018-11-28 00:08:11 +02:00
Ehsan Akhgari
7c937c2747 Bug 1508472 - Part 2: Second batch of comment fix-ups in preparation for the tree reformat r=sylvestre
This is a best effort attempt at ensuring that the adverse impact of
reformatting the entire tree over the comments would be minimal.  I've used a
combination of strategies including disabling of formatting, some manual
formatting and some changes to formatting to work around some clang-format
limitations.

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

--HG--
extra : moz-landing-system : lando
2018-11-27 21:36:18 +00:00
Andreea Pavel
945463d394 Backed out changeset 11d6688b953f (bug 1508472) for build bustages on a CLOSED TREE 2018-11-27 18:28:30 +02:00
Ehsan Akhgari
d0a3a76106 Bug 1508472 - Part 2: Second batch of comment fix-ups in preparation for the tree reformat r=sylvestre
This is a best effort attempt at ensuring that the adverse impact of
reformatting the entire tree over the comments would be minimal.  I've used a
combination of strategies including disabling of formatting, some manual
formatting and some changes to formatting to work around some clang-format
limitations.

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

--HG--
extra : moz-landing-system : lando
2018-11-27 15:18:32 +00:00
Makoto Kato
fcd1b7a07f Bug 1054087 - Turn on test_dom_input_event_on_htmleditor.html for Android. r=masayuki
Android's test runner passes this test, so I would like to run
test_dom_input_event_on_htmleditor.html even if Android.

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

--HG--
extra : moz-landing-system : lando
2018-11-27 04:50:40 +00:00
Masayuki Nakano
7bd2c26c2c Bug 1288640 - Make TextComposition not dispatch eCompositionChange events (DOM "text" event) in the default group of web content r=smaug
The usage of our specific "text" event is enough low (0.0003%).  So, let's
stop dispatching the event in the default group of web content.  Once we
release this new behavior, we can get rid of dispatching the event even in
chrome.  Then, we can optimize the event order for new specs.

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

--HG--
extra : moz-landing-system : lando
2018-11-27 13:26:51 +00:00
Emilio Cobos Álvarez
9ed36d7ba6 Bug 1506547 - Align user-select behavior more with other UAs. r=mats
There's a few subtle behavior changes here, which I'll try to break down in the
commit message.

The biggest one is the EditableDescendantCount stuff going away. This
was added in bug 1181130, to prevent clicking on the non-editable div from
selecting the editable div inside. This is problematic for multiple reasons:

 * First, I don't think non-editable regions of an editable element should
   be user-select: all.

 * Second, it just doesn't work in Shadow DOM (the editable descendant count is
   not kept up-to-date when not in the uncomposed doc), so nested
   contenteditables behave differently inside vs. outside a Shadow Tree.

 * Third, I think it's user hostile to just entirely disable selection if you
   have a contenteditable descendant as a child of a user-select: all thing.

   WebKit behaves like this patch in the following test-case (though not Blink):

     https://crisal.io/tmp/user-select-all-contenteditable-descendant.html

   Edge doesn't seem to support user-select: all at all (no pun intended).

   But we don't allow to select anything at all which looks wrong.

 * Fourth, it's not tested at all (which explains how we broke it in Shadow DOM
   and not even notice...).

In any case I've verified that this doesn't regress the editor from that bug. If
this regresses anything we can fix it as outlined in the first bullet point
above, which should also make us more compatible with other UAs in that
test-case.

The other change is `all` not overriding everything else. So, something like:

  <div style="-webkit-user-select: all">All <div style="-webkit-user-select: none">None</div></div>

Totally ignores the -webkit-user-select: none declaration in Firefox before this
change. This doesn't match any other UA nor the spec, and this patch aligns us
with WebKit / Blink.

This in turn makes us not need -moz-text anymore, whose only purpose was to
avoid this.

This also fixes a variety of bugs uncovered by the previous changes, like the
SetIgnoreUserModify(false) call in editor being completely useless, since
presShell->SetCaretEnabled ended in nsCaret::SetVisible, which overrode it.

This in turn uncovered even more bugs, from bugs in the caret painting code,
like not checking -moz-user-modify on the right frame if you're the last frame
of a line, to even funnier bits where before this patch you show the caret but
can't write at all...

In any case, the new setup I came up with is that when you're editing (the
selection is focused on an editable node) moving the caret forces it to end up
in an editable node, thus jumping over non-editable ones.

This has the nice effect of not completely disabling selection of
-moz-user-select: all elements that have editable descendants (which was a very
ad-hoc hack for bug 1181130, and somewhat broken per the above), and also
not needing the -moz-user-select: all for non-editable bits in contenteditable.css
at all.

This also fixes issues with br-skipping like not being able to insert content in
the following test-case:

  <div contenteditable="true"><span contenteditable="false">xyz </span><br>editable</div>

If you start moving to the left from the second line, for example.

I think this yields way better behavior in all the relevant test-cases from bug
1181130 / bug 1109968 / bug 1132768, shouldn't cause any regression, and the
complexity is significantly reduced in some places.

There's still some other broken bits that this patch doesn't fix, but I'll file
follow-ups for those.

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

--HG--
extra : moz-landing-system : lando
2018-11-26 09:21:37 +00:00
Masayuki Nakano
8cd4eff52f Bug 1497746 - part 6: Add static_assert for preventing TextEditor to grow up again r=m_kato
TextEditor instance is created per <input> element which has text editor and
<textarea> element.  Therefore, we should keep TextEditor slim as far as
possible.

Currently, TextEditor class size is 400 bytes on Win64.  So, we should keep
512 bytes border.

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

--HG--
extra : moz-landing-system : lando
2018-11-26 06:33:28 +00:00
Masayuki Nakano
674c63397e Bug 1497746 - part 5: Make EditorBase not reserve array for its listeners unless listeners are important r=m_kato
A lot of listeners are now notified with RefPtr for concrete classes.
Therefore, we can reduce size of arrays to listeners without damage for
the performance.

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

--HG--
extra : moz-landing-system : lando
2018-11-26 06:32:34 +00:00
Masayuki Nakano
b376e84323 Bug 1497746 - part 4: Move EditorBase::mRangeUpdater to AutoEditActionDataSetter r=m_kato
Similar to EditorBase::mSavedSel, we can move EditorBase::mRangeUpdater too
because of it's referred only when there is AutoEditActionDataSetter instance
so that it also does not need to be in the cycle collection.

And now, it can be marked as MOZ_STACK_CLASS and remove cycle collection
support.

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

--HG--
extra : moz-landing-system : lando
2018-11-26 06:31:56 +00:00
Masayuki Nakano
692bb4e545 Bug 1497746 - part 3: Move EditorBase::mSavedSel into AutoEditActionDataSetter r=m_kato
EditorBase::mSavedSel is used only by EditorBase methods which are called only
by AutoSelectionRestorer.  Additionally, AutoSelectionRestorer requires
AutoEditActionDataSetter instance.  So, we don't need to keep create for
editor instance anymore.  And also we don't need to keep it in the cycle
collection.

Note that SelectionState class is also used by PlaceholderTransaction.
Therefore, we cannot make it MOZ_STACK_CLASS.

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

--HG--
extra : moz-landing-system : lando
2018-11-26 06:31:13 +00:00
Masayuki Nakano
6daceee1f1 Bug 1497746 - part 2: Move EditorBase::mDirection to EditorBase::AutoEditActionDataSetter r=m_kato
EditorBase::mDirection is set and clear only when
EditorBase::AutoEditActionDataSetter::SetTopLevelEditSubAction().  So, the
direction is related to the top level edit sub action, and we can move it
into AutoEditActionDataSetter.

Note that except EditSubAction::eDeleteSelectedContent, the relation between
sub-action and direction is fixed so that this patch checks the relation with
MOZ_ASSERT.  If we could replace EditSubAction::eDeleteSelectedContent with
information of direction, we'd remove the new member of
AutoEditActionDataSetter, though.

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

--HG--
extra : moz-landing-system : lando
2018-11-26 06:30:29 +00:00
Masayuki Nakano
49181b7721 Bug 1497746 - part 1: Move EditorBase::mTopLevelEditSubAction to EditorBase::AutoEditActionDataSetter r=m_kato
EditorBase::mTopLevelEditSubAction is set only by
EditorBase::OnStartToHandleTopLevelEditSubAction() and
EditorBase::OnEndToHandleTopLevelEditSubAction() and they are called only by
AutoTopLevelEditSubActionNotifier().

So, this is used only in stack when a public method of editor is called.
Therefore, we can move it into EditorBase::AutoEditActionDataSetter.  Then,
we can reduce heap allocation for editor instances.

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

--HG--
extra : moz-landing-system : lando
2018-11-26 03:53:29 +00:00
Brindusan Cristian
31f0c21cca Backed out changeset 1575904619b5 (bug 1506547) for mochitest failures on test_reftests_with_caret.html. 2018-11-26 03:03:14 +02:00
Emilio Cobos Álvarez
b74c31e4d9 Bug 1506547 - Align user-select behavior more with other UAs. r=mats
There's a few subtle behavior changes here, which I'll try to break down in the
commit message.

The biggest one is the EditableDescendantCount stuff going away. This
was added in bug 1181130, to prevent clicking on the non-editable div from
selecting the editable div inside. This is problematic for multiple reasons:

 * First, I don't think non-editable regions of an editable element should
   be user-select: all.

 * Second, it just doesn't work in Shadow DOM (the editable descendant count is
   not kept up-to-date when not in the uncomposed doc), so nested
   contenteditables behave differently inside vs. outside a Shadow Tree.

 * Third, I think it's user hostile to just entirely disable selection if you
   have a contenteditable descendant as a child of a user-select: all thing.

   WebKit behaves like this patch in the following test-case (though not Blink):

     https://crisal.io/tmp/user-select-all-contenteditable-descendant.html

   Edge doesn't seem to support user-select: all at all (no pun intended).

   But we don't allow to select anything at all which looks wrong.

 * Fourth, it's not tested at all (which explains how we broke it in Shadow DOM
   and not even notice...).

In any case I've verified that this doesn't regress the editor from that bug. If
this regresses anything we can fix it as outlined in the first bullet point
above, which should also make us more compatible with other UAs in that
test-case.

The other change is `all` not overriding everything else. So, something like:

  <div style="-webkit-user-select: all">All <div style="-webkit-user-select: none">None</div></div>

Totally ignores the -webkit-user-select: none declaration in Firefox before this
change. This doesn't match any other UA nor the spec, and this patch aligns us
with WebKit / Blink.

This in turn makes us not need -moz-text anymore, whose only purpose was to
avoid this.

This also fixes a variety of bugs uncovered by the previous changes, like the
SetIgnoreUserModify(false) call in editor being completely useless, since
presShell->SetCaretEnabled ended in nsCaret::SetVisible, which overrode it.

This in turn uncovered even more bugs, from bugs in the caret painting code,
like not checking -moz-user-modify on the right frame if you're the last frame
of a line, to even funnier bits where before this patch you show the caret but
can't write at all...

In any case, the new setup I came up with is that when you're editing (the
selection is focused on an editable node) moving the caret forces it to end up
in an editable node, thus jumping over non-editable ones.

This has the nice effect of not completely disabling selection of
-moz-user-select: all elements that have editable descendants (which was a very
ad-hoc hack for bug 1181130, and somewhat broken per the above), and also
not needing the -moz-user-select: all for non-editable bits in contenteditable.css
at all.

This also fixes issues with br-skipping like not being able to insert content in
the following test-case:

  <div contenteditable="true"><span contenteditable="false">xyz </span><br>editable</div>

If you start moving to the left from the second line, for example.

I think this yields way better behavior in all the relevant test-cases from bug
1181130 / bug 1109968 / bug 1132768, shouldn't cause any regression, and the
complexity is significantly reduced in some places.

There's still some other broken bits that this patch doesn't fix, but I'll file
follow-ups for those.

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

--HG--
extra : moz-landing-system : lando
2018-11-25 20:01:07 +00:00
Masayuki Nakano
4ca52542bb Bug 1504911 - part 5: Make HTMLEditor::InsertTableCellsWithTransaction() create AutoPlaceholderBatch and AutoTopLevelEditSubActionNotifier r=m_kato
Currently, calling nsITableEditor.insertTableCell() does not cause dispatching
"input" event since it does not create AutoPlaceholderBatch.  Additionally,
different from InsertTableRowsWithTransaction() and
InsertTableColumnsWithTransaction(), it does not create
AutoTopLevelEditSubActionNotifier.

Because of those APIs should work similarly, we should make it creates
both auto class instances.

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

--HG--
extra : moz-landing-system : lando
2018-11-21 09:30:40 +00:00
Masayuki Nakano
b5ea72aa13 Bug 1504911 - part 3: Make TextEditRules::WillSetText() not handle anything when EditAction is eReplaceText r=m_kato
When all editor text is replaced while handling a user operation, editor
needs to dispatch "input" event.  Therefore, in such case, i.e., EditAction
is eReplaceText, TextEditor::SetTextAsSubAction() needs to handle it instead
of TextEditRules::WillSetText().

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

--HG--
extra : moz-landing-system : lando
2018-11-20 14:34:32 +00:00
Masayuki Nakano
abe138f771 Bug 1504911 - part 1: Make all "input" event dispatcher in C++ use new utility method r=smaug
Currently, a lot of code dispatch "input" event and some of them dispatch
"input" event with wrong interface and/or values.  Therefore this patch
creates nsContentUtils::DispatchInputEvent() to make all of them dispatch
correct event.

Unfortunately, due to bug 1506439, we cannot set pointer to refcountable
classes of MOZ_CAN_RUN_SCRIPT method to nullptr.  Therefore, this patch
creates temporary RefPtr<TextEditor> a lot even though it makes damage to
the performance if it's in a hot path.

This patch makes eEditorInput event dispatched with
InternalEditorInputEvent when "input" event should be dispatched with
dom::InputEvent.  However, this patch uses WidgetEvent whose message is
eUnidentifiedEvent and setting WidgetEvent::mSpecifiedEventType to
nsGkAtoms::oninput when "input" event should be dispatched with
dom::Event because we need to keep that eEditorInput and
InternalEditorInputEvent are mapped each other.

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

--HG--
extra : moz-landing-system : lando
2018-11-21 03:59:02 +00:00
Masayuki Nakano
388e64d857 Bug 1504911 - part 0: Add "input" event tests into existing tests r=smaug
It's difficult to create new test which checks "input" events caused by
all edit operations especially when text is inserted from our UI.  Therefore,
this adds "input" event type checks into existing tests.

Additionally, this adds new test for MozEditableElement.setUserInput() whose
behavior needs to be fixed in this bug.

Currently, InputEvent interface should be used only on text controls or
contenteditable editor when dispatching "input" event.
https://w3c.github.io/input-events/#events-inputevents

You may feel odd to use different event interface for same "input" events.
However, other browsers also use InputEvent interface only in the cases. So,
we should follow them for now.

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

--HG--
extra : moz-landing-system : lando
2018-11-20 14:24:06 +00:00
Tom Schuster
5a9d2a428c Bug 1493292 - Remove aDataLen parameters from nsITransferable.getTransferData. r=smaug
Depends on D11200

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

--HG--
extra : moz-landing-system : lando
2018-11-20 16:59:56 +00:00
Csoregi Natalia
df7483024d Backed out 6 changesets (bug 1493292) for bustage on /nsTransferable.cpp. CLOSED TREE
Backed out changeset f198bf91320b (bug 1493292)
Backed out changeset 6487aa307123 (bug 1493292)
Backed out changeset f2cabd69c568 (bug 1493292)
Backed out changeset 71430fceb4a3 (bug 1493292)
Backed out changeset 3a9b6d65d8c7 (bug 1493292)
Backed out changeset 55769869037c (bug 1493292)
2018-11-20 17:13:18 +02:00
Tom Schuster
b292ec7c2c Bug 1493292 - Remove aDataLen parameters from nsITransferable.getTransferData. r=smaug
Depends on D11200

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

--HG--
extra : moz-landing-system : lando
2018-11-20 14:47:02 +00:00
Nika Layzell
fe2f2478f7 Bug 1477432 - Part 2: Avoid using nsIJSID in GenerateQI, and produce better diagnostics, r=kmag
This is the first part of hiding the implementation of nsIJSID behind the
interface added in Part 1, such that we can substitute that implementation out.

I had to make a couple of changes to fix the errors caused by the new behaviour
in GenerateQI.

Differential Revision: https://phabricator.services.mozilla.com/D2279
2018-11-16 17:27:31 -05:00
Andreea Pavel
987516303f Backed out changeset f9900ac6071c (bug 571074) for failing clipboard at browser/base/content/test/general/browser_clipboard.js on a CLOSED TREE 2018-11-30 02:30:22 +02:00
Tom Schuster
891f0040e6 Bug 571074 - Mark nsITransferable.getTransferData as [must_use]. r=mats
Differential Revision: https://phabricator.services.mozilla.com/D13454

--HG--
extra : moz-landing-system : lando
2018-11-29 21:57:40 +00:00
Edgar Chen
6562a13ff2 Bug 1504179 - Trigger first spell-checking by moving focus to contenteditable element; r=smaug
The current test has an incorrect expectation for the first full spell-checking,
it actually happens when first-time focus moves to contenteditable element
(which trigger dictionary updating), not right after document loaded.

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

--HG--
extra : moz-landing-system : lando
2018-11-14 12:38:46 +00:00
Geoff Brown
450e947af0 Bug 1503299 - Disable a clipboard mochitest on more android variants; r=me,a=test-only 2018-11-14 09:20:09 -07:00
Masayuki Nakano
89cf9854fe Bug 1505679 - Make HTMLEditor::RemoveList() sets specific EditAction when it's called by execCommand("insertorderedlist") or execCommand("insertunorderedlist") r=m_kato
Even when execCommand("insertorderedlist") and
execCommand("insertunorderedlist") remove existing lists, we need to set
InputEvent.inputType value to "insertOrderedList" or "insertUnorderedList".

Fortunately, the XPCOM method is used only for handling
execCommand("insertorderedlist") and execCommand("insertunorderedlist") on
Firefox.  Therefore, we should make it set EditAction to
EditAction::eRemoveOrderedListElement or EditAction::RemoveUnorderedListElement.

Note that comm-central uses this method directly and uses "cmd_removeList"
which causes calling the XPCOM method with empty string.  However, input
events for them won't be exposed to the web.  Therefore, it's okay to set
EditAction::eRemoveListElement for the other cases.

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

--HG--
extra : moz-landing-system : lando
2018-11-12 08:13:58 +00:00
Masayuki Nakano
0451a3f0a7 Bug 1504910 - part 3: Make TextEditor::OnDrop() remove selected content before inserting dropped content and fire "input" event before inserting first content r=m_kato
Both Chrome and Safari dispatches 2 sets of "beforeinput" and "input" events
when user drag and drop content in same editor.  One is "deleteByDrag" and
the other is "insertFromDrop".  We need to follow same behavior since
it should be able to cancel only "deleteByDrag" or "insertFromDrop" when
we implement "beforeinput" event.

HTMLEditor::InsertObject() may handle asynchronously.  And we don't need to
do anything additionally for HTMLEditor.  Therefore, TextEditor::OnDrop()
can delete selection before inserting dropped content by itself.

Therefore, this patch makes TextEditor::OnDrop() call
TextEditor::PrepareToInsertContent() and EditorBase::FireInputEvent() by
itself.

Unfortunately, it seems that we cannot write automated tests for this.
Even if using synthesizeMouse() of EventUtils, synthesizing mouse events
won't generate "dragover" nor "drop" events.  Perhaps, like EventUtils.js,
we need to do something with drag service, but it means that we cannot
emulate drag and drop in an editor.

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

--HG--
extra : moz-landing-system : lando
2018-11-12 07:19:01 +00:00
Masayuki Nakano
484de9a0c4 Bug 1504910 - part 2: Make TextEditor::InsertTextAt() and HTMLEditor::DoInsertHTMLWithContext() share preparation code before inserting content r=m_kato
Only TextEditor::InsertTextAt() and HTMLEditor::DoInsertHTMLWithContext()
removes selected content before pasting from clipboard or inserting dropped
content, and they do same things.  Therefore, they can share the code with
a helper method.

Note that this makes each root caller won't return NS_ERROR_EDITOR_DESTROYED
since the destruction is expected by web app.

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

--HG--
extra : moz-landing-system : lando
2018-11-12 01:40:46 +00:00
Masayuki Nakano
9f7af9d8fc Bug 1504910 - part 1: Clean up methods which are called by TextEditor::OnDrop() r=m_kato
TextEditor::OnDrop() calls TextEditor::InsertFromDataTransfer() or
HTMLEditor::InsertFromDataTransfer() and they are called only by
TextEditor::OnDrop().

TextEditor::InsertFromDataTransfer() calls only TextEditor::InsertTextAt()
and TextEditor::InsertTextAt() calls only TextEditor::InsertTextAsSubAction() if
insertion point is nullptr.  Therefore, if the callers sets nullptr, they
should call TextEditor::InsertTextAsSubAction() directly.  Then, we can
make TextEditor::InsertTextAt() require non-nullptr insertion point.

HTMLEditor::InsertFromDataTransfer() calls HTMLEditor::InsertObject(),
HTMLEditor::DoInsertHTMLWithContext() or TextEditor::InsertTextAt().

HTMLEditor::InsertObject() calls HTMLEditor::DoInsertHTMLWithContext()
directly or via BlobReader (in this case, calls asynchronously).

Unfortunately both HTMLEditor::InsertObject() and
HTMLEditor::DoInsertHTMLWithContext() are called by
HTMLEditor::InsertFromTransferable() which is paste event handler.  Therefore,
we cannot make them require non-nullptr insertion point, though, anyway,
they cannot become simpler even if we could do that.

This patch marks them as MOZ_CAN_RUN_SCRIPT as far as possible and
makes them take |const EditorDOMPoint&| for insertion point.

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

--HG--
extra : moz-landing-system : lando
2018-11-09 08:40:57 +00:00
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