[webkit-dev] HTML attributes and tags - slight tweak
Maciej Stachowiak
mjs at apple.com
Mon Jul 25 00:41:18 PDT 2005
Hi Everyone,
Dave Hyatt's recent code QualifiedName changes were a much-needed
code cleanup and structural improvement. However, as things stand,
the symbolic names used for specific HTML tags and attributes in the
code have gotten a bit wordy. Compare:
Before:
---------
ID_SPAN
ID_A
ATTR_SRC
ATTR_CLASS
After:
------
HTMLTags::span()
HTMLTags::a()
HTMLAttributes::src()
HTMLAttributes::classAttr()
When you have an if test checking for several of these I think it
actually starts to hurt legibility a bit. Dave and I discussed ways
to improve this a bit and here's what we came up with:
* Change the various html name symbols from functions to global
variables - currently they are just inline functions that return a
global, which doesn't add much.
* Combine HTMLTags and HTMLAttributes classes into a single HTMLNames
namespace.
* Suffix all tag names with Tag and all attribute names with Attr
The net result would be that you import the HTMLNames namespace, and
you can write:
Proposed:
------------
spanTag
aTag
srcAttr
classAttr
Which compares favorably to the old names.
In cases where you might care about more than one markup language's
set of names you wouldn't import the HTML namespace, and could write
them fully qualified, e.g. HTMLNames::spanTag.
One possible variant is to just call the namespace HTML, so in the
fully qualified case you could just write HTML::spanTag. The tradeoff
is that people might expect the namespace to contain more than just
the names in that case, they might expect it to contain the whole
HTML DOM, which it wouldn't.
Anyway, I wanted to send this out to see if anyone has comments
before I make the change, so we can avoid too much thrashing back and
forth on the names.
Regards,
Maciej
More information about the webkit-dev
mailing list