Ok Kevin, all that free software is just too irresistable!
I put both functions in startwindow.js and pushed, so everybody have a look.

The css parser works like a dream!
You can even do it stand alone.

duk -i startwindow.js

parser = new cssjs;
list = parser.parseCSS(css_string);

list is an array of the css descriptors in the string.
Each is an object with members: selector, rules, comment.
The selector is something like "p.snork".
Rules is another array of all the keyword value pairs like  bgcolor = white
It's so simple and clean.
I took the ridiculous <style> tag out of acid3 and pushed it through the 
parser, and it worked perfectly.
45 descriptors corresponding to the contents of that <style> tag.

querySelectorAll is not as simple.
As Kevin pointed out, other websites use the same construct, maybe even the 
same code, and I don't want their function to collide with our function, 
especially if they work somewhat differently, so I call ours eb$qs.

eb$qs("div")

But there's another problem.
The code creates the function querySelectorAll, or in our case eb$qs, and in 
doing so it creates a temporary <div> tag.
That doesn't work unless we have a framework in place.
So I put a wrapper around it:  eb$qs$start().
That sets everything up to then run eb$qs as often as you like.
Eventually edbrowse will call eb$qs$start() after the html document is browsed 
and before the first javascript runs.

eb$qs$start()
parser.parseCSS() on every style tag in the document and every file <link 
type=css href=>
Then map those values onto the objects by applying eb$qs to each selector in 
each css descriptor.

But there are more problems.
Try it with jsrt.
Set db3 so you can see what is going on.
browse, jdb, eb$qs$start()
and now you're ready to go.
list = eb$qs("script");
Holy crap it works, list is an array of 9 objects for the 9 scripts in jsrt.
Step through each one and look at list[i].data.
That is the contents of each script.
This also works for "p" "a", and other such things.
It doesn't work for "table.filbert", even though we have a <table 
class=filbert> tag.
It calls a method getAttributeNode which we don't have. Oops.
That's probably our omission, and something we should address anyways.

Then try eb$qs("#jkl");
That doesn't work either.
We are missing the compareDocumentPosition() method.

So we can't move forward on this until we fill in some missing pieces in our 
DOM.
Any volunteers to implement getAttributeNode() or compareDocumentPosition()?
The former is easier, and more important, than the latter.

Karl Dahlke
_______________________________________________
Edbrowse-dev mailing list
[email protected]
http://lists.the-brannons.com/mailman/listinfo/edbrowse-dev

Reply via email to