> > It would be good if we could design a solution that avoids the need for > these duplicate CSS contents, but doesn't result in one internment > context for the entire process. As an additional complication, scripting > and CSSOM will require that CSS contents are copy-on-write.
How about use the same internment context only for the documents in the same host? And for the copy-on-write problems, I think the main problem is that when we copy an internment context, all its lwc_string pointer changed. So, all the pointers in the current documents and stylesheets became invalid. I think , we can solve this by add another indirection to the lwc_string. I mean, the lwc_string should be changed to some encoding to the position of the real string pointer: typedef lwc_string uint32_t; And we use the high 16 bits to be the number of the hash buckets index and the lower 16 bits to be the number of the chain node index. And we should add a new node to the end of collide chain instead of head present to make the encoding valid any time. In this way, when a copy occurs, we just copy all the internment context structure and all the lwc_string can remain unchanged and valid. I hope this make sense. Regards! Bo -- My blog: http://blog.morebits.org
