[webkit-dev] Optimizing DOMNode _nodeWith

Matt Gough devlists at softchaos.com
Mon Apr 24 12:06:09 PDT 2006

On 24 Apr 2006, at 19:39, Geoffrey Garen wrote:

> To me it seems wrong that the internal DOM would have to know about  
> the class naming scheme in a particular binding. A better approach  
> might be just to grab the tag name and swizzle it according to the  
> binding's class naming convention. Something like this:
> HTMLElement* htmlElt = static_cast<HTMLElement*>(impl);
> String tagName = htmlElt->tagName();
> String className = "DOMHTML" + tagName + "Element";
> That wouldn't be exactly right because of capitalization, but it  
> illustrates the general idea.

I thought of that too, but as you say, the Capitalisation is not  
consistent enough for a generic tagName to Obj-c class name. It would  
also require the className to be built up for each node. Not a great  
hit I know, but still slower than getting a constant string from my  
objcClassName proposal. Also, (AFAIK) some tags do not have an  
equivalent class in the internal DOM (e.g H1 - H6) and TBODY, THEAD  
and TFOOT. These would need special casing.

Other solutions I have been thinking about are:

1. Have an enum for all the HTML tags and have a method that returns  
this enum for each element kind. Then have a simple switch statement  
to map the enum to ClassName. This enum might then have other uses  
for when the element type needs knowing 'quickly'.

2. Have a HashMap (or NSDictionary) that maps the tagName to the  

Any other suggestions would be welcome


More information about the webkit-dev mailing list