Bug 12268

Summary: Give object prototypes their own names
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: WebCore JavaScriptAssignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Enhancement    
Priority: P2    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
proposed patch
none
proposed patch
mjs: review-
plus global renaming mjs: review+

Description Alexey Proskuryakov 2007-01-14 12:13:20 PST
Currently, JS objects and their prototypes have the same names, which can be confusing.
Comment 1 Alexey Proskuryakov 2007-01-14 12:22:47 PST
Created attachment 12431 [details]
proposed patch

The fast/tokenizer/external-script-document-write.html test seems to have been failing, going to research it separately.
Comment 2 Alexey Proskuryakov 2007-01-14 13:27:06 PST
Comment on attachment 12431 [details]
proposed patch

Sam has pointed out that this patch has an unintended consequence of changing what property is added to the global object (e.g., HTMLDocumentProto.prototype instead of HTMLDocument.prototype). OTOH, the former isn't available in Firefox anyway. Going to investigate this further.
Comment 3 Alexey Proskuryakov 2007-01-14 13:35:21 PST
That is, [[HTMLDocumentProto.prototype]] instead of [[HTMLDocument.prototype]].
Comment 4 Geoffrey Garen 2007-01-14 15:44:51 PST
(In reply to comment #3)
> That is, [[HTMLDocumentProto.prototype]] instead of [[HTMLDocument.prototype]].
> 

If you're talking about the hidden properties we create through cacheGlobalObject(), the fact that they're reachable at all from client code is really a minor bug, not a feature.

Can we spare a few extra letters and use "Prototype" instead of "Proto"?
Comment 5 Alexey Proskuryakov 2007-01-16 11:17:39 PST
Created attachment 12492 [details]
proposed patch

Mostly the same, just changed to append "Proto" in the macro (similar to how it works for constructors in CodGeneratorJS).

> Can we spare a few extra letters and use "Prototype" instead of "Proto"?

I tried to match how prototype classes are named in C++, so I guess I'd have to rename them at the same time then, as well.
Comment 6 Darin Adler 2007-01-16 11:22:41 PST
(In reply to comment #5)
> > Can we spare a few extra letters and use "Prototype" instead of "Proto"?
> 
> I tried to match how prototype classes are named in C++, so I guess I'd have to
> rename them at the same time then, as well.

I'm a big fan of words rather than abbreviations, so I like Geoff's suggestion.

We could use my rename script to do the renaming of the non-auto-generated C++ in an automated way.
Comment 7 Alexey Proskuryakov 2007-01-16 12:45:04 PST
Created attachment 12493 [details]
plus global renaming

Adds a global rename of Proto, ProtoFunc etc. Not exactly what I intended to do in this patch, but well.
Comment 8 Maciej Stachowiak 2007-01-17 02:06:52 PST
Comment on attachment 12493 [details]
plus global renaming

r=me on the fancier patch
Comment 9 Maciej Stachowiak 2007-01-17 02:08:36 PST
Comment on attachment 12492 [details]
proposed patch

r- the older patch to get it out of the queue
Comment 10 Alexey Proskuryakov 2007-01-17 11:52:58 PST
Committed revision 18912.
Comment 11 Alexey Proskuryakov 2007-01-18 21:40:36 PST
(In reply to comment #1)
> The fast/tokenizer/external-script-document-write.html test seems to have been
> failing, going to research it separately.

Filed bug 12333.