Commit Graph

6237 Commits

Author SHA1 Message Date
Masayuki Nakano
bf1c1cfd11 Bug 1574852 - part 110: Split HTMLEditor::WillInsert() r=m_kato
It does 4 different things so that it looks like a black-box from the
callers.

First, only `HTMLEditRules::WillDoAction()` refers `aCancel` out argument.
Therefore, it should check whether it's cancelled or not directly.

Next, `EnsureNoPaddingBRElementForEmptyEditor()` should be called by each
caller directly.

Then, the renaming part can be split to 2 methods.  One is adjusting
caret position and the other preparing inline style for new content.


Unfortunately, this patch makes each caller messy.  I think that for the
3rd job (i.e., adjusting caret position), each caller should retrieve the
adjusted caret position and use it directly instead of handling with
`Selection` in the future.

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

--HG--
extra : moz-landing-system : lando
2019-09-14 15:12:03 +00:00
Masayuki Nakano
87f73d9008 Bug 1574852 - part 109: Move TextEditRules::WillSetText() to TextEditor r=m_kato
And also renaming `EditorBase::SetTextImpl()`.

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

--HG--
extra : moz-landing-system : lando
2019-09-14 15:12:03 +00:00
Masayuki Nakano
75507785e6 Bug 1574852 - part 108: Move TextEditRules::WillOutputText() to TextEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45491

--HG--
extra : moz-landing-system : lando
2019-09-13 03:44:33 +00:00
Masayuki Nakano
af80a20e09 Bug 1574852 - part 107: Get rid of TextEditRules::GetTextNodeAroundSelectionStartContainer() since nobody uses it r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45490

--HG--
extra : moz-landing-system : lando
2019-09-13 03:39:13 +00:00
Masayuki Nakano
438470f81e Bug 1574852 - part 106-2: Move calling DeleteSelectionWithTransaction() and HTMLEditor specific post handling into HandleDeleteSelection() from TextEditor::DeleteSelectionAsSubAction() r=m_kato
In `TextEditor::HandleDeleteSelection()`, we have only one path of returning
`EditActionIgnored()`.  Therefore, it should call
`DeleteSelectionWithTransaction()` directly.

On the other hand, it's not clear in `HTMLEditor::HandleDeleteSelection()`
since it may be called recursively by its helper methods.  Therefore,
this patch creates `HTMLEditor::HandleDeleteSelectionInternal()` for the
recursive calls and makes `HTMLEditor::HandleDeleteSelection()` call
`DeleteSelectionWithTransaction()` if nobody handled it and to the
`HTMLEditor` specific post-process in it.

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

--HG--
extra : moz-landing-system : lando
2019-09-13 03:20:04 +00:00
Masayuki Nakano
053579099d Bug 1574852 - part 106-1: Move TextEditRules::WillDeleteSelection() and TextEditRules::DeleteSelectionWithTransaction() to TextEditor and make HTMLEditor::HandleDeleteSelection() override the former r=m_kato
`TextEditor::DeleteSelectionAsSubAction()` starts to handle all
"delete selection" sub-actions (i.e., even if the instance is `HTMLEditor`).
Therefore, `TextEditRules::WillDeleteSelection()` should be renamed to
`TextEditor::HandleDeleteSelection()` and we need to make it virtual.

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

--HG--
extra : moz-landing-system : lando
2019-09-13 02:49:43 +00:00
Masayuki Nakano
72fa9d1512 Bug 1574852 - part 105: Get rid of TextEditRules::WillSetProperty() and TextEditRules::WillRemoveProperty() r=m_kato
Oddly, they are used only by `HTMLEditor`, but implemented by `TextEditRules`.
They cancels when the editor is in plaintext mode.  So, actual things are
implemented by each caller.  This patch cleans them up too.

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

--HG--
extra : moz-landing-system : lando
2019-09-12 09:13:00 +00:00
Masayuki Nakano
f521a40385 Bug 1574852 - part 104: Move TextEditRules::WillInsertText() to TextEditor and make HTMLEditor::WillInsertText() override it r=m_kato
And also this patch moves `TextEditRules::HandleNewLines()` and
`TextEditRules::DontEchoPassword()` to `TextEditor`.

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

--HG--
extra : moz-landing-system : lando
2019-09-13 02:40:09 +00:00
Masayuki Nakano
d0bf28c6cc Bug 1574852 - part 103: Move TextEditRules::WillInsertLineBreak() to TextEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45297

--HG--
extra : moz-landing-system : lando
2019-09-12 08:03:57 +00:00
Masayuki Nakano
80be9ab956 Bug 1574852 - part 102: Move TextEditRules::TruncateInsertionIfNeeded() to TextEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45296

--HG--
extra : moz-landing-system : lando
2019-09-12 07:48:29 +00:00
Masayuki Nakano
d0e7a72d94 Bug 1574852 - part 101: Move HTMLEditRules::DidDeleteSelection() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45295

--HG--
extra : moz-landing-system : lando
2019-09-12 07:27:30 +00:00
Masayuki Nakano
45ef18ee30 Bug 1574852 - part 100: Get rid of TextEditRules::DidDeleteSelection() r=m_kato
There are only 3 callers and it does simple but different 2 things.  One of
the callers is `HTMLEditRules::DidDeleteSelection()` so that if same things
are done by `TextEditor::DeleteSelectionAsSubAction()`, it does not need to
duplicate the code.  Therefore, we need to duplicate the code into
`TextEditor::DeleteSelectionAsSubAction()` and `TextEditRules::WillSetText()`.
Then, `TextEditRules::WillSetText()` can avoid accessing `Selection` since
it still grabs the modified text node.

Note that only when it's called by `TextEditRules::DidDoAction()`,
`AutoTransactionsConserveSelection` has been set.  However, neither
`DeleteNodeWithTransaction()` nor `DeleteNodeTransaction::DoTransaction()`
changes `Selection`.  Therefore, it hasn't do anything.  So, we can remove
it right now.

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

--HG--
extra : moz-landing-system : lando
2019-09-12 06:51:26 +00:00
Masayuki Nakano
d87ff4830d Bug 1574852 - part 99: Move HTMLEditRules::WillRelativeChangeZIndex() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45293

--HG--
extra : moz-landing-system : lando
2019-09-12 06:20:49 +00:00
Masayuki Nakano
fee93a3a4d Bug 1574852 - part 98: Move HTMLEditRules::WillAbsolutePosition() and HTMLEditRules::WillRemoveAbsolutePosition() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45292

--HG--
extra : moz-landing-system : lando
2019-09-12 05:45:13 +00:00
Masayuki Nakano
878bbf3cb8 Bug 1574852 - part 97: Move HTMLEditRules::PrepareToMakeElementAbsolutePosition() to HTMLEditor r=m_kato
Only caller of it is `WillRemoveAbsolutePosition()` and it always sets
`*aHandled` to true before calling it.  Therefore, it does not need to take
it as an argument.

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

--HG--
extra : moz-landing-system : lando
2019-09-12 04:07:30 +00:00
Masayuki Nakano
8b9c4d3ad1 Bug 1574852 - part 96: Merge HTMLEditRules::DidAbsolutePosition() with HTMLEditRules::WillAbsolutePosition() r=m_kato
Oddly, absolute position is handled as following steps.
1. `WillAbsolutePosition()` calls `PrepareToMakeElementAbsolutePosition()`
   to consider the target element.
2. Set TopLevelEditSubActionData::mNewBlockElement to it.
3. `DidAbsolutePosition()` makes it absolute-positioned.

So that, all of them can be done in `WillAbsolutePosition()` like other
edit sub-action handling.

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

--HG--
extra : moz-landing-system : lando
2019-09-12 01:54:28 +00:00
Masayuki Nakano
d5f8e358d2 Bug 1574852 - part 95: Move HTMLEditRules::AfterEditInner() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44799

--HG--
extra : moz-landing-system : lando
2019-09-11 10:39:38 +00:00
Masayuki Nakano
821d89d488 Bug 1574852 - part 94: Move HTMLEditRules::PinSelectionToNewBlock() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44798

--HG--
extra : moz-landing-system : lando
2019-09-11 09:44:39 +00:00
Masayuki Nakano
e3bcdb2d3c Bug 1574852 - part 93: Move HTMLEditRules::CheckInterlinePosition() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44797

--HG--
extra : moz-landing-system : lando
2019-09-11 01:07:27 +00:00
Masayuki Nakano
875a9d4d05 Bug 1574852 - part 92: Move HTMLEditRules::RemoveEmptyNodesInChangedRange() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44796

--HG--
extra : moz-landing-system : lando
2019-09-10 04:46:55 +00:00
Masayuki Nakano
9ab5c8f493 Bug 1574852 - part 91: Move HTMLEditRules::InsertBRElementToEmptyListItemsAndTableCellsInRange() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44795

--HG--
extra : moz-landing-system : lando
2019-09-10 04:32:21 +00:00
Masayuki Nakano
24f1d9a9b3 Bug 1574852 - part 90: Move HTMLEditRules::ConfirmSelectionInBody() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44794

--HG--
extra : moz-landing-system : lando
2019-09-10 03:52:44 +00:00
Masayuki Nakano
a2c5d981ee Bug 1574852 - part 89: Move HTMLEditRules::AdjustSelection() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44793

--HG--
extra : moz-landing-system : lando
2019-09-10 03:38:04 +00:00
Masayuki Nakano
9a7cb5f3c8 Bug 1574852 - part 88: Move HTMLEditRules::FindNearEditableNode() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44792

--HG--
extra : moz-landing-system : lando
2019-09-09 10:09:38 +00:00
Masayuki Nakano
a8504046a4 Bug 1574852 - part 87: Move HTMLEditRules::SelectionEndpointInNode() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44791

--HG--
extra : moz-landing-system : lando
2019-09-09 05:21:04 +00:00
Masayuki Nakano
b1ead5a6f3 Bug 1574852 - part 86: Move HTMLEditRules::WillAlign() and HTMLEditRules::AlignContentsAtSelection() to HTMLEditor r=m_kato
And also this splits large 2 blocks of
`HTMLEditRules::AlignContentsAtSelection()` to 2 methods.

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

--HG--
extra : moz-landing-system : lando
2019-09-09 04:57:50 +00:00
Masayuki Nakano
04e8f93b98 Bug 1574852 - part 85: Move HTMLEditRules::AlignBlock() to HTMLEditor r=m_kato
With guaranteeing the argument element type with `MOZ_ASSERT()`, we can
make it really simpler.

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

--HG--
extra : moz-landing-system : lando
2019-09-09 02:48:56 +00:00
Masayuki Nakano
85fb6afdf7 Bug 1574852 - part 84: Move HTMLEditRules::RemoveAlignment() to HTMLEditor r=m_kato
And also this patch removes unnecessary declarations in `HTMLEditRules.h`.

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

--HG--
extra : moz-landing-system : lando
2019-09-09 10:47:47 +00:00
Masayuki Nakano
2bc7658314 Bug 1574852 - part 83: Move HTMLEditRules::MakeSureElemStartsOrEndsOnCR() to HTMLEditor r=m_kato
`HTMLEditRules::MakeSureElemStartsOrEndsOnCR()` is unclear what it does.
And fortunately, its job is simple if we split it to each mode.  Therefore,
this patch splits it to `EnsureHardLineBeginsWithFirstChildOf()` and
`EnsureHardLineEndsWithLastChildOf()`.  Finally, the batch caller of them,
`HTMLEditRules::MakeSureElemStartsAndEndsOnCR()` is removed since directly
calling both of them is clearer.

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

--HG--
extra : moz-landing-system : lando
2019-09-09 10:47:08 +00:00
Masayuki Nakano
d87e610645 Bug 1574852 - part 82: Move HTMLEditRules::MakeTransitionList() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44786

--HG--
extra : moz-landing-system : lando
2019-09-09 10:46:17 +00:00
Masayuki Nakano
fe64aaca55 Bug 1574852 - part 81: Move HTMLEditRules::AlignInnerBlocks() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44785

--HG--
extra : moz-landing-system : lando
2019-09-08 05:29:24 +00:00
Masayuki Nakano
31f29e011e Bug 1574852 - part 80: Move HTMLEditRules::AlignBlockContents() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44784

--HG--
extra : moz-landing-system : lando
2019-09-08 05:28:56 +00:00
Masayuki Nakano
c7ac0cebe5 Bug 1574852 - part 79: Make HTMLEditor::IndentAsAction() and HTMLEditor::OutdentAsAction() call specific AsSubAction() methods instead of WillDoAction() and DidDoAction() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44783

--HG--
extra : moz-landing-system : lando
2019-09-08 05:12:43 +00:00
Masayuki Nakano
13e63d57ea Bug 1574852 - part 78: Move HTMLEditRules::WillOutdent() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44782

--HG--
extra : moz-landing-system : lando
2019-09-08 05:05:38 +00:00
Masayuki Nakano
183c471149 Bug 1574852 - part 77: Move HTMLEditRules::WillIndent(), HTMLEditRules::WillHTMLIndent() and HTMLEditRules::WillCSSIndent() to HTMLEditor r=m_kato
The caller of `HTMLEditRules::WillDoAction()` is shared with "outdent".
Therefore, this patch is a preparation of makes `HTMLEditor` stop calling it.

Be aware, `HTMLEditRules::WillIndent()` won't cancel the action, and also
always handles the action unless editor has already been destroyed.  Therefore,
we can remove the dead code in `HTMLEditor::IndentOrOutdentAsSubAction()`
right now.

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

--HG--
extra : moz-landing-system : lando
2019-09-08 04:35:52 +00:00
Masayuki Nakano
67f54f71f8 Bug 1574852 - part 76: Move HTMLEditRules::OutdentAroundSelection() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44780

--HG--
extra : moz-landing-system : lando
2019-09-08 04:03:06 +00:00
Masayuki Nakano
a322625816 Bug 1574852 - part 75: Move HTMLEditRules::OutdentPartOfBlock() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44779

--HG--
extra : moz-landing-system : lando
2019-09-08 03:23:16 +00:00
Masayuki Nakano
d64c6562b7 Bug 1574852 - part 74: Move HTMLEditRules::IndentAroundSelectionWithHTML() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44778

--HG--
extra : moz-landing-system : lando
2019-09-08 03:05:46 +00:00
Masayuki Nakano
9ff1becd88 Bug 1574852 - part 73: Move HTMLEditRules::IndentAroundSelectionWithCSS() to HTMLEditor r=m_kato
And also this patch fixes unexpected behavior change by bug 1460509:
https://searchfox.org/mozilla-central/diff/d5d67de86f23655fcccc7bbcf4423bb75148fd34/editor/libeditor/HTMLEditRules.cpp#4466

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

--HG--
extra : moz-landing-system : lando
2019-09-06 12:57:56 +00:00
Masayuki Nakano
07dae7f820 Bug 1574852 - part 72: Move HTMLEditRules::ChangeMarginStart() to HTMLEditor and get rid of its wrappers r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44465

--HG--
extra : moz-landing-system : lando
2019-09-06 08:51:36 +00:00
Masayuki Nakano
de7cc1a3a0 Bug 1574852 - part 71: Move HTMLEditRules::WillRemoveList() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44464

--HG--
extra : moz-landing-system : lando
2019-09-06 06:01:57 +00:00
Masayuki Nakano
cfd3ee7e70 Bug 1574852 - part 70: Move HTMLEditRules::RemoveListStructur() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44463

--HG--
extra : moz-landing-system : lando
2019-09-06 05:46:15 +00:00
Geoff Brown
56ca134785 Bug 1579272 - Cleanup obviously fennec-centric test annotations; r=bc
Remove test manifest annotations that specifically target fennec,
or likely target the android 4.3 emulator.

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

--HG--
extra : moz-landing-system : lando
2019-09-06 16:51:10 +00:00
Masayuki Nakano
e6a72f86be Bug 1574852 - part 69: Move HTMLEditRules::PopListItem() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44462

--HG--
extra : moz-landing-system : lando
2019-09-06 04:51:51 +00:00
Masayuki Nakano
c4c3b160eb Bug 1574852 - part 68: Make HTMLEditRules::GetDefinitionListItemTypes() to a stack class r=m_kato
It scans children and returns whether `<dt>` and `<dd>` are found or not.
So, we can make it a stack class and makes caller pick the necessary value
with getter methods.

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

--HG--
extra : moz-landing-system : lando
2019-09-06 04:32:36 +00:00
Masayuki Nakano
f213a8f6d0 Bug 1574852 - part 67-10: Move HTMLEditRules::WillDeleteSelection() and related methods to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44460

--HG--
extra : moz-landing-system : lando
2019-09-06 04:31:38 +00:00
Masayuki Nakano
23c21f055e Bug 1574852 - part 67-9: Make next early return-style code work without AutoTrackDOMPoint r=m_kato
The next simple case is using early-return style and does not refer modified
`firstRangeStart` nor `firstRangeEnd` so that it can do same thing without
`AutoTrackDOMPoint`.

Then, there is remaining the complicated case.  We cannot split it anymore.

Note that we should not split `HandleDeleteNonCollapsedSelection()` anymore
because as you know, it does not make sense.  It checks only first range
and consider how to treat all ranges.  We should split it after we investigate
deeper with writing new WPT.

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

--HG--
extra : moz-landing-system : lando
2019-09-06 03:46:03 +00:00
Masayuki Nakano
7c0f0f1a19 Bug 1574852 - part 67-8: Make next simple deletion code use early-return style r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44458

--HG--
extra : moz-landing-system : lando
2019-09-06 02:59:57 +00:00
Masayuki Nakano
07dea9b716 Bug 1574852 - part 67-7: Make early-return style for first simple deletion case of HTMLEditRules::HandleDeleteNonCollapsedSelection() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44457

--HG--
extra : moz-landing-system : lando
2019-09-06 01:49:57 +00:00
Masayuki Nakano
3e4575061a Bug 1574852 - part 67-6: Split the last common part of HTMLEditRules::HandleDeleteNonCollapsedSelection() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44456

--HG--
extra : moz-landing-system : lando
2019-09-06 01:44:00 +00:00
Masayuki Nakano
05db7b82d5 Bug 1574852 - part 67-5: Rewrite HTMLEditRules::HandleDeleteNonCollapsedSelection() with EditorDOMPoint r=m_kato
Before splitting the method, we should make it use `EditorDOMPoint` to
treat selection edges.

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

--HG--
extra : moz-landing-system : lando
2019-09-06 00:59:32 +00:00
Masayuki Nakano
1a4a5cb8b9 Bug 1574852 - part 67-4: Split HTMLEditRules::HandleDeleteAroundCollapsedSelection() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44454

--HG--
extra : moz-landing-system : lando
2019-09-05 13:38:07 +00:00
Masayuki Nakano
f3b99207af Bug 1574852 - part 67-3: Split HTMLEditRules::WillDeleteSelection() to 3 methods r=m_kato
First, we can split it with 3 parts:
1. preparation with current selection part.
2. handling deletion with collapsed selection part.
3. handling deletion with non-collapsed selection part.
The first should leave in `WillDeleteSelection()`, but the others should be
moved to independent methods.

With this change, we need to fix an odd case when there is no visible node
and `GetFirstSelectedTableCellElement()` returned error due to crossing
the method boundary.  The method returns error only when there is no selection
ranges.  In such case, we cannot handle deletion of current selection anyway.
So, it must not be a problem to handle the error immediately after calling
`GetFirstSelectedTableCellElement()`.  Note that this shouldn't occur in
normal cases since `WillDoAction()` checks it before calling
`WillDeleteSelection()`.

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

--HG--
extra : moz-landing-system : lando
2019-09-05 13:37:57 +00:00
Masayuki Nakano
b9ab4d13e9 Bug 1574852 - part 67-2: Rename variables in HTMLEditRules::WillDeleteSelection() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44452

