Commit Graph
299 Commits
Author SHA1 Message Date
Masayuki Nakano aab055ae21 Bug 1802668 - part 2: Make AutoInlineStyleSetter stop using <strong>, <em> and <strike> as alternative container of <b>, <i> and <strike> r=m_kato
The other browsers do not do this. From semantics point of view, stop reusing
them is better.

Depends on D163185

Differential Revision: https://phabricator.services.mozilla.com/D163186
2022-12-01 00:16:56 +00:00
Masayuki Nakano ea0a1148d0 Bug 1802418 - Make the style editor remove potentially conflicting vertical-align styles at applying <sup> or <sub> style r=m_kato
`execCommand("superscript")` and `execCommand("subscript")` are handled
specially.

`<sup>` and `<sub>` are exclusive. Therefore, existing element is removed first.

However, they are not mapped to CSS due to bug 394304 comment 2 even though the
behavior is different from the other browsers.  Therefore, Gecko does not remove
`vertical-align` styles from selected ranges. On the other hand, the other
browsers do it. This makes sense and matches with the handling in HTML mode.

Therefore, we should remove `vertical-align` style around the selection ranges.

Note that this updates existing WPTs.

The first block of each command checks how the command work with similar
`<span>` having `vertical-align` style. The new expectation matches with the
other browsers (i.e., currently they fail in the other browsers).

The second block of each command checks how the command work with similar
situation but there is a sibling which has the applying style (i.e., `<sup>`
or `<sub>`).  These tests keep failing in the other browsers since they want
to update `vertical-align` style at the selected range in the `<span>` having
`vertical-align` style.

Anyway, this fix is for avoiding new WPT failures of fixing bug 1792386, and
these commands must not be used so widely especially in the CSS mode.
Therefore, I believe that this change is not so risky.

Depends on D163183

Differential Revision: https://phabricator.services.mozilla.com/D163184
2022-11-29 05:48:53 +00:00
Masayuki Nakano fd8da25d31 Bug 1802402 - Group the inline style setter methods into stack only class r=m_kato
* `SetInlinePropertyOnTextNode`
* `SetInlinePropertyOnNode`
* `SetInlinePropertyOnNodeImpl`
* `ElementIsGoodContainerForTheStyle`

These `HTMLEditor` methods run only when `SetInlinePropertyOnTextNode` or
`SetInlinePropertyOnNode` is called, they take common style information as 3
arguments and they run in a short period.  Therefore, they can be in a stack
only class.

Differential Revision: https://phabricator.services.mozilla.com/D163183
2022-11-28 11:13:02 +00:00
Masayuki Nakano 88aa660625 Bug 1801028 - part 18: Make CSSEditUtils::GenerateCSSDeclarationsFromHTMLStyle take EditorElementStyle r=m_kato
And also making it and `BuildCSSDeclarations` return pairs of CSS property and
value with an array makes their callers simpler.

Depends on D162517

Differential Revision: https://phabricator.services.mozilla.com/D162518
2022-11-25 12:57:26 +00:00
Masayuki Nakano a9570014cf Bug 1801028 - part 17: Make CSSEditUtils::IsCSSEditableProperty take EditorElementStyle r=m_kato
It can take `const Element&` instead of `nsINode*`, then most callers can be
simpler.

Depends on D162516

Differential Revision: https://phabricator.services.mozilla.com/D162517
2022-11-25 09:29:07 +00:00
Masayuki Nakano 660a55f386 Bug 1801028 - part 15: Make HTMLEditor::RemoveCSSEquivalentToHTMLStyle(With|Without)Transaction take EditorElementStyle r=m_kato
Depends on D162514

Differential Revision: https://phabricator.services.mozilla.com/D162515
2022-11-25 09:14:38 +00:00
Masayuki Nakano 91d4c3ff9b Bug 1801028 - part 14: Make CSSEditUtils::SetCSSEquivalentToHTMLStyle(With|Without)Transaction take EditorElementStyle r=m_kato
This patch creates a base class of `EditorInlineStyle`, the name is
`EditorElementStyle`.  It requires only attribute of HTML.  However, it's
obviously different from `EditorInlineStyle`'s rule which is `mHTMLProperty`
cannot be `nullptr`.  Therefore, the methods which can treat only
`EditorInlineStyle` do not want the data only whose attribute is not `nullptr`.
For solving this issue at build time, this approach is better than renaming
`EditorInlineStyle` and make it have the new mode.

