[webkit-dev] about hashmap staticDOMObjects

by ZHOU Xiao-boon 2009-04-22T07:27:19+00:00
--001636163eb55b60a404681fb129
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
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
--001636163eb55b60a404681fb129
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
hi all:=A0=A0=A0=A0 I still don't understand the purpose of the Has=
hMap:static DOMObjectMap& domObjects(){ =A0=A0=A0 // Do=
n't use malloc here. Calling malloc from a mark function can deadlock.=A0=A0=A0 static DOMObjectMap staticDOMObjects;
=A0=A0=A0 return staticDOMObjects;}what kind of DOMObjects shou=
ld be stored in it? And why?I searched the source codes and I found tha=
t these classes below will do that: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
but what's the reason? Is it because these classes are essentially =
simple and just acting as a tool?thanks a lot
--001636163eb55b60a404681fb129--

Re: [webkit-dev] about hashmap staticDOMObjects

by ZHOU Xiao-boon 2009-04-22T08:15:49+00:00.
--00163646d1b8913bd80468205e3f
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
oh, I got an idea:
Is it because these domobjects doesn't belong to a Document, so they can't
be
stored in
static NodePerDocMap& domNodesPerDocument()
{
ASSERT(JSLock::lockCount());
static NodePerDocMap staticDOMNodesPerDocument;
return staticDOMNodesPerDocument;
}

2009/4/22 ZHOU Xiao-bo
> 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
>
--00163646d1b8913bd80468205e3f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
oh, I got an idea: Is it because these domobjects doesn't belong to=
a Document, so they can't bestored in static NodePerDocMap=
& domNodesPerDocument(){=A0=A0=A0 ASSERT(JSLock::lockCount());
=A0=A0=A0 static NodePerDocMap staticDOMNodesPerDocument;=A0=A0=A0 retu=
rn staticDOMNodesPerDocument;}2009/4/22 ZHOU Xiao-bo <zhxb.ustc@gmail.com>
hi all:=A0=A0=
=A0=A0 I still don't understand the purpose of the HashMap:stat=
ic DOMObjectMap& domObjects()
{ =A0=A0=A0 // Don't use malloc here. Calling malloc from a mark fu=
nction can deadlock.=A0=A0=A0 static DOMObjectMap staticDOMObjects;
=A0=A0=A0 return staticDOMObjects;}what kind of DOMObjects shou=
ld be stored in it? And why?I searched the source codes and I found tha=
t these classes below will do that: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
but what's the reason? Is it because these classes are essentially =
simple and just acting as a tool?thanks a lot

--00163646d1b8913bd80468205e3f--

Re: [webkit-dev] about hashmap staticDOMObjects

by Maciej Stachowiakon 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
_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev