When calling a method that returns a style sheet object, the Objective-C DOM wrappers don't create the right type of wrapper for a CSSStyleSheet. You end up with a DOMStyleSheet instead of a DOMCSSStyleSheet.
Created attachment 3246 [details] patch to fix the problem Added code to handle this like other DOM wrappers with subclasses. Looks like there's also a double-deref bug here that this fixes.
Comment on attachment 3246 [details] patch to fix the problem Patch looks good, but needs some sort of testing. r=me if you find a way to test it.
Comment on attachment 3246 [details] patch to fix the problem Looks fine. I think this is a good change (simplifies code). I will note however, your current solution may have some rather odd failure symantics when passed the wrong pointer type to the wrong class. If you call _CSSStyleSheetWithImpl and pass a DOMStyleSheetImpl, you'll get back a valid pointer to an Obj-C object, but it will be a DOMStyleSheet *. Likewise if you call _DOMStyleSheetWithImpl and pass a DOMCSSStyleSheetImpl *, you'll get back a DOMCSSStyleSheet * instead of the expected DOMStyleSheet * In an ideal world, at least the first case (passing a DOMStyleSheetImpl * to the DOMCSSStyleSheet creation method) should return nil instead of a DOMStyleSheet *. But hopefully all this code will be going away in the next 6 months anyway (to be replaced by autogeneration). r=me.
As ggaren correctly points out, all of these really should have layout tests. For better or worse I ignored that fact, realizing that we don't currently (AFAIK) have any way of testing the Obj-C DOM API. I talked with andersca a bit on IRC, he said he started the py-objc Obj-C DOM testing system, but hasn't finished yet.
Eric, the way this is supposed to work is that you get a compile-time error if you try to pass a DOMStyleSheetImpl to _CSSStyleSheetWithImpl. There's no need for the code to handle this case at runtime. Same for the other cases you mentioned.
Sorry, the other case was in the other direction. If you call _DOMStyleSheetWithImpl and pass a DOMCSSStyleSheetImpl *, you *must* get a DOMCSSStyleSheet *. That's a feature of the DOM binding, not a bug. The same is true of any subclasses of DOM nodes in a similar way. So the first of the two cases you mentioned is an error that is supposed to be caught at compile time, not runtime. And the second of the two cases is a feature, not a bug. I don't think there's anything wrong here. Lets talk about this in person if you're still concerned.
*** Bug 6680 has been marked as a duplicate of this bug. ***