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

10418 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 0e90b72f58 Bug 1663370 - part 3: Use early-return style when `AutoInclusiveAncestorBlockElementsJoiner::Prepare()` returns `false` r=m_kato
Note that in such cases, current code mark the results as both "canceled" and
"handled", but only "canceled" state is important for the root caller.
* https://searchfox.org/mozilla-central/rev/ac142717cc067d875e83e4b1316f004f6e063a46/editor/libeditor/HTMLEditSubActionHandler.cpp#4200-4204
* https://searchfox.org/mozilla-central/rev/ac142717cc067d875e83e4b1316f004f6e063a46/editor/libeditor/HTMLEditSubActionHandler.cpp#3452-3457
* https://searchfox.org/mozilla-central/rev/ac142717cc067d875e83e4b1316f004f6e063a46/editor/libeditor/HTMLEditSubActionHandler.cpp#3100-3125

Depends on D89572

Differential Revision: https://phabricator.services.mozilla.com/D89573
2020-09-14 03:44:54 +00:00
Masayuki Nakano a87c9efc84 Bug 1663370 - part 2: Move `AutoTrackDOMPoint` for `AutoInclusiveAncestorBlockElementsJoiner::Run()` into the minimum scope r=m_kato
Now, `AutoInclusiveAncestorBlockElementsJoiner::Run()` is wrapped by a
small block in every caller.  Therefore, `AutoTrackDOMPoint` for it can
be moved into the small blocks.

Depends on D89571

Differential Revision: https://phabricator.services.mozilla.com/D89572
2020-09-14 01:36:42 +00:00
Masayuki Nakano c326309928 Bug 1663370 - part 1: Make `AutoInclusiveAncestorBlockElementsJoiner::Prepare()` stop returning `EditActionResult` r=m_kato
For making the refactoring patch simpler, `Prepare()` considers the
`EditActionResult` value of its callers instead.  However, this is odd
so that it just return whether the caller should keep working with
it or not as `bool` result.  Then, for the additional information, whether
the caller should consume the edit action handling or not, this patch
adds a new method, `CanJoinBlocks()`.

Depends on D89440

Differential Revision: https://phabricator.services.mozilla.com/D89571
2020-09-14 01:25:52 +00:00
longsonr da2fc5609a Bug 1664699 - Remove unused HTMLEditor::GetHTMLDocument method r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D90039
2020-09-14 01:54:33 +00:00
Timothy Nikkel 30f528e804 Bug 1664446. Properly wait to make sure any potential scroll events get fired in several tests. r=kats
Doing rAF rAF flushApzRepaints is not enough to make sure that any potential scroll events are sent to content. The reason is that if the apz repaint request causes us to do scrolling on the main thread then the scrolling will be finished after flushApzRepaints, and the scroll event will be pending, but it's not sent until the next refresh driver tick. So we need to do at least one rAF after flushApzRepaints.

Differential Revision: https://phabricator.services.mozilla.com/D90035
2020-09-13 20:21:11 +00:00
Timothy Nikkel 3fa3a926a6 Bug 1664446. Disable zoom to focus input for mochitests in editor/libeditor/tests/. r=botond
I think the scrolls that zoom to focus input causes are giving us scroll events that we don't expect. I don't think there is a better way around this.

Differential Revision: https://phabricator.services.mozilla.com/D89993
2020-09-11 23:30:26 +00:00
Timothy Nikkel fa760298a9 Bug 1664446. Increase fuzz in editor/libeditor/tests/test_selection_move_commands.html slightly. r=botond
Disabling zoom to focused input seems to have slightly changed how much fuzz we get when comparing scroll position.

Differential Revision: https://phabricator.services.mozilla.com/D90005
2020-09-12 01:24:23 +00:00
Emilio Cobos Álvarez 20252cfeaf Bug 1664411 - Factor out a condition to unconditionally enable clipboard events in some documents. r=masayuki
This patch shouldn't introduce any behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D89834
2020-09-11 11:08:35 +00:00
Timothy Nikkel 86ef6eea77 Bug 1663537. Fix various tests for desktop zooming scrollbars. r=kats
The test fixes all fell into the follow categories:

A) The test uses requestAnimationFrame to wait one frame and expects scrolling to be complete. With the desktop zooming scrollbars in order for the scrolling to show up on the main thread we need to send the scroll request to the compositor and then hear back from it via an apz repaint request (apz callback helper). Waiting on requestAnimationFrame will complete the first part, but not necessarily the second part. The fix is to wait for a scroll event.

B) Switching tests to wait for scroll events exposes another problem: the test can do things that cause a scroll in order to setup the test (and that may not be obvious that it causes a scroll) before actually proceeding to do the test and do something that causes a scroll and then checks for the scroll change of the second thing. Waiting for a requestAnimationFrame would include both those scrolls without desktop zooming scrollbars, but if we wait for a scroll event we will get the scroll event for the first thing which we are not interested in. So we need to make sure scroll events are cleared out before waiting for any scroll events. We do this by waiting two requestAnimationFrame's and waiting for apz to be flushed. We also use this when a test does something and it wants to test that scrolling is not performed.

The main thing that causes scrolling that may not be obvious: calling node.focus(). With stacks like:

from test_scroll_per_page.html

```
#01: mozilla::ScrollFrameHelper::CompleteAsyncScroll(nsRect const&, mozilla::ScrollOrigin) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x47d6cc0]
#02: mozilla::ScrollFrameHelper::ScrollToWithOrigin(nsPoint, mozilla::ScrollMode, mozilla::ScrollOrigin, nsRect const*, nsIScrollbarMediator::ScrollSnapMode) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x47d7732]
#03: mozilla::layout::ScrollAnchorContainer::ApplyAdjustments() [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4742913]
#04: mozilla::PresShell::FlushPendingScrollAnchorAdjustments() [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4650069]
#05: mozilla::PresShell::ProcessReflowCommands(bool) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x465742b]
#06: mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4656af8]
#07: mozilla::dom::Document::FlushPendingNotifications(mozilla::ChangesToFlush) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1a87d3c]
#08: mozilla::PresShell::ScrollContentIntoView(nsIContent*, mozilla::ScrollAxis, mozilla::ScrollAxis, mozilla::ScrollFlags) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4652b96]
#09: nsFocusManager::ScrollIntoView(mozilla::PresShell*, nsIContent*, unsigned int) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1bedd1c]
#10: nsFocusManager::Focus(nsPIDOMWindowOuter*, mozilla::dom::Element*, unsigned int, bool, bool, bool, bool, bool, nsIContent*) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be6be0]
#11: nsFocusManager::SetFocusInner(mozilla::dom::Element*, int, bool, bool) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be212f]
#12: nsFocusManager::SetFocus(mozilla::dom::Element*, unsigned int) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be32ba]
#13: mozilla::dom::Element::Focus(mozilla::dom::FocusOptions const&, mozilla::dom::CallerType, mozilla::ErrorResult&) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1aaf283]
#14: mozilla::dom::HTMLElement_Binding::focus(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x2d65f3b]
```

from editor/libeditor/tests/test_bug549262.html

```
#01: mozilla::ScrollFrameHelper::CompleteAsyncScroll(nsRect const&, mozilla::ScrollOrigin) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x47d6cc0]
#02: mozilla::ScrollFrameHelper::ScrollToWithOrigin(nsPoint, mozilla::ScrollMode, mozilla::ScrollOrigin, nsRect const*, nsIScrollbarMediator::ScrollSnapMode) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x47d7732]
#03: mozilla::PresShell::ScrollFrameRectIntoView(nsIFrame*, nsRect const&, mozilla::ScrollAxis, mozilla::ScrollAxis, mozilla::ScrollFlags) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x46541bc]
#04: mozilla::PresShell::DoScrollContentIntoView() [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4653776]
#05: mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4656b11]
#06: mozilla::dom::Document::FlushPendingNotifications(mozilla::ChangesToFlush) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1a87d3c]
#07: mozilla::PresShell::ScrollContentIntoView(nsIContent*, mozilla::ScrollAxis, mozilla::ScrollAxis, mozilla::ScrollFlags) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4652b96]
#08: nsFocusManager::ScrollIntoView(mozilla::PresShell*, nsIContent*, unsigned int) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1bedd1c]
#09: nsFocusManager::Focus(nsPIDOMWindowOuter*, mozilla::dom::Element*, unsigned int, bool, bool, bool, bool, bool, nsIContent*) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be6be0]
#10: nsFocusManager::SetFocusInner(mozilla::dom::Element*, int, bool, bool) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be212f]
#11: nsFocusManager::SetFocus(mozilla::dom::Element*, unsigned int) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be32ba]
#12: mozilla::dom::Element::Focus(mozilla::dom::FocusOptions const&, mozilla::dom::CallerType, mozilla::ErrorResult&) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1aaf283]
#13: mozilla::dom::HTMLElement_Binding::focus(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x2d65f3b]
```

C) Several tests use nsIDOMWindowUtils advanceTimeAndRefresh/restoreNormalRefresh and expect scrolling to be done after a call to advanceTimeAndRefresh. This is basically A), advanceTimeAndRefresh does a refresh driver tick but doesn't allow a repaint request to come back to the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D89403
2020-09-11 10:45:28 +00:00
Emilio Cobos Álvarez 3ccd260400 Bug 1664114 - Try to find a more usable selection for copy-paste if copying from an HTMLEditor. r=masayuki
See the bug for the complications that made me write this slightly hacky
fix... Other solutions definitely welcome.

Add a test, adjusted so it would fail without the change.

Differential Revision: https://phabricator.services.mozilla.com/D89835
2020-09-11 09:14:07 +00:00
Kagami Sascha Rosylight eb9d5c9792 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-09-09 23:45:45 +00:00
Kagami Sascha Rosylight a9222dc61e 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-09-09 23:45:37 +00:00
Masayuki Nakano 8bb9ef510a Bug 1663601 - Make `RangeBoundaryBase::GetNextSiblingOfChildAtOffset()` check whether `mRef` is nullptr or not r=mbrodesser
`RangeBoundaryBase` stores a previous sibling of child node at offset with
`mRef`.  Therefore, even if the callers check whether its instance points a
child node, `mRef` may be `nullptr` when it points first child of its container.
So, `GetNextSiblingOfChildAtOffset()` needs to handle the case.

This patch adds the crash case test into
`test_dom_input_event_on_htmleditor.html` because of a basic behavior.
For now, this patch adds 2 chunks which are coded with using same style as
previous ones.  However, the test should be redesigned later for making
non-dependency of each chunk guaranteed.  (The new chunks are completely
independent from previously running tests.)

Differential Revision: https://phabricator.services.mozilla.com/D89440
2020-09-09 11:19:04 +00:00
Jonathan Kew 60e923ac0b Bug 1533462 - Add a possible retry step in test_bug1200533 to handle potential disruption by font-list refresh. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D89120
2020-09-07 16:20:56 +00:00
Masayuki Nakano 3ed5c1ea83 Bug 1658702 - part 9: Add `AutoDeleteRangesHandler::ComputeRangesToDeleteHRElement()` to compute the target range for deleting `<hr>` element r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3362-3375
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3679-3695
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3728-3742

Note that the complicated cases (surrounded by invisible `<br>` element and/or
surrounded by invisible white-spaces) are handled as deleting non-collapsed
range so that this improves only the simple cases.

And also this adds a pref to disable the Gecko specific complicated `<hr>`
element handling.

Differential Revision: https://phabricator.services.mozilla.com/D88969
2020-09-07 03:09:30 +00:00
Masayuki Nakano 76a83d0a21 Bug 1661893 - Make `WhiteSpaceVisibilityKeeper::ReplaceText()` refer replacing range end information to consider whether the last ASCII white-space of inserting string should be replaced with an NBSP or not r=m_kato
This is simple mistake of the patch:
https://phabricator.services.mozilla.com/D82286

The method refers start of replacing range to consider whether replace or
keep last ASCII white-space of inserting string, but it should refer the
end of the replacing range, of course.

Differential Revision: https://phabricator.services.mozilla.com/D89124
2020-09-07 03:20:35 +00:00
Masayuki Nakano dc906b0477 Bug 1658702 - part 8: Add `AutoDeleteRangesHandler::ComputeRangesToDeleteAtomicContent()` to compute atomic content deleting target range r=m_kato
This patch corresponds to the following part:
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3346-3360
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3750-3761
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/WSRunObject.cpp#1075-1113

Let's return a range selecting the deleting atomic content (i.e., between
`EditorDOMPoint(&content)` and `EditorDOMPoint::After(content)`).

For doing it, we need to shrink the computed range after
`AutoRangeArray::ExtendAnchorFocusRangeFor()` because layout code puts
range boundaries to start or end of text node in this case.

Then, surprisingly, our deletion code have not used
`HandleDeleteCollapsedSelectionAtAtomicContent()` in most cases because
`AutoRangeArray::ExtendAnchorFocusRangeFor()` makes the collapsed range
to non-collapsed.  For making the deletion faster and simpler, this patch
shrinks the result of `AutoRangeArray::ExtendAnchorFocusRangeFor()` if
it has only one range and selects only one atomic content node.

Differential Revision: https://phabricator.services.mozilla.com/D88968
2020-09-07 04:59:22 +00:00
Masayuki Nakano f1c2353722 Bug 1658702 - part 7: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` compute text deletion range from a collapsed range r=m_kato
Just for computing the deletion range, we can use new path for the Blink-compat
white-space normalizer.

This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3278-3284
* https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3298-3344
* https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3422-3455

Differential Revision: https://phabricator.services.mozilla.com/D88941
2020-09-04 11:30:52 +00:00
Masayuki Nakano 1bc1fa2c82 Bug 1658702 - part 6: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` skip the case deleting an invisible `<br>` element for now r=m_kato
For implementing this case, we need more helper methods.  Let's do this after
implementing other cases.
https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3207-3276

Depends on D88939

Differential Revision: https://phabricator.services.mozilla.com/D88940
2020-09-04 02:34:41 +00:00
Masayuki Nakano 040765e7aa Bug 1658702 - part 5: Add preparation part for deleting collapsed range to `AutoDeleteRangesHandler::ComputeRangesToDelete()` r=m_kato
This patch implements the preparation part of deleting collapsed range.
https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3188-3206

Depends on D88379

Differential Revision: https://phabricator.services.mozilla.com/D88939
2020-09-01 08:01:34 +00:00
Kagami Sascha Rosylight 11ef0ef23e Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
Depends on D88702

Differential Revision: https://phabricator.services.mozilla.com/D88920
2020-09-03 03:45:26 +00:00
Mihai Alexandru Michis 0600dacd03 Backed out 3 changesets (bug 1623413) for causing failures in Selection_collapse.html
CLOSED TREE

Backed out changeset d3d67293f115 (bug 1623413)
Backed out changeset 75ed1b8a5c67 (bug 1623413)
Backed out changeset 0eef32d6a454 (bug 1623413)
2020-09-03 05:37:49 +03:00
Kagami Sascha Rosylight 010d7de462 Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
Depends on D88702

Differential Revision: https://phabricator.services.mozilla.com/D88920
2020-09-02 23:42:27 +00:00
Aaron Klotz 14408edb59 Bug 1662313: Add a wait on a selectionchange event to test_resizers_resizing_elements to prevent race condition in test; r=masayuki DONTBUILD
Wait for `selectionchange` to ensure that input events have been processed
before verifying a target's bounds.

Differential Revision: https://phabricator.services.mozilla.com/D88936
2020-09-01 04:46:04 +00:00
Mirko Brodesser 7056730ef8 Bug 1649121: part 85) Follow-up for part 74. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88430
2020-08-31 12:30:54 +00:00
Mirko Brodesser d396b5502a Bug 1649121: part 78) Revert part 77. r=masayuki
The assertion added in part 77 isn't violated, but it needs exhaustive
analysis to ensure it's indeed intended to not be violated.

Differential Revision: https://phabricator.services.mozilla.com/D88258
2020-09-01 02:07:24 +00:00
Masayuki Nakano 06407fa939 Bug 1658702 - part 4: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` extend collapsed ranges for deleting adjacent character or word or the line r=m_kato
This patch adding computation code corresponding to:
https://searchfox.org/mozilla-central/rev/27932d4e6ebd2f4b8519865dad864c72176e4e3b/editor/libeditor/HTMLEditSubActionHandler.cpp#3157-3185

For `beforeinput` event listeners, `AutoSetTemporaryAncestorLimiter` is not
enough since when `beforeinput` event listeners modifies `Selection`, the
ancestor limit is not set when it has a job.  Perhaps, we should make editor
stop using focus/blur event listener and makes `nsFocusManager` notifies
editor of them synchronously before dispatching the events.  But it's not
scope of this bug at least.

Differential Revision: https://phabricator.services.mozilla.com/D88379
2020-09-01 02:04:02 +00:00
Masayuki Nakano c8894e5ea6 Bug 1658702 - part 3: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` quit without modifying the ranges when it shouldn't delete adjacent character(s) in bidi text r=m_kato
This change is corresponding to the part:
https://searchfox.org/mozilla-central/rev/73a14f1b367948faa571ed2fe5d7eb29460787c1/editor/libeditor/HTMLEditSubActionHandler.cpp#3143-3155

When caret is not adjacent the deleting character in bidi text, we may do
nothing except putting caret to the character.  So, `ComputeRangesToDelete()`
shouldn't update the caret position since the caret position will be check
by its `Run()` later if `beforeinput` event is not canceled.  For avoiding
the code duplication, this patch reimplements
`EditorBase::SetCaretBidiLevelForDeletion()` as a stack only class and
split the check and updating part from correcting the data.

Note that by the default pref, the new tests failed since it won't be
canceled, and the method still don't compute for deleting a character.

Differential Revision: https://phabricator.services.mozilla.com/D88378
2020-09-01 02:03:23 +00:00
Masayuki Nakano f94c0a973f Bug 1658702 - part 2: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` handle the case deleting empty ancestor(s) r=m_kato
This patch implements computation of target ranges for this part:
https://searchfox.org/mozilla-central/rev/73a14f1b367948faa571ed2fe5d7eb29460787c1/editor/libeditor/HTMLEditSubActionHandler.cpp#3099-3141

This patch adds some utility methods for computing the ranges.  Currently,
it's not yet standardized, but the other browser engines look for leaf content
of another block when blocks are joined (or a block is deleted like this case).
Therefore, we follow the behavior basically, but different from the other
browsers, we should include invisible white-spaces into the range when they
are included.  That avoids the invisible white-spaces become visible when
web apps do something instead of us.  Note that utility methods have the code,
but this patch does not use it because in this case, we just delete a empty
block ancestor, not join it with previous/next block.

Differential Revision: https://phabricator.services.mozilla.com/D88377
2020-09-01 02:02:50 +00:00
Mihai Alexandru Michis e0f7ab5885 Backed out changeset bacd9a2d26c1 (bug 1658702) for causing hazard bustages in HTMLEditSubActionHandler.cpp
CLOSED TREE
2020-08-31 13:29:36 +03:00
Masayuki Nakano a43b290e4e Bug 1658702 - part 2: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` handle the case deleting empty ancestor(s) r=m_kato
This patch implements computation of target ranges for this part:
https://searchfox.org/mozilla-central/rev/73a14f1b367948faa571ed2fe5d7eb29460787c1/editor/libeditor/HTMLEditSubActionHandler.cpp#3099-3141

This patch adds some utility methods for computing the ranges.  Currently,
it's not yet standardized, but the other browser engines look for leaf content
of another block when blocks are joined (or a block is deleted like this case).
Therefore, we follow the behavior basically, but different from the other
browsers, we should include invisible white-spaces into the range when they
are included.  That avoids the invisible white-spaces become visible when
web apps do something instead of us.  Note that utility methods have the code,
but this patch does not use it because in this case, we just delete a empty
block ancestor, not join it with previous/next block.

Differential Revision: https://phabricator.services.mozilla.com/D88377
2020-08-31 08:33:14 +00:00
Masayuki Nakano cb8cfd084a Bug 1658702 - part 1: Create a path to compute target ranges of deleting edit actions for `beforeinput` events on `HTMLEditor` r=m_kato
In strictly speaking, we should use same computed target ranges for any edit
actions which causes removing non-collapsed selection.  However, for now,
this patch makes only `DeleteSelectionAsAction()` because it's not so important
differences for shipping `beforeinput` in Nightly channel.

Differential Revision: https://phabricator.services.mozilla.com/D88376
2020-08-31 03:48:39 +00:00
Jonathan Kew 84a6685131 Bug 1533462 - Execute the deferred font-info loader immediately when running spell-check and animation mochitests, to avoid intermittent issues. r=jwatt
Depends on D87194

Differential Revision: https://phabricator.services.mozilla.com/D87195
2020-08-30 22:59:57 +00:00
Mirko Brodesser 26fc5e08a4 Bug 1649121: part 77) `MOZ_ASSERT` html info is only provided when there's html context. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88257
2020-08-28 12:56:29 +00:00
Mirko Brodesser e564162061 Bug 1649121: part 76) Factor `IsInsertionCookie` out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88247
2020-08-28 10:28:39 +00:00
Mirko Brodesser e5822e1262 Bug 1649121: part 75) Declare `FragmentFromPasteCreator`'s `Document` argument `const`. r=masayuki
Simplifies reasoning about it.

Differential Revision: https://phabricator.services.mozilla.com/D88119
2020-08-27 15:00:00 +00:00
Mirko Brodesser 9c5b92954c Bug 1649121: part 74) Pass `Document` instead of `HTMLEditor` to `CreateDocumentFragmentFromPaste`. r=masayuki
`CreateDocumentFragmentFromPaste` doesn't need to know about
`HTMLEditor`, `Document` suffices.

Differential Revision: https://phabricator.services.mozilla.com/D88118
2020-08-28 10:27:30 +00:00
Mirko Brodesser 355bcdd416 Bug 1652557: remove failure expectation for "test_resizers_resizing_elements.html" when xorigin iframes and fission are enabled. r=hsivonen
Fixed by bug 1653160.

Differential Revision: https://phabricator.services.mozilla.com/D88563
2020-08-28 09:59:39 +00:00
Masayuki Nakano 5bca4199fb Bug 1660378 - part 9: Avoid QI for getting `nsStyledElement` pointer r=smaug
The editor modules does QI too many times when it sets or removes some style
with `execCommand` or XPCOM API.  Therefore, there should be an API to
retrieve `nsStyledElement` pointer from `nsINode*`.

Differential Revision: https://phabricator.services.mozilla.com/D87990
2020-08-26 05:29:06 +00:00
Masayuki Nakano b500d7d549 Bug 1660378 - part 8: Make `HTMLEditor::IsSimpleModifiableNode()` take `Element&` instead of `nsIContent*` r=m_kato
Although it starts to return error if it causes destroying the editor, but
it should not occur because it modifies new and orphan node and it shouldn't
kick any mutation event listeners.  Therefore, this patch makes the callers
handle error as-is rather than ignoring errors except
`NS_ERROR_EDITOR_DESTROYED`.

Differential Revision: https://phabricator.services.mozilla.com/D87989
2020-08-26 04:48:36 +00:00
Masayuki Nakano bc279d2448 Bug 1660378 - part 7: Make `CSSEditUtils::SetCSSEquivalentToHTMLStyle()` take `nsStyledElement&` instead of `Element*` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87988
2020-08-26 04:48:32 +00:00
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 `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