Implement AbstractRange and StaticRange
Categories
(Core :: DOM: Core & HTML, enhancement, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox69 | --- | fixed |
People
(Reporter: annevk, Assigned: masayuki)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete)
Attachments
(10 files)
18.13 KB,
patch
|
Details | Diff | Splinter Review | |
23.03 KB,
patch
|
Details | Diff | Splinter Review | |
9.01 KB,
patch
|
Details | Diff | Splinter 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 |
Reporter | ||
Updated•7 years ago
|
Updated•7 years ago
|
Comment 1•7 years ago
|
||
Assignee | ||
Comment 2•6 years ago
|
||
What's the status of this bug? Perhaps, I can fix bug 998941 soon. Then, I'll work on implementing beforeinput behind a flag. (Perhaps, I need to rewrite a lot especially around keypress event dispatcher, so, still not so urgent though.)
Comment 3•6 years ago
|
||
Comment 4•6 years ago
|
||
Comment 5•6 years ago
|
||
Updated•6 years ago
|
Comment 6•6 years ago
|
||
Assignee | ||
Comment 7•6 years ago
|
||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 8•6 years ago
|
||
This patch is based on the patch created by Makoto Kato-san.
Range
and StaticRange
have common base interface, AbstractRange
.
https://dom.spec.whatwg.org/#abstractrange
This interface has simply returns startContainer
, endContainer
,
startOffset
, endOffset
and collapsed
.
Different from the original patch's approach, this patch moves related
members in nsRange
to AbstractRange
since this approach avoids
virtual call cost. Additionally, this patch makes them not throw as
declared by the spec. As far as I know, the destruction cost of
ErrorResult
may appear in profile so that we should avoid creating
the instance if we can avoid it.
Unfortunately, the instance size of nsRange
becomes larger with this
patch. The size is changed from 176 to 184. I.e., now, nsRange
requires bigger chunk.
Assignee | ||
Comment 9•6 years ago
|
||
For avoiding confusion between API of nsRange
and StaticRange
, I'd like to
rename nsRange::CreateRange()
to nsRange::MaybeCreate()
because
StaticRange::CreateStaticRange()
is too long name and
StaticRange::CreateRange()
sounds odd. And sometimes, it won't return new
instance. This patch renames it and changes related methods to template
methods for avoiding runtime cost of temporary RawRangeBoundary
instance creation.
Assignee | ||
Comment 10•6 years ago
|
||
Some nsRange
static methods are useful in StaticRange
and some of them
are used in a lot of places but not related to nsRange
directly. This
patch moves them into new static method only class, mozilla::RangeUtils
.
Assignee | ||
Comment 11•6 years ago
|
||
This patch is based on Makoto Kato-san's patch.
This patch implements mozilla::dom::StaticRange
class and creating some
static factory methods.
Then, makes AbstractRange
has a utility method of SetStartAndEnd()
method of nsRange
and StaticRange
for sharing same logic in one place.
However, there are some additional work is required only in nsRange
, e.g.,
nsRange
needs to start observing mutation of the range, but StaticRange
does not it. Therefore, it's implemented as a template method which takes
nsRange*
or StaticRange*
as a parameter. Then, each DoSetRange()
method of them can do different things without virtual calls.
Note that StaticRange
does not have any properties, methods nor constructor.
Therefore, we need additional API to test it.
Assignee | ||
Comment 12•6 years ago
|
||
This patch makes HTMLEditRules::ExpandSelectionForDeletion()
use StaticRange
instead of nsRange
for comparing a point and a range (i.e., the DOM tree
won't be changed during it's alive). Unfortunately, we still have allocation
cost, but we can save the cost of registering and unregistering mutation
observer and computing common ancestor of the range.
Assignee | ||
Comment 13•6 years ago
|
||
This patch makes HTMLEditRules::PinSelectionToNewBlock()
use StaticRange
instead of nsRange
for comparing a point and a range (i.e., the DOM tree
won't be changed during it's alive). Unfortunately, we still have allocation
cost, but we can save the cost of registering and unregistering mutation
observer and computing common ancestor of the range.
Assignee | ||
Comment 14•6 years ago
|
||
EditorSpellCheck
clones nsRange
instance only for temporary use during
initialization even though the DOM tree won't be changed during it. In this
case, using StaticRange
is better since it does not need to observe the
DOM tree mutation. I.e., we can save the cost of registering and
unregistering the mutation observer.
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 15•6 years ago
|
||
I think that we should land part.1 ~ part.5 first. Then, part.6 and part.7 should be landed separately for making it easier to look for regression-window.
Assignee | ||
Comment 16•6 years ago
|
||
Comment 17•6 years ago
|
||
Comment 18•6 years ago
|
||
bugherder |
Comment 19•6 years ago
|
||
Comment 20•6 years ago
|
||
Comment 21•6 years ago
|
||
bugherder |
Assignee | ||
Updated•6 years ago
|
Comment 22•6 years ago
|
||
Comment 23•6 years ago
|
||
bugherder |
Updated•6 years ago
|
Description
•