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

152 Коммитов

Автор SHA1 Сообщение Дата
Andi-Bogdan Postelnicu b6b336c821 Bug 1683534 - Make `editor` buildable outside of `unified-build` environment. r=sg
Differential Revision: https://phabricator.services.mozilla.com/D100206
2021-01-04 14:18:50 +00:00
Masayuki Nakano 9b606cfb10 Bug 1624005 - Make `WSScanResult` have error state and make the scan methods of `WSRunScanner` use it when it fails to initialize `TextFragmentData` r=m_kato
The test runs `execCommand("insertHorizontalRule")` when the document node
has no children.  In this case, `TextFragmentData` fails to initialize itself.
In this case, our editor cannot do anything.  Therefore, returning error
in this case must be better.

This patch makes all callers of the scan methods handle the error case unless
the caller cannot return error.

Comparing with Blink, perhaps, we should insert `<html>` and `<body>` element
in this case first and keep doing the requested operation in the future.
Currently, doing it may cause another complicated issue with mutation event
listeners.

Differential Revision: https://phabricator.services.mozilla.com/D95126
2020-10-30 07:33:39 +00:00
Masayuki Nakano a9cd962def Bug 1658702 - part 22: Get rid of wrong `MOZ_ASSERT`s in `WSRunScanner::GetRangeExtendToContainInvisibleWhiteSpacesAtRangeBoundaries()` r=m_kato
If deleting/replacing range selects a text node, it may shrink the range
to start and end of the text node.  So, the result may not be wider than
the original range.

This behavior is compatible with Blink.

Depends on D90639

Differential Revision: https://phabricator.services.mozilla.com/D90640
2020-09-27 06:02:38 +00:00
Masayuki Nakano 969699a0f3 Bug 1658702 - part 12: Implement paths to compute ranges to delete non-collapsed ranges r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/8a0745cd346f0cfb89ae71690babbf7bff706113/editor/libeditor/HTMLEditSubActionHandler.cpp#3531-3537
* https://searchfox.org/mozilla-central/rev/8a0745cd346f0cfb89ae71690babbf7bff706113/editor/libeditor/HTMLEditSubActionHandler.cpp#4443-4561
* https://searchfox.org/mozilla-central/rev/8a0745cd346f0cfb89ae71690babbf7bff706113/editor/libeditor/HTMLEditSubActionHandler.cpp#2778-2822

Note that the new failure of `input-events-get-target-ranges-forwarddelete.html`
is mismatch between target range (including the trailing white-space) and
actually deleted range (not including the trailing white-space).  Let's
accept this new failure for now since not so important problem and same test
with backspace has same bug.

Differential Revision: https://phabricator.services.mozilla.com/D89870
2020-09-16 10:55:22 +00:00
Masayuki Nakano e09be3fb17 Bug 1664109 - Fix `!=` operator of `EditorDOMRangeBase` r=m_kato
This is causes taking back bugs in
`WSRunScanner::GetNewInvisibleLeadingWhiteSpaceRangeIfSplittingAt()` and
`WSRunScanner::GetNewInvisibleTrailingWhiteSpaceRangeIfSplittingAt()`  (I.e.,
they were fixed by bug 1647556).  Therefore, this removes the odd `if` blocks
which are pointed with `XXX` comment for avoiding "regressions" (without them,
some WPTs for `InputEvents.getTargetRanges()` become failure).

Depends on D89582

Differential Revision: https://phabricator.services.mozilla.com/D89869
2020-09-16 02:17:33 +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 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 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 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 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 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
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 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 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 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
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
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 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
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 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
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 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 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
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
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
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
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
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
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