Commit Graph

10018 Commits

Author SHA1 Message Date
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 WSFragments 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 WSFragments 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 WSFragments 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