Bug 4309 - CSSStyleSheet objects don't get Obj-C DOMCSSStyleSheet wrappers
Summary: CSSStyleSheet objects don't get Obj-C DOMCSSStyleSheet wrappers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
: 6680 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-08-06 20:14 PDT by Darin Adler
Modified: 2006-07-28 05:16 PDT (History)
2 users (show)

See Also:


Attachments
patch to fix the problem (2.22 KB, patch)
2005-08-06 20:16 PDT, Darin Adler
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2005-08-06 20:14:16 PDT
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.
Comment 1 Darin Adler 2005-08-06 20:16:51 PDT
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 2 John Sullivan 2005-08-08 09:27:28 PDT
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 3 Eric Seidel (no email) 2005-09-17 14:54:55 PDT
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.
Comment 4 Eric Seidel (no email) 2005-09-18 14:44:44 PDT
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.
Comment 5 Darin Adler 2005-09-23 10:38:32 PDT
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.
Comment 6 Darin Adler 2005-09-23 10:40:39 PDT
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.
Comment 7 Alexey Proskuryakov 2006-07-28 05:16:16 PDT
*** Bug 6680 has been marked as a duplicate of this bug. ***