[Webkit-unassigned] [Bug 33785] [Gtk] AtkHyperlink needs to be implemented

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Oct 28 03:31:45 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=33785





--- Comment #15 from Mario Sanchez Prada <msanchez at igalia.com>  2010-10-28 03:31:45 PST ---
(In reply to comment #14)
> [...]
> > > WebCore/accessibility/gtk/WebKitAccessibleHyperlink.cpp:44
> > > +// Use this hash table to help reusing instances of the
> > > +// WebKitAccessibleHyperlink class throughout the
> > > +// webkitAccessibleHyperlinkGetOrCreate method
> > > +static GHashTable* hashTable = 0;
> > 
> > I offered a suggestion via Jabber about how this might be avoided.
> 
> True, and I finally implemented it as it's way better than using this global hashtable:
> 
> It basically consists of just having a property in the WebKitAccessible instance implementing the 
> AtkHyperlinkImpl interface to keep a reference to the WebKitAccessibleHyperlink instance, so we can just 
> create and assign that property the first time it's required to create the AtkHyperlink, and reuse it later. 
> Also, from the side of the WebKitAccessibleHyperlink instance, a weak reference is kept to the 
> WebKitAccessible instance, so we can safely unref that AtkHyperlink when the AtkObject is destroyed too.

Sorry, I didn't give the right explanation here:

I did not use a property in the WebKitAccessible class to hold a pointer to WebKitAccessibleHyperlinkg, basically because that would affect to all the subclasses of WebKitAccessible, no matter what interface they implemented, and so that would require some dirty code to only actually use it in those instances of classes implementing the AtkHyperlinkImpl interface (which are dinamically generated, btw).

Besides, as the classes actually being used are dinamically defined and registered (depending on the interfaces being implemented) I couldn't install such a property in any of them either...

So, the final solution was basically to use the g_object_set_data() / g_object_get_data() mechanism to make sure the 'property' is used only when needed, from webkitAccessibleHyperlinkImplGetHyperlink():

  static AtkHyperlink* webkitAccessibleHyperlinkImplGetHyperlink(AtkHyperlinkImpl* hyperlink)
  {
      AtkHyperlink* hyperlinkObject = ATK_HYPERLINK(g_object_get_data(G_OBJECT(hyperlink), "hyperlink-object"));
      if (!hyperlinkObject) {
          hyperlinkObject = ATK_HYPERLINK(webkitAccessibleHyperlinkNew(hyperlink));
          g_object_set_data(G_OBJECT(hyperlink), "hyperlink-object", hyperlinkObject);
      }
      return hyperlinkObject;
  }

Sorry for the wrong explanation before, I was thinking of the orignal proposal (a property) not in the actual final implementation :/

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list