static DOMObjectMap& domObjects()
{
// Don't use malloc here. Calling malloc from a mark function can
deadlock.
static DOMObjectMap staticDOMObjects;
return staticDOMObjects;
}
what kind of DOMObjects should be stored in it? And why?
I searched the source codes and I found that these classes below will do
that:
Document, Event, HTMLCollection, XMLHttpRequest, CanvasGradient,
CanvasPattern, CanvasRenderingContext2D, DOMCoreException,
DOMImplementation, DOMParser, EventException, History, NamedNodeMap,
NodeFilter, NodeIterator, NodeList, Range, RangeException, TreeWalker,
XMLHttpRequestException, XMLSerializer, Clipboard
but what's the reason? Is it because these classes are essentially simple
and just acting as a tool?
thanks a lot
br>=A0=A0=A0 static DOMObjectMap staticDOMObjects;<br>
=A0=A0=A0 return staticDOMObjects;<br>}<br><br>what kind of DOMObjects shou=
ld be stored in it? And why?<br>I searched the source codes and I found tha=
t these classes below will do that:<br><br>Document, Event, HTMLCollection,=
XMLHttpRequest, CanvasGradient, CanvasPattern, CanvasRenderingContext2D, D=
OMCoreException, DOMImplementation, DOMParser, EventException, History, Nam=
edNodeMap, NodeFilter, NodeIterator, NodeList, Range, RangeException, TreeW=
alker, XMLHttpRequestException, XMLSerializer, Clipboard<br>
<br>but what's the reason? Is it because these classes are essentially =
simple and just acting as a tool?<br><br>thanks a lot<br>
Re: webkit-dev - about hashmap staticDOMObjects by ZHOU Xiao-bo on
2009-04-22T08:15:49+00:00
stored in
static NodePerDocMap& domNodesPerDocument()
{
ASSERT(JSLock::lockCount());
static NodePerDocMap staticDOMNodesPerDocument;
return staticDOMNodesPerDocument;
}
2009/4/22 ZHOU Xiao-bo <zhxb.ustc@gmail.com>
> hi all:
> I still don't understand the purpose of the HashMap:
>
> static DOMObjectMap& domObjects()
> {
> // Don't use malloc here. Calling malloc from a mark function can
> deadlock.
> static DOMObjectMap staticDOMObjects;
> return staticDOMObjects;
> }
>
> what kind of DOMObjects should be stored in it? And why?
> I searched the source codes and I found that these classes below will do
> that:
>
> Document, Event, HTMLCollection, XMLHttpRequest, CanvasGradient,
> CanvasPattern, CanvasRenderingContext2D, DOMCoreException,
> DOMImplementation, DOMParser, EventException, History, NamedNodeMap,
> NodeFilter, NodeIterator, NodeList, Range, RangeException, TreeWalker,
> XMLHttpRequestException, XMLSerializer, Clipboard
>
> but what's the reason? Is it because these classes are essentially simple
> and just acting as a tool?
>
> thanks a lot
>
br>
=A0=A0=A0 static NodePerDocMap staticDOMNodesPerDocument;<br>=A0=A0=A0 retu=
rn staticDOMNodesPerDocument;<br>}<br><br><br><br><br><div class=3D"gmail-q=
uote">2009/4/22 ZHOU Xiao-bo <span dir=3D"ltr"><<a href=3D"mailto:zhxb.u=
stc@gmail.com">zhxb.ustc@gmail.com</a>></span><br>
<blockquote class=3D"gmail-quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">hi all:<br>=A0=A0=
=A0=A0 I still don't understand the purpose of the HashMap:<br><br>stat=
ic DOMObjectMap& domObjects()<br>
{ <br>=A0=A0=A0 // Don't use malloc here. Calling malloc from a mark fu=
nction can deadlock.<br>=A0=A0=A0 static DOMObjectMap staticDOMObjects;<br>
=A0=A0=A0 return staticDOMObjects;<br>}<br><br>what kind of DOMObjects shou=
ld be stored in it? And why?<br>I searched the source codes and I found tha=
t these classes below will do that:<br><br>Document, Event, HTMLCollection,=
XMLHttpRequest, CanvasGradient, CanvasPattern, CanvasRenderingContext2D, D=
OMCoreException, DOMImplementation, DOMParser, EventException, History, Nam=
edNodeMap, NodeFilter, NodeIterator, NodeList, Range, RangeException, TreeW=
alker, XMLHttpRequestException, XMLSerializer, Clipboard<br>
<br>but what's the reason? Is it because these classes are essentially =
simple and just acting as a tool?<br><br>thanks a lot<br>
</blockquote></div><br>
Re: webkit-dev - about hashmap staticDOMObjects by Maciej Stachowiak on
2009-04-22T21:26:54+00:00
On Apr 22, 2009, at 12:27 AM, ZHOU Xiao-bo wrote:
> hi all:
> I still don't understand the purpose of the HashMap:
>
> static DOMObjectMap& domObjects()
> {
> // Don't use malloc here. Calling malloc from a mark function
> can deadlock.
> static DOMObjectMap staticDOMObjects;
> return staticDOMObjects;
> }
>
> what kind of DOMObjects should be stored in it? And why?
> I searched the source codes and I found that these classes below
> will do that:
>
> Document, Event, HTMLCollection, XMLHttpRequest, CanvasGradient,
> CanvasPattern, CanvasRenderingContext2D, DOMCoreException,
> DOMImplementation, DOMParser, EventException, History, NamedNodeMap,
> NodeFilter, NodeIterator, NodeList, Range, RangeException,
> TreeWalker, XMLHttpRequestException, XMLSerializer, Clipboard
>
> but what's the reason? Is it because these classes are essentially
> simple and just acting as a tool?
The hash map is to ensure that DOM wrappers are unique but created on
demand, without consuming a pointer in the underlying C++ object. For
DOM Nodes, we use a hash table in the Node's owner document, but in
the case of non-Node objects and the Document itself (which has no
owner document), we need this global hash table.
Regards,
Maciej