Commit Graph

10227 Commits

Author SHA1 Message Date
Masayuki Nakano
decd85f7d6 Bug 1660378 - part 6: Make CSSEditUtils::SetCSSProperty() and its callers take nsStyledElement& instead of Element& r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87987
2020-08-26 04:48:28 +00:00
Masayuki Nakano
d03e0e65d8 Bug 1660378 - part 5: Make CSSEditUtils::RemoveCSSInlineStyle() take nsStyledElement& instead of nsINode& r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87986
2020-08-26 04:48:25 +00:00
Masayuki Nakano
67e64be5b4 Bug 1660378 - part 4: Make CSSEditUtils::DoElementsHaveSameStyle() take nsStyledElement& instead of Element& r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87985
2020-08-26 04:48:22 +00:00
Masayuki Nakano
2a4a68855c Bug 1660378 - part 3: Make CSSEditUtils::RemoveCSSEquivalentToHTMLStyle() take nsStyledElement& instead of Element* r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87984
2020-08-26 04:48:19 +00:00
Masayuki Nakano
801ca86f89 Bug 1660378 - part 2: Make CSSEditUtils::RemoveCSSPoperty() take nsStyledElement& instead of Element& r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87983
2020-08-26 04:48:16 +00:00
Masayuki Nakano
5d36739f8b Bug 1660378 - part 1: Get rid of CSSEditUtils::GetInlineStyles() r=m_kato
It should take `nsStyledElement&` instead of `const Element&`.  Then, it won't
fail and will just return the result of `nsStyleElement::Style()`.  Therefore,
we can get rid of it.

Note that this patch makes all its callers keep using strong pointer because
I'm not sure whether the layout APIs which are called with them are safe or
not.

Differential Revision: https://phabricator.services.mozilla.com/D87982
2020-08-26 04:48:12 +00:00
Masayuki Nakano
f75a7ec162 Bug 1658536 - part 8: Make AutoBlockElementsJoiner::HandleDeleteCollapsedSelectionAtOtherBlockBoundary() creates another instance of AutoDeleteRangesHandler by itself r=m_kato
When it returns `EditActionIgnored()`,
`AutoDeleteRangesHandler::HandleDeleteAroundCollapsedRanges()` creates another
`AutoDeleteRangesHandler` instance to delete leaf content node in another
block element.  However, this dependency makes developers understand the
behavior harder.  Therefore, we should make the method do it instead.

Differential Revision: https://phabricator.services.mozilla.com/D87439
2020-08-24 03:06:03 +00:00
Masayuki Nakano
68e817dd75 Bug 1658536 - part 7: Make HTMLEditor::HandleDeleteSelection() stop calling DeleteRangesWithTransaction() a fallback when AutoDeleteRangesHandler::Run() returns "ignored" r=m_kato
For avoiding infinite recursive calls, `AutoDeleteRangesHandler` returns
`EditActionIgnored()` when it needs to fall it back to
`DeleteRangesWithTransaction()` after modifying the DOM tree or the ranges
to delete.  However, this makes developers understand the code harder.
And now, with making constructor of `AutoDeleteRangesHandler` manage the
recursive call state, we can make `HandleDeleteSelection()` stop handling
the fallback path.

Differential Revision: https://phabricator.services.mozilla.com/D87438
2020-08-24 03:06:00 +00:00
Masayuki Nakano
fd1b043de1 Bug 1658536 - part 6: Move AutoEmptyBlockAncestorDeleter into AutoDeleteRangesHandler r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87437
2020-08-24 03:05:56 +00:00
Masayuki Nakano
cf5d24e31e Bug 1658536 - part 5: Move HTMLEditor::HandleDeleteSelectionInternal() into AutoDeleteRangesHandler r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87436
2020-08-24 03:05:53 +00:00
Masayuki Nakano
0a484e2bdb Bug 1658536 - part 4: Move some methods used only in AutoDeleteRangesHandler into the class r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87435
2020-08-24 00:53:32 +00:00
Masayuki Nakano
7a2da49ab3 Bug 1658536 - part 3: Move HTMLEditor::SelectionWasCollapsed into AutoDeleteRangesHandler r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87434
2020-08-24 00:53:13 +00:00
Masayuki Nakano
05434c1073 Bug 1658536 - part 2: Move AutoBlockElementsJoiner and AutoInclusiveAncestorBlockElementsJoiner into AutoDeleteRangesHandler r=m_kato
Even though their method names in stack trace become too long, but we can
guarantee that they are used only at handling deletion.

Differential Revision: https://phabricator.services.mozilla.com/D87433
2020-08-24 00:52:58 +00:00
Masayuki Nakano
cfc4ba0b10 Bug 1658536 - part 1: Move methods called by HTMLEditor::HandleDeleteSelectionInternal() to AutoDeleteRangesHandler r=m_kato
This patch just moves them into the new stack only class and make each of them
take `HTMLEditor&` as their first argument.

Differential Revision: https://phabricator.services.mozilla.com/D87432
2020-08-24 00:52:44 +00:00
Masayuki Nakano
4405418105 Bug 1659717 - Make AutoSetTemporaryAncestorLimiter update cached ranges if selection limiter is updated r=m_kato
If `AutoSetTemporaryAncestorLimiter` sets ancestor limiter of the `Selection`,
existing range which is already cached by `AutoRangeArray` may be changed
into the new limiter.

Therefore, this patch makes `AutoSetTemporaryAncestorLimiter` take
`AutoRangeArray` optionally and reset it only when it sets new limiter for
the performance.

Differential Revision: https://phabricator.services.mozilla.com/D87820
2020-08-24 08:54:56 +00:00
Masayuki Nakano
19c23d725f Bug 1659276 - Make AutoPlaceholderBatch choose whether do or do not ScrollSelectionIntoView r=m_kato
The root cause of this bug is a bug of async `ScrollSelectionIntoView` that
is what it won't be canceled even if web app changes scroll position with
any API.  Fixing it is really risky and this bug affects an existing website.
Therefore, this patch makes the constructors of `AutoPlaceholderBatch` take
whether do or do not `ScrollSelectionIntoView` when it's destructed.  And
makes `HTMLEditor::SetInlinePropertyAsAction()` not request
`ScrollSelectionIntoView` for taking back the traditional behavior.

Note that this patch does not make it an optional argument because it's hard to
guess that it'll run `ScrollSelectionIntoView` automatically.

Differential Revision: https://phabricator.services.mozilla.com/D87819
2020-08-24 06:39:50 +00:00
Chris Fronk
3b7a1daba2 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-22 15:47:59 +00:00
Simon Giesecke
cfd7d0ea9c Bug 1659923 - Avoid unnecessary copies around Base64Encode. r=xpcom-reviewers,necko-reviewers,froydnj,valentin
This also adds some more variants of Base64Encode and Base64EncodeAppend.

Differential Revision: https://phabricator.services.mozilla.com/D87559
2020-08-19 17:45:16 +00:00
Masayuki Nakano
37a2794486 Bug 1655388 - part 7: Split off the check whether <hr> element should be removed or not from HTMLEditor::HandleDeleteCollapsedSelectionAtHRElement() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87035
2020-08-19 06:48:31 +00:00
Masayuki Nakano
d84d4847b0 Bug 1655388 - part 6: Get rid of unnecessary arguments of HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent() and HTMLEditor::HandleDeleteCollapsedSelectionAtHRElement() r=m_kato
Depends on D87033

Differential Revision: https://phabricator.services.mozilla.com/D87034
2020-08-19 05:39:36 +00:00
Masayuki Nakano
c9bee9126b Bug 1655388 - part 5: Split the special handling for <hr> element off from HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent() r=m_kato
Depends on D87032

Differential Revision: https://phabricator.services.mozilla.com/D87033
2020-08-19 02:15:01 +00:00
Masayuki Nakano
416bf2f5ad Bug 1655388 - part 4: Get rid of WhiteSpaceVisiblityKeeper::PrepareToDeleteNode() r=m_kato
Now, the new method is only user of it.  So, we can get rid of it.

Depends on D87031

Differential Revision: https://phabricator.services.mozilla.com/D87032
2020-08-18 23:03:08 +00:00
Masayuki Nakano
e844854c69 Bug 1655388 - part 3: Make HTMLEditor::HandleDeleteSelectionInternal() use the new method when it removes an invisible <br> element r=m_kato
Even though it hasn't normalize white-spaces before invisible `<br>` element,
it needs to do it for making them visible.  Therefore, we should make it
use the new method in this case too.

Depends on D87030

Differential Revision: https://phabricator.services.mozilla.com/D87031
2020-08-18 09:23:16 +00:00
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 EditorDOMPoints 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