Optimize usage and implementation of `UIEvent::GetRangeParent()` and `UIEvent::RangeOffset()`
Categories
(Core :: DOM: Events, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox74 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
Details
Attachments
(1 file)
UIEvent::GetRangeParent()
retrieves nsIContent
instance but it needs to return already_AddRefed<nsINode>
because of a WebIDL method. However, nsIContent
is better type in C++ code (at least one caller still using do_QueryInterface
to get a reference to nsIContent
pointer).
Additionally, some callers call UIEvent::RangeOffset()
too, but that means that they compute same things twice because both of them use nsLayoutUtils::GetContainerAndOffsetAtEvent()
with same input arguments.
Assignee | ||
Comment 1•6 years ago
|
||
UIEvent::GetRangeParent()
retrieves nsIContent
instance but it needs to
return already_AddRefed<nsINode>
because of a WebIDL method. However,
nsIContent
is better type in C++ code. Therefore, this patch renames it
to UIEvent::GetRangeParentContent()
and makes new UIEvent::GetRangeParent()
and just call it.
Additionally, some callers call UIEvent::RangeOffset()
too, but that means
that they compute same things twice because both of them use
nsLayoutUtils::GetContainerAndOffsetAtEvent()
with same input arguments.
Thus, UIEvent::GetRangeParentContent()
should also return offset with optional
out argument. (Note that this does not make RangeOffset()
use
GetRangeParentContent()
because using out parameter for range parent causes
unnecessary computation cost for RangeOffset()
.)
Therefore, finally, UIEvent::GetRangeParentContent()
becomes also an alias of
raw method UIEvent::GetRangeParentContentAndOffset()
which also returns offset
with out argument.
Comment 3•6 years ago
|
||
bugherder |
Description
•