The dom_string design
jmb at netsurf-browser.org
Fri May 1 14:56:58 BST 2009
On Fri, 2009-05-01 at 20:56 +0800, Bo Yang wrote:
> Hi Daniel,
> Thanks for your advice! And following is my opinion on your
> proposal, I hope it is helpful.
> > I wouldn't say "optionally"
> > In order for libcss, hubbub and libdom to work sensibly together, the
> > attribute names, tag names, and many of the attribute values *MUST* be
> By saying "optionally", I mean all tag names, all attribute names and
> some attribute values, I think we are the same at this point. :)
I'm not sure you are :) I think, like myself, Daniel is advocating
interning *all* attribute values.
[Two string types]
> After some thoughts about the idea that using two types of string in
> libDOM API. I have some questions.
> Firstly our API may be:
> dom_element_get_id(lwc_string *name, lwc_string **value);
What is this? I can't find it in the IDL.
> dom_element_get_text_content(lwc_string *name, dom_cdata_string **value);
> So, all APIs must be bundled with a type of string. If we decide to
> change some string type of some DOM elment/attribute in future, we
> should change the API. I don't think this is a good way.
That's a valid point. I'm not sure, however, that we intend to change
things incompatibly once we've worked out the correct way of doing it.
The point of this discussion, of course, is to work out what the correct
way is :)
> And we should expose the two type of strings to our clients, I think
> it is better to just use one type of string and it is clearer for our
Except that clients will still need access to the lwc_string to be able
to perform useful comparisons (e.g. when matching CSS selectors). So
exposing one or two string types makes little difference from that
perspective. It'd be nice to avoid making the client poke around in our
data structures to get at the information they need, too.
> There is another problem for this, the above two API used to fetch the
> "id" and "TextContent" attributes and both attributes can be fetched
> by all :
> dom_element_get_attribute(lwc_string *attr, <a string type> **ret);
No, they can't. textContent is a DOM attribute. It cannot be accessed
through the getAttribute() API (which is for content attributes).
<title>This is a title</title>
var x = document.getElementById("x");
var y = x.getAttribute("nodeName"); // could be textContent
var z = x.getAttribute("id");
window.alert("name: " + y + " id: " + z);
<h1 id="x">foo<span> bar </span> baz bat</h1>
> so, if we use two types of string, what is the string type for above API?
More information about the netsurf-dev