Closed Bug 1406215 Opened 7 years ago Closed 7 years ago

Remove the usage of nsINode::GetChildAt() from nsTextServicesDocument::GetCollapsedSelection()

Categories

(Core :: DOM: Editor, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

References

Details

Attachments

(2 files)

No description provided.
This offset is obtained from a Range, so it doesn't need to be validated.
Attachment #8915782 - Flags: review?(masayuki)
Attachment #8915782 - Flags: review?(masayuki) → review+
Comment on attachment 8915783 [details] [diff] [review] Part 2: Remove the usage of nsINode::GetChildAt() from nsTextServicesDocument::GetCollapsedSelection() >@@ -2384,23 +2384,20 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS > nsIContent* saveNode; > if (parent->HasChildren()) { > // XXX: We need to make sure that all of parent's > // children are in the text block. > > // If the parent has children, position the iterator > // on the child that is to the left of the offset. > >- uint32_t childIndex = offset; >- >- if (childIndex > 0) { >- childIndex -= 1; Current implementation does not try to retrieve previous child if the offset is 0. >+ nsIContent* content = range->GetChildAtStartOffset(); >+ if (content) { >+ content = content->GetPreviousSibling(); > } So, looks like that you need to check: if (content && parent->GetFirstChild() != content) { content = content->GetPreviousSibling(); } If I misunderstood, ignore this review. Otherwise, fix it before landing.
Attachment #8915783 - Flags: review?(masayuki) → review+
Good catch. You're right!
Pushed by eakhgari@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/756a3fa73513 Part 1: Remove a useless bounds check for a selection range offset; r=masayuki https://hg.mozilla.org/integration/mozilla-inbound/rev/3edd962139b6 Part 2: Remove the usage of nsINode::GetChildAt() from nsTextServicesDocument::GetCollapsedSelection(); r=masayuki
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: