Commit Graph

10227 Commits

Author SHA1 Message Date
longsonr
dee8245fe3 Bug 1664788 - rewrite nsEditingSession::SetupEditorOnWindow r=masayuki
Avoid converting strings from UTF16 to ASCII

Differential Revision: https://phabricator.services.mozilla.com/D90092
2020-09-15 14:40:54 +00:00
Masayuki Nakano
620c728792 Bug 1658702 - part 10: Implement a path to compute target ranges when joining 2 blocks from current block boundary r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/HTMLEditSubActionHandler.cpp#3525-3543
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/HTMLEditSubActionHandler.cpp#2710-2719
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/HTMLEditSubActionHandler.cpp#4140-4165
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/HTMLEditSubActionHandler.cpp#5650-5716
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/WSRunObject.cpp#97-213
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/WSRunObject.cpp#218-386
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/WSRunObject.cpp#391-480

In `WSRunObject.cpp`, joining 2 blocks code is split to 3 methods, they are
for:

1. left block element is an ancestor of right block element
2. right block element is an ancestor of left block element
3. left block element and right block element are siblings

The reason why they are split to is, they need to move descendants of child
block element or right block element with different logic.  However, this
difference is not a big problem when we compute target ranges because only
the difference is where we need to check whether there are invisible white-
spaces.  Therefore, this patch creates only a utility method in `WSRunScanner`
and makes `AutoInclusiveAncestorBlockElementsJoiner::ComputeRangesToDelete()`
much simpler than `AutoInclusiveAncestorBlockElementsJoiner::Run()`.

Differential Revision: https://phabricator.services.mozilla.com/D89278
2020-09-11 06:24:08 +00:00
Masayuki Nakano
d060d644d6 Bug 1663797 - Make delete handler of HTMLEditor not try to join <html>, <head> and <body> r=m_kato
It'll fail to join them when its utility methods actually join them.
However, it should be considered earlier timing because the preparation
DOM tree changes before joining them causes creating odd tree (see the
removed cases of the test).  Therefore, we should make them stop handling
deletion before modifying the DOM tree.

Depends on D89579

Differential Revision: https://phabricator.services.mozilla.com/D89580
2020-09-15 07:33:58 +00:00
Masayuki Nakano
7effeb6cde Bug 1663370 - part 9: Make AutoInclusiveAncestorBlockElementsJoiner::Prepare() consider whether it will NOT join the elements or not r=m_kato
This makes `AutoInclusiveAncestorBlockElementsJoiner` stores whether `Run()`
will return "ignored" or not when `Prepare()` is called.  And this patch adds
`NS_ASSERTION()` to compare the result of `Run()` and the guess.

Note that this shouldn't used for considering whether its user call or not
`Run()` actually for the risk of regressions and if we do it with current
implementation, some web apps may be broken if they do modify the DOM tree
at white-space adjustment before joining the left and right block elements.

The method will be used by `ComputeTargetRanges()` which will be implemented
by bug 1658702.

Depends on D89578

Differential Revision: https://phabricator.services.mozilla.com/D89579
2020-09-15 06:07:01 +00:00
Masayuki Nakano
9ed84efbc7 Bug 1663370 - part 8: Make AutoInclusiveAncestorBlockElementsJoiner::Prepare() scan preceding invisible <br> element r=m_kato
When its `Run()` join the block elements, even if it won't move any content
nodes in first line, it may notify the callers as "handled" when there is a
preceding invisible `<br>` element since it needs to delete it in any cases.
Therefore, whether there is or not a preceding invisible `<br>` element is
important to compute target ranges since if there is one, `Run()` won't return
"ignored" and the callers won't delete leaf content instead.

Note that the new assertions are not hit in any tests, but due to searching
preceding invisible `<br>` element in `Prepare()`, expected assertion
count of 2 tests is increased.

Depends on D89577

Differential Revision: https://phabricator.services.mozilla.com/D89578
2020-09-14 13:35:42 +00:00
Masayuki Nakano
4a6cf53eeb Bug 1663370 - part 7: Make AutoInclusiveAncestorBlockElementsJoiner::Prepare() check the relation of its mLeftBlockElement and mRightBlockElement r=m_kato
The relation is important when the class handles both joining them and computing
target ranges.  Additionally, it's required to consider whether it can join the
block elements.  So, it should store the relation when `Prepare()` is called.

Depends on D89576

Differential Revision: https://phabricator.services.mozilla.com/D89577
2020-09-14 11:40:34 +00:00
Masayuki Nakano
da0f19a5f3 Bug 1663370 - part 6: Create a method to check whether HTMLEditor::MoveOneHardLineContents() returns "handled" or "canceled" r=m_kato
Unfortunately, `HTMLEditor::MoveOneHardLineContents()`,
`HTMLEditor::MoveChildrenWithTransaction()` and
`HTMLEditor::MoveNodeOrChildrenWithTransaction()` return strict result whether
at least one node is moved or not.  Therefore, we need to scan the DOM tree
whether there is at least one content node which can be moved by them for
computing target ranges.

We cannot do same thing for ``HTMLEditor::MoveOneHardLineContents()` because
it split parent elements first and use `ContentSubtreeIterator` which lists
up topmost nodes which are completely in the range, but we need to compute
target ranges without splitting nodes at the range boundaries.  Therefore,
this patch checks whether the line containing specified point has content
except invisible `<br>` element.

The others are simple.  We can use same logic with them.

Finally, this adds `NS_ASSERTION()`s to check whether the computation is done
correctly at running any automated tests on debug build, and I don't see any
failure with them.

Depends on D89575

Differential Revision: https://phabricator.services.mozilla.com/D89576
2020-09-14 10:54:42 +00:00
Masayuki Nakano
6355f06829 Bug 1663370 - part 5: Make helper methods of AutoInclusiveAncestorBlockElementsJoiner::Run() use simple constructor of EditActionResult when they return error r=m_kato
When they return error, neither "handled" nor "canceled" state is referred.
So, for making the code simpler, we can make them return
`EditActionResult(NS_ERROR_*)` instead of `EditActionIgnored(NS_ERROR_*)`.

Depends on D89574

Differential Revision: https://phabricator.services.mozilla.com/D89575
2020-09-14 07:25:08 +00:00
Masayuki Nakano
f081792788 Bug 1663370 - part 4: Sort out "handled" state settings around AutoInclusiveAncestorBlockElementsJoiner users r=m_kato
The 2 of them always mark the edit action as "handled", but it's not important
when it's "canceled" or an error.  Therefore, we can make the users simpler
as this patch does.

Depends on D89573

Differential Revision: https://phabricator.services.mozilla.com/D89574
2020-09-14 05:07:48 +00:00
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