Make `DeleteRangeTransaction` and `DeleteTextTransaction` stop updating `Selection`
Categories
(Core :: DOM: Editor, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox112 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
(Blocks 2 open bugs)
Details
Attachments
(6 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Assignee | ||
Comment 1•2 years ago
|
||
The deleting selection code in HTMLEditor
is really hard to understand. One of the reasons of that is a lot of methods including the transaction classes' DoTransaction
updates Selection
immediately and cannot be controlled in root caller side. Therefore, I should refactor it when I have spare time.
Assignee | ||
Comment 2•2 years ago
|
||
I read the code around there a bit in my spare time.
DeleteRangeTransaction
contains only DeleteNodeTransaction
and DeleteTextTransaction
. Perhaps, adding MOZ_ASSERT_IF
check into EditAggretateTransaction
to make this guaranteed at least in debug builds.
DeleteNodeTransaction
does not touch Selection
, therefore, we don't need to touch it.
DeleteTextTransaction::DoTransaction
collapses Selection
to start of the deletion range.
DeleteRangeTransaction::DoTransaction
overwrites Selection
of DeleteTextTransaction
.
EditorBase::CreateTransactionForDeleteSelection
creates EditAggregateTransaction
for containing only DeleteRangeTransaction
, DeleteNodeTransaction
and DeleteTextTransaction
. For making this safer at build time, DeleteNodeTransaction
and DeleteTextTransaction
should have DeleteContentTransaction
as common base class. Then, the type check in EditAggretateTransaction
can be simpler.
EditorBase::DeleteRangesWithTransaction
is the only user of EditorBase::CreateTransactionForDeleteSelection
, and it needs to collapse Selection
to where the last executed DeleteRangeTransaction
or DeleteTextTransaction
wants to collapse. Therefore, I want a method to get an API to get selection to the result of CreateTransactionForDeleteSelection
. However, it's also a base class of PlaceholderTransaction
which is created a lot. Therefore, I don't like it'll have new member(s). I think that new sub class of EditAggregateTransaction
is required such as DeleteMultipleRangesTransaction
.
Assignee | ||
Comment 3•2 years ago
|
||
First, EditorBase::CreateTransactionForDeleteSelection
returns an instance of
EditAggregateTransaction
. It's a base class of PlaceholderTransaction
and
DeleteRangeTransaction
but it's also a concrete class. However, it's too
generic. Therefore, this patch creates DeleteMultipleRangesTransaction
which
is a simple sub-class of it, and makes EditAggregateTransaction
be an abstract
class. Then, add AddChild
methods to each concrete class to restrict the
type of child transactions.
Next, DeleteRangeTransaction
contains only DeleteNodeTransaction
and
DeleteTextTransaction
. Therefore, once they have a common base class,
we can check the type easier. Therefore, this patch also adds
DeleteContentTransactionBase
and
EditorBase::CreateTransactionForCollapsedRange
becomes clearer what it
returns.
With these changes, DeleteRangeTransaction
obviously contains only
DeleteContentTransactionBase
, DeleteMultipleRangesTransaction
contains only
DeleteRangeTransaction
, DeleteNodeTransaction
and DeleteTextTransaction
.
And they are guaranteed at build time (at least from outside the classes).
fix
Depends on D169037
Assignee | ||
Comment 4•2 years ago
|
||
Depends on D169038
Assignee | ||
Comment 5•2 years ago
|
||
Due to the loose error checks, this patch changes the behavior in edge cases.
E.g., if there is a case that Selection
is extended by some unexpected JS
listeners/observers, the result may be different. However, it must be not a
problem because normal web apps should handle it later.
Depends on D169039
Assignee | ||
Comment 6•2 years ago
|
||
Depends on D169040
Assignee | ||
Comment 7•2 years ago
|
||
Depends on D169041
Assignee | ||
Comment 8•2 years ago
|
||
Depends on D169042
Comment 10•2 years ago
|
||
Comment 11•2 years ago
|
||
Comment 12•2 years ago
|
||
Comment 13•2 years ago
|
||
Comment 14•2 years ago
|
||
Comment 15•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/363d2f6f523a
https://hg.mozilla.org/mozilla-central/rev/2c5fbabd76ea
https://hg.mozilla.org/mozilla-central/rev/99d62e2f0002
https://hg.mozilla.org/mozilla-central/rev/716218023d3e
https://hg.mozilla.org/mozilla-central/rev/606a58dc8f93
https://hg.mozilla.org/mozilla-central/rev/428d580e81db
Description
•