Depends on D162513

Differential Revision: https://phabricator.services.mozilla.com/D162514
2022-11-25 09:04:35 +00:00
Masayuki Nakano cd1ecc6e69 Bug 1801028 - part 13: Make HTMLEditUtils::IsInlineStyleSetByElement take EditorInlineStyle r=m_kato
Depends on D162512

Differential Revision: https://phabricator.services.mozilla.com/D162513
2022-11-25 07:14:16 +00:00
Masayuki Nakano 80dd5a8116 Bug 1801028 - part 12: Make CSSEditUtils::Have(Specified|Computed)CSSEquivalentStyles take EditorInlineStyle r=m_kato
Depends on D162511

Differential Revision: https://phabricator.services.mozilla.com/D162512
2022-11-25 06:55:31 +00:00
Masayuki Nakano ff0dced7c9 Bug 1801028 - part 11: Make CSSEditUtils::Is(Computed|Specified)CSSEquivalentToHTMLInlineStyleSet take EditorInlineStyle r=m_kato
Depends on D162510

Differential Revision: https://phabricator.services.mozilla.com/D162511
2022-11-25 06:43:51 +00:00
Masayuki Nakano 7fd9c5ea2a Bug 1801028 - part 10: Make HTMLEditor::RemoveStyleInside take EditorInlineStyle r=m_kato
Depends on D162509

Differential Revision: https://phabricator.services.mozilla.com/D162510
2022-11-25 06:26:04 +00:00
Masayuki Nakano 28026f23ec Bug 1801028 - part 9: Make HTMLEditor::ElementIsGoodContainerForTheStyle take EditorInlineStyleAndValue r=m_kato
Depends on D162508

Differential Revision: https://phabricator.services.mozilla.com/D162509
2022-11-25 06:01:03 +00:00
Masayuki Nakano 2c93609e80 Bug 1801028 - part 8: Make HTMLEditor::SetInlinePropertyOnNode and HTMLEditor::SetInlinePropertyOnNodeImpl take EditorInlineStyleAndValue r=m_kato
They are called each other. Therefore, this patch changes them once.

Depends on D162507

Differential Revision: https://phabricator.services.mozilla.com/D162508
2022-11-25 05:20:49 +00:00
Masayuki Nakano ab6e29169b Bug 1801028 - part 7: Make HTMLEditor::SetInlinePropertyOnTextNode take EditorInlineStyleAndValue r=m_kato
Depends on D162506

Differential Revision: https://phabricator.services.mozilla.com/D162507
2022-11-25 04:52:25 +00:00
Masayuki Nakano a04806dcfe Bug 1801028 - part 6: Make HTMLEditor::SplitAncestorStyledInlineElementsAt take EditorInlineStyle r=m_kato
Depends on D162505

Differential Revision: https://phabricator.services.mozilla.com/D162506
2022-11-25 04:17:46 +00:00
Masayuki Nakano bf8361d3fe Bug 1801028 - part 5: Make HTMLEditor::SplitAncestorStyledInlineElementsAtRangeEdges take EditorInlineStyle r=m_kato
Depends on D162504

Differential Revision: https://phabricator.services.mozilla.com/D162505
2022-11-25 02:38:56 +00:00
Masayuki Nakano a52e6adf9a Bug 1801028 - part 4: Make HTMLEditor::ClearStyleAt take EditorInlineStyle r=m_kato
Depends on D162503

Differential Revision: https://phabricator.services.mozilla.com/D162504
2022-11-25 02:15:51 +00:00
Masayuki Nakano a8f6e15d50 Bug 1801028 - part 3: Make HTMLEditor::GetInlinePropertyBase take EditorInlineStyle r=m_kato
Depends on D162502

Differential Revision: https://phabricator.services.mozilla.com/D162503
2022-11-25 00:54:55 +00:00
Masayuki Nakano 175fe247b2 Bug 1801028 - part 2: Move CSSEditUtils::IsCSSInvertible to EditorInlineStyle r=m_kato
It does not make sense to make the static method take only `EditorInlineStyle`.

Depends on D162501

Differential Revision: https://phabricator.services.mozilla.com/D162502
2022-11-25 00:22:32 +00:00
Masayuki Nakano e468aa0600 Bug 1801028 - part 1: Make HTMLEditor::IsRemovableParentStyleWithNewSpanElement take EditorInlineStyle r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D162501
2022-11-25 00:12:58 +00:00
Masayuki Nakano 29d339af74 Bug 1793694 - part 2: Move some protected inline method definitions of HTMLEditor to non-exposed header r=m_kato
Depends on D158631

Differential Revision: https://phabricator.services.mozilla.com/D158632
2022-10-12 02:44:18 +00:00
Masayuki Nakano 6a157a88b2 Bug 1793694 - part 1: Move some static inline methods of HTMLEditor to HTMLEditUtils r=m_kato
Depends on D158483

Differential Revision: https://phabricator.services.mozilla.com/D158631
2022-10-12 02:44:17 +00:00
Masayuki Nakano af5b2b3933 Bug 1792642 - Make SplitNodeResult treated as ok type of Result r=m_kato
Depends on D158333

Differential Revision: https://phabricator.services.mozilla.com/D158334
2022-10-04 07:28:10 +00:00
Masayuki Nakano f95e379091 Bug 1792641 - Make JoinNodesResult treated as ok type of Result r=m_kato
Depends on D158332

Differential Revision: https://phabricator.services.mozilla.com/D158333
2022-10-03 23:17:02 +00:00
Masayuki Nakano 12cb1be55f Bug 1792639 - Make SplitRangeOffFromNodeResult treated as ok type of Result r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158332
2022-10-03 07:52:45 +00:00
Masayuki Nakano b7ee3d1410 Bug 1792624 - Make SplitRangeOffResult treated as ok type of Result r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158243
2022-10-03 01:19:59 +00:00
Masayuki Nakano 767307c38d Bug 1791501 - Use EditActionResult as ok type of mozilla::Result r=m_kato
Any callers do not refer "ignored", "handled" and "cancel" state without
checking whether the method returns error or not.  Therefore, error state
can be (and should be) managed by `mozilla::Result`'s error state.

Perhaps, it should store a caret position later because deletion handlers
of `HTMLEditor` use it, but update `Selection` immediately.

Differential Revision: https://phabricator.services.mozilla.com/D158080
2022-09-28 07:21:37 +00:00
Masayuki Nakano 21ac65a3c0 Bug 1791224 - Use CreateNodeResultBase as the ok type of mozilla::Result r=m_kato
Similar to the previous patch, this changes a lot of lines.  However, I think
that it's not so hard to investigate regression point in this patch because
`CreateNodeResultBase` is not used so many times at handling on edit action.

Differential Revision: https://phabricator.services.mozilla.com/D157575
2022-09-28 04:00:19 +00:00
Butkovits Atila b4aaa49444 Backed out changeset 865c5d292958 (bug 1791224) for causing build bustages at Result.h. CLOSED TREE 2022-09-27 11:55:04 +03:00
Masayuki Nakano 099575b4bf Bug 1791224 - Use CreateNodeResultBase as the ok type of mozilla::Result r=m_kato
Similar to the previous patch, this changes a lot of lines.  However, I think
that it's not so hard to investigate regression point in this patch because
`CreateNodeResultBase` is not used so many times at handling on edit action.

Differential Revision: https://phabricator.services.mozilla.com/D157575
2022-09-27 05:12:05 +00:00
Masayuki Nakano f1a20cf34a Bug 1791223 - Use MoveNodeResult as the ok type of mozilla::Result r=m_kato
Unfortunately, it's hard to split this (and similar) patch because we need to
touch `MoveNodeResult` itself for making it available as the ok type of
`Result`.  However, I guess that it's not so hard to investigate regression
point if something would be found later because `MoveNodeResult` is mainly
used by deletion which is the most complicated part of `HTMLEditor`, but
`MoveNodeResult` is used only in a few cases.

Differential Revision: https://phabricator.services.mozilla.com/D157574
2022-09-26 00:56:46 +00:00
Masayuki Nakano ad7a74b296 Bug 1782911 - part 9: Make WhiteSpaceVisibilityKeeper::MergeFirstLineOfRightBlockElementIntoAncestorLeftBlockElement stop creating empty nodes r=m_kato
It splits inline elements at the destination of first line in the right block.
However, it typically creates empty inline elements before the right block and
may be never used because it sets the insertion point to before the right node
of the splitting.

Therefore, it should stop creates empty inline elements (if they are required,
they should be created in `HTMLEditor::MoveNodeOrChildrenWithTransaction`
instead) and adjust split point after the element if it didn't split any nodes.

Differential Revision: https://phabricator.services.mozilla.com/D157418
2022-09-25 12:49:46 +00:00
Magnus Melin 56eb9483d1 Bug 1790725 - Allow useCss for mail editor. r=masayuki
After this change, it's possible to set the pref, or use editor.document.execCommand("styleWithCSS", false, "true") to enable css in mail compose.

Differential Revision: https://phabricator.services.mozilla.com/D157276
2022-09-14 10:27:39 +00:00
Makoto Kato 93b5820110 Bug 1787680 - Part 2. Don't create CSSEditUtils instance. r=masayuki
We can change all methods in `CSSEditUtils` to static method if we add
`HTMLEditor` parameter.

Differential Revision: https://phabricator.services.mozilla.com/D155976
2022-09-01 04:33:36 +00:00
Masayuki Nakano 4b66b7255f Bug 1784192 - part 10: Make PendingStyles::GetTypeInState() return an enum class instead of taking 2 bool out parameters r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D155319
2022-08-26 03:31:26 +00:00
Masayuki Nakano a31e91fc29 Bug 1784192 - part 9: Rename TypeInState to PendingStyles r=m_kato
Additionally,
* `PropItem` -> `PendingStyle`
* `StyleCache` -> `PendingStyleCache`
* `AutoStyleCacheArray` -> `AutoPendingStyleCacheArray`

And finally, `PendingStyle` (formally `PropItem`) is changed to `class` and
its members are encapsuled.

Differential Revision: https://phabricator.services.mozilla.com/D155318
2022-08-26 03:31:26 +00:00
Masayuki Nakano e4d1127db6 Bug 1784192 - part 7: Rename TypeInState::ClearProp and related methods r=m_kato
For consistency with the previous patch, we should rename them too.  Then, we're
getting rid of unclear word "Prop" from the public methods.

Differential Revision: https://phabricator.services.mozilla.com/D155316
2022-08-26 03:25:19 +00:00
Masayuki Nakano 00ff420891 Bug 1784192 - part 6: Rename TypeInState::SetProp and TypeInState::TakeSetProperty r=m_kato
I usually retry to understand what they mean.  Therefore, I'd like to give new
names for them (and rename `TypeInState` class in a following patch).

Differential Revision: https://phabricator.services.mozilla.com/D155315
2022-08-26 03:20:14 +00:00
Masayuki Nakano ab78a6de30 Bug 1784192 - part 1: Change PropItem::tag to nsStaticAtom* r=m_kato
It's always a pointer to `nsStaticAtom` instance or `nullptr`.  Therefore,
it can be `nsStaticAtom*` and we can make its users treat `nsStaticAtom`
instead of `nsAtom`.

Additionally, this patch changes some pointer parameters to references if
they are never `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D155310
2022-08-26 03:10:30 +00:00
Masayuki Nakano e4df4c43e2 Bug 1781994 - part 11: Clean up HTMLEditor::RelativeFontChange r=m_kato
It should use `AutoRangeArray` to stop using `AutoSelectionRestorer`.

Depends on D154352

Differential Revision: https://phabricator.services.mozilla.com/D154353
2022-08-16 01:17:45 +00:00
Masayuki Nakano 259bd9426d Bug 1781994 - part 10: Make HTMLEditor::RelativeFontChangeOnNode and HTMLEditor::RelativeFontChangeHelper stop touching Selection directly r=m_kato
They are renamed to `SetFontSizeWithBigOrSmallElement` and
`SetFontSizeOfFontElementChildren`.

Depends on D154351

Differential Revision: https://phabricator.services.mozilla.com/D154352
2022-08-16 01:09:31 +00:00
Masayuki Nakano 43343bb803 Bug 1781994 - part 9: Make HTMLEditor::RelativeFontChangeOnNode and HTMLEditor::RelativeFontChangeHelper use FontSize r=m_kato
`HTMLEditor::RelativeFontChange()` and its helpers are based on
`SetInlinePropertiesAsSubAction()` and its helpers.  Therefore, they may have
similar problem to switch join/split direction.  Therefore, this and the
following patches clean them up too.

Depends on D154350

Differential Revision: https://phabricator.services.mozilla.com/D154351
2022-08-16 01:01:06 +00:00
Masayuki Nakano 4c09fdbb5c Bug 1781994 - part 8: Make HTMLEditor::SetInlinePropertyAsSubAction handle multiple styles once r=m_kato
Depends on D154349

Differential Revision: https://phabricator.services.mozilla.com/D154350
2022-08-16 01:01:05 +00:00
Masayuki Nakano a0ac0a7ca4 Bug 1781994 - part 7: Make HTMLEditor::RemoveInlinePropertyAsSubAction handle multiple styles once r=m_kato
I think that `HTMLEditor::SetInlinePropertyAsSubAction` and
`HTMLEditor::RemoveInlinePropertyAsSubAction` should not be called multiple
times in one edit action.  Therefore, I'd like to make them take multiple
styles once.  Then, we could collect all targets before touching the DOM tree
in the future.

Depends on D154348

Differential Revision: https://phabricator.services.mozilla.com/D154349
2022-08-16 00:55:06 +00:00
Masayuki Nakano 54a054333a Bug 1781994 - part 6: Make HTMLEditor::SetInlinePropertyInternal use AutoRangeArray r=m_kato
Depends on D154347

Differential Revision: https://phabricator.services.mozilla.com/D154348
2022-08-16 00:38:30 +00:00
Masayuki Nakano 4c29eb8cdc Bug 1781994 - part 5: Make HTMLEditor::RemoveInlinePropertyAsSubAction handle correct text node after splitting a text to any direction r=m_kato
This is a pre-fix for bug 1735608.  Currently, the loop assumes that collected
nodes are always right node, but it'll be changed, therefore, it creates
new array for the follow up loops handle expected nodes.

Depends on D154346

Differential Revision: https://phabricator.services.mozilla.com/D154347
2022-08-16 00:31:45 +00:00
Masayuki Nakano 35739345a7 Bug 1781994 - part 4: Make HTMLEditor::RemoveInlinePropertyInternal use AutoRangeArray r=m_kato
I'd like to get rid of `AutoSelectionRangeArray` and `AutoRestoreSelection`,
and I'd like to make it stop touching `Selection` while it is removing style
of each content nodes in the range.  Therefore, this patch rewrites it with
`AutoRangeArray`.  Then, we can reduce the indent level of the nested `for`
loops.

Note that it creates `AutoEditSubActionNotifier`, so it's a sub-edit action
handler.  Therefore, this patch renames it.

Depends on D154345

Differential Revision: https://phabricator.services.mozilla.com/D154346
2022-08-16 00:26:05 +00:00
Masayuki Nakano 7c4721729d Bug 1781994 - part 3: Make HTMLEditor::SetInlinePropertyOnTextNode stop touching Selection directly r=m_kato
Depends on D154344

Differential Revision: https://phabricator.services.mozilla.com/D154345
2022-08-16 00:13:40 +00:00
Masayuki Nakano 2f63891f53 Bug 1781994 - part 2: Make HTMLEditor::SplitAncestorStyledInlineElementsAtRangeEdges stop touching Selection directly r=m_kato
Depends on D154343

Differential Revision: https://phabricator.services.mozilla.com/D154344
2022-08-16 00:08:07 +00:00
Masayuki Nakano 6a7b048277 Bug 1781994 - part 1: Make HTMLEditor::SplitAncestorStyledInlineElementsAt and HTMLEditor::ClearStyleAt stop touching Selection directly r=m_kato
I've already made a caller of `HTMLEditor::ClearStyleAt`,
`HTMLEditor::CreateStyleForInsertText`, in bug 1770877, so this fixes a bug of
the patch.

`HTMLEditor::ClearStyleAt` is still updates `Selection` only in some cases.
And one of the caller has not handle the `Selection` update.  Therefore, once
it completely stop touching `Selection`, `ComputeEditingHost` will fail and
the other paths update `Selection`, so it should do it too.  (Without the
change, `test_dragdrop.html` fails.)

Finally, we don't need `EditResult` anymore because we have
`Result<EditorDOMPoint, nsresult>`.

Differential Revision: https://phabricator.services.mozilla.com/D154343
2022-08-16 00:02:25 +00:00