[webkit-dev] Prefix naming scheme for DOM-exposed functions
mjs at apple.com
Fri Dec 7 13:36:31 PST 2012
If the answer to these questions is "yes", then I think this is too much complexity tax on all exposed methods and properties to make up for the benefit. It's likely only a minority of methods where it's highly desirable to have a specialized version for internal use.
As a side note, I don't see how this would address the concrete example given, that of firstElementChild likely becoming more efficient than firstChild. If we add bindingsFirstChild() and bindingsFirstElementChild(), how does this help WebCore developers know that they should use the internal firstElementChild() instead of the internal firstChild()? I expect both have to exist, because there really are cases where you need to traverse the whole DOM, not just elements, and even if we were to convert, firstElementChild() is not a drop-in replacement.
It also seems to me that internal methods that do the exact same thing as a bindings...() version but lack an ExceptionCode parameter, we'll still want to avoid excess code duplication, in some cases of tricky algorithms. I would not want a second copy of ContainerNode::insertBefore() and its helper methods that replaces exception checking with preflight checks that return false without setting an exeption code (I don't think you can just skip the checks entirely or you'd make a method that is extremely dangerous to call if you have not met very complex preconditions).
I do agree with the goal of having efficient internal interfaces that are not constrained by what is exposed to the Web, but a blanket introduction of methods just for bindings does not seem like a good way to get there.
- Use something in the IDL to call a bindings... variant only in cases where we know there is a materially better internal method.
- Use the style checker to ban calling select exposed methods from hand-written WebCore code, and give the corresponding internal methods different names.
These approaches could achieve the goals described for critical DOM methods without having to infect things like XHR::send() or HTMLMediaElement::setMuted().
On Dec 7, 2012, at 9:27 AM, Darin Adler <darin at apple.com> wrote:
> Hi folks.
> void bindingsAppendChild(Node*, ExceptionCode&);
> The internal function that’s used to add a child node would be designed for the best clarity, ease of use, and efficiency within WebKit implementation code, even when that does not match up with the DOM standard. And could be refactored over time as WebKit design changes without affecting the bindings.
> - It’s not clear what the best prefix is. I don’t like the prefix “dom”, since it’s a lowercased acronym and an overloaded not all that precise term. The prefix “bindings” is sort of silly because these functions are not themselves “bindings”, rather they are the non-language-specific functions designed to be bound to each language. However, I do like the idea of a brief non-acronym word. So, still looking for a great prefix.
> - When appropriate, these exposed functions can be short inline functions that turn around and call internal functions.
> - These functions aren’t needed at all to implement reflected content attributes. Hooray!
> - So far my best idea on how to stage this is to new inlines without cutting the bindings over to them. Then cut the bindings generation script over, then remove and refactor the various unneeded underlying functions. Other ways to stage this would be add an attribute so we can can switch a class or a function at a time over to the new naming scheme, but base classes could make that process challenging and needlessly complex.
> - This will be particularly helpful for future optimizations, such as one we are contemplating that will make currently-heavily-used functions such as firstChild more expensive, and currently-lightly-used functions such as firstElementChild cheaper. We need a way to rename such things and find internal callers and prevent people from accidentally undoing that effort as they do additional WebKit work.
> -- Darin
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
More information about the webkit-dev