Commit Graph

291 Commits

Author SHA1 Message Date
Masayuki Nakano
4d856eb67e Bug 1598327 - part 2: Make TopLevelEditSubActionData::mCachedInlineStyle create only in HTMLEditor r=m_kato
The initialization cost of `AutoStyleCacheArray` is still expensive and it's
used only by `HTMLEditor`.  Therefore, we should make it `Maybe` and construct
it only when the editor is an `HTMLEditor`.

Depends on D54253

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

--HG--
extra : moz-landing-system : lando
2019-11-23 01:12:33 +00:00
Cosmin Sabou
f2a93e6f4d Backed out 2 changesets (bug 1598327) for browser chrome failures on browser_bug399606.js
Backed out changeset c2996e694ada (bug 1598327)
Backed out changeset fd1c9515bd8b (bug 1598327)
2019-11-23 02:52:20 +02:00
Masayuki Nakano
f846ab4ab6 Bug 1598327 - part 2: Make TopLevelEditSubActionData::mCachedInlineStyle create only in HTMLEditor r=m_kato
The initialization cost of `AutoStyleCacheArray` is still expensive and it's
used only by `HTMLEditor`.  Therefore, we should make it `Maybe` and construct
it only when the editor is an `HTMLEditor`.

Depends on D54253

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

--HG--
extra : moz-landing-system : lando
2019-11-22 15:02:57 +00:00
Mirko Brodesser
1ae8f1b996 Bug 1591417: part 4) Adapt InsertTextIntoTextNodeWithTransaction to pass adjusted range to TopLevelEditSubActionDataRef.DidInsertText. r=masayuki
Otherwise, an invalid `EditorRawDOMPoint` was constructed by a test.

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

--HG--
extra : moz-landing-system : lando
2019-11-13 09:16:06 +00:00
Mirko Brodesser
c4342625ea Bug 1591417: part 2) Rename HasMutationEventListeners to MaybeHasMutationEventListeners. r=masayuki
After removing all mutation event listeners, the corresponding method
still returns `true`, so the new name is more accurate.

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

--HG--
extra : moz-landing-system : lando
2019-11-12 15:20:20 +00:00
Masayuki Nakano
a1a0330433 Bug 1593920 - Clean up HTMLEditor::TabInTable() with taking WidgetKeyboardEvent* and returning EditActionResult r=m_kato
With making it take `WidgetKeyboardEvent*`, it won't need to return "handled"
state.  However, when we implement `beforeinput` event, it needs to return
"canceled" state.  Therefore, it should return `EditActionResult`.

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

--HG--
extra : moz-landing-system : lando
2019-11-07 02:59:51 +00:00
Masayuki Nakano
6789366d5e Bug 1540029 - part 10: Get rid of TextEditRules and HTMLEditRules r=m_kato
Now, we can get rid of `TextEditRules` and `HTMLEditRules` completely.
And also this patch renames their cpp files to `TextEditSubActionHandler`
and `HTMLEditSubActionHandler`.

`TextEditor::Init()` and `HTMLEditor::Init()` are still complicated due to
`AutoEditInitRulesTrigger`.  The following patch will remove it.

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

--HG--
rename : editor/libeditor/HTMLEditRules.cpp => editor/libeditor/HTMLEditSubActionHandler.cpp
rename : editor/libeditor/TextEditRules.cpp => editor/libeditor/TextEditSubActionHandler.cpp
extra : moz-landing-system : lando
2019-09-18 08:40:08 +00:00
Masayuki Nakano
8b7e7ba3d1 Bug 1540029 - part 8: Replace HTMLEditRules::GetParagraphState() with new stack only class r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45790

--HG--
extra : moz-landing-system : lando
2019-09-18 08:20:29 +00:00
Masayuki Nakano
ed4c1cd65a Bug 1540029 - part 7: Replace HTMLEditRules::GetAlignment() with new stack only class r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45789

--HG--
extra : moz-landing-system : lando
2019-09-18 06:26:56 +00:00
Masayuki Nakano
6ff81fdbe4 Bug 1540029 - part 6: Replace HTMLEditRules::GetListItemState() with new stack only class r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45788

--HG--
extra : moz-landing-system : lando
2019-09-18 04:42:55 +00:00
Masayuki Nakano
320d1209c9 Bug 1540029 - part 5: Replace HTMLEditRules::GetListState() with new stack class r=m_kato
It takes a lot of `bool` out arguments.  Therefore, we should make it a
stack only class and caller should retrieve only necessary information.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 03:39:00 +00:00
Masayuki Nakano
b3115e6972 Bug 1540029 - part 4: Merge BeforeEdit() and OnStartToHandleTopLevelEditSubAction(), and AfterEdit() and OnEndHandlingTopLevelEditSubAction() r=m_kato
And also this patch make each `AutoEditSubActionNotifier` creator check
the result of `OnStartToHandleTopLevelEditSubAction()` at least for
`NS_ERROR_EDITOR_DESTROYED`.

We need to take care of its destructor's result later, though.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 03:01:28 +00:00
Masayuki Nakano
db32271cec Bug 1540029 - part 2: Get rid of TextEditRules::DocumentIsEmpty() and HTMLEditRules::DocumentIsEmpty() r=m_kato
`TextEditRules::DocumentIsEmpty()` is a wrapper of `TextEditor::IsEmpty()` so
that we can get rid of it simply.

`HTMLEditRules::DocumentIsEmpty()` needs to change.  It's oddly checks only
`EditorBase::mPaddingBRElementForEmptyEditor` is `nullptr` or not.  However,
the editor may be completely empty.  And the result may be different from
`TextEditor::IsEmpty()` which is not overridden by `HTMLEditor`.  For partially
solving this issue, this patch makes `HTMLEditor` overrides `IsEmpty()` and
optimizes `TextEditor::IsEmpty()`.

With this change, the caller of `HTMLEditRules::DocumentIsEmpty()` may behave
differently in the only caller, `HTMLEditor::SelectEntireDocument()`.  And
unfortunately, its root called from `SelectAllCommand::DoCommand()`.  However,
it does just collapse `Selection` into the root element (`<body>` or
`Document.documentElement`) if it returns `true`.  Therefore, this change
must be safe since anyway `SelectionRefPtr()->SelectAllChildren()` with
the root element is exactly same as `SelectionRefPtr()->Collapse()` with
the empty root element if it's truly empty.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 06:58:06 +00:00
Masayuki Nakano
9ee5b3bbef Bug 1540029 - part 1: Move old edit action listener methods of HTMLEditRules to EditorBase::TopLevelEditSubActionData r=m_kato
The main purpose of them is modifying
`TopLevelEditSubActionData::mChangedRange`.  Therefore, they should be in the
struct.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 04:27:59 +00:00
Masayuki Nakano
0da92b7d7d 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-17 02:21:35 +00:00
Gurzau Raul
ba23dcf114 Backed out 2 changesets (bug 1574852) for assertion failures at TextEditRules.cpp
Backed out changeset f54f6af6359d (bug 1574852)
Backed out changeset 2b6968592570 (bug 1574852)
2019-09-15 02:32:09 +03: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
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
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
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
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
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
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
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
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
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
Mirko Brodesser
81a41b2d7d Bug 1573119: declare more methods around HTMLEditor const/static. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D41524

--HG--
extra : moz-landing-system : lando
2019-08-13 07:34:11 +00:00
Masayuki Nakano
ede2ddb459 Bug 1572375 - part 8: Wrap EditorBase::mPaddingBRElementForEmptyEditor with an inline method r=m_kato
`TextEditRules` and `HTMLEditRules` still refer
`EditorBase::mPaddingBRElementForEmptyEditor` directly but this is really ugly.
Therefore, this patch creates `EditorBase::HasPaddingBRElementForEmptyEditor()`
for wrapping its access.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 00:57:38 +00:00
Masayuki Nakano
c1906f614d Bug 1572375 - part 5: Move TextEditRules::CreatePaddingBRElementForEmptyEditorIfNeeded() into EditorBase r=m_kato
`TextEditRules::CreatePaddingBRElementForEmptyEditorIfNeeded()` is used by
both `TextEditor` and `HTMLEditor` so that this moves it into `EditorBase`.

Additionally, making `TextEditor::MaybeChangePaddingBRElementForEmptyEditor()`
call it if there is no content.  Then, we can avoid the dependency of them.

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

--HG--
extra : moz-landing-system : lando
2019-08-09 10:19:11 +00:00
Masayuki Nakano
b0606032ba Bug 1572375 - part 2: Split TextEditRules::WillInsert() r=m_kato
`TextEditRules::WillInsert()` is not used with initial purpose since
`HTMLEditor` always works with `HTMLEditRules` and its `WillDoAction()`
always handles `EditSubAction::eInsertElement`.

Additionally, its name is too generic since it does non-related 3 things.

One is checking whether the editor is readonly or disabled.  However, this
may not be necessary since its callers may have already checked it or
just ignored the result.  So, this should be check by each caller.

Next one is masking password if auto-masking is enabled.  This is `TextEditor`
specific feature so that this patch moves the code into
`TextEditor::MaybeDoAutoPasswordMasking()`.

Final one is removing empty `<br>` element for empty editor if there is.
This is common feature so that this patch moves this code into
`EditorBase::EnsureNoPaddingBRElementForEmptyEditor()`.

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

--HG--
extra : moz-landing-system : lando
2019-08-09 08:25:37 +00:00
Masayuki Nakano
b25f8b0e06 Bug 1572375 - part 1: Move TextEditRules::mPaddingBRElementForEmptyEditor to EditorBase r=m_kato
`TextEditRules::mPaddingBRElementForEmptyEditor` are used by both `TextEditor`
and `HTMLEditor`.  Therefore, it should be in `EditorBase`.

This patch makes `TextEditRules` and `HTMLEditRules` directly access the
private member of `EditorBase` temporarily.  It'll be fixed by the following
patches.

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

--HG--
extra : moz-landing-system : lando
2019-08-09 07:03:29 +00:00
Mirko Brodesser
d0e7afc285 Bug 1572715: part 1) Factor out WSRunScanner from WSRunObject. r=masayuki
This allows users of `WSRunScanner`'s functionality to pass a `const
HTMLEditor*`, allowing themselves to become const-correct.

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

--HG--
extra : moz-landing-system : lando
2019-08-12 08:30:57 +00:00
Mirko Brodesser
1274c8140e Bug 1572060: declare a few methods around HTMLEditor static/const. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D40982

--HG--
extra : moz-landing-system : lando
2019-08-07 15:58:41 +00:00
Masayuki Nakano
11ae238f0f Bug 1569902 - part 4: Make TextEditor inserts padding <br> element for empty last line after setting flags to NS_PADDING_FOR_EMPTY_LAST_LINE r=m_kato
Stopping using attribute for "moz-br", `IMEContentObserver` cannot know when
new `<br>` element is changed to padding element for empty last line.
Therefore, editor needs to insert padding `<br>` element after setting the
flag properly.  Then, `IMEContentObserver` does not need to recompute the
length of `<br>` element (if it's for padding, it computes the length as 0).

Unfortunately, `TextEditor::InsertBrElementWithTransaction()` is used in too
many places and it already has optional argument.  Therefore, it's difficult
to change it.  However, we should share the preparation before creating `<br>`
element in it with new method.  Therefore, this patch creates
`EditorBase::PrepareToInsertBRElement()` to share the preparation point (almost
just moved from the method).  Then, new method is created as
`EditorBase::InsertPaddingBRElementForEmptyLastLineWithTransaction()` because
it's used both in `TextEditor` and `HTMLEditor`.  Finally, `TextEditor` won't
insert `<br>` element with `InsertBrElementWithTransaction()`.  Therefore, it's
moved to `HTMLEditor` with renaming to `InsertBRElementWithTransaction()`.

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

--HG--
extra : moz-landing-system : lando
2019-08-02 05:46:41 +00:00
Masayuki Nakano
23a22c597a Bug 1569902 - part 2: Stop using attribute to consider whether a <br> element is a special node for empty last line or not r=m_kato,smaug
Editor creates a `<br>` element to end of a block if last line
of the block is empty because caret should be placed as there is an empty
line.  Such special `<br>` element has `type` attribute whose value is "_moz".
However, adding/removing the attribute is expensive and such hacky attribute
shouldn't be referred nor changed by web apps.

Therefore, this patch makes `HTMLBRElement` take another specific flag whether
it's a special node for empty last line.  For making the meaning clearer,
this patch calls the such `<br>` elements as "padding `<br>` element for
empty last line" insead of "moz-br".  So, this patch also includes a lot of
renaming methods and variables, and modifying related comments.

Note that with this change, `IMEContentObserver` counts the padding `<br>`
element in `<textarea>` because it's inserted before setting the new flag
and setting the flag does not cause DOM tree mutation.  This issue will be
fixed by the following patches.

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

--HG--
extra : moz-landing-system : lando
2019-08-02 05:45:18 +00:00
Masayuki Nakano
765e91b497 Bug 1569902 - part 1: Stop using attribute to consider whether a <br> element is an editor bogus node or not r=m_kato,smaug
Editor creates a `<br>` element when it's root element is empty.
Then, it's stored by `TextEditRules::mBogusNode` and used for checking
whether the editor is empty quickly.  However, this `<br>` element has
`mozeditorbogusnode` attribute whose value is `true`.  However, adding or
removing the attribute is not cheap and web apps can refer such illegal
attribute.

Therefore, this patch makes `HTMLBRElement` take a specific flag whether
it's a bogus node or not.  However, this means that this hacky thing will be
exposed outside editor module.  For making what is the bogus node clearer,
this patch calls the such `<br>` elements as "padding `<br>` element for
empty editor".  So, this patch also includes a lot of renaming methods and
variables, and modifying related comments.

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

--HG--
extra : moz-landing-system : lando
2019-08-02 05:44:40 +00:00
Masayuki Nakano
3102de8053 Bug 1548389 - part 3: Make editor mark text node in password field as "maybe masked" r=smaug
With the previous patches, editor has stopped masking characters in password
field.  Instead, layout code needs to handle it.  However, layout code
especially around `nsTextFrame` is performance critical area.  Therefore,
layout code requires a quick way to check whether a text node in password
field or not.

This patch creates new flag for `CharacterData` node and marks all text nodes
whose characters should be masked with the flag when `EditorBase` or
`nsTextControlFrame` creates them.

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

--HG--
extra : moz-landing-system : lando
2019-07-22 03:54:16 +00:00