Make `WSRunScanner` and `WSRunObject` stop using array of `WSFragment`
Categories
(Core :: DOM: Editor, task, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox80 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
Details
(Whiteboard: [h2review-noted])
Attachments
(27 files)
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review |
WSFragment looks like that it abstractly explains its range's meaning and its array can explain any cases. However, it's created only for specific cases which WSRunScanner and WSRunObject want to do something and have incomplete data but enough for what they do something. This is a big reason why nobody cannot explain what WSRunObject is doing. So, there should be a new class instead of WSFragment and which explain what currently array of WSFragment explain with more self-documented methods.
| Assignee | ||
Comment 1•6 years ago
|
||
The patches too many, but I've not achieved what I planned. Therefore, I'd like to split this patch only for making WSRunScanner and WSRunObject stop using WSFragment array.
| Assignee | ||
Comment 2•6 years ago
|
||
This adds some WPTs for testing how to treat invisible leading and/or trailing
white-spaces in block elements. I think that they should be removed as far
as possible because they may become visible suddenly if browsers fail to handle
them with their bugs. However, it's acceptable if the result keeps white-
spaces as invisible. Therefore, this makes some new tests allow multiple
results.
| Assignee | ||
Comment 3•6 years ago
|
||
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
| Assignee | ||
Comment 4•6 years ago
|
||
This patch just creates new stack only class and make it initializes
WSRunScanner::mFragments instead of WSRunScanner.
Depends on D82269
| Assignee | ||
Comment 5•6 years ago
|
||
One of the WSFragmentusers' 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.
Depends on D82270
| Assignee | ||
Comment 6•6 years ago
|
||
Depends on D82272
| Assignee | ||
Comment 7•6 years ago
|
||
Different from GetInvisibleTrailingWhiteSpaceRange(), it always returns
the range even if it's collapsed (i.e., there is no leading white-space).
Depends on D82273
| Assignee | ||
Comment 8•6 years ago
|
||
Scrub() does remove leading white-spaces and trailing white-spaces if
there is. So, it does not require WSFragment anymore.
Depends on D82274
| Assignee | ||
Comment 9•6 years ago
|
||
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.
Depends on D82275
| Assignee | ||
Comment 10•6 years ago
|
||
This patch implements the case that when the range is not start of hard line.
Depends on D82276
| Assignee | ||
Comment 11•6 years ago
|
||
Depends on D82277
| Assignee | ||
Comment 12•6 years ago
|
||
It scans all WSFragments 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).
Depends on D82278
| Assignee | ||
Comment 13•6 years ago
|
||
They return a point in an WSFragment whose IsVisibleAndMiddleOfLine()
returns true or start/end of the range. Therefore, they can ignore the
other WSFragments and save comparing points to at most twice.
Depends on D82279
| Assignee | ||
Comment 14•6 years ago
|
||
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().
Depends on D82280
| Assignee | ||
Comment 15•6 years ago
|
||
Depends on D82281
| Assignee | ||
Comment 16•6 years ago
|
||
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.
Depends on D82282
| Assignee | ||
Comment 17•6 years ago
|
||
Similar to WSRunObject::InsertBreak(), WSRunObject::InsertText() can work
with the new API.
Depends on D82283
| Assignee | ||
Comment 18•6 years ago
|
||
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.
Depends on D82284
| Assignee | ||
Comment 19•6 years ago
|
||
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.
Depends on D82285
| Assignee | ||
Comment 20•6 years ago
|
||
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.
Depends on D82286
| Assignee | ||
Comment 21•6 years ago
|
||
Similar to the previous changes, WSRunObject::PrepareToDeleteRangePriv()
can use TextDataFragment::CreateWSFragmentForVisibleAndMiddleOfLine() and
result of comparing with deleting range.
Depends on D82287
| Assignee | ||
Comment 22•6 years ago
|
||
Similar to the previous patches, it can use invisible white-space ranges.
Depends on D82288
| Assignee | ||
Comment 23•6 years ago
|
||
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.
Depends on D82289
| Assignee | ||
Comment 24•6 years ago
|
||
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.
Depends on D82290
| Assignee | ||
Comment 25•6 years ago
|
||
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.
Depends on D82291
| Assignee | ||
Comment 26•6 years ago
|
||
Depends on D82292
| Assignee | ||
Comment 27•6 years ago
|
||
Now, WSFragment instances are created only by
TextFragmentData::CreateWSFragmentForVisibleWhiteSpaces(). Therefore, it's
always visible.
Additionally, this patch hides WSFragment constructors from the others too.
Depends on D82293
| Assignee | ||
Comment 28•6 years ago
|
||
Now, we can call WSFragment VisibleWhiteSpacesData. Then, the methods of
WSRunObject which take WSFragment as their arguments become clearer what
they mean.
Depends on D82294
| Assignee | ||
Updated•6 years ago
|
Updated•6 years ago
|
Comment 29•6 years ago
|
||
Comment 32•6 years ago
|
||
| bugherder | ||
Comment 34•6 years ago
|
||
Comment 35•6 years ago
|
||
| bugherder | ||
Comment 36•6 years ago
|
||
Comment 37•6 years ago
|
||
Comment 38•6 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 39•6 years ago
|
||
Comment 40•6 years ago
|
||
| bugherder | ||
Comment 41•6 years ago
|
||
| bugherder | ||
Comment 42•6 years ago
|
||
Comment 43•6 years ago
|
||
Comment 44•6 years ago
|
||
| bugherder | ||
Comment 45•6 years ago
|
||
Comment 46•6 years ago
|
||
| bugherder | ||
Comment 47•6 years ago
|
||
Comment 48•6 years ago
|
||
Comment 49•6 years ago
|
||
| bugherder | ||
Comment 50•6 years ago
|
||
| bugherder | ||
Comment 51•6 years ago
|
||
Comment 52•6 years ago
|
||
Comment 53•6 years ago
|
||
| bugherder | ||
Comment 54•6 years ago
|
||
Comment 55•6 years ago
|
||
| bugherder | ||
Comment 56•6 years ago
|
||
| bugherder | ||
Comment 57•6 years ago
|
||
Comment 58•6 years ago
|
||
Comment 59•6 years ago
|
||
Comment 60•6 years ago
|
||
Comment 61•6 years ago
|
||
Comment 62•6 years ago
|
||
Comment 63•6 years ago
|
||
| bugherder | ||
| Assignee | ||
Updated•6 years ago
|
Comment 64•6 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/b7cdd57e400b
https://hg.mozilla.org/mozilla-central/rev/14f31c9d33d9
https://hg.mozilla.org/mozilla-central/rev/1711f8f090e3
https://hg.mozilla.org/mozilla-central/rev/7963aeba2dae
https://hg.mozilla.org/mozilla-central/rev/b9cae60a1da4
https://hg.mozilla.org/mozilla-central/rev/bc2e1b86dcd3
https://hg.mozilla.org/mozilla-central/rev/6afa4d826913
Updated•6 years ago
|
Description
•