Closed Bug 1185307 Opened 9 years ago Closed 8 years ago

Need to add nsISelection::AsSelection() or something

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox42 --- affected
firefox50 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(2 files)

Currently, there is only one concrete class implementing nsISelection, that is mozilla::dom::Selection. Therefore, a lot of code casts nsISelection to Selection.
http://mxr.mozilla.org/mozilla-central/search?string=static_cast%3CSelection*%3E

This is safe at least for now, but not so in strictly speaking.

I think that nsISelection should have |Selection* AsSelection()| as noxpcom and noscript method.
makes sense to me. nsISelection is marked as builtinclass, so at least there aren't other
JS implementations.
Assignee: nobody → masayuki
Status: NEW → ASSIGNED
This patch adds nsISelection::AsSelection() for safer "upcast".

Review commit: https://reviewboard.mozilla.org/r/59498/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/59498/
Attachment #8763247 - Flags: review?(bugs)
Attachment #8763248 - Flags: review?(bugs)
Attachment #8763247 - Flags: review?(bugs) → review+
Attachment #8763248 - Flags: review?(bugs) → review+
Comment on attachment 8763248 [details]
Bug 1185307 part.2 Replace upcast from nsISelection to mozilla::dom::Selection with nsISelection::AsSelection()

https://reviewboard.mozilla.org/r/59500/#review56652
Comment on attachment 8763247 [details]
Bug 1185307 part.1 Add nsISelection::AsSelection()

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/59498/diff/1-2/
Comment on attachment 8763248 [details]
Bug 1185307 part.2 Replace upcast from nsISelection to mozilla::dom::Selection with nsISelection::AsSelection()

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/59500/diff/1-2/
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/fd0960e65810
part.1 Add nsISelection::AsSelection() r=smaug
https://hg.mozilla.org/integration/mozilla-inbound/rev/fa1be718504b
part.2 Replace upcast from nsISelection to mozilla::dom::Selection with nsISelection::AsSelection() r=smaug
https://hg.mozilla.org/mozilla-central/rev/fd0960e65810
https://hg.mozilla.org/mozilla-central/rev/fa1be718504b
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: