Closed Bug 1729170 Opened 4 years ago Closed 4 years ago

Make `nsTextFragment::CharAt` should take `uint32_t` rather than `int32_t`

Categories

(Core :: DOM: Core & HTML, task, P3)

task

Tracking

()

RESOLVED FIXED
95 Branch
Tracking Status
firefox95 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

https://searchfox.org/mozilla-central/rev/36a784a4c4b666c3da6677259a635c48a058c95a/dom/base/nsTextFragment.h#213

I know it's never larger than NS_MAX_TEXT_FRAGMENT_LENGTH, so it has no problem actually.

However, child offset in DOM nodes is uint32_t. So without explicit conversion, we get this waning in Fabricator.

WARNING: narrowing conversion from 'uint32_t' (aka 'unsigned int') to signed type 'int32_t' (aka 'int') is implementation-defined

So I think that it should take uint32_t for avoiding unnecessary casting.

nsTextFragment is a storage of data node and DOM offset is uint32_t, but
some methods of nsTextFragment takes int32_t for the offset/length in
its text. Therefore, callers need to cast from uint32_t to int32_t if
the offset value is offset in a DOM node. Therefore, all methods of it should
take uint32_t values as offset/length in its text.

Depends on D127612

Assignee: nobody → masayuki
Status: NEW → ASSIGNED
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/05d338fecf52 Make all methods of `nsTextFragment` take `uint32_t` for the offset and length of text r=smaug
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 95 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: