Closed Bug 838691 Opened 12 years ago Closed 12 years ago

Support calling a function to determine whether a property is defined in a WebIDL binding, not just checking a pref

Categories

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

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

(Keywords: dev-doc-complete)

Attachments

(5 files, 2 obsolete files)

Need this for bug 838614.
Blocks: 838614
Whiteboard: [need review]
Attached patch Part 3 actually compiling (obsolete) (deleted) — Splinter Review
Attachment #711129 - Flags: review?(peterv)
Attachment #711095 - Attachment is obsolete: true
Attachment #711095 - Flags: review?(peterv)
Attachment #711136 - Flags: review?(peterv)
Attachment #711129 - Attachment is obsolete: true
Attachment #711129 - Flags: review?(peterv)
Comment on attachment 711092 [details] [diff] [review] part 1. Add support in Prefable for calling a function to determine whether a property should be exposed in a WebIDL binding. Review of attachment 711092 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/bindings/BindingUtils.cpp @@ +649,4 @@ > } > > static bool > XrayResolveAttribute(JSContext* cx, JSObject* wrapper, jsid id, Would it make sense to actually pass in the unwrapped object as |JSObject* obj| here too (we already do that for all the Xray* hooks)? @@ +901,5 @@ > id, desc); > } > > bool > +XrayEnumerateAttributes(JSContext* cx, JSObject* wrapper, Add |JSObject* obj| here too. @@ +924,5 @@ > return true; > } > > bool > +XrayEnumerateProperties(JSContext* cx, JSObject* wrapper, Same here. @@ +1029,5 @@ > const NativePropertiesHolder& nativeProperties = > nativePropertyHooks->mNativeProperties; > > if (nativeProperties.regular && > + !XrayEnumerateProperties(cx, wrapper, flags, props, type, Pass in obj here. @@ +1036,5 @@ > } > > if (nativeProperties.chromeOnly && > xpc::AccessCheck::isChrome(js::GetObjectCompartment(wrapper)) && > + !XrayEnumerateProperties(cx, wrapper, flags, props, type, And here. ::: dom/bindings/DOMJSClass.h @@ +69,5 @@ > + inline bool isEnabled(JSContext* cx, JSObject* obj) { > + return enabled && > + (!enabledFunc || > + enabledFunc(cx, js::GetGlobalForObjectCrossCompartment(obj))); > + Trailing whitespace.
Attachment #711092 - Flags: review?(peterv) → review+
> Would it make sense to actually pass in the unwrapped object as |JSObject* obj| here too Makes sense. I'll do that.
Comment on attachment 711093 [details] [diff] [review] part 2. Add codegen support for calling a function to determine whether a property should be exposed in a WebIDL binding. Review of attachment 711093 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/bindings/BindingUtils.cpp @@ +716,5 @@ > } > if (methods) { > Prefable<JSFunctionSpec>* method; > for (method = methods; method->specs; ++method) { > + if (method->isEnabled(cx, js::UnwrapObject(wrapper))) { If you plan to land these separately you should merge this into part 1. ::: dom/bindings/Codegen.py @@ +1049,2 @@ > return None > + # It's a list of strings Wrong indentation. ::: dom/bindings/DOMJSClass.h @@ +69,5 @@ > inline bool isEnabled(JSContext* cx, JSObject* obj) { > return enabled && > (!enabledFunc || > enabledFunc(cx, js::GetGlobalForObjectCrossCompartment(obj))); > + } Again, should probably merge this into part 1. @@ +76,5 @@ > bool enabled; > // A function pointer to a function that can say the property is disabled > // even if "enabled" is set to true. If the pointer is null the value of > // "enabled" is used as-is. > + PropertyEnabled enabledFunc; And this.
Attachment #711093 - Flags: review?(peterv) → review+
Attachment #711136 - Flags: review?(peterv) → review+
Attachment #711097 - Flags: review?(peterv) → review+
Attachment #711098 - Flags: review?(peterv) → review+
> If you plan to land these separately you should merge this into part 1. > Again, should probably merge this into part 1. > And this. Done locally when addressing the comments for part 1. Sorry I didn't post an updated part 2. :( > Wrong indentation. Fixed.
Blocks: 842372
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: