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

9457 Коммитов

Автор SHA1 Сообщение Дата
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