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

10354 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 9494d7d9c7 Bug 1655388 - part 2: Make deleting `<br>` element after `<hr>` element in `HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent()` use the new method r=m_kato
Although it does not need to join text nodes around the `<br>` element since
its previous node is `<hr>`, it can use
`WhiteSpaceVisibilityKeeper::DeleteContentNodeAndJoinTextNodesAroundIt()` too.

Depends on D87029

Differential Revision: https://phabricator.services.mozilla.com/D87030
2020-08-18 08:17:17 +00:00
Masayuki Nakano 07e4f0f69d Bug 1655388 - part 1: Move the last part of `HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent()` into `WhiteSpaceVisibilityKeeper` r=m_kato
It works with the traditional white-space normalizer.  Therefore, it should
be moved into `WhiteSpaceVisibilityKeeper`.

Depends on D86910

Differential Revision: https://phabricator.services.mozilla.com/D87029
2020-08-18 08:16:33 +00:00
Sonia Singla 5f5c9fd7f2 Bug 1659267 - Remove usages of -moz-user-select across the Firefox codebase. r=emilio,marionette-reviewers,geckoview-reviewers,preferences-reviewers,whimboo,agi
Differential Revision: https://phabricator.services.mozilla.com/D87499
2020-08-18 23:37:51 +00:00
Masayuki Nakano 3da9fc2299 Bug 1658534 - part 2: Avoid infinite recursive calls at removing an invisible `<br>` element r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86910
2020-08-18 07:26:02 +00:00
Masayuki Nakano e21079f1fd Bug 1658534 - part 1: Split the removing invisible `<br>` element part off from `HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent()` r=m_kato
Depends on D86886

Differential Revision: https://phabricator.services.mozilla.com/D86909
2020-08-18 05:35:39 +00:00
Masayuki Nakano d550a723f8 Bug 1658472 - part 6: Make some utility methods for `AutoInclusiveAncestorBlockElementsJoiner` r=m_kato
This patch changes the behavior in the following 2 points:
* When both content is in same block element, won't return error
* When `<hr>` element has block children accidentally, this solves its container

The former case must not change actual behavior because
`AutoBlockElementsJoiner` is used with content nodes which are in different
blocks.

Differential Revision: https://phabricator.services.mozilla.com/D86886
2020-08-17 10:57:47 +00:00
Masayuki Nakano 909288b9a6 Bug 1658472 - part 5: Split `AutoInclusiveAncestorBlockElementsJoiner::Run()` to computation part and touching the DOM tree part r=m_kato
Depends on D86884

Differential Revision: https://phabricator.services.mozilla.com/D86885
2020-08-17 10:51:44 +00:00
Masayuki Nakano 5d03594318 Bug 1658472 - part 4: Make `AutoInclusiveAncestorBlockElementsJoiner` store new list element tag name with its member r=m_kato
Depends on D86883

Differential Revision: https://phabricator.services.mozilla.com/D86884
2020-08-17 10:24:13 +00:00
Masayuki Nakano 3e0a1d8d61 Bug 1658472 - part 3: Make `AutoInclusiveAncestorBlockElementsJoiner` store left block element and right block element as its members r=m_kato
Depends on D86882

Differential Revision: https://phabricator.services.mozilla.com/D86883
2020-08-17 09:54:49 +00:00
Masayuki Nakano 3496851ec0 Bug 1658472 - part 2: Make `AutoInclusiveAncestorBlockElementsJoiner` store left content and right content at construction r=m_kato
Depends on D86881

Differential Revision: https://phabricator.services.mozilla.com/D86882
2020-08-17 09:34:11 +00:00
Masayuki Nakano 1a08039730 Bug 1658472 - part 1: Move `HTMLEditor::TryToJoinBlocksWithTransaction()` into new nested class of `AutoBlockElementsJoiner` r=m_kato
Now all users of the method is methods of `AutoBlockElementsJoiner`.
Therefore, we can move it into the nested class.  And for splitting the
method in the following patch, it should be a nested class of
`AutoBlockElementJoiner`.

Depends on D86791

Differential Revision: https://phabricator.services.mozilla.com/D86881
2020-08-17 09:22:19 +00:00
Masayuki Nakano 33a78c310f Bug 1655392 - part 6: Split the text deletion part of start and/or end of range off from `HandleDeleteNonCollapsedRanges` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86791
2020-08-17 00:26:24 +00:00
Masayuki Nakano 21d81f986c Bug 1655392 - part 5: Split the part removing contents in each range off from `HandleDeleteNonCollapsedRanges()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86790
2020-08-16 04:33:39 +00:00
Masayuki Nakano 9d1482c813 Bug 1655392 - part 4: Give independent mode and handler for the next block of `AutoBlockElementsJoiner::HandleDeleteNonCollapsedRanges()` r=m_kato
And now, `HTMLEditor::JoinNodesDeepWithTransaction()` is used only by
`AutoBlockElementsJoiner`.  Therefore, this patch moves it to the
stack only class.

Differential Revision: https://phabricator.services.mozilla.com/D86789
2020-08-16 04:20:38 +00:00
Masayuki Nakano aa3497a28e Bug 1655392 - part 3: Give independent mode and handler for first case of `AutoBlockElementsJoiner::HandleDeleteNonCollapsedRanges()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86788
2020-08-13 11:54:21 +00:00
Masayuki Nakano fa6c54cc66 Bug 1655392 - part 2: Make `AutoBlockElementsJoiner::PrepareToDeleteNonCollapsedRange()` initialize `mLeftContent` and `mRightContent` with inclusive ancestor block elements of start and end of first range r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86787
2020-08-13 11:17:24 +00:00
Masayuki Nakano 7d56bc1b36 Bug 1655392 - part 1: Move some part of `HTMLEditor::HandleDeleteNonCollapsedRanges()` to `AutoBlockElementsJoiner` r=m_kato
For making the following review easier, this patch just moves some part of
`HandleDeleteNonCollapsedRanges()` into `AutoBlockElementJoiner`.

Differential Revision: https://phabricator.services.mozilla.com/D86786
2020-08-13 10:12:13 +00:00
Mihai Alexandru Michis fb644eda26 Backed out changeset 5838f8b581ed (bug 1647536) for causing failures in browser_active_mediasession_among_tabs.js
CLOSED TREE
2020-08-14 19:42:51 +03:00
Chris Fronk 8770c8a332 Bug 1647536 - Support ref counted pointers in nsDeque r=froydnj
Adds a new specialization of nsDeque, nsRefPtrDeque for use with
reference counted pointers.

Differential Revision: https://phabricator.services.mozilla.com/D84766
2020-08-14 15:19:48 +00:00
Mirko Brodesser 21078a7903 Bug 1652557: don't skip test_bug767684.html when xorigin iframes and fission are enabled. r=masayuki
The test failed neither locally nor on try, hence enabling it again.

Differential Revision: https://phabricator.services.mozilla.com/D86706
2020-08-12 02:02:49 +00:00
Masayuki Nakano 220db95ff0 Bug 1657269 - part 2: Make `HTMLEditor::HandleDeleteSelectionInternal()` take `AutoRangeArray` instead of referring `Selection` ranges r=m_kato
Now, only when deleting table cell contents, `HandleDeleteSelectionInternal()`
depends on `Selection`.  However, this can be moved to `HandleDeleteSelection()`
because recursive callers expects `Selection` is collapsed by its previous job.

Differential Revision: https://phabricator.services.mozilla.com/D86183
2020-08-11 09:35:42 +00:00
Masayuki Nakano d5ed562a13 Bug 1657269 - part 1: Move `EditorBase::ExtendSelectionForDelete()` into `AutoRangeArray` r=m_kato
This patch moves `EditorBase::ExtendSelectionForDelete()` into `AutoRangeArray`
and make it stop modifying `Selection`.

The method extends anchor-focus range with `nsFrameSelection` and it refers
bidi information in it too.  Therefore, it needs to be called before modifying
anchor-focus range of `Selection`.  Unfortunately, this makes the code messy,
but for now, we should take this.  In the future, we should make the API of
`nsFrameSelection` free from `Selection`.

Differential Revision: https://phabricator.services.mozilla.com/D86182
2020-08-11 06:11:10 +00:00
Masayuki Nakano 0b7819addd Bug 1657270 - part 5: Guarantee that `AutoEmptyBlockAncestorDeleter` did nothing if it returns "not handled" or an error at the caller r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85999
2020-08-11 05:04:33 +00:00
Masayuki Nakano 76b257fb0f Bug 1657270 - part 4: Split caret computation part off from `AutoEmptyBlockAncestorDeleter::Run()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85998
2020-08-11 05:04:08 +00:00
Masayuki Nakano 087c7979ab Bug 1657270 - part 3: Split `<br>` element insertion part for empty list element off from `AutoEmptyBlockAncestorDeleter::Run()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85997
2020-08-11 04:35:05 +00:00
Masayuki Nakano d76fe99f0d Bug 1657270 - part 2: Split `AutoEmptyBlockAncestorDeleter::Run()` to scanning the target part and touching the DOM tree part r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85996
2020-08-11 02:02:31 +00:00
Masayuki Nakano 42c32fd19a Bug 1657270 - part 1: Move `HTMLEditor::MaybeDeleteTopMostEmptyAncestor()` into new stack only class r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85995
2020-08-11 02:02:19 +00:00
Edgar Chen ad6affb211 Bug 1658176 - Make mochitest tests with xorigin and fission enabled report assertion properly; r=kmag DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D86516
2020-08-10 20:48:13 +00:00
Dorel Luca c243829674 Backed out 5 changesets (bug 1623764) for WPT failures in /editing/run/forwarddelete.html. CLOSED TREE
Backed out changeset 838b1a256f25 (bug 1623764)
Backed out changeset 00911e3c92c3 (bug 1623764)
Backed out changeset 5f7d278953d7 (bug 1623764)
Backed out changeset 0059379a3c29 (bug 1623764)
Backed out changeset 6e3a9276ec41 (bug 1623764)
2020-08-10 09:07:48 +03:00
Kagami Sascha Rosylight a371405cd9 Bug 1623764 - Part 5: Prevent test failure by subpixel difference r=emilio
The failures already have been there: https://treeherder.mozilla.org/#/jobs?repo=try&revision=3d6cc94f2db7a2e55f41405ef0575102637e0633&selectedTaskRun=ZUj4QROIQo6nGympvvqvjA.0

... but they only fail inside a job "geckoview-test-verify" and the job even does not always runs the test. It makes hard to track the initial failure, so this patch just allows subpixel difference.

Differential Revision: https://phabricator.services.mozilla.com/D86486
2020-08-10 01:46:26 +00:00
Kagami Sascha Rosylight ddbb369d71 Bug 1623764 - Part 4: Stop at hard linebreaks when eat_space_to_next_word r=emilio,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D85923
2020-08-09 12:58:27 +00:00
Masayuki Nakano 5b78d2b3c1 Bug 1657052 - Make `HTMLEditor::HandleDeleteAroundCollapsedSelection()` take ranges to delete instead of retrieving them via `Selection` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85965
2020-08-07 06:13:00 +00:00
Masayuki Nakano 4588958dcb Bug 1656799 - part 5: Make `HTMLEditor::GetRangeExtendedToIncludeInvisibleNodes()` directly extend given range r=m_kato
Creation cost of `nsRange` is expensive, and it's only user,
`HTMLEditor::HandleDeleteNonCollapsedRanges()` wants to extend the range.
Therefore, we can make it directly extend the given range.

Differential Revision: https://phabricator.services.mozilla.com/D85849
2020-08-07 06:12:17 +00:00
Masayuki Nakano 6346ed0316 Bug 1656799 - part 4: Make `HTMLEditor::HandleDeleteNonCollapsedSelection()` take ranges to delete instead of retrieving it via `Selection` r=m_kato
Depends on D85847

Differential Revision: https://phabricator.services.mozilla.com/D85848
2020-08-07 05:53:16 +00:00
Masayuki Nakano 3397c35fa4 Bug 1656799 - part 3: Make `WhiteSpaceVisibilityKeeper::PrepareToDeleteRange()` not track `EditorDOMPoint`s r=m_kato
It may be faster to use `AutoTrackDOMRange` directly.  Therefore, current
`WhiteSpaceVisibilityKeeper::PrepareToDeleteRange()` should be renamed to
`WhiteSpaceVisibilityKeeper::PrepareToDeleteRangeAndTrackPoints()` and
we should make `HTMLEditor::HandleDeleteNonCollapsedSelection()` track
the range by itself.

Depends on D85846

Differential Revision: https://phabricator.services.mozilla.com/D85847
2020-08-06 08:07:39 +00:00
Masayuki Nakano 0ada126b2a Bug 1656799 - part 2: Create range tracker r=m_kato
There is only `AutoTrackDOMPoint`, but
`HTMLEditor::HandleDeleteNonCollapsedSelection()` requires to tack pairs of
DOM points, i.e., requires to track ranges.  For making the code simpler,
we should have range tracker too.

Depends on D85845

Differential Revision: https://phabricator.services.mozilla.com/D85846
2020-08-08 02:57:16 +00:00
Masayuki Nakano 93ff6864bb Bug 1656799 - part 1: Make `HTMLEditor::HandleDeleteNonCollapsedSelection()` store selection ranges with `AutoRangeArray` first r=m_kato
Depends on D85686

Differential Revision: https://phabricator.services.mozilla.com/D85845
2020-08-06 07:03:55 +00:00
Cosmin Sabou 1fd1260b5e Backed out 4 changesets (bug 1623764) for mochitest failures on test_movement_by_characters.html. CLOSED TREE
Backed out changeset f927522d89bc (bug 1623764)
Backed out changeset c100eb8ae430 (bug 1623764)
Backed out changeset 1147ded16458 (bug 1623764)
Backed out changeset 7af572ec5edf (bug 1623764)
2020-08-06 08:09:42 +03:00
Kagami Sascha Rosylight 0f2d254487 Bug 1623764 - Part 4: Stop at hard linebreaks when eat_space_to_next_word r=emilio,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D85923
2020-08-06 01:18:52 +00:00
Masayuki Nakano e12a28bb16 Bug 1656430 - part 3: Create `EditorBase::DeleteRangesWithTransaction()` r=m_kato
This patch makes `EditorBase::DeleteSelectionWithTransaction()` a wrapper of
`EditorBase::DeleteRangesWithTransaction()`.

Differential Revision: https://phabricator.services.mozilla.com/D85686
2020-08-05 07:13:40 +00:00
Masayuki Nakano 65db771e7f Bug 1656430 - part 2: Add `AutoRangeArray` for alternative class of `Selection` r=m_kato
This new class will be used for treating selection ranges without modifying
it temporarily.

Differential Revision: https://phabricator.services.mozilla.com/D85685
2020-08-05 06:45:37 +00:00
Masayuki Nakano 9c3084ace7 Bug 1656430 - part 1: Rename `AutoRangeArray` to `AutoSelectionRangeArray` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85684
2020-08-05 01:37:26 +00:00
Masayuki Nakano 25994d720f Bug 1656432 - part 3: Get rid of `nsIEditActionListener::WillDeleteSelection()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85683
2020-08-04 15:01:18 +00:00
Masayuki Nakano d68f059017 Bug 1656432 - part 1: Create `nsIEditActionListener::WillDeleteRanges()` r=m_kato
Currently, `nsIEditActionListener::WillDeleteSelection()` notifies
`FinderHighliter` of deleting selection ranges.  But it's referred only
the ranges, not selection object itself and editor shouldn't modify
`Selection` as far as possible for reducing the runtime cost.

Therefore, it should be replaced with this new API.  Then,
`EditorBase::WillDeleteSelectionWithTransaction()` can be rewritten as
`EditorBase::WillDeleteRangesWithTransaction()` later.

Differential Revision: https://phabricator.services.mozilla.com/D85681
2020-08-04 14:59:03 +00:00
Masayuki Nakano 4a9059edde Bug 1655389 - part 3: Split the case deleting `<br>` element off from `AutoBlockElementsJoiner::HandleDeleteCollapsedSelectionAtOtherBlockBoundary()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85578
2020-08-05 05:08:21 +00:00
Masayuki Nakano 4d84607c7e Bug 1655389 - part 2: Move recursive call in `AutoBlockElementsJoiner::HandleDeleteCollapsedSelectionAtCurrentBlockBoundary()` to `HTMLEditor::HandleDeleteAroundCollapsedSelection()` r=m_kato
The recursive call is not safe.  We should do it more carefully.  For now,
we should not hide the recursive call into the leaf handler.

Differential Revision: https://phabricator.services.mozilla.com/D85573
2020-08-04 12:14:33 +00:00
Masayuki Nakano 2323c386e9 Bug 1655389 - part 1: Move `HTMLEditor::HandleDeleteCollapsedSelectionAtCurrentBlockBoundary()` into `AutoBlockElementJoiner` r=m_kato
Same as the patch for bug 1655391, this patch splits the method to 2 parts.
One is to consider content nodes to join or a `<br>` element to delete instead.

Note that this patch changes the behavior a little.  That is, when the other
block is not editable, it throws an exception here:
https://searchfox.org/mozilla-central/rev/56bb74ea8e04bdac57c33cbe9b54d889b9262ade/editor/libeditor/HTMLEditSubActionHandler.cpp#3124

But it should just cancel the edit action.  Therefore, some tests in
BrowserScope are fixed by this patch.  I.e., result of DOM tree in the
situation isn't changed, but stops throwing unnecessary exception.

Differential Revision: https://phabricator.services.mozilla.com/D85569
2020-08-04 11:42:55 +00:00
Masayuki Nakano 804e3ce7de Bug 1655391 - Make new stack only class handle deletion at current block boundary r=m_kato
This patch creates new stack only class, `HTMLEditor::AutoBlockElementsJoiner`
and splits `HTMLEditor::HandleDeleteCollapsedSelectionAtCurrentBlockBoundary()`
to considering the content nodes to be joined part and doing join the nodes
part.

Differential Revision: https://phabricator.services.mozilla.com/D85567
2020-08-04 03:01:21 +00:00
Butkovits Atila 7a09391039 Backed out changeset 2e7e9d83e56b (bug 1655391) for bustage at HTMLEditor. CLOSED TREE 2020-08-03 14:54:27 +03:00
Masayuki Nakano 04fa88ff17 Bug 1655391 - Make new stack only class handle deletion at current block boundary r=m_kato
This patch creates new stack only class, `HTMLEditor::AutoBlockElementsJoiner`
and splits `HTMLEditor::HandleDeleteCollapsedSelectionAtCurrentBlockBoundary()`
to considering the content nodes to be joined part and doing join the nodes
part.

Differential Revision: https://phabricator.services.mozilla.com/D85567
2020-08-03 09:52:38 +00:00
Sonia Singla 34ac1b2de3 Bug 1656292 - Enable remaining ESLint rules on editor/libeditor/tests/*.xhtml files. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D85450
2020-07-31 23:58:46 +00:00
Masayuki Nakano 8147272ea7 Bug 1655706 - part 3-2: Move `AutoTransactionsConserveSelection` in `HTMLEditor::TryToJoinBlocksWithTransaction()` into each `WhiteSpaceVisibilityKeeper` method r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85534
2020-08-03 08:25:33 +00:00
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
Masayuki Nakano dd8f12dbc3 Bug 1647556 - part 9-2: Make `WSRunObject::InsertBreak()` stop using `FindNearestFragment()` r=m_kato
It removes some invisible leading and/or trailing white-spaces when it inserts
`<br>` element into the invisible white-space sequence.  It currently checks
whether the insertion point is in invisible leading and trailing white-spaces
or not with `FindNearestFragment()`, but we can do same thing with
comparing the insertion point with the result of
`TextFragmentData::GetInvisibleLeadingWhiteSpaceRange()` and
`TextFragmentData::GetInvisibleLeadingWhiteSpaceRange()`.  However, current
implementation does not make sense because:
- It checks trailing white-spaces with `!IsEndOfHardLine()` and
  `IsStartOfHardLine()`, but this means that it does ignores invisible
   white-spaces which are the only content in a line.
- It checks leading white-spaces with `!IsStartOfHardLine()` and
  `IsEndOfHardLine()`, so, this also ignores invisible white-spaces which
  are the only content in a line.
- The important thing of the logic is prevent that invisible leading and
  trailing white-spaces become visible with new `<br>` element, but this
  is done only for trailing white-spaces.

Differential Revision: https://phabricator.services.mozilla.com/D82283
2020-07-09 09:44:41 +00:00
Mirko Brodesser abe1457b3b Bug 1649121: part 29) Rename and simplify arguments of `InsertContents`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82662
2020-07-09 05:44:18 +00:00
Mirko Brodesser 4560c59527 Bug 1649121: part 28) Add `InsertContents`. r=masayuki
Its arguments are renamed in the following review.

Differential Revision: https://phabricator.services.mozilla.com/D82661
2020-07-09 05:41:48 +00:00
Mirko Brodesser 637ad4a65b Bug 1649121: part 27) Add `MoveCaretOutsideOfLink`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82520
2020-07-08 12:14:16 +00:00
Mirko Brodesser dcff5a5f40 Bug 1649121: part 26) Move `CollectTopMostChildContentsCompletelyInRange`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82518
2020-07-08 12:15:06 +00:00
Mirko Brodesser 47b1f0e01f Bug 1649121: part 25) Factor detecting invisible `<br>` out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82517
2020-07-09 05:39:05 +00:00
Masayuki Nakano 7ffb8f8c90 Bug 1647556 - part 9-1: Make `WSRunObject::InsertBreak()` use `TextFragmentData::CreateWSFragmentForVisibleAndMiddleOfLine()` like previous patch r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82282
2020-07-09 06:32:24 +00:00
Masayuki Nakano 3092ad9e61 Bug 1650972 - Fix wrong argument check of `EditorBase::AppendNodeToSelectionAsRange()` r=m_kato
This is just a mistake of my previous change.

Differential Revision: https://phabricator.services.mozilla.com/D82655
2020-07-09 06:46:19 +00:00
Masayuki Nakano e63d0f9e18 Bug 1647556 - part 8: Make `WSRunObject::PrepareToSplitAcrossBlocksPriv()` stop using `FindNearestFragment()` r=m_kato
It looks for same `WSFragment` twice with comparing text and what it looks for
is the instance whose `IsVisibleAndMiddleOfLine()` returns `true`.
Additionally, doing twice is for checking only whether the split point is
start or end of the range.  Therefore, we can make it simpler with using
`TextFragmentData::CreateWSFragmentForVisibleAndMiddleOfLine()`.

Differential Revision: https://phabricator.services.mozilla.com/D82281
2020-07-09 05:04:56 +00:00
Masayuki Nakano 60451652c9 Bug 1647556 - part 7: Make `ScanPreviousVisibleNodeOrBlockBoundaryFrom()` and `ScanNextVisibleNodeOrBlockBoundaryFrom()` use `TextFragmentData::CreateWSFragmentForVisibleAndMiddleOfLine()` instead of scanning all `WSFragment`s r=m_kato
They return a point in an `WSFragment` whose `IsVisibleAndMiddleOfLine()`
returns `true` or start/end of the range.  Therefore, they can ignore the
other `WSFragment`s and save comparing points to at most twice.

Differential Revision: https://phabricator.services.mozilla.com/D82280
2020-07-09 01:42:27 +00:00
Masayuki Nakano b546936467 Bug 1647556 - part 6: Make `WSRunObject::AdjustWhiteSpace()` use `TextFragmentData::CreateWSFragmentForVisibleAndMiddleOfLine()` instead of scanning all `WSFragment`s r=m_kato
It scans all `WSFragment`s in the array and call `NormalizeWhiteSpacesAtEndOf()`
only with visible instance.  However, as we know, there is at most one such
instance.  Therefore, it does not need to scan the fragments (i.e., don't need
to create all fragments).

Differential Revision: https://phabricator.services.mozilla.com/D82279
2020-07-08 10:11:35 +00:00
Masayuki Nakano 61003960ec Bug 1647556 - part 5-3: Implement the other case of `CreateWSFragmentForVisibleAndMiddleOfLine()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82278
2020-07-08 09:08:39 +00:00
Masayuki Nakano 03b956b20d Bug 1647556 - part 5-2: Implement another case of `CreateWSFragmentForVisibleAndMiddleOfLine()` r=m_kato
This patch implements the case that when the range is not start of hard line.

Differential Revision: https://phabricator.services.mozilla.com/D82277
2020-07-08 07:37:48 +00:00
Masayuki Nakano d813074347 Bug 1647556 - part 5-1: Create new API to get `WSFragment` in middle of line and visible r=m_kato
Most methods handling something with `WSFragment` work only with instances
whose `IsVisibleAndMiddleOfHardLine()` return true, and currently, such
instance exists only one at most in the array.  Therefore, they just want
an API to get such fragment.

Differential Revision: https://phabricator.services.mozilla.com/D82276
2020-07-08 01:23:14 +00:00
Masayuki Nakano c28c0b9359 Bug 1647556 - part 4: Rewrite `WSRunObject::Scrub()` r=m_kato
`Scrub()` does remove leading white-spaces and trailing white-spaces if
there is.  So, it does not require `WSFragment` anymore.

Differential Revision: https://phabricator.services.mozilla.com/D82275
2020-07-07 16:21:50 +00:00
Mirko Brodesser df5c5a5851 Bug 1649121: part 24) Move `StripFormattingNodes`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82389
2020-07-07 12:32:40 +00:00
Mirko Brodesser db05434bca Bug 1649121: part 23) Move `MoveStartAndEndAccordingToHTMLInfo`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82388
2020-07-07 12:32:33 +00:00
Mirko Brodesser 28c0b32d43 Bug 1649121: part 22) Move `ParseFragment`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82387
2020-07-07 12:32:30 +00:00
Mirko Brodesser ce817796aa Bug 1649121: part 21) Move `CreateDOMFragmentFromPaste`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82386
2020-07-07 12:32:20 +00:00
Mirko Brodesser 1360293f83 Bug 1649121: part 20) Move `GetNewCaretPointAfterInsertingHTML` to `HTMLWithContextInserter`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82385
2020-07-07 12:32:13 +00:00
Mirko Brodesser b1c3499828 Bug 1649121: part 19) Add `HTMLWithContextInserter` and move content of `DoInsertHTMLWithContext` to it. r=masayuki
This is minimally invasive. In the following parts, methods will be
moved to it and potentially other methods will be extracted.

Differential Revision: https://phabricator.services.mozilla.com/D82384
2020-07-07 12:32:05 +00:00
Mirko Brodesser 1684d9040a Bug 1649121: part 18) Declare `CreateDOMFragmentFromPaste` `const`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82198
2020-07-07 12:31:58 +00:00
Masayuki Nakano ec9ecbc50f Bug 1647556 - part 3-3: Implement the other complicated case of `GetInvisibleLeadingWhiteSpaceRange()` r=m_kato
Different from `GetInvisibleTrailingWhiteSpaceRange()`, it always returns
the range even if it's collapsed (i.e., there is no leading white-space).

Differential Revision: https://phabricator.services.mozilla.com/D82274
2020-07-07 09:21:27 +00:00
Masayuki Nakano abb2c132b1 Bug 1647556 - part 3-2: Implement complicated case of `GetInvisibleTrailingWhiteSpaceRange()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D82273
2020-07-07 07:39:20 +00:00
Masayuki Nakano 0ed0d74c18 Bug 1647556 - part 3-1: Add API to `WSRunScanner::TextFragmentData` to get range of invisible leading or trailing white-spaces r=m_kato
One of the `WSFragment`users' purpose is, they remove invisible white-spaces
when there are.  So, `TextFragmentData` should have API to retrieve the
ranges and use them for initializing `WSFragment` which represents leading
or trailing white-spaces.  For making this patch smaller as far as possible,
these APIs implements only the case when there is no NBSP.

For result of the new API, this creates a template class, `EditorDOMRangeBase`,
whose boundary type is `EditorDOMPointBase`.  Its methods are named from
`nsRange`'s same methods.

Differential Revision: https://phabricator.services.mozilla.com/D82272
2020-07-07 05:31:34 +00:00
Masayuki Nakano 3d01ff0123 Bug 1647556 - part 2: Create `WSRunScanner::TextFragmentData` class for the alternative of `WSFragment`s r=m_kato
This patch just creates new stack only class and make it initializes
`WSRunScanner::mFragments` instead of `WSRunScanner`.

Differential Revision: https://phabricator.services.mozilla.com/D82270
2020-07-06 16:21:27 +00:00
Masayuki Nakano a639ed9828 Bug 1647556 - part 1: Get rid of `WSRunScanner::InitializeWithSingleFragment()` r=m_kato
For making easier to understand the contents of `WSRunScanner::mFragments`,
we should stop using `InitializeWithSingleFragment()` for now because it's
designed for doing same things a lot, but used only by 2 users and they set
different parameters so that it does not do same things for the callers.

Depends on D82268

Differential Revision: https://phabricator.services.mozilla.com/D82269
2020-07-06 10:33:06 +00:00
Sylvestre Ledru caf785c695 Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D82178
2020-07-04 09:38:43 +00:00
Mirko Brodesser 324ad8b2e7 Bug 1649121: part 17) Correct style for previous commit. r=masayuki
Separate commit to reduce possibility for typos.

Differential Revision: https://phabricator.services.mozilla.com/D82148
2020-07-03 09:55:37 +00:00
Mirko Brodesser 91f0344d40 Bug 1649121: part 16) Factor getting new caret point out of `DoInsertHTMLWithContext`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82147
2020-07-03 09:55:11 +00:00
Mirko Brodesser f5d347f5a7 Bug 1649121: part 15) Declare `IsVisibleBRElement` `const`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82009
2020-07-03 09:25:25 +00:00
Mirko Brodesser 17833bb634 Bug 1649121: part 14) Rename local variables `mostAncestorTableRelatedElement`, `maybeTableRelatedElement`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D82008
2020-07-03 09:25:22 +00:00
Mirko Brodesser e79ae100d0 Bug 1649121: part 13) Rename `GetMostAncestorListOrTableElement`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81994
2020-07-03 09:27:45 +00:00
Mirko Brodesser 72ae1c4c1f Bug 1649121: part 12) Remove duplicated code in `IsReplaceableListElement`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81993
2020-07-03 09:25:18 +00:00
Mirko Brodesser bb175a0e82 Bug 1649121: part 11) Factor some functionality of `GetMostAncestorListOrTableElement` out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81849
2020-07-03 09:26:19 +00:00
Mirko Brodesser aec19fc27a Bug 1649121: part 10) Rename `CollectTopMostChildNodesCompletelyInRange` to `CollectTopMostChildContentsCompletelyInRange`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81848
2020-07-02 11:53:03 +00:00
Masayuki Nakano 2c83c27c9c Bug 1644903 - Make `nsINode::InsertBefore()` callers call `ErrorResult::WouldReportJSException()` when inserting node may be in another document r=m_kato
`nsINode::InsertBefore()` removes inserting node from a document if it's in
a document including different document.  In this case, `UpdateReflectorGlobal`
in BindingUtils.cpp calls `ErrorResult::MightThrowJSException()`, but editor
never throws exception with `ErrorResult`.  Therefore, editor needs to call
`ErrorResult::WouldReportJSException()` explicitly if the inserting node may
be in another document.

As far as I checked, it can happen only when undoing or redoing a transaction.
Therefore, this patch touches only transaction classes.

Depends on D81683

Differential Revision: https://phabricator.services.mozilla.com/D81684
2020-07-01 13:13:13 +00:00
Masayuki Nakano 66545f5913 Bug 1648564 - Make `WSRunScanner::GetFirstASCIIWhiteSpacePointCollapsedTo()` and `WSRunScanner::GetEndOfCollapsibleASCIIWhiteSpaces()` not return point in empty text node r=m_kato
Although their callers may want to remove empty text nodes around white-space
sequence, but for now, we should make them not return empty text node because
the former's name means so, and the latter should behave similarly for
consistency.

Differential Revision: https://phabricator.services.mozilla.com/D81683
2020-07-02 08:30:25 +00:00
Simon Giesecke 9364b353d4 Bug 1648010 - Remove NS_NAMED_LITERAL_CSTRING and NS_NAMED_LITERAL_STRING macros. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80631
2020-07-01 08:42:31 +00:00
Simon Giesecke e3c223da3e Bug 1648010 - Fix uses of NS_LITERAL_STRING with C string literals. r=geckoview-reviewers,agi,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80861
2020-07-01 08:34:12 +00:00
Simon Giesecke cd8b8939b9 Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
Mirko Brodesser fb374f2e74 Bug 1649121: part 9) Simplify `GetMostAncestorListOrTableElement`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81547
2020-06-30 13:13:12 +00:00
Mirko Brodesser 4477882999 Bug 1649121: part 8) Rename `CollectListAndTableRelatedElementsAt` to `CollectTableAndAnyListElementsOfInclusiveAncestorsAt`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81546
2020-06-30 13:13:04 +00:00
Mirko Brodesser a533835579 Bug 1649121: part 7) Rename `HTMLEditUtils::IsList` to `HTMLEditUtils::IsAnyListElement`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81545
2020-06-30 13:12:56 +00:00
Mirko Brodesser a30c22f525 Bug 1649121: part 6) Rename `HTMLEditUtils::IsTableElementButNotTable` to `HTMLEditUtils::IsAnyTableElementButNotTable`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81544
2020-06-30 13:12:49 +00:00
Mirko Brodesser 7fe5d9f63c Bug 1649121: part 5) Declare `HTMLEditor::GetBetterInsertionPointFor` `const`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81543
2020-06-30 13:12:47 +00:00
Mirko Brodesser 592ca1c3b6 Bug 1649121: part 4) Rename `HTMLEditUtils::IsTableElement` to `HTMLEditUtils::IsAnyTableElement`. r=masayuki
The old name was misleading.

Differential Revision: https://phabricator.services.mozilla.com/D81542
2020-06-30 13:12:39 +00:00
Mirko Brodesser 2937ae1381 Bug 1649121: part 3) Declare some methods in `HTMLEditor` `static`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81541
2020-06-30 13:12:31 +00:00
Mirko Brodesser f52a74862a Bug 1649121: part 2) Factor moving start and end of out `CreateDOMFragmentForPaste`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81540
2020-06-30 13:12:29 +00:00
Mirko Brodesser 9ae430ad1a Bug 1649121: part 1) Add some documentation to `HTMLEditor::CreateDOMFragmentFromPaste`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D81539
2020-06-30 13:12:16 +00:00
Chris Fronk 6f84249b41 Bug 1337953 - Make nsDeque templated on pointer type r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D79629
2020-06-25 02:39:23 +00:00
Masayuki Nakano a240090dfd Bug 1646325 - part 4: Make `WSRunScanner` create `WSFragment` when it's needed r=m_kato
In most methods of `WSRunScanner`, `WSFragment`s are never used.  Therefore,
this patch makes them created when they are necessary.

Depends on D80315

Differential Revision: https://phabricator.services.mozilla.com/D80638
2020-06-24 08:37:26 +00:00
Masayuki Nakano 5ef63f4bd4 Bug 1646325 - part 3: Make `WSFragment` non-double-linked-list r=m_kato
Now, `WSFragment` is managed by `AutoTArray` so that it does not need to
be double-linked-list.

Differential Revision: https://phabricator.services.mozilla.com/D80315
2020-06-24 03:43:05 +00:00
Masayuki Nakano 69d6f854ee Bug 1646325 - part 2: Manage `WSFragment`s with array r=m_kato
`WSFragment` is created at least one instance, and at most 3 instances per
`WSRunScanner` instance.  They can be managed with `AutoTArray` simpler and
we can avoid heap allocation with this approach.

Differential Revision: https://phabricator.services.mozilla.com/D80314
2020-06-24 03:00:07 +00:00
Masayuki Nakano 379f838107 Bug 1646325 - part 1-3: Rewrite remaining part of `WSRunScanner::GetRuns()` with early-return style r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D80313
2020-06-24 01:22:45 +00:00
Masayuki Nakano cc4a5ebe14 Bug 1646325 - part 1-2: Rewrite the new `if` block in `WSRunScanner::GetRuns()` with early-return style r=m_kato
Depends on D80311

Differential Revision: https://phabricator.services.mozilla.com/D80312
2020-06-23 05:13:58 +00:00
Masayuki Nakano 86e3ff72ea Bug 1646325 - part 1-1: Make `WSRunScanner::GetRuns()` handle the case not starting from hard line break first r=m_kato
Part 1-* rewrite `WSRunScanner::GetRuns()` with early-return style, but it's
hard to review if changing it with a patch.

This just swaps the `if` and `else` block because the `else` block is
shorter than the `if` block.

Depends on D79973

Differential Revision: https://phabricator.services.mozilla.com/D80311
2020-06-23 04:46:20 +00:00
Butkovits Atila 7916df7f02 Backed out changeset 5614bcd268d1 (bug 1337953) for bustage at FuzzyLayer.cpp. CLOSED TREE 2020-06-23 11:01:37 +03:00
Chris Fronk cea9cef934 Bug 1337953 - Make nsDeque templated on pointer type r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D79629
2020-06-23 00:58:13 +00:00
Masayuki Nakano fcdef2c8b9 Bug 1646890 - Add automated test for bug 1645983 r=m_kato
This patch adds new test which is based on actual scenario in
Gmail composer.

Differential Revision: https://phabricator.services.mozilla.com/D80310
2020-06-22 14:48:47 +00:00
Masayuki Nakano 6b7588bbe2 Bug 1646296 - part 8: Make stack only classes to group start/end boundary information of `WSRunScanner` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D79973
2020-06-22 14:48:15 +00:00
Kagami Sascha Rosylight 166f2891a2 Bug 1643464 - Part 1: Rename eLeft/eRight to ePrimary/eSecondary r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D80331
2020-06-19 18:02:41 +00:00
tkhan 6ccabd4784 Bug 1602668 - M(1) manifest and test changes. r=kmag,karlt,necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D70362
2020-06-22 19:09:49 +00:00
Masayuki Nakano 8243db7082 Bug 1646296 - part 7: Make `WSRunScanner::InitializeRange*()` template methods r=m_kato
Depends on D79971

Differential Revision: https://phabricator.services.mozilla.com/D79972
2020-06-22 08:12:37 +00:00
Masayuki Nakano 196304c105 Bug 1646296 - part 6: Make `WSRunScanner::InitializeRange*()` stop using the loops which are rarely run twice and more r=m_kato
With the previous patches, we know that the loops in
`WSRunScanner::InitializeRangeStart()` and `WSRunScanner::InitializeRangeEnd()`
rarely run twice and more.  Therefore, we can make use recursive calls instead
of the loop.

Depends on D79970

Differential Revision: https://phabricator.services.mozilla.com/D79971
2020-06-22 06:05:16 +00:00
Masayuki Nakano c1be8ae82a Bug 1646296 - part 5: Make the last `else` block in the loops of `WSRunScanner::InitializeRange*()` handled before the text node case r=m_kato
Similar to the previous patch, this patch moves the last `else` block of
the loops in `WSRunScanner::InitializeRangeStart()` and
`WSRunScanner::InitializeRangeEnd()` to before the text node handling case.
This makes that clearer that the loops are continued only when text node
has no text or only white-spaces.

Depends on D79969

Differential Revision: https://phabricator.services.mozilla.com/D79970
2020-06-22 02:40:41 +00:00
Masayuki Nakano 7666461289 Bug 1646296 - part 4: Make the loops in `WSRunScanner::InitializeRange*()` handle topmost `else` block first r=m_kato
Their topmost `else` blocks mean there is no visible content before/after the
point.  In this case, the initialization is simpler.  So, they should be
handled first, and make the other blocks outdented.

Depends on D79966

Differential Revision: https://phabricator.services.mozilla.com/D79969
2020-06-22 02:11:30 +00:00
Masayuki Nakano 0847d6a6c2 Bug 1646296 - part 3: Create helper methods of `WSRunScanner::InitializeRange*()` to scan a text node r=m_kato
There are duplicated code in both `WSRunScanner::InitializeRangeStart()`
and `WSRunScanner::InitializeRangeEnd()`.  They scan text node to store
first and last NBSP positions and initialize start/end with found visible
character position.  This patch makes the loop clearer.

Depends on D79965

Differential Revision: https://phabricator.services.mozilla.com/D79966
2020-06-19 09:25:35 +00:00
Kagami Sascha Rosylight f424c247ba Bug 1640276 - Part 11: Mark nsINode as const in IsPointInSelection() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D80177
2020-06-19 00:58:40 +00:00
Masayuki Nakano abe7626ff4 Bug 1646296 - part 2: Split `WSRunScanner::GetWSNodes()` r=m_kato
Despite the name, it stores range of white-space sequence and/or start/end
reason.  Initializing start and end are completely independent.  Therefore,
we can move them into independent methods.

Depends on D79964

Differential Revision: https://phabricator.services.mozilla.com/D79965
2020-06-18 07:20:54 +00:00
Masayuki Nakano a852a50071 Bug 1646296 - part 1: Make `WSRunScanner::FindNearestRun()` return `const WSFragment*` instead of `WSFragment*` r=m_kato
The result should never be modified so that it should return `const`-pointer.

Differential Revision: https://phabricator.services.mozilla.com/D79964
2020-06-18 06:02:47 +00:00
Gijs Kruitbosch 222e2d1158 Bug 1644863 - fix trailing whitespace in cross-tree tests, r=emilio,marionette-reviewers,whimboo
Differential Revision: https://phabricator.services.mozilla.com/D79202
2020-06-17 22:45:31 +00:00
Kris Maglione 3bda67deab Bug 1638153: Part 2 - Fix uses of .rootTreeItem to get top browser window. r=geckoview-reviewers,nika,snorp
Differential Revision: https://phabricator.services.mozilla.com/D75429
2020-06-17 17:17:16 +00:00
Masayuki Nakano d2108a7fcd Bug 1645983 - Check whether `EditorDOMPointInText` is set before calling `IsCharASCIISpace()` r=m_kato
I guess that the `Maybe` is `mOffset` of `EditorDOMPointBase` because new
`Maybe::value()`s are called with checking `Maybe::isSome()`.  So, accessing
`EditorDOMPointBase::mOffset` newly should cause the assertion.

Then, I found a new caller `IsCharASCIISpace()` which calls `Char()` without
validation here:
https://hg.mozilla.org/mozilla-central/diff/289c293af80b12744b5d35c5b8427ba8d8ebf13e/editor/libeditor/WSRunObject.cpp#l1.383

That could be unset, but I cannot reproduce it, but I succeeded to reproduce
similar assertion hit with using empty text node (see the crashtest).  I hope
this fixes the original crash too.

Differential Revision: https://phabricator.services.mozilla.com/D79816
2020-06-17 07:03:25 +00:00
Masayuki Nakano e51cdb3ca3 Bug 1642594 - part 5: Implement first version of new white-space normalizer which simulates Blink's one r=m_kato
This patch tries to implement Blink-compat white-space normalizer for
`HTMLEditor`.

It's difficult to list up our traditional white-space normalization rules
because `WSRunObject` touches white space sequence only when there is not
acceptable case, e.g., an ASCII white-spaces will be adjacent to another
one, and replaces only unacceptable white-space only.  Therefore, whether
white-space sequence may start with either an ASCII white-space or an NBSP.
On the other hand, Blink and WebKit makes white-space sequence always
starts with an NBSP or an ASCII white-space (unfortunately, they behave
differently!).  So, for web-compat, we should simulate Blink's behavior
because either behavior is reasonable but Blink have more market share.

This patch simply adds new white-space normalization path for the new one,
and it's switchable with a pref, and still disabled by default.

The other reason why we should do this is, our traditional white-space
normalizer touches the DOM a lot of times per edit action, and the timing
is both before and after touches the DOM tree.  Therefore, it's difficult
to compute actual deleting range for `InputEvent.getTargetRanges()` and
touching a lot of times causes running mutation event listeners a lot and
creates a lot of transaction class instances.  So, new one have a lot of
merits:

1. Improve web-compat
2. Improve the peformance
3. Improve the security
4. Improve the footprint (but this is now worse then traditional one)
5. Simplify the implementation

The new normalizer is mostly implemented with only 3 `HTMLEditor` methods.

One is `HTMLEditor::DeleteTextAndNormalizeSurroundingWhiteSpaces()`.  This is
semi-public method for the edit action handlers.  This takes a range with
2 `EditorDOMPoinInText` to delete the range simply.  This also replaces
surrounding white-space sequence if necessary.  For inserting text case,
this method also handles only white-space normalization when it's called
with collapsed range, i.e., same `EditorDOMPointInText`.  This tries to use
`RepaceTextWithTransaction()` as far as possible to reduce creation cost of
transaction classes and the footprint.

Another one is `HTMLEditor::ExtendRangeToDeleteWithNormalizingWhiteSpaces()`.
This tries to extend the given range to normalize surrounding white-spaces.
This is currently not optimized for footprint because this may include
white-spaces which do not need to be replaced.  This optimization should be
done before shipping, but for now, enabling `InputEvent.getTargetRanges()` in
Nightly channel is more important.  So that it should be done in a follow-up
bug.

The other is `HTMLEditor::GenerateWhitepaceSequence()`.  This creates
normalized white-space sequence with surrounding character information.
For keeping this method simple as far as possible, we shouldn't optimize
the range of generation even in follow-ups.

Finally, the white-space sequence is not tested in mochitests, so that we
can enable this new normalizer when we run mochitests under
`editor/libeditor/tests`.  However, WPT has some tests.  We should keep
them running with current normalizer for checking regression.  Instead,
we should enable the pref only for the new WPT added by the previous patch.

Depends on D78655

Differential Revision: https://phabricator.services.mozilla.com/D78656
2020-06-15 07:37:56 +00:00
Masayuki Nakano e01c0de610 Bug 1642594 - part 4: Stop using "whitespace" in under libeditor r=m_kato
I realized that there is no word "whitespace" in formal English.  This patch
replaces it with "white-space" in comments, and change method names to use
"WhiteSpace".

Depends on D78654

Differential Revision: https://phabricator.services.mozilla.com/D78655
2020-06-10 13:44:10 +00:00
Masayuki Nakano 3d4e1bc4bb Bug 1642594 - part 2: Make `WSRunObject::ReplaceASCIIWhitespacesWithOneNBSP()` take range of collapsible ASCII whitespaces instead of a position in it r=m_kato
This patch makes the method not smart intentionally because we need only the
range without DOM mutation.

Differential Revision: https://phabricator.services.mozilla.com/D77987
2020-06-08 11:31:37 +00:00
Masayuki Nakano 5cfc474a9c Bug 1642594 - part 1: Split `WSRunObject::GetASCIIWhitespacesBounds()` and redesign them r=m_kato
Callers of `WSRunObject::GetASCIIWhitespacesBounds()` may want to scan only
previous or next whitespaces.  Therefore, we can split it to save creation
cost of `EditorDOMPointInText`.

Additionally, this makes them scan whitespace sequence in a text node until
hitting its end for avoiding to use expensive API of `WSRunScanner`.

Differential Revision: https://phabricator.services.mozilla.com/D77986
2020-06-08 11:30:37 +00:00
Ping Chen c055ecfef2 Bug 1636971 - Load EditorOverride.css in HTMLEditor->Init to fix image styles in editor. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D79285
2020-06-12 12:22:12 +00:00
Emilio Cobos Álvarez ef3d21048d Bug 1640623 - Use enum classes for LookAndFeel int and float IDs. r=jmathies,geckoview-reviewers,esawin
Differential Revision: https://phabricator.services.mozilla.com/D76694
2020-06-11 11:27:43 +00:00
Simon Giesecke 82dc9b2271 Bug 1642949 - Replace uses of RemoveElementAt by RemoveLastElement/PopLastElement where possible. r=necko-reviewers,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D78027
2020-06-10 10:46:14 +00:00
Butkovits Atila e3dce68834 Backed out 3 changesets (bug 1643289, bug 1642949) for causing failure at test_headless_screenshot.html. CLOSED TREE
Backed out changeset 98c420f73380 (bug 1643289)
Backed out changeset 9447ea8910aa (bug 1643289)
Backed out changeset 0c827da9d847 (bug 1642949)
2020-06-10 10:07:23 +03:00
Simon Giesecke d419f0ff08 Bug 1642949 - Replace uses of RemoveElementAt by RemoveLastElement/PopLastElement where possible. r=necko-reviewers,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D78027
2020-06-10 05:49:28 +00:00
Kagami Sascha Rosylight c883340a3b Bug 1643495 - Revert contextmenu change in test_bug417418 r=masayuki
This change was only needed when the previous version of the patch for Bug 1632425 wanted to move things into contextmenu event handler. This patch reverts the change as 1) the suggested behavior never landed and 2) opening context menu in a test can cause conflict with other tests.

Differential Revision: https://phabricator.services.mozilla.com/D78673
2020-06-08 23:35:53 +00:00
Masayuki Nakano 72a41b4a70 Bug 1636855 - Disallow to paste longer text than `maxlength` value except in Nightly channel and early Beta r=emilio
Fix of bug 1320229 allowed to paste longer text than `maxlength` attribute of
`<input>` and `<textarea>` because it was thought that the longer text causes
"too long" invalidate state, makes users notified and prevent to submit
form data.

However, according to Bug 1636855 comment 7 (*1), it breaks a major enterprise
web app, SAP, at least because it sends form data without checking validity of
each form data and discards invalid data on server side silently.

According to bug 1636855 comment 24 (*2), one of new behavior's fault is
on Gecko side too.  The style of `<input>` element or `<textarea>` element
which has too long text after pasting is changed when it loses focus.
Therefore, users can post the data before they know pasted data is too
long if sending the form data with `Enter` key or something immediately
after pasting (i.e., without moving focus) web apps handle it by themselves.

On the other hand, the original bug report, bug 1320229, should be solved in
the future especially in password field because users may register password
which is cut by `maxlength` silently and they don't use builtin password
manager, only the pasted password is saved, and then, they won't be able to
login as the account.  This is really long standing issue of the web forms.
An article (*3) warned this to web developers in 2011.  Therefore, we should
keep going advance for solving this issue at least in Nightly channel to get
more feedback from testers and web developers.

1 https://bugzilla.mozilla.org/show_bug.cgi?id=1636855#c7
2 https://bugzilla.mozilla.org/show_bug.cgi?id=1636855#c24
3 https://www.christophermanning.org/writing/dont-use-maxlength-on-password-inputs

Differential Revision: https://phabricator.services.mozilla.com/D78613
2020-06-07 21:29:48 +00:00
Bogdan Tara 86d1eef7a6 Backed out changeset 6e99a3e6c77b (bug 1642588) for test_bug1642588.html failures CLOSED TREE 2020-06-06 02:45:52 +03:00
Masayuki Nakano bb4b3d4e9d Bug 1642270 - Make `EditorBase::MaybeHasMutationEventListeners()` always return `true` in debug build for testing complicated path r=m_kato
According to the telemetry data, almost all web apps in the word do not use
mutation event listeners, but if they are used, editor needs to check
whether modifying node is modified by web apps.  The checking cost may not
cheap in some cases.  Therefore, we check whether the window has at least one
mutation event listeners or not before non-cheap checking.

However, like actual web apps, most our mochitests and WPT do not add
mutation event listeners.  Therefore, such additional checking code is not
tested even though they should work as exactly same as the case when
there are mutation event listeners but they don't touch the DOM.

This patch makes it always return only in debug build for checking the
complicated path.

Differential Revision: https://phabricator.services.mozilla.com/D78173
2020-06-05 19:25:18 +00:00
Kagami Sascha Rosylight e29858d3ad Bug 1642588 - Make Triple click only select within editing host r=masayuki,emilio
Differential Revision: https://phabricator.services.mozilla.com/D78315
2020-06-05 22:45:30 +00:00
Bogdan Tara 1ba73a9900 Backed out changeset 094a2fc0fc50 (bug 1642588) for test_bug1642588.html failures CLOSED TREE 2020-06-05 21:50:36 +03:00
Kagami Sascha Rosylight d02396bd67 Bug 1642588 - Make Triple click only select within editing host r=masayuki,emilio
Differential Revision: https://phabricator.services.mozilla.com/D78315
2020-06-05 13:41:26 +00:00
Kagami Sascha Rosylight 45b185573f Bug 1632425 - Part 3: Triple click to select anchors r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D77683
2020-06-03 23:47:55 +00:00
Kagami Sascha Rosylight c948a3aa98 Bug 1632425 - Part 2: Mark const methods as such r=masayuki
Depends on D77812

Differential Revision: https://phabricator.services.mozilla.com/D77942
2020-06-03 03:08:58 +00:00
Kagami Sascha Rosylight 60c853771e Bug 1632425 - Part 1: Add EditorUtils::IsPointInSelection() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D77812
2020-06-03 03:08:05 +00:00
Razvan Maries a36bb7751f Backed out 3 changesets (bug 1638153) for perma failures on cross-origin-objects.html. CLOSED TREE
Backed out changeset f7aedc92d396 (bug 1638153)
Backed out changeset 07ec713926c6 (bug 1638153)
Backed out changeset 5a656842e241 (bug 1638153)
2020-06-01 23:51:35 +03:00
Kris Maglione b3fcd970ec Bug 1638153: Part 2 - Fix uses of .rootTreeItem to get top browser window. r=geckoview-reviewers,nika,snorp
Differential Revision: https://phabricator.services.mozilla.com/D75429
2020-06-01 17:59:01 +00:00
Emilio Cobos Álvarez 54fd961a29 Bug 1641245 - Make string comparators not virtual. r=froydnj,necko-reviewers,geckoview-reviewers,jgilbert,agi,valentin
There's no use case for stateful comparators, so they can be just plain
function pointers.

This is used in some hot places like CSS selector matching.

Differential Revision: https://phabricator.services.mozilla.com/D77084
2020-05-27 18:11:12 +00:00
Emilio Cobos Álvarez 525520f10b Bug 1640601 - Also reframe the closest non-anonymous root when switching anonymous content from display: none to something else. r=mats
We were dealing with it correctly when switching display from e.g. block
to inline, or such. But we were not dealing with it when the node was
undisplayed.

Handle it properly, and free one frame bit while at it. We can't really
do this for ManualNAC (the editor resizers) because they request a
reframe explicitly.

Differential Revision: https://phabricator.services.mozilla.com/D76679
2020-05-25 23:54:10 +00:00
Emilio Cobos Álvarez 89958b377a Bug 1640605 - Remove IsInAnonymousSubtree / IsRootOfAnonymousSubtree. r=edgar
In favor of the NativeAnonymous versions which they forward to.

Done automatically with:

  rg -l 'IsInAnonymousSubtree' | xargs sed -i 's/IsInAnonymousSubtree/IsInNativeAnonymousSubtree/g'

And removing the function definitions afterwards.

Differential Revision: https://phabricator.services.mozilla.com/D76681
2020-05-25 11:43:51 +00:00