--HG--
extra : moz-landing-system : lando
2019-09-05 13:16:12 +00:00
Masayuki Nakano
ce5e7d1651 Bug 1574852 - part 67-1: Make HTMLEditRules::WillDeleteSelection() return EditActionResult` r=m_kato
Before moving the largest method in our tree, we should split it.  This is
first preparation of that.

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

--HG--
extra : moz-landing-system : lando
2019-09-05 13:37:42 +00:00
Masayuki Nakano
0382baf2fe Bug 1574852 - part 66: Move HTMLEditRules::ExpandSelectionForDelete() to HTMLEditor r=m_kato
And this patch makes the new method do not touch `Selection`, instead, return
new `StaticRange`.  Although the creation cost may make damage to the
performance but let's keep using `StaticRange` for now.  There should be
a stack only class which have 2 `RangeBoundaryBase` or `EditorDOMPointBase`.

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

--HG--
extra : moz-landing-system : lando
2019-09-05 07:25:51 +00:00
Masayuki Nakano
ff5055d6e2 Bug 1574852 - part 65: Move TextEditRules::CheckBidiLevelForDeletion() to EditorBase r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44204

--HG--
extra : moz-landing-system : lando
2019-09-05 02:21:26 +00:00
Masayuki Nakano
656648d70f Bug 1574852 - part 64: Move HTMLEditRules::MaybeDeleteTopMostEmptyAncestor() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44203

--HG--
extra : moz-landing-system : lando
2019-09-05 01:30:37 +00:00
Masayuki Nakano
c6648a62df Bug 1574852 - part 63: Move HTMLEditRules::GetGoodSelPointForNode() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44202

--HG--
extra : moz-landing-system : lando
2019-09-05 01:14:24 +00:00
Masayuki Nakano
d2ce733c6a Bug 1574852 - part 62: Move HTMLEditRules::TryToJoinBlocksWithTransaction() to HTMLEditor r=m_kato
Additionally, `WSRunObject::ScrabBlockBoundary()` and
`WSRunObject::PreparetToJoinBlocks()` are used only the it.  Therefore, we
can clean them up.

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

--HG--
extra : moz-landing-system : lando
2019-09-04 08:43:12 +00:00
Masayuki Nakano
e0847a6b6d Bug 1574852 - part 61: Move HTMLEditRules::MoveBlock() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44200

--HG--
extra : moz-landing-system : lando
2019-09-04 05:00:11 +00:00
Masayuki Nakano
e06533766b Bug 1574852 - part 60: Move HTMLEditRules::MoveNodeSmart() and HTMLEditRules::MoveContents() to HTMLEditor r=m_kato
Making them return next insertion point with `nsresult` makes the callers
easier to understand.  Therefore, this patch declares `MoveNodeResult` class
newly and make them use it.

And also we can get rid of the case of setting `*aInOutDestOffset` to -1
because it's a hacky case of `HTMLEditRules::MoveBlock()`.  If we keep it,
`MoveNodeSmart()` needs to compute new insertion point with different logic.
Therefore, this patch makes `HTMLEditRules::MoveBlock()` adjust new insertion
point with checking its argument.

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

--HG--
extra : moz-landing-system : lando
2019-09-04 03:32:26 +00:00
Masayuki Nakano
9c8bc82f51 Bug 1574852 - part 59: Move HTMLEditRules::JoinNearestEditableNodesWithTransaction() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44198

--HG--
extra : moz-landing-system : lando
2019-09-04 00:18:18 +00:00
Masayuki Nakano
e9b4c8468b Bug 1574852 - part 58: Move HTMLEditRules::CheckForInvisibleBR() to HTMLEditor r=m_kato
This is defined as too complicated than what it does actually since there
was not `EditorDOMPointBase`.

If given point's offset is `0`, returns `nullptr`.  If `aWhere` is
`BRLocation::blockEnd`, treats `aOffset` is length of `aBlock`.  Otherwise,
using given point.  Then, if the `WSRun` start reason is `br`, returns the
start reason node.  This means that this method just retrieves invisible
`<br>` element if it starts `WSRun` at given point.

Now, callers can specify end of block with `EditorDOMPointBase::SetToEndOf()`
easier.  Therefore, we can make it take only an `EditorDOMPointBase` instance.

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

--HG--
extra : moz-landing-system : lando
2019-09-03 10:31:41 +00:00
Masayuki Nakano
e1d468e330 Bug 1574852 - part 57: Move HTMLEditRules::DeleteNodeIfCollapsedText() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44196

--HG--
extra : moz-landing-system : lando
2019-09-03 09:57:28 +00:00
Masayuki Nakano
1edcec042e Bug 1574852 - part 56: Merge HTMLEditRules::WillMakeList() and HTMLEditRules::WillMakeDefinitionList() and make HTMLEditor call it directly r=m_kato
`HTMLEditRules::WillMakeDefinitionList()` just calls
`HTMLEditRules::WillMakeList()` and `HTMLEditRules::WillMakeList()` can be
called as `HTMLEditRules::MakeOrChangeListAndListItemAsSubAction()` so that
we should merge them and make `HTMLEditor` call it directly.

This patch also removes default action part of
`HTMLEditor::MakeOrChangeListAsAction()` because it runs only when
`HTMLEditRules::WillDoAction()` does not return canceled nor error but not
handled, however, it's won't occur since `HTMLEditRules::WillMakeList()`
always sets `aHandled` to `true` when it returns `NS_OK`.

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

--HG--
extra : moz-landing-system : lando
2019-09-03 09:32:17 +00:00
Masayuki Nakano
447a15d680 Bug 1574852 - part 55: Move HTMLEditRules::MakeList() to HTMLEditor r=m_kato
Additionally, this patch makes it use early-return style with `continue` as
far as making number of changing line minimized.

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

--HG--
extra : moz-landing-system : lando
2019-09-03 07:24:41 +00:00
Masayuki Nakano
d4fab048af Bug 1574852 - part 54: Move HTMLEditRules::ConvertListType() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44193

--HG--
extra : moz-landing-system : lando
2019-09-03 05:13:35 +00:00
Masayuki Nakano
2fc50edf06 Bug 1574852 - part 53: Move HTMLEditRuies::InDifferentTableElements() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44191

--HG--
extra : moz-landing-system : lando
2019-09-03 04:18:02 +00:00
Masayuki Nakano
f92de6dd34 Bug 1574852 - part 52: Make HTMLEditRules::WillInsertParagraph() merged with HTMLEditor::InsertParagraphSeparatorAsSubAction() r=m_kato
Meaningful job of `HTMLEditor::InsertParagraphSeparatorAsSubAction()` is only
calling `HTMLEditRules::WillInsertParagraph()` via
`HTMLEditRules::WillDoAction()`.  Therefore, we can move all jobs in them
into `HTMLEditRules::WillInsertParagraph()` and rename it to
`HTMLEditor::InsertParagraphSeparatorAsSubAction()`.

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

--HG--
extra : moz-landing-system : lando
2019-09-03 03:59:11 +00:00
Masayuki Nakano
298b98043f Bug 1574852 - part 51: Move HTMLEditRules::IsInListItem() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44189

--HG--
extra : moz-landing-system : lando
2019-09-02 23:59:49 +00:00
Masayuki Nakano
b588b7f775 Bug 1574852 - part 50: Move TextEditRules::UndefineCaretBidiLevel() to EditorBase r=m_kato
It's used both by `TextEditRules` and `HTMLEditRules` so that `EditorBase`
should have it instead.

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

--HG--
extra : moz-landing-system : lando
2019-09-02 10:08:57 +00:00
Masayuki Nakano
d6d83bd331 Bug 1574852 - part 49: Move HTMLEditRules::ReturnInListItem() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44186

--HG--
extra : moz-landing-system : lando
2019-09-02 09:16:31 +00:00
Masayuki Nakano
5941cef758 Bug 1574852 - part 48: Move HTMLEditRules::ReturnInHeader() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44185

--HG--
extra : moz-landing-system : lando
2019-09-02 09:14:23 +00:00
Masayuki Nakano
e356eee3f9 Bug 1574852 - part 47: Move HTMLEditRules::ReturnInParagraph() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44184

--HG--
extra : moz-landing-system : lando
2019-09-02 08:49:18 +00:00
Masayuki Nakano
425de0b16f Bug 1574852 - part 46: Move HTMLEditRules::SplitParagraph() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44183

--HG--
extra : moz-landing-system : lando
2019-09-02 08:09:47 +00:00
Masayuki Nakano
16447ba211 Bug 1574852 - part 45: Move HTMLEditRules::DefaultParagraphSeparator() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44182

--HG--
extra : moz-landing-system : lando
2019-09-02 08:06:56 +00:00
Masayuki Nakano
7c64e596da Bug 1574852 - part 44: Move HTMLEditRules::IsEmptyBlockElement() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44181

--HG--
extra : moz-landing-system : lando
2019-09-02 06:37:43 +00:00
Masayuki Nakano
fc08e740d8 Bug 1574852 - part 43: Move HTMLEditRules::DidMakeBasicBlock() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44180

--HG--
extra : moz-landing-system : lando
2019-09-02 06:36:33 +00:00
Masayuki Nakano
8438c04ae7 Bug 1574852 - part 42: Merge HTMLEditRules::WillMakeBasicBlock() into HTMLEditor::InsertBasicBlockWithTransaction() r=m_kato
`HTMLEditRules::WillMakeBasicBlock()` just calls
`HTMLEditor::FormatBlockContainer()` and it's called only for
`EditSubAction::eCreateOrRemoveBlock` and it's used only in
`HTMLEditor::InsertBasicBlockWithTransaction()`.  Therefore, we can replace
calling `HTMLEditRules::WillDoAction()` in it with what
`HTMLEditRules::WIllMakeBasicBlock()` does.

First, `HTMLEditRules::WillDoAction()` checks whether first selection range
is editable.  If it's not so, it returns `NS_OK` with setting `aCancel` to
`true`.  Therefore, this patch moves this part to
`HTMLEditor::CanHandleHTMLEditSubAction()` for making
`HTMLEditor::InsertBasicBlockWithTransaction()` can check it easier.

Next, `HTMLEditor::InsertBasicBlockWithTransaction()` does something if
`HTMLEditRules::WillDoAction()` returns as not handled nor canceled.
However, this special handling requires at least one selection range:
https://searchfox.org/mozilla-central/rev/597a69c70a5cce6f42f159eb54ad1ef6745f5432/editor/libeditor/HTMLEditor.cpp#2284-2288
Surprisingly, `handled` is set to `false` only when there is an error or
there is no selection range.  Therefore, this long block has already been
dead code so that we can remove this.  Removing this block causes that we
become not throwing exception when `Document.execCommand("formatblock")`
without selection ranges.  But this is better since Chrome does not throw
excption.

Finally, this patch renames some related methods:
- `HTMLEditor::FormatBlockContainer()` -> `HTMLEditor::FormatBlockContainerWithTransaction()`
- `HTMLEditor::InsertBasicBlockWithTransaction()` -> `HTMLEditor::FormatBlockContainerAsSubAction()`

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

--HG--
extra : moz-landing-system : lando
2019-09-02 06:08:43 +00:00
Masayuki Nakano
816dbbb57d Bug 1574852 - part 41: Move HTMLEditRules::InsertBRIfNeeded(nsINode&) to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44178

--HG--
extra : moz-landing-system : lando
2019-09-02 03:17:14 +00:00
Masayuki Nakano
08108eda15 Bug 1574852 - part 40: Move HTMLEditRules::InsertPaddingBRElementForEmptyLastLineIfNeeded() to HTMLEditor r=m_kato
And this fixes the caller which has not guaranteed the lifetime of the
start container.

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

--HG--
extra : moz-landing-system : lando
2019-09-02 03:16:26 +00:00
Masayuki Nakano
1155464d4c Bug 1574852 - part 39: Move HTMLEditRules::InsertBRIfNeeded() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D44174

--HG--
extra : moz-landing-system : lando
2019-09-02 01:47:14 +00:00
Makoto Kato
9d24379b0f Bug 1577969 - Get rid of nsIHTMLEditor.getLinkedObject and nsIURIRefObject. r=masayuki
Since bug 1577443 is landed in comm-central, no one uses `nsIHTMLEditor.getLinkedObject`.

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

--HG--
extra : moz-landing-system : lando
2019-09-02 12:15:41 +00:00
Masayuki Nakano
1779535bf3 Bug 1574852 - part 38: Move HTMLEditRules::MakeBasicBlock() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43199

--HG--
extra : moz-landing-system : lando
2019-08-26 07:09:11 +00:00
Masayuki Nakano
a6be29d2bf Bug 1574852 - part 37: Move HTMLEditRules::ApplyBlockStyle() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43198

--HG--
extra : moz-landing-system : lando
2019-08-26 04:48:21 +00:00
Masayuki Nakano
364649f84e Bug 1574852 - part 36: Move HTMLEditRules::RemvoeBlockStyle() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43197

--HG--
extra : moz-landing-system : lando
2019-08-26 04:00:15 +00:00
Masayuki Nakano
72ea02b6a7 Bug 1574852 - part 35: Move HTMLEditRules::SplitRangeOffFromBlockAndRemoveMiddleContainer() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43196

--HG--
extra : moz-landing-system : lando
2019-08-26 03:59:48 +00:00
Masayuki Nakano
627c9ff582 Bug 1574852 - part 34: Move HTMLEditRules::SplitRangeOffFromBlock() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43195

--HG--
extra : moz-landing-system : lando
2019-08-26 03:20:35 +00:00
Masayuki Nakano
d42fe61844 Bug 1574852 - part 33: Move HTMLEditRules::MakeBlockquote() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43194

--HG--
extra : moz-landing-system : lando
2019-08-26 01:55:01 +00:00
Masayuki Nakano
337a97617a Bug 1574852 - part 32: Move HTMLEditRules::MaybeSplitAncestorsForInsertWithTransaction() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43193

--HG--
extra : moz-landing-system : lando
2019-08-26 01:38:56 +00:00
Masayuki Nakano
1a76778801 Bug 1574852 - part 31: Move HTMLEditRules::IsEmptyInline() and HTMLEditRules::ListIsEmptyLine() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43192

--HG--
extra : moz-landing-system : lando
2019-08-25 06:59:24 +00:00
Masayuki Nakano
bff247acdd Bug 1574852 - part 30: Move HTMLEditRules::NormalizeSelection() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43191

--HG--
extra : moz-landing-system : lando
2019-08-25 06:19:48 +00:00
Masayuki Nakano
ff26989c8d Bug 1574852 - part 29: Merge HTMLEditRules::GetListActionNodes() with HTMLEditor::CollectEditTargetNodes() r=m_kato
This patch fixes an existing bug with this clean up.

Except `HTMLEditRules::MoveBlock()`, `GetListActionNodes()` is called after
calling `SplitInlinesAndCollectEditTargetNodesInExtendedSelectionRanges()`
or `CollectEditTargetNodesInExtendedSelectionRanges()` **with**
`EditSubAction::eCreateOrChangeList`.  I think that `HTMLEditRules::MoveBlock()`
using the edit sub-action is a simple mistake.  Perhaps, it should be
`EditSubAction::eCreateOrRemvoeBlock`.  However, I'm not 100% sure because
`HTMLEditor::CollectEditTargetNodes()` does special handling for
`EditSubAction::eCreateOrRemvoeBlock` but not so for
`EditSubAction::eCreateOrChangeList`.  The behavior of difference between
those edit sub-actions are only here.  Therefore, this patch creates new
`EditSubAction` `eMergeBlockContents` for `MoveBlock()`.

Then, this patch makes `HTMLEditor::CollectEditTargetNodes()` handle
`EditSubAction::eCreateOrChangeList` insead of `GetListActionNodes()`.
This causes one logic change in `SplitInlinesAndCollectEditTargetNodes()`.
It calls `MaybeSplitElementsAtEveryBRElement()` after `CollectEditTargetNodes()`
so that this change makes calling `MaybeSplitElementsAtEveryBRElement()` at
last.  According to my tests, new behavior must be expected since `<br>`
elements outside and in `<table>` should be handled consistently.  Therefore,
this patch adds some simple testcases into WPT.

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

--HG--
extra : moz-landing-system : lando
2019-08-25 04:20:34 +00:00
Masayuki Nakano
24835249e4 Bug 1574852 - part 28: Make methods collecting event target nodes take additional argument which can specify whether aOutArrayOfNodes includes non-editable nodes or not r=m_kato
`HTMLEditRules::GetListActionNodes()` removes non-editable element.  However,
this should've been done by collector methods.

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

--HG--
extra : moz-landing-system : lando
2019-08-25 04:11:06 +00:00
Masayuki Nakano
071b3d92c1 Bug 1574852 - part 27: Move first half of HTMLEditRules::GetListActionNodes() to HTMLEditor and each caller r=m_kato
First half of `HTMLEditoRules::GetListActionNodes()` does 2 things.  One is
trying to get parent list element of `Selection` ranges if `aEntireList` is
`EntireList::yes`.  If it found a list element, it does nothing anymore.
Otherwise, falls backs to `EntireList::no` case.  So, if each caller which
calls it with `EntireList::yes`, `GetListActionNodes()` does not need the
argument.  Therefore, this patch does it first.

Then, `GetListActionNodes()` calls
`CollectEditTargetNodesInExtendedSelectionRanges()` or
`SplitInlinesAndCollectEditTargetNodesInExtendedSelectionRanges()`.  It's
considered with `aTouchContent` is `yes` or `no`.  So, this should be done
by each caller for making it clearer.

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

--HG--
extra : moz-landing-system : lando
2019-08-25 03:45:34 +00:00
Masayuki Nakano
4b1fe5b646 Bug 1574852 - part 26: Move a part of HTMLEditRules::LookInsideDivBQandList() and remove the others r=m_kato
`HTMLEditRules::LookInsideDivBQandList()` does complicated things and I cannot
explain with a method name what it does.  Fortunately, there are only 2 callers.
Therefore, this patch duplicates the part of modifying the range and creates
a method to retrieve "deepest and only editable child of `<div>`, `<blockquote>`
and one of list items".

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

--HG--
extra : moz-landing-system : lando
2019-08-23 09:20:05 +00:00
Cosmin Sabou
a876ab139c Bug 1575739 - Disable test on Android cause of frequent failures. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43347

--HG--
extra : moz-landing-system : lando
2019-08-25 03:44:10 +00:00
Masayuki Nakano
7002a0f988 Bug 1574852 - part 25: Move HTMLEditRules::GetChildNodesForOperation() to HTMLEditor r=m_kato
It just collects all children of given node so that it can be a static method
in `HTMLEditor`.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 07:34:38 +00:00
Masayuki Nakano
6b6f24ee0f Bug 1574852 - part 24: Move HTMLEditRules::GetNodesFromPoint() to HTMLEditor r=m_kato
It's called only from `HTMLEditRules::MoveBlock()`.  Even though it has 4
patters to call different methods, we need only one of them.  Therefore,
this patch moves it into `HTMLEditor.h` as
`SplitInlinesAndCollectEditTargetNodesInOneHardLine()`.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 07:33:50 +00:00
Masayuki Nakano
6a2026a28d Bug 1574852 - part 23: Move HTMLEditRules::GetNodesFromSelection() to HTMLEditor r=m_kato
`HTMLEditRules::GetNodesFromSelection()` has a patch to call
`HTMLEditor::GetSelectionRangesExtendedToIncludeAdjuscentWhiteSpaces()`.
However, nobody uses this path so that we can get rid of this path.
Then, it becomes just calling `SplitInlinesAndCollectEditTargetNodes()` or
`CollectEditTargetNodes()` with result of
`GetSelectionRangesExtendedToHardLineStartAndEnd()`.  Therefore, we can split
it to `SplitInlinesAndCollectEditTargetNodesInExtendedSelectionRanges()` and
`CollectEditTargetNodesInExtendedSelectionRanges()`.  Then, we can mark
only the former as `MOZ_CAN_RUN_SCRIPT`.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 07:04:15 +00:00
Masayuki Nakano
dd792e1d82 Bug 1574852 - part 22: Move HTMLEditRules::GetPromotedRanges() to HTMLEditor r=m_kato
`HTMLEditRules::GetPromotedRanges()` does 2 things.  Calling
`CreateRangeIncludingAdjuscentWhiteSpaces()` or
`CreateRangeExtendedToHardLineStartAndEnd()` with each range of `Selection`.
The difference is considered with current edit sub-action.  Therefore, we cal
split it to `GetSelectionRangesExtendedToIncludeAdjuscentWhiteSpaces()` and
`GetSelectionRangesExtendedToHardLineStartAndEnd()`.  Then, we got clearer code
at each caller.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 06:55:34 +00:00
Masayuki Nakano
620c07b2bb Bug 1574852 - part 21: Move HTMLEditRules::PromoteRange() to HTMLEditor r=m_kato
The method name is really unclear what's done.  The method does 3 things.
One is try to select a `<br>` element in empty block if given range is
collapsed in the block.  This is moved as
`HTMLEditor::SelectBRElementIfCollapsedInEmptyBlock()`.  Next, it extends the
given range to include adjuscent whitespaces only when edit sub-action is
inserting or deleting text.  This is moved as
`HTMLEditor::CreateRangeIncludingAdjuscentWhiteSpaces()`.  Finally, when
handling the other edit sub-actions, extends the given range to start/end
of line at both edges.  This is moved as
`HTMLEditor::CreateRangeExtendedToHardLineStartAndEnd()`.

And also this patch makes each caller of `PromoteRange()` to check edit
sub-action by themselves.  Unfortunately, this duplicates same logic to
multiple places, but makes what they do clearer.  I think that the duplication
issue should be fixed later if necessary.  Instead, we should shine the
blackbox of `HTMLEditRules` right now.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 06:32:27 +00:00
Masayuki Nakano
39bbc90bb9 Bug 1574852 - part 20: Move HTMLEditRules::GetPromotedPoint() to HTMLEditor r=m_kato
`HTMLEditRules::GetPromotedPoint()` does too many things.  Therefore, this patch
splits it to 3 methods.  One is for specific `EditSubAction` values, that's
the first block in `GetPromotedPoint()`.  It's named as
`GetWhiteSpaceEndPoint()`.  Next one is for expanding start of the range to
start of its line.  It's named as `GetCurrentHardLineStartPoint()`.  The last
one is for expanding end of the range to end of its line.  It's named as
`GetCurrentHardLineEndPoint()`.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 06:05:38 +00:00
Masayuki Nakano
b8dba99d81 Bug 1574852 - part 19: Move HTMLEditRules::GetNodesForOperation() to HTMLEditor r=m_kato
This does not move the method simply.  Instead, splits it to 4 simpler
methods.

Despite of the name, it modifies the DOM tree if `aTouchContent` is
`TouchContent::yes`.  For avoiding this confusion and avoiding unnecessary
`MOZ_CAN_RUN_SCRIPT` attribute, the main part is split to
`HTMLEditor::CollectEditTargetNodes()`.

 If callers want to call `HTMLEditRules::GetNodesForOperation()` with
`TouchContent::no`, only calling this method equals to the call of
`GetNodesForOperation()`.

Otherwise, the callers should call
`HTMLEditor::SplitInlinesAndCollectEditTargetNodes()`.  This calls internal
methods automatically.

First, `HTMLEditor::SplitTextNodesAtRangeEnd()` splits text nodes at end of
each range.  Then, `HTMLEditor::SplitParentInlineElementsAtRangeEdges()`
overload splits inline elements at both edges of each range.  Then, collects
event target nodes with calling `HTMLEditor::CollectEditTargetNodes()`.
Finally, `HTMLEditor::MaybeSplitElementsAtEveryBRElement()` may split the
result nodes at every <br> element in them.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 04:38:28 +00:00
Masayuki Nakano
2271a1a433 Bug 1574852 - part 18: Move HTMLEditRules::BustUpInlinesAtBRs() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42789

--HG--
extra : moz-landing-system : lando
2019-08-23 04:14:56 +00:00
Masayuki Nakano
6cb490583d Bug 1574852 - part 17: Move HTMLEditRules::GetInnerContent() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42788

--HG--
extra : moz-landing-system : lando
2019-08-23 03:35:40 +00:00
Masayuki Nakano
9cd140da4a Bug 1574852 - part 16: Move HTMLEditRules::BustUpInlinesAtRangeEndpoints() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42787

--HG--
extra : moz-landing-system : lando
2019-08-23 01:28:26 +00:00
Mirko Brodesser
460b937f0b Bug 1575584: prevent reading uninitialized variable in TextEditor::ComputeValueInternal. r=masayuki
The fix here is to first check `NS_FAILED(rv)`, because if that's the
case, `cancel` wasn't necessarily set to a value.

As best practice I initialized `cancel` and `handled` with default
values.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 09:25:00 +00:00
Masayuki Nakano
495df615e7 Bug 1574852 - part 15: Move HTMLEditUtils::GetHighestInlineParent() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42786

--HG--
extra : moz-landing-system : lando
2019-08-22 08:47:50 +00:00
Masayuki Nakano
bee148c761 Bug 1574852 - part 14: Move HTMLEditRules::InsertBRElement() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42785

--HG--
extra : moz-landing-system : lando
2019-08-22 08:33:28 +00:00
Masayuki Nakano
6c17e180aa Bug 1574852 - part 13: Move HTMLEditRules::CanContainParagraph() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42784

--HG--
extra : moz-landing-system : lando
2019-08-22 08:29:38 +00:00
Masayuki Nakano
d0797846a4 Bug 1574852 - part 12: Move HTMLEditRules::SplitMailCites() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42783

--HG--
extra : moz-landing-system : lando
2019-08-22 08:29:16 +00:00
Masayuki Nakano
ba9cfcb2a7 Bug 1574852 - part 11: Move HTMLEditRules::GetTopEnclosingMailCite() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42782

--HG--
extra : moz-landing-system : lando
2019-08-22 13:11:16 +00:00
Masayuki Nakano
f23c09bbd0 Bug 1574852 - part 10: Move HTMLEditRules::WillInsertText() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42781

--HG--
extra : moz-landing-system : lando
2019-08-22 08:01:39 +00:00
Masayuki Nakano
3822de5442 Bug 1574852 - part 9: Move HTMLEditRules::CreateStyleForInsertText() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42780

--HG--
extra : moz-landing-system : lando
2019-08-22 07:33:41 +00:00
Masayuki Nakano
7ed950a31c Bug 1574852 - part 8: Move HTMLEditRules::WillInsert() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42778

--HG--
extra : moz-landing-system : lando
2019-08-22 07:08:19 +00:00
Masayuki Nakano
ed5707df5b Bug 1574852 - part 7: Get rid of HTMLEditRules::ClearCachedStyles() r=m_kato
It's declared, but not defined.

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

--HG--
extra : moz-landing-system : lando
2019-08-22 06:03:52 +00:00
Masayuki Nakano
f135e00456 Bug 1574852 - part 6: Move HTMLEditRules::CacheInlineStyles() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42776

--HG--
extra : moz-landing-system : lando
2019-08-22 05:13:50 +00:00
Masayuki Nakano
ab4e7103b0 Bug 1574852 - part 5: Move HTMLEditRules::ReapplyCachedStyles() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42775

--HG--
extra : source : 6456b7a6cc679d744637e639d37cb73e795c1357
2019-08-22 05:12:28 +00:00
Noemi Erli
8586a20580 Backed out changeset 6456b7a6cc67 (bug 1574852) for failing in browser_html_tooltip-05.js 2019-08-22 11:41:29 +03:00
Masayuki Nakano
df6c33c509 Bug 1574852 - part 5: Move HTMLEditRules::ReapplyCachedStyles() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42775

--HG--
extra : moz-landing-system : lando
2019-08-22 05:12:28 +00:00
Masayuki Nakano
0d08551fbd Bug 1574852 - part 4: Move HTMLEditRules::GetInlineStyles() to HTMLEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42774

--HG--
extra : moz-landing-system : lando
2019-08-22 01:10:30 +00:00
Makoto Kato
b4d246692c Bug 1574596 - Keep editing UI until PresShell is really gone. r=masayuki
This is regression by bug 1543312.

By bug 1543312, we destroy editor when destroying PresShell. But when destroying PresShell, editor doesn't remove anonymous content of editing UI from PresShell. Then, when destroying the frame manager in `PresShell::Destroy`, it hits assertion due to uncomposed doc.

We shouldn't hide editing UI during destroying PresShell and we should hide it after destroyed.

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

--HG--
extra : moz-landing-system : lando
2019-08-21 06:05:16 +00:00
Masayuki Nakano
3e52c98a82 Bug 1574852 - part 3: Get rid of HTMLEditRules::InitFields() r=m_kato
It's called immediately before setting `mHTMLEditor` and sets `mHTMLEditor` to
`nullptr`.  So, it does nothing actually.  We can get rid of it.

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

--HG--
extra : moz-landing-system : lando
2019-08-21 07:14:09 +00:00
Masayuki Nakano
d22d8c911e Bug 1574852 - part 2: Replace HTMLEditRules::IsInlineNode() with HTMLEditor::NodeIsInlineStatic() r=m_kato
`HTMLEditRules::IsInlineNode()` is a wrapper of
`HTMLEditor::NodeIsInlineStatic()`, but returns opposite value.

This patch moves it into `HTMLEditor` and names it with same rule as
`NodeIsBlockStatic()`.

Note that this method may return true if given node is unexpected node type.
E.g., comment node, CDATA node, etc.  However, it's not scope of this bug.

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

--HG--
extra : moz-landing-system : lando
2019-08-21 07:13:41 +00:00
Masayuki Nakano
24e7c7235d Bug 1574852 - part 1: Get rid of HTMLEditRules::IsBlockNode() r=m_kato
`HTMLEditRules::IsBlockNode()` just wraps `HTMLEditor::NodeIsBlockStatic()`
and all its users will be moved into `HTMLEditor`.  Therefore, we should
unwrap it.

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

--HG--
extra : moz-landing-system : lando
2019-08-21 06:21:05 +00:00
Masayuki Nakano
eeb6d0434a Bug 1572685 - part 13: Get rid of HTMLEditRules::mReturnInEmptyLIKillsList r=m_kato
`HTMLEditRules::mReturnInEmptyLIKillsList` stores value of
`editor.html.typing.returnInEmptyListItemClosesList` at construction, and it's
set to true unless the pref value is `"false"`.  However, this pref isn't
registered in anywhere (all.js, firefox.js, etc) nor used in comm-central
and BlueGriffon.

Even if I search the pref in the web, I don't see any information so that
this hidden pref must not be used anybody.  Therefore, this patch just removes
this member.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 01:53:35 +00:00
Masayuki Nakano
47e3467fa6 Bug 1572685 - part 12: Move HTMLEditRules::mListenerEnabled to EditSubActionData r=m_kato
This patch includes a logic change.  `HTMLEditRules::mListenerEnabled` is used
for storing 2 state.  One is that whether `HTMLEditRules` can handle the legacy
listener methods (they came from `nsIEditActionListener`) with `mHTMLEditor` or
not.  The other is that whether current edit sub-action handler temporarily
disables the listeners for performance or not.

For the former, we can check same result with `HTMLEditRules::mInitialized`
and `HTMLEditRules::mHTMLEditor`.

However, the latter, current design is obviously wrong.  Currently,
`HTMLEditRules::mListenerEnabled` is set only to `false` temporarily from
`WillInsertText()`, but the state will be affected to other edit sub-actions
which are nested by mutation event listeners.  So, currently,
`HTMLEditRules::mDocChangeRange` may not contain modified range caused by
nested edit sub-actions.

For solving this bug, this patch moves it into `EditSubActionData` rather
than `HTMLEditor` and `TopLevelEditSubActionData`.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 01:53:02 +00:00
Masayuki Nakano
d741d7dbe7 Bug 1572685 - part 11: Move HTMLEditRules::JoinOffset to EditorBase::EditSubActionData r=m_kato
The members of `HTMLEditRules` which are used only while `WillDoAction()` and
`DidDoAction()` are called should be moved to specific stack only struct
`EditorBase::EditSubActionData`.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 01:52:50 +00:00
Masayuki Nakano
f3a6c9590b Bug 1572685 - part 10: Get rid of HTMLEditRules::mUtilRange r=m_kato
`HTMLEditRules::mUtilRange` is used only for the argument of
`HTMLEditRules::UpdateDocChangeRange()`.  However, it does not need to be
a range instance since it compares its start and
`TopLevelEditSubAction::mChangedRange->StartRef()`, and its end and
`TopLevelEditSubAction::mChangedRange->EndRef()`.  Therefore, with rewriting
it as taking 2 `EditorRawDOMPoint`s, we don't need `mUtilRange`.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 01:52:23 +00:00
Masayuki Nakano
0cc09df825 Bug 1572685 - part 9: Move HTMLEditRules::mDocChangeRange to TopLevelEditSubActionData r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42104

--HG--
extra : moz-landing-system : lando
2019-08-20 01:51:59 +00:00
Masayuki Nakano
a2367ac28f Bug 1572685 - part 8: Move HTMLEditRules::mCachedStyles to TopLevelEditSubAction r=m_kato
This patch makes `StyleCache` not inherit `ItemProp` because `MOZ_COUNT_CTOR`
and `MOZ_COUNT_DTOR` do not work well with `AutoTArray` and there is no reason
to do that since nobody treat `StyleCache` instance with `ItemProp` pointer.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 01:51:36 +00:00
Masayuki Nakano
d696ee098d Bug 1572685 - part 7: Move HTMLEditRules::mRangeItem to TopLevelEditSubActionData r=m_kato
For avoiding allocation cost of `RangeItem`, it should be stored by `HTMLEditor`
and reused by all `TopLevelEditSubActionData` instances for the editor instance.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 01:51:19 +00:00
Masayuki Nakano
5f2af66e4b Bug 1572685 - part 6: Move HTMLEditRules::mNewBlock to TopLevelEditSubActionData r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42101

--HG--
extra : moz-landing-system : lando
2019-08-20 01:50:56 +00:00
Masayuki Nakano
0bc1ae3058 Bug 1572685 - part 5: Move HTMLEditRules::mRestoreContentEditableCount to TopLevelEditSubActionData r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42100

--HG--
extra : moz-landing-system : lando
2019-08-20 01:50:34 +00:00
Masayuki Nakano
7b09e44b5c Bug 1572685 - part 4: Move HTMLEditRules::mDidEmptyParentBlocksRemoved to TopLevelEditSubActionData r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42099

--HG--
extra : moz-landing-system : lando
2019-08-20 01:50:21 +00:00
Masayuki Nakano
8f2394e050 Bug 1572685 - part 3: Move HTMLEditRules::mDidRangedDelete to TopLevelEditSubActionData r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42098

--HG--
extra : moz-landing-system : lando
2019-08-20 01:50:04 +00:00
Masayuki Nakano
396a69a2bc Bug 1572685 - part 2: Move HTMLEditRules::mDidExplicitlySetInterLine to TopLevelEditSubActionData r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42097

--HG--
extra : moz-landing-system : lando
2019-08-20 01:50:02 +00:00
Masayuki Nakano
992c1c0972 Bug 1572685 - part 1: Move HTMLEditRules::mDidDeleteSelection into AutoEditActionDataSetter r=m_kato
Most member variables of `HTMLEditRules` are temporary used while between
`BeforeEdit()` and `AfterEdit()` are called or `WillDoAction()` and
`DidDoAction()` are called.

The former means the data should be stored during top-level edit sub-action
is set.  Therefore, this patch creates a struct, `TopLevelEditSubActionData`
and make it a member of `AutoEditActionDataSetter`.  Then, makes
`EditorBase::TopLevelEditActionDataRef()` return reference of it.

And also this patch moves `HTMLEditRules::mDidDeleteSelection` into it.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 01:50:00 +00:00
Mark Banner
ca74b508b7 Bug 1574915 - Fix some instances of using async functions as promise executors. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D42508

--HG--
extra : moz-landing-system : lando
2019-08-19 16:26:31 +00:00
Emilio Cobos Álvarez
bfcf9b881b Bug 1574544 - Remove now-unnecessary condition that makes the frame constructor get confused with editor anonymous nodes. r=mats
This condition was needed when FindInsertionPrevSibling and co didn't understand
display: contents.

Editor is pretty broken (and calls into PresShell::ContentRemoved directly, and
incorrectly, using anonymous nodes).

In this case we were taking the XBL path because of display: contents, which
means that we tried to seek to the editor anonymous node, and crash (since it's
not an explicit kid).

Editor needs to get fixed, but this is technically more correct and fixes the
crash, so we may as well take it in the interim.

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

--HG--
extra : moz-landing-system : lando
2019-08-19 12:16:28 +00:00
Emilio Cobos Álvarez
6779b66f01 Bug 1571530 - Remove various bool arguments in sheet loader APIs. r=heycam
They're bad, specially if they do vastly different thing in overloaded
functions, like aUseSystemPrincipal and aIsPreload. :)

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

--HG--
extra : moz-landing-system : lando
2019-08-16 10:56:05 +00:00
Emilio Cobos Álvarez
2353359865 Bug 1571530 - Make Loader APIs return a Result. r=heycam
On the fence on this one, but I do think it's nicer.

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

--HG--
extra : moz-landing-system : lando
2019-08-16 10:56:03 +00:00
Masayuki Nakano
0e763a968a Bug 1572681 - part 6: Move TextEditRules::mDidExplicitlySetInterline to HTMLEditRules r=m_kato
`TextEditRules::mDidExplicitlySetInterline` is set to true only by
`HTMLEditRules`, but `TextEditRules::DidDeleteSelection()` refers it.
So, it's enough to make `TextEditRules::DidDeleteSelection()` take the
value and we can move it into `HTMLEditRules`.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 08:53:45 +00:00
Masayuki Nakano
8870cb5d53 Bug 1572681 - part 5: Get rid of TextEditRules::mDeleteBidiImmediately r=m_kato
`TextEditRules::mDeleteBidiImmediately` is cache of
`bidi.edit.delete_immediately` pref value at creation time of `TextEditRules`.
However, this is referred when user removes selection.  So, there is no
reason to keep same behavior starting from editor creation.  In other words,
it must be better to take same behavior in all editor instances.

Therefore, we should remove it and the pref value should be referred directly
when user tries to remove selection.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 04:41:51 +00:00
Masayuki Nakano
7759842058 Bug 1572681 - part 4: Get rid of arguments of TextEditRules::BeforeEdit() and TextEditRules::AfterEdit() r=m_kato
`TextEditRules::BeforeEdit()`, `TextEditRules::AfterEdit()`,
`HTMLEditRules::BeforeEdit()` and `HTMLEditRules::AfterEdit()` are always
called with same values as the result of
`EditorBase::GetTopLevelEditSubAction()` and
`EditorBase::GetDirectionOfTopLevelEditSubAction()`.

For making what they do clearer, we should make them access with those
`EditorBase` members for now.  This makes those methods ugly due to increasing
number of long lines.  However, this issue should be solved when we move them
into `TextEditor` and `HTMLEditor`.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 04:41:18 +00:00
Masayuki Nakano
726b15369f Bug 1572681 - part 3: Change TextEditRules::mLockRulesSniffing to HTMLEditRules::mInitialized r=m_kato
`TextEditRules::mLockRulesSniffing` is set by `AutoLockRulesSniffing`.
It's created during `BeforeEdit()` and `AfterEdit()` are called, and
`HTMLEditRules::Init()` is initializing `mDocChangeRange`.

The purpose of it is, preventing `BeforeEdit()` and `AfterEdit()` to do
something in that time.  For the former cases, we don't need this member
anymore since they won't be nested.  Therefore, we need to manage
`HTMLEditRules::BeforeEdit()` and `HTMLEditRules::AfterEdit()` won't do
anything only while `HTMLEditRules::Init()` is called.  Therefore,
there should be only `HTMLEditRules::mInitialized` instead.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 04:26:52 +00:00
Masayuki Nakano
a866a356da Bug 1572681 - part 2: Get rid of TextEditRules::mTopLevelEditSubAction and TextEditRules::mActionNesting r=m_kato
`TextEditRules::BeforeEdit()`, `TextEditRules::AfterEdit()`,
`HTMLEditRules::BeforeEdit()` and `HTMLEditRules::AfterEdit()` manages
`TextEditRules::mActionNesting` for preventing that they won't do same thing
per top-level edit sub-action.  However, this has already been checked by
their caller, `AutoTopLevelEditSubActionNotifier`.  So, we can get rid of it.
Then, `TextEditRules::mTopLevelEditSubAction` is also always same as
`EditorBase::GetTopLevelEditSubAction()`.  Therefore, we can get rid of it
too.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 02:42:25 +00:00
Masayuki Nakano
13b14b9b2f Bug 1572681 - part 1: Move TextEditRules::mCachedSelection* to EditorBase::AutoEditActionDataSetter r=m_kato
Despite of their names, `TextEditRules::mCachedSelectionNode` and
`TextEditRules::mCachedSelectionOffset` are used only for calling
`EditorBase::HandleInlineSpellCheck()` so that they should be renamed to
explain the purpose.

Additionally, they are not necessary to be in the heap since they are
necessary until `TextEditRules::AfterEdit()` is called.  Therefore, we can
move them into `EditorBase::HandleInlineSpellCheck()`.

Finally, `TextEditRules::BeforeEdit()` and `TextEditRules::AfterEdit()` are
called only by `TextEditor::OnStartToHandleTopLevelEditSubAction()` and
`TextEditor::OnEndHandlingTopLevelEditSubAction()`.  Therefore, we can move
the setter to `TextEditor::OnStartToHandleTopLevelEditSubAction()`.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 01:24:01 +00:00