Closed Bug 901362 Opened 11 years ago Closed 11 years ago

Refactor nsJSUtils::EvaluateString to take an option object and optionally propagate exceptions

Categories

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

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: bholley, Assigned: bholley)

References

Details

Attachments

(2 files)

This is the refactoring I proposed in bug 877673 comment 42.
Comment on attachment 785561 [details] [diff] [review]
Part 1 - Refactor nsJSUtils::EvaluateString to take an EvaluateOptions structure. v1

Review of attachment 785561 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/base/nsJSEnvironment.cpp
@@ +1254,2 @@
>      rv = nsJSUtils::EvaluateString(mContext, aScript, aScopeObject,
> +                                            aCompileOptions, evalOptions, aRetValue);

While you're here, please fix the indentation?

::: dom/base/nsJSUtils.h
@@ +71,5 @@
> +    {}
> +
> +    EvaluateOptions& setCoerceToString(bool aCoerce) {
> +      coerceToString = aCoerce;
> +      return *this;

(I really don't like this chaining pattern.)
Comment on attachment 785561 [details] [diff] [review]
Part 1 - Refactor nsJSUtils::EvaluateString to take an EvaluateOptions structure. v1

Review of attachment 785561 [details] [diff] [review]:
-----------------------------------------------------------------

Setters on EvaluateOptions do not make much sense to me, since the members are public... Ofc for chaining them, they could be handy I just don't see that happening... the idea is that this struct will have many members like the CompileOptions in the future?
Attachment #785561 - Flags: review?(gkrizsanits) → review+
Attachment #785562 - Flags: review?(gkrizsanits) → review+
(In reply to :Ms2ger from comment #3)
> (I really don't like this chaining pattern.)


(In reply to Gabor Krizsanits [:krizsa :gabor] (moving to Berlin: in and out for a few weeks) from comment #4)
> Setters on EvaluateOptions do not make much sense to me, since the members
> are public... Ofc for chaining them, they could be handy I just don't see
> that happening... the idea is that this struct will have many members like
> the CompileOptions in the future?

I'm mostly just interested in following the established JSAPI pattern on this (see CompartmentOptions, CompileOptions, etc).
https://hg.mozilla.org/mozilla-central/rev/dacad5a40811
https://hg.mozilla.org/mozilla-central/rev/901902206d27
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
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: