Commit Graph

10152 Commits

Author SHA1 Message Date
Masayuki Nakano
92735646e3 Bug 1655706 - part 3-1: Move the last block of HTMLEditor::TryToJoinBlocksWithTransaction() into WhiteSpaceVisibilityKeeper r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85533
2020-08-03 08:25:31 +00:00
Masayuki Nakano
9ae8cf6836 Bug 1655706 - part 2-2: Move 2nd block of HTMLEditor::TryToJoinBlocksWithTransaction() into WhiteSpaceVisibilityKeeper r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85532
2020-08-03 08:24:14 +00:00
Masayuki Nakano
597a2135a9 Bug 1655706 - part 2-1: Make HTMLEditor::TryToJoinBlocksWithTransaction() stop using leftListElement and rightListElement after initializing newListElementTagNameOfRightListElement r=m_kato
`rightListElement` is not used, so, we can put it into smaller scope.

`leftListElement` is used for storing original `leftBlockElement` when
`newListElementTagNameOfRightListElement` is some.  Therefore, we can
stop using it with caching the original `leftBlockElement` before
maybe modified its value.

Differential Revision: https://phabricator.services.mozilla.com/D85531
2020-08-03 08:23:56 +00:00
Masayuki Nakano
3bc58929de Bug 1655706 - part 1-3: Get rid of WhiteSpaceVisibilityKeeper::PrepareToJoinNodes() r=m_kato
Now, the new method,
`WhiteSpaceVisibilityKeeper::MergeFirstLineOfRightBlockElementIntoLeftBlockElement()`
is the only user of the method so that we can get rid of it since it does enough
simple thing.

Differential Revision: https://phabricator.services.mozilla.com/D85530
2020-08-03 08:23:44 +00:00
Masayuki Nakano
c2315414ea Bug 1655706 - part 1-2: Move last part of HTMLEditor::TryToJoinBlocksWithTransaction() to WhiteSpaceVisibilityKeeper r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85529
2020-08-03 08:23:31 +00:00
Masayuki Nakano
f6bf4c09ab Bug 1655706 - part 1-1: Move HTMLEditor::GetInvisibleBRElementAt() to WSRunScanner r=m_kato
And the name is wrong.  It depends on `aPoint` whether the `<br>` element is
visible or invisible because it just scans preceding `<br>` element but
stop doing it when it meets a visible content.  Therefore, this patch renames
it to explain what it does.

Differential Revision: https://phabricator.services.mozilla.com/D85528
2020-08-03 08:23:13 +00:00
Sylvestre Ledru
843f943758 Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D85678
2020-08-02 15:29:15 +00:00
Andreas Farre
b13577d8e4 Bug 1613431 - Part 3: Handle synced setters return value. r=nika
Depends on D83646

Differential Revision: https://phabricator.services.mozilla.com/D83647
2020-07-31 13:37:13 +00:00
Nathan Froyd
e3ebda1914 Bug 1223932 - delete guard object uses from the tree; r=jwalden
CLOSED TREE

We don't need these macros anymore, for two reasons:

1. We have static analysis to provide the same sort of checks via `MOZ_RAII`
   and friends.
2. clang now warns for the "temporary that should have been a declaration" case.

The extra requirements on class construction also show up during debug tests
as performance problems.

This change was automated by using the following sed script:

```
# Remove declarations in classes.
/MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER/d
/MOZ_GUARD_OBJECT_NOTIFIER_INIT/d

# Remove individual macros, carefully.
{
  # We don't have to worry about substrings here because the closing
  # parenthesis "anchors" the match.
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)/)/g;

  # Remove the longer identifier first.
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT//g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM//g;
}

# Remove the actual include.
\@# *include "mozilla/GuardObjects.h"@d
```

and running:

```
find . -name \*.cpp -o -name \*.h | grep -v 'GuardObjects.h' |xargs sed -i -f script 2>/dev/null
mach clang-format
```

Differential Revision: https://phabricator.services.mozilla.com/D85168
2020-07-30 14:22:38 +00:00
Mihai Alexandru Michis
a911a108d0 Backed out changeset ac9c811bc427 (bug 1223932) for causing spidermonkey rust failures.
CLOSED TREE
2020-07-30 18:23:21 +03:00
Nathan Froyd
bec9f9b93a Bug 1223932 - delete guard object uses from the tree; r=jwalden
We don't need these macros anymore, for two reasons:

1. We have static analysis to provide the same sort of checks via `MOZ_RAII`
   and friends.
2. clang now warns for the "temporary that should have been a declaration" case.

The extra requirements on class construction also show up during debug tests
as performance problems.

This change was automated by using the following sed script:

```
# Remove declarations in classes.
/MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER/d
/MOZ_GUARD_OBJECT_NOTIFIER_INIT/d

# Remove individual macros, carefully.
{
  # We don't have to worry about substrings here because the closing
  # parenthesis "anchors" the match.
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)/)/g;

  # Remove the longer identifier first.
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT//g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM//g;
}

# Remove the actual include.
\@# *include "mozilla/GuardObjects.h"@d
```

and running:

```
find . -name \*.cpp -o -name \*.h | grep -v 'GuardObjects.h' |xargs sed -i -f script 2>/dev/null
mach clang-format
```

Differential Revision: https://phabricator.services.mozilla.com/D85168
2020-07-30 14:22:38 +00:00
Masayuki Nakano
d13c1f61c7 Bug 1655911 - Get rid of DidCreateNode(), DidInsertNode(), DidSplitNode() and DidDeleteSelection() of nsIEditActionListener because of unused r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85266
2020-07-30 06:40:44 +00:00
Masayuki Nakano
1ca256c5ff Bug 1655651 - Fix end point comparison in EditorDOMRangeBase::Contains() r=m_kato
Fortunately, nobody uses this API yet.

Differential Revision: https://phabricator.services.mozilla.com/D85108
2020-07-30 03:47:40 +00:00
Masayuki Nakano
515b4fb502 Bug 1644313 - part 6: Make HTMLEditor::HandleDeleteAroundCollapsedSelection() cancel the deletion if caret position is not editable r=m_kato
The previous patch changed target of white-space normalization.  That caused
`editor/libeditor/tests/test_bug1425997.html` starting to failed with new
exception.  What happens in the test is, selection is collapsed into comment
node (I think that this behavior is also a bug though) after second
`document.execCommand("delete")`, and then, failed to delete anything
and throws the exception.  For fixing this issue, the most simple approach is
make `HTMLEditor::HandleDeleteAroundCollapsedSelection()` stop handling
deletion when caret position is not editable.  So, unfortunately, this
patch changes traditional path too.

Depends on D84948

Differential Revision: https://phabricator.services.mozilla.com/D84949
2020-07-29 17:20:01 +00:00
Masayuki Nakano
1248b55a7e Bug 1644313 - part 5: Make ExtendRangeToDeleteWithNormalizingWhiteSpaces() not normalize preceding white-spaces when deleting range all characters in first text node after start to delete r=m_kato
Blink normalizes preceding white-spaces of deleting range only when the range is
NOT remove last character or there are no following text nodes.  If removing
last character at first text node which is followed by another text node, Blink
normalize white-spaces at start of the following text node.

This behavior seems odd, but we should follow the Blink's behavior for better
compatibility.

Note that new test failures in
`white-spaces-after-execCommand-forwarddelete.tentative.html` is caused by
that forward deletion is handled by existing path instead of the new handler.
Therefore, it's no problem for now.

Additionally, this change causes a mochitest
(`editor/libeditor/tests/test_bug1425997.html`) and a crash test
(`editor/libeditor/crashtests/1424450.html`) becoming oranges since their
DOM tree becomes different after applying this patch.  The oranges will
be fixed by the following patches.

Depends on D84947

Differential Revision: https://phabricator.services.mozilla.com/D84948
2020-07-29 12:48:42 +00:00
Masayuki Nakano
dbb0ffdb8d Bug 1644313 - part 4: Make WSRunScanner::GetRangeInTextNodesTo*From() available with non-white-space characters r=m_kato
The difference between `HTMLEditor::HandleDeleteCollapsedSelectionAtTextNode()`
and `HTMLEditor::HandleDeleteCollapsedSelectionAtWhiteSpace()` is whether
it treats surrogate pair or not.  And it's easy to handle it in `WSRunScanner`.
Therefore, they can handle all deletion in a text node.

Some new failures are caused by that we normalize preceding white-spaces of
deletion range but Blink does not to it.  These failures will be fixed by
part 5.

Depends on D84946

Differential Revision: https://phabricator.services.mozilla.com/D84947
2020-07-29 22:13:46 +00:00
Masayuki Nakano
e8940879ba Bug 1644313 - part 3: Make HTMLEditor::HandleDeleteTextAroundCollapsedSelection() call HTMLEditor::DeleteTextAndNormalizeSurroundingWhiteSpaces() with TreatEmptyTextNodes::RemoveAllEmptyInlineAncestors r=m_kato
When it calls `DeleteTextAndNormalizeSurroundingWhiteSpaces()`, we need to
remove empty text nodes and newly empty inline ancestors.  Currently, empty
nodes are removed by `HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal()`:
https://searchfox.org/mozilla-central/rev/25d491b7924493b5d4bedc07841a1cd92f271100/editor/libeditor/HTMLEditSubActionHandler.cpp#510
But we should stop using this in this case for reducing transactions.

Depends on D84945

Differential Revision: https://phabricator.services.mozilla.com/D84946
2020-07-29 12:19:07 +00:00
Masayuki Nakano
8846a44f37 Bug 1644313 - part 2: Make HTMLEditor::DeleteTextAndTextNodeWithTransaction() remove empty text node or most distant empty inline ancestor optionally r=m_kato
For the following patches, it's nicer that the API has optional behavior which
removes new empty text node or empty parent elements because directly removing
parent element can reduce the number of transactions and avoid storing text
with `DeleteTextTransaction()`.

Depends on D84944

Differential Revision: https://phabricator.services.mozilla.com/D84945
2020-07-29 06:28:40 +00:00
Masayuki Nakano
a269bbe497 Bug 1644313 - part 1: Create new path to handle backspace or (forward) delete with the new normalizer r=m_kato
`InputEvent.getTargetRange()` should have actual delete range.  It means that
the range should contain the invisible leading/trailing white-spaces which
need to be removed for keep them invisible, but should not contain the range
of normalizing white-space sequence because they are not target of edit action
indicated by `InputEvent.inputType`.

So, we can use new path which uses the new white-space normalizer for
computing the value of `InputEvent.getTargetRanges()` because difference of
white-space normalizer shouldn't affect the deleting ranges (although, some
existing path calls `DeleteNodeIfInvisibleAndEditableTextNode()` later so that
the new method, `ComputeRangeInTextNodesContainingInvisibleWhiteSpaces()`, does
not exactly same thing, but the result shouldn't become different in usual
cases).  This new path can test with some WPTs under `editing/other`.

This patch creates new backspace/delete key handler when caret is at next
to a white-space as `HTMLEditor::HandleDeleteTextAroundCollapsedSelection()`
and creates helper methods of `WSRunScanner` to treat invisible leading and
trailing white-spaces.

Note that new failures are caused by the difference whether adjacent white-space
sequence at deletion is normalized or not in edge cases.  They will be fixed
by the part.5.

Depends on D84943

Differential Revision: https://phabricator.services.mozilla.com/D84944
2020-07-29 00:04:00 +00:00
tkhan
8e2aaafc76 Bug 1655424 - Add skip-if annotation for xorigin and fission timeout, r=gbrown
Differential Revision: https://phabricator.services.mozilla.com/D85030
2020-07-28 13:42:36 +00:00
Masayuki Nakano
0f69748e1a Bug 1653534 - part 5: Fix new intermittent orange of editor/libeditor/crashtests/1424450.html r=m_kato
With the previous patch, 2 bugs become visible.

One is a `MOZ_ASSERT` in
`WhiteSpaceVisibilityKeeper::MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()`
is wrong.  When `TextFragmentData::GetReplaceRangeDataAtEndOfDeletionRange()`
returns a replace range, it may set the start to inclusive next character of
end to delete.  So, start of replace range may start after end to delete when
container of end to delete is not a text node and its next editable char point
is an ASCII white-space.  Therefore, this patch rewrite it with
`MOZ_ASSERT_IF` and `EditorDOMPoint::IsInTextNode()`.

The other is `TextFragmentData::GetReplaceRangeDataAtEndOfDeletionRange()`
and `TextFragmentData::GetReplaceRangeDataAtStartOfDeletionRange()` may call
`TextFragmentData::GetFirstASCIIWhiteSpacePointCollapsedTo()` and
`TextFragmentData::GetEndOfCollapsibleASCIIWhiteSpaces()` with a point in
preformatted text node.  Therefore, this patch adds the check into them.

Depends on D84323

Differential Revision: https://phabricator.services.mozilla.com/D84943
2020-07-27 15:20:31 +00:00
Masayuki Nakano
1665d4bfb2 Bug 1653534 - part 4: Make TextFragmentData set its mIsPreformatted more carefully r=m_kato
Traditionally, `WSRunScanner` (and formerly `WSRunObject`) treats all text
nodes in its range when scan start container node has preformatted style.
This means that when starting start from start or end of preformatted text node
or inline element, it treats adjacent white-spaces which is not preformatted
as preformatted.

This patch fixes this issue.  Because of the fix of preceding patches,
`BoundaryData` stops scanning if it meets preformatted text node.  So,
`BoundaryData` can store whether the scanners found a preformatted character.
Therefore, if one of `BoundaryData`s is marked as "preformatted", it means
the range contains a preformatted character.  And keep referring the style
of scan start point if there is no visible text nodes around it.

Note that the above change causes new failures with `<listing>` element which
should be treated as `<pre>` element, but `HTMLEditUtils` treats it as
non-container inline element.
https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom:listing

Therefore, this patch changes the definition of `<listing>` element and
`<xmp>` element which is also mentioned in the above link to container
element etc.  `<listing>` element is treated exactly same as `<pre>`,
therefore, the new definition is same as `<pre>`, but `<xmp>` does not
allow any tags after opens it (i.e., even if its close tag).  Therefore,
`<xmp>` definition is different from `<listing>` and `<pre>` elements'
definition.

Differential Revision: https://phabricator.services.mozilla.com/D84323
2020-07-27 23:58:04 +00:00
Masayuki Nakano
d389880eab Bug 1653534 - part 3: Make TextFragmentData::InvisibleLeadingWhiteSpaceRangeRef() and TextFragmentData::InvisibleTrailingWhiteSpaceRangeRef() stop checking whether scanning start point is preformatted or not r=m_kato
The check does not make sense because `TextFragmentData`'s range may contain
multiple text nodes which may have different style.

With the previous patch, the range won't cross characters in preformatted
text nodes.  Therefore, their result won't contain preformatted characters
right now.  So, we can just drop the unnecessary check from them.

Differential Revision: https://phabricator.services.mozilla.com/D84320
2020-07-27 07:46:22 +00:00
Masayuki Nakano
7c120ffd68 Bug 1653534 - part 2: Add text node style check in WSRunObject.cpp r=m_kato
Simply, if a white-space is in a preformatted text node, we shouldn't modify
it for normalizing.  This patch adds such checks to various points in
`WSRunObject.cpp`.

Differential Revision: https://phabricator.services.mozilla.com/D84319
2020-07-27 07:44:26 +00:00
Masayuki Nakano
1738b19f28 Bug 1653534 - part 1: Make TextFragmentData treat only collapsible white-spaces as its non-collapsed range r=m_kato
Currently, `TextFragmentData` stores whether the scan start point is
preformatted or not.  However, it does not make sense because the class
may contain other text nodes which may have different style in its range.
The main job of `TextFragmentData` is managing white-spaces as visible
sequence or invisible sequence.  So, preformatted white-space should be
treated as visible character because of not collapsible with adjacent
formatted ASCII white-spaces.

First of all, this patch its initializer stop scanning white-spaces if
it meets non-empty preformatted text node.

Note that the new failures are caused by the difference whether which
white-space sequence should be normalized when modifying text at text node
or inline element boundary.  This difference should be fixed in another
bug because our new normalizer does not handle this same as Blink for now.

Differential Revision: https://phabricator.services.mozilla.com/D84317
2020-07-27 05:56:38 +00:00
tkhan
e67129e6ad Bug 1655017 - Update xorigin and fission mochitest annotations, r=intermittent-reviewers,gbrown
Differential Revision: https://phabricator.services.mozilla.com/D84860
2020-07-27 01:16:21 +00:00
tkhan
e778811453 Bug 1653400 - Add xorigin and fission annotations, r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D84006
2020-07-23 18:05:05 +00:00
Emilio Cobos Álvarez
ff61891772 Bug 1653011 - Simplify and make WeakPtr<Derived> usable and compact. r=froydnj,sg,geckoview-reviewers,jgilbert,kvark,snorp
Having two classes in the inheritance chain inherit from SupportsWeakPtr
now won't compile, but you can use WeakPtr<Derived> when any base class
inherits from SupportsWeakPtr.

Differential Revision: https://phabricator.services.mozilla.com/D83674
2020-07-23 14:51:46 +00:00
Kashav Madan
ae956c4eef Bug 1653674 - Unskip passing fission tests, r=kmag
It's possible that some of these are still failing intermittently. We can't
really know without first unskipping them.

https://github.com/annygakh/audit-tests

Differential Revision: https://phabricator.services.mozilla.com/D84017
2020-07-21 15:42:48 +00:00
Masayuki Nakano
34c574b18a Bug 1653485 - part 3: Rename WSRunScanner::TextFragmentDataAtStart() to WSRunScanner::TextFragmentDataAtStartRef() r=m_kato
Depends on D83920

Differential Revision: https://phabricator.services.mozilla.com/D83921
2020-07-20 09:56:24 +00:00
Masayuki Nakano
143dc7787e Bug 1653485 - part 2: Change each lvalue which is initialized with result of *Ref() methods in WSRunObject.cpp to const Foo& r=m_kato
Depends on D83919

Differential Revision: https://phabricator.services.mozilla.com/D83920
2020-07-20 09:41:35 +00:00
Masayuki Nakano
63f1a6f5a8 Bug 1653485 - part 1: Make TextFragmentData::GetInvisibleLeadingWhiteSpaceRange() and TextFragmentData::GetInvisibleTrailingWhiteSpaceRange() return const-reference r=m_kato
They return copy of cached `EditorDOMRange` instance.  So, they can return
const-reference rather than copy of stored data.

Differential Revision: https://phabricator.services.mozilla.com/D83919
2020-07-20 09:39:00 +00:00
Mirko Brodesser
2c374acd88 Bug 1649121: part 45) Rename FindTargetNodeOfContextForPastedHTML. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83783
2020-07-17 08:44:38 +00:00
Mirko Brodesser
76c391b27f Bug 1649121: part 44) Factor PreProcessContextDocumentFragmentForMerging out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83661
2020-07-17 08:44:36 +00:00
Mirko Brodesser
d8b92c4ea0 Bug 1649121: part 43) Factor PostProcessFragmentForPastedHTMLWithoutContext out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83660
2020-07-17 08:44:33 +00:00
Mirko Brodesser
434ad21fa9 Bug 1649121: part 42) Factor MergeAndPostProcessFragmentsForPastedHTMLAndContext out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83659
2020-07-17 08:44:31 +00:00
Mirko Brodesser
2edf97ca16 Bug 1649121: part 41) Add local variable for pasted HTML document fragment. r=masayuki
It's clearer and allows setting the output fragment at the end of the
method.

Differential Revision: https://phabricator.services.mozilla.com/D83658
2020-07-17 08:44:28 +00:00
Masayuki Nakano
f97dcee20c Bug 1651874 - part 10: Move GetReplaceRangeDataAtEndOfDeletionRange() and GetReplaceRangeDataAtStartOfDeletionRange() to TextFragmentData r=m_kato
With this patch, the creation cost of `TextFragmentData` is minimized, but
`MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()` can work
with the latest DOM tree information at touching start of the deleting range
even after touching end of the range.

Depends on D83228

Differential Revision: https://phabricator.services.mozilla.com/D83229
2020-07-16 16:41:00 +00:00
Masayuki Nakano
58cf70f8ca Bug 1651874 - part 9: Make MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange() correct delete range when it modifies the DOM tree at end of deleting range r=m_kato
This is what the original method should've done.  Mutation event listeners may
change the DOM tree at the first modification, but it hasn't checked whether
the range to delete or replace around start of deleting range is still valid
or not.

Depends on D83226

Differential Revision: https://phabricator.services.mozilla.com/D83228
2020-07-16 13:40:36 +00:00
Masayuki Nakano
35e5829194 Bug 1651874 - part 8: Make helper methods of MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange() return replace or delete data r=m_kato
For representing delete or replace data which have the range and replace string,
this patch creates `ReplaceRangeDataBase` class which is stack-only, has
`EditorDOMRange` or `EditorDOMRangeInTexts` as the range and has replace string
which can be empty string.

Then, `MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()` should
modify the DOM tree by itself.  With the following patch, the behavior is
corrected for multiple DOM tree changes.

Depends on D83224

Differential Revision: https://phabricator.services.mozilla.com/D83226
2020-07-16 12:24:21 +00:00
Masayuki Nakano
5cd974a324 Bug 1651874 - part 7: Rename ReplaceASCIIWhiteSpacesWithOneNBSP() to ReplaceTextAndRemoveEmptyTextNodes() r=m_kato
Depends on D83223

Differential Revision: https://phabricator.services.mozilla.com/D83224
2020-07-16 05:54:41 +00:00
Masayuki Nakano
2d02a70bfb Bug 1651874 - part 6: Make the last blocks of MakeSureToKeepVisibleStateOfWhiteSpacesAtEndOfDeletingRange() and MakeSureToKeepVisibleStateOfWhiteSpacesAtStartOfDeletingRange() use early-return style r=m_kato
Depends on D83221

Differential Revision: https://phabricator.services.mozilla.com/D83223
2020-07-16 03:41:00 +00:00
Masayuki Nakano
111b0ccc2e Bug 1651874 - part 5: Make MakeSureToKeepVisibleStateOfWhiteSpacesAtEndOfDeletingRange() and MakeSureToKeepVisibleStateOfWhiteSpacesAtStartOfDeletingRange() stop collecting all data first r=m_kato
Depends on D83220

Differential Revision: https://phabricator.services.mozilla.com/D83221
2020-07-16 03:40:23 +00:00
Masayuki Nakano
b48a53e99f Bug 1651874 - part 4: Get rid of check of out of range in MakeSureToKeepVisibleStateOfWhiteSpacesAtEndOfDeletingRange() and MakeSureToKeepVisibleStateOfWhiteSpacesAtStartOfDeletingRange() r=m_kato
Depends on D83219

Differential Revision: https://phabricator.services.mozilla.com/D83220
2020-07-16 02:12:26 +00:00
Masayuki Nakano
affa364e8c Bug 1651874 - part 3: Remove unnecessary variables in MakeSureToKeepVisibleStateOfWhiteSpacesAtEndOfDeletingRange() and MakeSureToKeepVisibleStateOfWhiteSpacesAtStartOfDeletingRange() r=m_kato
Depends on D83218

Differential Revision: https://phabricator.services.mozilla.com/D83219
2020-07-15 15:05:37 +00:00
Masayuki Nakano
f0994f25cd Bug 1651874 - part 2: Get rid of unnecessary blocks in MakeSureToKeepVisibleStateOfWhiteSpacesAtEndOfDeletingRange() and MakeSureToKeepVisibleStateOfWhiteSpacesAtStartOfDeletingRange() r=m_kato
Depends on D83217

Differential Revision: https://phabricator.services.mozilla.com/D83218
2020-07-15 15:05:12 +00:00
Masayuki Nakano
743a2e3ea9 Bug 1651874 - part 1: Duplicate the definition of MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange() r=m_kato
This patch is preparation for easier to review.

This patch duplicates the body of
`MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()` and calls the
copies from new `MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()`.
The one is for handling start of deleting range, and the other is for handling
end of deleting range.

As you see, this patch and the following patches do not work because of the
duplicated code.  Perhaps, part 2 works if there is no mutation event listeners.
Part 9 works even if there is mutation event listeners which touch the DOM
tree in the worst case (when it touches both end of delete range and start of
delete range, and around the start of deleting range is modified by JS).
Finally, part 9 takes back the original performance.

Depends on D82715

Differential Revision: https://phabricator.services.mozilla.com/D83217
2020-07-15 15:04:54 +00:00
Mirko Brodesser
19dff2f032 Bug 1649121: part 40) Factor DetermineContextLocalNameForParsingPastedHTML out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83517
2020-07-16 11:48:07 +00:00
Mirko Brodesser
c142c4747d Bug 1649121: part 39) Rename parameters and variables around CreateDocumentFragmentAndGetParentOfPastedHTMLInContext. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83516
2020-07-16 10:07:06 +00:00
Mirko Brodesser
ee40150e1c Bug 1649121: part 38) Add CreateDocumentFragmentAndGetParentOfPastedHTMLInContext. r=masayuki
The parameters will be renamed in the following review.

Differential Revision: https://phabricator.services.mozilla.com/D83515
2020-07-16 10:08:21 +00:00
Simon Giesecke
da069e50be Bug 1652942 - Remove unnecessary includes from Element.h. r=smaug
Depends on D83114

Differential Revision: https://phabricator.services.mozilla.com/D83632
2020-07-15 14:09:01 +00:00
Masayuki Nakano
75c8215499 Bug 1649980 - part 22: Make VisibleWhiteSpacesData store start point and end point with EditorDOMPoint r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82715
2020-07-14 12:54:51 +00:00
Masayuki Nakano
cb58def02f Bug 1649980 - part 21: Move BoundaryData and NoBreakingWhiteSpacesData into TextFragmentData r=m_kato
Now, these classes are used only by `TextFragmentData` and they can be not
exposed.  Therefore, we should hide them with making them private nested
classes of `TextFragmentData`.

Differential Revision: https://phabricator.services.mozilla.com/D82714
2020-07-14 12:51:05 +00:00
Masayuki Nakano
9ef57c0e72 Bug 1649980 - part 20: Rename WSRunObject to WhiteSpaceVisibilityKeeper r=m_kato
Although the new name is long, but I have no better idea.  The class's purpose
is to keep white-space visibility around modifying DOM position.  Therefore,
I use "keeper" for the name.

Differential Revision: https://phabricator.services.mozilla.com/D82713
2020-07-14 12:40:13 +00:00
Masayuki Nakano
28151f4d79 Bug 1649980 - part 19: Make WSRunObject class not instantiated r=m_kato
Now, all member methods of `WSRunObject` are static.  So, it shouldn't
be able to instantiated.

Differential Revision: https://phabricator.services.mozilla.com/D82712
2020-07-14 12:21:19 +00:00
Masayuki Nakano
8695ba2c43 Bug 1649980 - part 18: Merge WSRunObject::NormalizeWhiteSpacesAtEndOf() to WSRunObject::NormalizeWhiteSpacesAround() r=m_kato
Similar to the previous patch, `WSRunObject::NormalizeWhiteSpacesAround()` is
a wrapper to create `WSRunObject` instance for calling
`NormalizeWhiteSpacesAtEndOf()`, but it does not need to be `WSRunObject`'s
instance.  Therefore, we can merge them.

Note that this renames the merged method to `NormalizeVisibleWhiteSpacesAt`.

Differential Revision: https://phabricator.services.mozilla.com/D82711
2020-07-14 12:20:10 +00:00
Masayuki Nakano
0c8108d6fb Bug 1649980 - part 17: Merge WSRunObject::DeleteInvisibleASCIIWhiteSpacesInternal() to WSRunObject::DeleteInvisibleASCIIWhiteSpaces() r=m_kato
Now, it does not need to be a `WSRunObject` instance so that its wrapper to
create `WSRunObject` instance is not necessary.

Differential Revision: https://phabricator.services.mozilla.com/D82710
2020-07-14 11:57:22 +00:00
Masayuki Nakano
6d5a2ed757 Bug 1649980 - part 16: Make WSRunObject::DeleteWSForward() static r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82709
2020-07-14 11:25:13 +00:00
Masayuki Nakano
6d8ecf188f Bug 1649980 - part 15: Make WSRunObject::DeleteWSBackward() static r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82708
2020-07-14 10:59:10 +00:00
Mirko Brodesser
cac98dad3c Bug 1649121: part 37) Move some methods to FragmentFromPasteCreator. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83325
2020-07-14 08:54:14 +00:00
Mirko Brodesser
0d5c14fde1 Bug 1649121: part 36) Move setting start- and end-offsets out of FragmentFromPasteCreator. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83324
2020-07-14 09:08:25 +00:00
Mirko Brodesser
b16297fa5f Bug 1649121: part 35) Add FragmentFromPasteCreator. r=masayuki
First step of breaking up the complex corresponding method.

Differential Revision: https://phabricator.services.mozilla.com/D83323
2020-07-14 09:23:58 +00:00
Masayuki Nakano
af86f0b72b Bug 1649980 - part 14: Make WSRunObject::PrepareToSplitAcrossBlocksPriv() static r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82707
2020-07-14 10:07:41 +00:00
Razvan Maries
6269129e09 Backed out changeset 4d835cc17a7f (bug 1649121) for build bustages on HTMLEditorDataTransfer.cpp. CLOSED TREE 2020-07-14 11:14:25 +03:00
Mirko Brodesser
9aadf57d94 Bug 1649121: part 35) Add FragmentFromPasteCreator. r=masayuki
First step of breaking up the complex corresponding method.

Differential Revision: https://phabricator.services.mozilla.com/D83323
2020-07-14 05:13:33 +00:00
Masayuki Nakano
8018883ae8 Bug 1649980 - part 13: Make WSRunObject::PrepareToDeleteRangePriv() static r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82706
2020-07-14 03:54:34 +00:00
Masayuki Nakano
2e76a2dbb5 Bug 1649980 - part 12: Make WSRunObject::InsertBreak() static r=m_kato
It's now can work with static helper methods and a `TextFragmentData` instance.
Therefore, this patch makes it a static method.

Note that it's always called with `nsIEditor::eNone` so that we can get rid of
the argument.

Differential Revision: https://phabricator.services.mozilla.com/D82705
2020-07-14 01:29:34 +00:00
Masayuki Nakano
89d1495bf1 Bug 1649980 - part 11: Make WSRunObject::ReplaceASCIIWhiteSpacesWithOneNBSP() static r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82704
2020-07-13 15:30:51 +00:00
Masayuki Nakano
55c0146bd3 Bug 1649980 - part 10: Get rid of WSRunScanner::mScanEndPoint r=m_kato
Now, `mScanEndPoint` is not used.  This patch removes it and clean up the
constructors of `WSRunScanner` and `WSRunObject`.

Differential Revision: https://phabricator.services.mozilla.com/D82703
2020-07-13 14:57:38 +00:00
Masayuki Nakano
1d08048cd9 Bug 1649980 - part 9: Make WSRunScanner::InsertText() a static method r=m_kato
It's simpler to make `WSRunScanner::InsertText()` take insertion point.
Then, it can do its jobs with `TextFragmentData` instance(s).

Differential Revision: https://phabricator.services.mozilla.com/D82702
2020-07-13 14:25:44 +00:00
tkhan
75ea54bf01 Bug 1650919 - Adding manifest annotations for xorigin test harness. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D82763
2020-07-13 20:34:46 +00:00
Bogdan Tara
6faddf7d8f Backed out changeset 1a0f002865d3 (bug 1650919) for test_deprecated.html failures CLOSED TREE 2020-07-13 19:22:21 +03:00
tkhan
e50031dfc7 Bug 1650919 - Adding manifest annotations for xorigin test harness. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D82763
2020-07-13 13:01:43 +00:00
Mirko Brodesser
530067672e Bug 1649121: part 34) Factor FragmentParser out. r=masayuki
First step of separating parsing more clearly from other fragment
mutations.

Differential Revision: https://phabricator.services.mozilla.com/D83046
2020-07-13 10:30:15 +00:00
Masayuki Nakano
b0b71dbf13 Bug 1649980 - part 8: Make TextFragmentData::CreateVisibleWhiteSpacesData() cache its result and returns reference instead of copy of the instance r=m_kato
`CreateVisibleWhiteSpacesData()` is now called multiple times and maybe called
after the DOM tree is modified even though it's a bug.  Therefore, we should
make it store first result and return its reference instead.

Differential Revision: https://phabricator.services.mozilla.com/D82701
2020-07-13 10:37:12 +00:00
Masayuki Nakano
ab1d1d9708 Bug 1649980 - part 7: Redesign WSRunObject::MaybeReplaceInclusiveNextNBSPWithASCIIWhiteSpace() r=m_kato
Same as the previous patch, it can be split to computation part and
modifying the DOM tree part.  Then, the former can be in `TextFragmentData`
and the latter can be done by the caller which is only
`WSRunObject::InsertText()`.

Depends on D82699

Differential Revision: https://phabricator.services.mozilla.com/D82700
2020-07-13 08:31:51 +00:00
Mirko Brodesser
b85c0263f1 Bug 1649121: part 33) Rename FindTargetNode to FindTargetNodeOfContextForPastedHTML. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82895
2020-07-10 12:02:54 +00:00
Mirko Brodesser
ad6e91b777 Bug 1649121: part 32) Rename RemoveBodyAndHead to RemoveHeadChildAndStealBodyChildsChildren. r=masayuki
More accurate, less misleading.

Differential Revision: https://phabricator.services.mozilla.com/D82894
2020-07-10 12:02:51 +00:00
Mirko Brodesser
16c2811dc8 Bug 1649121: part 31) Change StripFormattingNodes to RemoveNonPreWhiteSpaceOnlyTextNodesForIgnoringInvisibleWhiteSpaces. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82886
2020-07-10 12:02:38 +00:00
Masayuki Nakano
fcfd044076 Bug 1649980 - part 6: Redesign WSRunObject::MaybeReplacePreviousNBSPWithASCIIWhiteSpace() r=m_kato
It's called by `WSRunObject::InsertText()` and `WSRunObject::InsertBreak()` and
it has 2 parts.  One is, considering whether previous char is an NBSP or not
and whether it should be replaced with an ASCII white-space if it's followed
by visible character.  The other is, doing the replacement.  The latter code
is enough simple.  Therefore, we can copy them into the callers.  Then,
we can move the check logic into `TextFragmentData`.

Depends on D82698

Differential Revision: https://phabricator.services.mozilla.com/D82699
2020-07-13 05:55:58 +00:00
Masayuki Nakano
c0c258172d Bug 1649980 - part 5: Implement GetEndOfCollapsibleASCIIWhiteSpaces() and GetPreviousCharPointFromPointInText() in TextFragmentData instead of WSRunScanner r=m_kato
Depends on D82697

Differential Revision: https://phabricator.services.mozilla.com/D82698
2020-07-13 01:48:39 +00:00
Masayuki Nakano
0c97489216 Bug 1649980 - part 4: Implement GetInclusiveNextEditableCharPoint() and GetPreviousEditableCharPoint() in TextFragmentData instead of WSRunScanner r=m_kato
They work with a `TextFragmentData` instance, and the following patches
require to run it without `WSRunScanner`/`WSRunObject` instances.
Therefore, this patch moves them into `TextFragmentData`.

Depends on D82695

Differential Revision: https://phabricator.services.mozilla.com/D82697
2020-07-13 01:44:01 +00:00
Masayuki Nakano
e0fab23e4d Bug 1649980 - part 3: Make WSRunScanner store white-space sequence data with a TextFragmentData instance r=m_kato
This patch makes `WSRunScanner` have `TextFragmentData const mTextFragmentData`
instead of 2 `BoundaryData`s, a `NoBreakingSpaceData` and a `bool` storing
whether it's preformatted or not.

Depends on D82694

Differential Revision: https://phabricator.services.mozilla.com/D82695
2020-07-13 01:30:11 +00:00
Kris Maglione
b6be72f351 Bug 1649554: Part 1 - Move deprecated component registration helpers out of XPCOMUtils. r=mccr8,remote-protocol-reviewers,marionette-reviewers,perftest-reviewers,webcompat-reviewers,whimboo,twisniewski
Differential Revision: https://phabricator.services.mozilla.com/D81749
2020-07-10 23:58:30 +00:00
Kris Maglione
9d78661f88 Bug 1649221: Update ChromeUtils.generateQI callers to pass strings. r=mccr8,remote-protocol-reviewers,marionette-reviewers,perftest-reviewers,webcompat-reviewers,geckoview-reviewers,preferences-reviewers,agi,whimboo,Bebe,twisniewski
Differential Revision: https://phabricator.services.mozilla.com/D81594
2020-07-10 23:58:28 +00:00
Masayuki Nakano
444700f8d1 Bug 1649980 - part 2: Move WSRunScanner::GetEditableBlockParentOrTopmotEditableInlineContent() to HTMLEditUtils r=m_kato
Depends on D82693

Differential Revision: https://phabricator.services.mozilla.com/D82694
2020-07-10 12:38:56 +00:00
Masayuki Nakano
73ed807abb Bug 1649980 - part 1: Move WSRunScanner::mStart and WSRunScanner::mEnd initializers into BoundaryData r=m_kato
For making `WSRunScanner::BoundaryData` independent from `WSRunScanner`,
its initializer should be in the class itself as static factory methods.

Depends on D82295

Differential Revision: https://phabricator.services.mozilla.com/D82693
2020-07-10 06:58:49 +00:00
Masayuki Nakano
4cce915acd Bug 1647556 - part 16: Rename WSFragment to VisibleWhiteSpacesData r=m_kato
Now, we can call `WSFragment` `VisibleWhiteSpacesData`.  Then, the methods of
`WSRunObject` which take `WSFragment` as their arguments become clearer what
they mean.

Differential Revision: https://phabricator.services.mozilla.com/D82295
2020-07-10 05:47:55 +00:00
Masayuki Nakano
939400f8ac Bug 1647556 - part 15: Get rid of visible state of WSFragment r=m_kato
Now, `WSFragment` instances are created only by
`TextFragmentData::CreateWSFragmentForVisibleWhiteSpaces()`.  Therefore, it's
always visible.

Additionally, this patch hides `WSFragment` constructors from the others too.

Differential Revision: https://phabricator.services.mozilla.com/D82294
2020-07-10 05:01:44 +00:00
Masayuki Nakano
3c1d6d127b Bug 1647556 - part 14: Get rid of unnecessary WSFragment memebers r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82293
2020-07-10 04:48:33 +00:00
Masayuki Nakano
5386e3310c Bug 1647556 - part 13: Rename CreateWSFragmentForVisibleAndMiddleOfLine() to CreateWSFragmentForVisibleWhiteSpaces() r=m_kato
Now, we know that it returns `WSFragment` for visible white-spaces and may
lie position in the line.  Therefore, we should rename it as just representing
visible white-spaces.

Differential Revision: https://phabricator.services.mozilla.com/D82292
2020-07-10 04:46:01 +00:00
Masayuki Nakano
9dd0f65471 Bug 1647556 - part 12: Get rid of WSRunScanner::FindNearestRun() and WSRunScanner::mFragments r=m_kato
Now, nobody uses `WSRunScanner::FindNearestRun()` so that we can remove it.
Then, there is no users of `WSRunScanner:mFragments`.  Therefore, we can remove
the member, accessors and initializers.

Differential Revision: https://phabricator.services.mozilla.com/D82291
2020-07-10 04:03:39 +00:00
Masayuki Nakano
2c944d309a Bug 1647556 - part 11-3: Make WSRunObject::PrepareToDeleteRangePriv() stop using WSRunScanner::FindNearestRun() r=m_kato
Unfortunately, remaining code which use `beforeRun` and `afterRun` of
`WSRunObject::PreareToDeleteRangePriv()` is completely broken.  It tries to
do what the new utility methods say, but as you see in the method, the
checking code does not make sense.  For now, we should keep this broken
check even with the expensive DOM point comparisons.  I hope that this does
not harm any benchmark score.

Note that I tested this with all automated tests with comparing the result
of these methods with `MOZ_ASSERT()` like this:
https://hg.mozilla.org/try/rev/29cb7840e404473a41d2d1fbdd229f762ccac5d3
So, I think that this is enough safe because the most edge cases are tested
by the first patch in this bug and `editing/run/(forwarddelete|delete).html`
of WPT.

Differential Revision: https://phabricator.services.mozilla.com/D82290
2020-07-10 04:03:21 +00:00
Masayuki Nakano
f9e93231db Bug 1647556 - part 11-2: Make WSRunObject::PrepareToDeleteRangePriv() use TextFragmentData::GetNewInvisibleLeadingWhiteSpaceRangeIfSplittingAt() and TextFragmentData::GetNewInvisibleTrailingWhiteSpaceRangeIfSplittingAt() r=m_kato
Similar to the previous patches, it can use invisible white-space ranges.

Differential Revision: https://phabricator.services.mozilla.com/D82289
2020-07-10 02:27:47 +00:00
Masayuki Nakano
5542e44de3 Bug 1647556 - part 11-1: Make WSRunObject::PrepareToDeleteRangePriv() use TextFragmentData::CreateWSFragmentForVisibleAndMiddleOfLine() r=m_kato
Similar to the previous changes, `WSRunObject::PrepareToDeleteRangePriv()`
can use `TextFragmentData::CreateWSFragmentForVisibleAndMiddleOfLine()` and
result of comparing with deleting range.

Differential Revision: https://phabricator.services.mozilla.com/D82288
2020-07-10 02:11:20 +00:00
Masayuki Nakano
06d6743328 Bug 1647556 - part 10-4: Make WSRunObject::InsertText() stop rescan end of replacing range if it's collapsed r=m_kato
For handling composition, `WSRunObject::InsertText()` rescan white-spaces at
end of replacing range.  However, in most cases, `mScanStartPoint` and
`mScanEndPoint` are same.  Therefore, we can save the runtime cost of the
rescan easier than the old design.

Differential Revision: https://phabricator.services.mozilla.com/D82287
2020-07-09 16:53:25 +00:00
Masayuki Nakano
5e5e7fea51 Bug 1647556 - part 10-3: Make WSRunObject::InsertText() stop using WSRunScanner::FindNearestFragment() r=m_kato
I realized that `WSFragment::MarkAsVisible()` is called only by
`TextFragmentData::CreateWSFragmentForVisibleAndMiddleOfLine()`.  Therefore,
`beforeRun && !beforeRun->IsStartOfHardLine() && beforeRun->IsVisible()` can be
handled with `pointPositionWithVisibleWhiteSpacesAtStart` and
`afterRun && !afterRun->IsEndOfHardLine() && afterRun->IsVisible()` can be
handled with `pointPositionWithVisibleWhiteSpacesAtEnd`.  So, we can make
`WSRunObject::InsertText()` stop using `FindNearestFragment()` to compute
inserting string.

Differential Revision: https://phabricator.services.mozilla.com/D82286
2020-07-09 16:41:30 +00:00
Masayuki Nakano
12b7d18656 Bug 1647556 - part 10-2: Make WSRunObject::InsertText() use TextFragmentData::GetNewInvisibleLeadingWhiteSpaceRangeIfSplittingAt() and TextFragmentData::GetNewInvisibleTrailingWhiteSpaceRangeIfSplittingAt() r=m_kato
Similar to `WSRunObject::InsertBreak()`, `WSRunObject::InsertText()` can use
the new APIs for `InsertBreak()` even though the name is odd for `InsertText()`,
but the mismatching is caused by odd logic of it.  If replacing range starts
from and/or ends by middle of invisible white-space sequence, all of the
invisible white-spaces should be removed to prevent they become visible.
However, we shouldn't change any behavior in this bug.

Differential Revision: https://phabricator.services.mozilla.com/D82285
2020-07-09 16:23:42 +00:00
Masayuki Nakano
d19cea4314 Bug 1647556 - part 10-1: Make WSRunObject::InsertText() use TextFragmentData::CreateWSFragmentForVisibleAndMiddleOfLine() r=m_kato
Similar to `WSRunObject::InsertBreak()`, `WSRunObject::InsertText()` can work
with the new API.

Differential Revision: https://phabricator.services.mozilla.com/D82284
2020-07-09 12:34:35 +00:00
Mirko Brodesser
d127a6ed32 Bug 1649121: part 30) Move RemoveBodyAndHead, FindTargetNode. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82885
2020-07-09 13:23:21 +00:00