[webkit-dev] AXObjectCache memory management?

Maciej Stachowiak mjs at apple.com
Mon Aug 23 02:09:29 PDT 2010


On Aug 23, 2010, at 12:47 AM, Eric Seidel wrote:

> Does anyone know why AXObjectCache is not ref counted?  It has some
> manual scheme which seems likely to have bugs in it.
> 
> http://trac.webkit.org/browser/trunk/WebCore/dom/Document.cpp#L1742
> 
> There just seems to be a lot of code in Document to manage this simple cache.

I don't know the history of this code, but I suspect refcounting would work.

Note: a bunch of the complexity there is to ensure there is only one AXObjectCache per frame/document tree, but still keep it in a member of Document. Using refcounting would get rid of the explicit new/delete calls, but would not greatly simplify the overall logic.

If there is only supposed to be one per top-level document rather than one per document, perhaps it should live off of Page. Then it could follow single ownership and be held by an OwnPtr. It would add more indicrection to accessing it, but would save multiple function calls and branches, so probably not a performance issue. I believe there is no need to ever get AXObjects for a Document that is not currently held by a Frame that belongs to a Page. 

Of course, refcounting would still be fine in this case, these objects are not so common that a refcount field is an extravagant expense. My point is mainly this: I believe the key design problem is that the AXObject cache is held by Document instead of Page even though our goal is to have one per Page.

I expect we have enough regression tests for accessibility to try this change.

Regards,
Maciej



More information about the webkit-dev mailing list