edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev]  tag list
@ 2014-03-01 19:24 Karl Dahlke
  2014-03-02 13:47 ` Adam Thompson
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Dahlke @ 2014-03-01 19:24 UTC (permalink / raw)
  To: Edbrowse-dev

Yeah, this is something I got confused about too,
until Chris set me straight.
Duh - I wrote it - and then I got confused about it.
I can be dumb as a box of rocks sometimes.
The linked list or array or vector or whatever holds pointers
to struct htmlTag, not the struct itself.
So structs can go ahead and point to each other as parents and children,
because the structs don't move.
The growing vector simply reallocates the list of pointers to those structures.

I already do this, don't I?
t->controller is the form that owns the input tag,
and for an option t->controller is the select that owns the option.
Just rename controller parent and you're halfway there.

So with this in mind 

static list < struct htmlTag *>htmlStack;

becomes

static vector < struct htmlTag *>htmlStack;

Then sure it's all normal after that, and I'd just love to
set cw->tags to htmlStack, but cw->tags
is one of those things that is in C, not C++.
In fact it's in eb.h, thus in every C file,
so we'd have to use void * or some such, or convert the whole project to C++.
But that's the idea, and we can certainly move forward there.
Then there is no trouble adding new tags as we need to,
as js creates new thingees for us.

Karl Dahlke

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Edbrowse-dev]   tag list
@ 2014-03-02 14:15 Karl Dahlke
  2014-03-02 19:28 ` Adam Thompson
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Dahlke @ 2014-03-02 14:15 UTC (permalink / raw)
  To: Edbrowse-dev

> At some stage I really need to familiarise myself with the html code.

Yes, but please ask if unsure. A question can sometimes replace
days of reading code, especially my code, which isn't well commented.

> but why are we storing a list of pointers?

Precisely so the structures don't move.
Each tag can point, by a pointer, to its parent or children
and those pointers will remain valid,
even if c++ vector does a realloc on the list of pointers,
which it will do as new tags are created.
Chris and I went through this - I even started writing
vector<struct htmlTag> code, but then I could see the structures
were moving, and the parent and child links became invalid.

> We also need to store a list of children in each tag, i.e. in the code:

Yes, and javascript has set for us a partial standard;
should we follow it?
A form contains input elements, right?
Well js standard says form contains a member named elements, which is an array
of all the input tags, in order.
Now suppose one of those inputs is a dropdown list, a select.
Dom standard says that input tag contains a member named options.
It is an array of objects, each object an option in the select list.
So children seem to be held in an array that is owned by the parent.

> Example of <body> <div>
>
> The body would have a list of two pointers to the two div tags,

js already has an array of div tags.
It is called divs, I think.
I know it has n array of link tags called links, an array of image tags called images, and so on.
What I don't know is whether this, in the standard, is a global array of all images on the page,
or a local array of images in the current structure,
like elements in a form or options in a select.
We would want the latter.
More research is needed.
domlink() in jsdom.cpp is suppose to do all of this.
And it looks like it treats elements and options as a local list,
in the current structure, but images and links and heads and metas
and anchors as a global list under document.
I don't know if this is right.
If this is the standard perhaps we can do both,
document/images[] for all image tags on the page,
and local/images[] for the array of images that are inside the current paragraph
or whatever.

Another aspect of this js standard is it is type specific.
Here is the list of elements in the form, here is the list
of images, here is the list of anchors, etc.
Maybe that's ok, but maybe we also need an array of all tags in order
within each construct.
IDK

> No need to do this rewrite at the moment,

Absolutely agree.
I think we all agree here.
Let's get 3.5.1 stable and working with distributed libraries.
We're just talking, and thinking, and planning for the future,
and I think it is helpful.


Karl Dahlke

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Edbrowse-dev] tag list
@ 2014-03-01 14:00 Karl Dahlke
  2014-03-01 19:01 ` Adam Thompson
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Dahlke @ 2014-03-01 14:00 UTC (permalink / raw)
  To: Edbrowse-dev

Well the tags are built in a growing linked list as the page is parsed,
but at the end of parse I plop them all into an array,
so it is easy to grab tag 243 (example), just index the array,
because the text in your buffer actually has encoded

tag 243 {go to this link}

You don't see tag code 243 but it's there,
and it is accessed when you go to that link.

If we want tags to continue to grow after page parse,
new tags because of javascript creating html structures etc,
then we want something with the dynamic power of a linked list or a tree
but also an easy way to index like an array.
Not sure if C++ list has this much power, or vector,
but in C there wasn't anything, which is why I made the compromise I did.
Anyways we might be able to forget the array and stay with the c++ list,
and use its power to move forward.
Create tags whenever javascript tells us to,
and they can have parent links inside them to define the tree structure
of forms and tables and so  on.

Karl Dahlke

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-02 19:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-01 19:24 [Edbrowse-dev] tag list Karl Dahlke
2014-03-02 13:47 ` Adam Thompson
  -- strict thread matches above, loose matches on Subject: below --
2014-03-02 14:15 Karl Dahlke
2014-03-02 19:28 ` Adam Thompson
2014-03-01 14:00 Karl Dahlke
2014-03-01 19:01 ` Adam Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).