Closed Bug 1609338 Opened 6 years ago Closed 6 years ago

Optimize usage and implementation of `UIEvent::GetRangeParent()` and `UIEvent::RangeOffset()`

Categories

(Core :: DOM: Events, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla74
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.

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.

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/06fbf308795f Optimize usage and implementation of `UIEvent::GetRangeParent()` and `UIEvent::RangeOffset()` r=smaug
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: