Closed Bug 1503577 Opened 6 years ago Closed 6 years ago

Remove more nsPrimitiveHelpers::CreateDataFromPrimitive usage

Categories

(Core :: Widget, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla65

People

(Reporter: evilpie, Assigned: evilpie)

References

Details

Attachments

(2 files)

CreateDataFromPrimitive is a bad abstraction. It gives you back raw bytes, that are either 8-bit chars or 16-bit chars. Some callers even rely on the function returning char16_t, because they know that CreateDataFromPrimitive only returns 8bit chars for kTextMime or kCustomTypesMime flavors.
The previous |if (data)| check is not quite the same as !data.IsEmpty(), because
the previous code just checked if the do_QueryInterface failed, but not if the resulting
string is empty.
Keywords: leave-open
Right now CreateDataFromPrimitive doesn't use the aDataLen parameter, and after this change the out
value should be the same as the value passed in, as long as we are dealing with strings.
Attachment #9021686 - Flags: review?(spohl.mozilla.bugs)
Attachment #9022148 - Flags: review?(mstange)
Attachment #9022148 - Flags: review?(mstange)
Attachment #9021686 - Flags: review?(spohl.mozilla.bugs) → review+
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/2df61d7610d6
Remove CreateDataFromPrimitive from macOS clipboard code. r=spohl
https://hg.mozilla.org/integration/autoland/rev/8b1dc4b08aab
Change CreateDataFromPrimitive aDataLen to out parameter with size of string in bytes. r=mstange
Status: NEW → RESOLVED
Closed: 6 years ago
Keywords: leave-open
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: