[Webkit-unassigned] [Bug 22518] Element subclasses need only pass an optional prefix in their constructor

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Nov 26 16:17:49 PST 2008


------- Comment #2 from eric at webkit.org  2008-11-26 16:17 PDT -------
Moving discussion from bug 22441 comment 21

(In reply to comment #21)
> I don't agree with adding qname parameter to every element. There is no reason
> to ever construct HTMLHtmlElement if other tag name than <html>. We lose
> self-documenting nature of code like this:
>     RefPtr<HTMLTableCaptionElement> caption = new
> HTMLTableCaptionElement(document());
> vs.
>    RefPtr<HTMLTableSectionElement> newBody = new
> HTMLTableSectionElement(tbodyTag, document());
> where we can immeditealy see that HTMLTableSectionElement can represent
> multiple tags while HTMLTableCaptionElement can not.
> Surely you it would be better to make your autogeneration script slightly
> smarter rather than losing this architectural feature?

There is also a (rather un-important) bug in the current code that code like

<foo:html id="test" xmlns:foo="http://www.w3c.org/1999/xhtml">
document.getElementById("test").prefix; // is null when it should be "foo"

The autogen scripts certainly could be made "smarter" to not pass the prefix
when not needed (or not to pass it for HTML where it is not universally

The "common case" for creating elements is via the ElementFactory, direct "new"
creation of Element subclasses is only done in a few places where we handle
places where inserting one HTMl element actually causes several to end up in
the tree.  We could of course use document->createElement(tBodyTag) in those
cases, which would execute more code, but might be even cleaner still
(certainly safer, if we ever decide to move HTMLElement/TreeShared subclasses
away from allowing direct "new" like we have for RefCounted subclasses.)

Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

More information about the webkit-unassigned mailing list