Closed Bug 850958 Opened 12 years ago Closed 12 years ago

Implement instanceof without relying on nsIDOM interfaces

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: dzbarsky, Assigned: dzbarsky)

References

Details

Attachments

(1 file, 1 obsolete file)

No description provided.
Attached patch Patch (obsolete) — Splinter Review
Attachment #724804 - Flags: review?(bzbarsky)
So the one thing that bothers me here is that if we have something like "Node implements foo" we'll end up with a bajillion entries in the if cascade with this patch, whereas if we just looked for the node proto id at the right depth we'd only need one entry. Or put another way, if we just look at the right depths, we only need entries for the things that actually have our interface as a consequential interface, not for all of their descendants... Thoughts?
I considered that, but I didn't know how to find the right depth. In addition, iface.interfacesBasedOnSelf returns all the descendants as well, so we would need to change that. Another option would be to avoid checking for non-concrete interfaces, except that concreteness is stored on the descriptor so we would need to find the right descriptor for the interface or something.
> I considered that, but I didn't know how to find the right depth. PrototypeTraits<PrototypeID>::Depth > In addition, iface.interfacesBasedOnSelf returns all the descendants as well, so we > would need to change that Or rather add another thing tracking what we care about here. > so we would need to find the right descriptor for the interface or something. That's always doable, no? But we don't want to worry about concrete vs not, because all the HTML*Element things are in fact concrete....
Attached patch PatchSplinter Review
Attachment #724804 - Attachment is obsolete: true
Attachment #724804 - Flags: review?(bzbarsky)
Attachment #725584 - Flags: review?(bzbarsky)
Comment on attachment 725584 [details] [diff] [review] Patch >+ interfacesImplementing |= d.interface.interfacesImplementing s/interfacesImplementing/interfacesImplementingSelf/ please? >+ return true; >+ """ % self.descriptor.interface.identifier.name I'd think the """ should come right after the "return true;" bit; otherwise the generated code has random weird whitespace. >+ else: This is an else after return, right? Better to not do that, imo. r=me with those nits fixed. Thanks!
Attachment #725584 - Flags: review?(bzbarsky) → review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
Depends on: 854532
Depends on: 860551
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: