Closed
Bug 1031440
Opened 11 years ago
Closed 11 years ago
Start moving mozInlineSpellChecker off of nsIDOM* APIs
Categories
(Core :: DOM: Editor, defect)
Tracking
()
RESOLVED
FIXED
mozilla33
People
(Reporter: mrbkap, Assigned: mrbkap)
Details
Attachments
(3 files)
9.39 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
1.21 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
18.99 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
Reading through this code the other day, I noticed that we're still using nsIDOM* APIs in a bunch of places that we don't have to. I've left some in (I only really cared about the main spellchecking loop), so there are still a few extraneous uses left. I also had to leave all of the places that touch the editor core alone because editor.
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → mrbkap
Comment 1•11 years ago
|
||
(In reply to Blake Kaplan (:mrbkap) from comment #0)
> I also had to leave all of the places that touch
> the editor core alone because editor.
Good reason. ;-)
Assignee | ||
Comment 2•11 years ago
|
||
SkipSpellcheckForNode, despite the name, returns true if we *should* spell check the node. I fixed that.
This also makes it use modern APIs and it looks much cleaner now.
Attachment #8447341 -
Flags: review?(ehsan)
Assignee | ||
Comment 3•11 years ago
|
||
It's illegal to call methods on XPCOM objects whose refcounts are 0 and it's worse to do so with runnables (even though this is main-thread-only) because it introduces possible races.
Attachment #8447342 -
Flags: review?(ehsan)
Assignee | ||
Comment 4•11 years ago
|
||
Return values are *so* much nicer than out params, especially when they let us avoid a bunch of refcounting. This also removes a few now-redundant local variables, which is cleaner.
Attachment #8447346 -
Flags: review?(ehsan)
Comment 5•11 years ago
|
||
Comment on attachment 8447341 [details] [diff] [review]
Un nsIDOMify SkipSpellcheckForNode
Review of attachment 8447341 [details] [diff] [review]:
-----------------------------------------------------------------
Nice!
::: extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ +49,2 @@
> #include "nsRange.h"
> +#include "Selection.h"
Please use mozilla/dom/Selection.h. Apparently we export that header in both places. :(
Attachment #8447341 -
Flags: review?(ehsan) → review+
Updated•11 years ago
|
Attachment #8447342 -
Flags: review?(ehsan) → review+
Comment 6•11 years ago
|
||
Comment on attachment 8447346 [details] [diff] [review]
Switch to internal ranges and selection interfaces
Review of attachment 8447346 [details] [diff] [review]:
-----------------------------------------------------------------
::: extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ +1368,5 @@
> NS_ENSURE_SUCCESS(rv, rv);
>
> bool doneChecking;
> + for (int32_t idx = 0; idx < count; idx++) {
> + nsRange *checkRange = ranges[idx];
I think |ranges[idx]| here returns a temporary nsRefPtr here which gets destroyed, so technically |checkRange| after this line could be UAF. Although that of course doesn't happen because the array will still hold the object alive, I think I'd be more comfortable if you made checkRange a nsRefPtr<nsRange>&, or better yet, an auto&.
Attachment #8447346 -
Flags: review?(ehsan) → review+
Assignee | ||
Comment 7•11 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=c47730dfb13f with that and a missing null check that I noticed. I'll check in once try is green.
Assignee | ||
Comment 8•11 years ago
|
||
Comment 9•11 years ago
|
||
Comment on attachment 8447346 [details] [diff] [review]
Switch to internal ranges and selection interfaces
> nsCOMPtr<nsIDOMRange> checkRange;
...
>+ nsRange *checkRange = ranges[idx];
Unused variable?
Comment 10•11 years ago
|
||
(In reply to Ehsan Akhgari from comment #6)
> > + nsRange *checkRange = ranges[idx];
>
> I think |ranges[idx]| here returns a temporary nsRefPtr here
No, operator[] returns elem_type& (otherwise you wouldn't be able to change it!) but I don't see why you don't just write status.mRange = ranges[idx]; in the first place.
Assignee | ||
Comment 11•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/95c7e00d68b4
Done and done. Thanks for pointing that out.
Comment 12•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/d774d2c87e78
https://hg.mozilla.org/mozilla-central/rev/95c7e00d68b4
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in
before you can comment on or make changes to this bug.
Description
•