[at-spi2-core] Fix/rework selective caching
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] Fix/rework selective caching
- Date: Sun, 22 May 2011 23:40:55 +0000 (UTC)
commit 78beee3d5f5f919fd2ec1ed99bef9a4126c0b56c
Author: Mike Gorse <mgorse novell com>
Date: Sun May 22 18:37:27 2011 -0500
Fix/rework selective caching
Previously, atspi_accessible_set_cache_mask would not affect accessibles
which were already cached, but this was not very useful, as caching is done
automatically when a new app is discovered. Functions that may retrieve
cached data now test the cache setting for the application--not just whether
there is a value stored for the data--whe ndetermining whether to call the app.
Also, annotate atspi_accessible_set_cache_mask as a gint. This is temporary;
properly generating GTypes for enums/flags is TODO for 2.2.
atspi/atspi-accessible.c | 50 ++++++++++++++++++++++++++++++++-------------
atspi/atspi-accessible.h | 1 +
atspi/atspi-constants.h | 2 +-
3 files changed, 37 insertions(+), 16 deletions(-)
---
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 1085b72..6aec075 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -307,7 +307,7 @@ gchar *
atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
{
g_return_val_if_fail (obj != NULL, g_strdup (""));
- if (!(obj->cached_properties & ATSPI_CACHE_NAME))
+ if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
{
if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
"s", &obj->name))
@@ -331,7 +331,7 @@ atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
{
g_return_val_if_fail (obj != NULL, g_strdup (""));
- if (!(obj->cached_properties & ATSPI_CACHE_DESCRIPTION))
+ if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
{
if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
"Description", error, "s",
@@ -360,7 +360,8 @@ atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
{
g_return_val_if_fail (obj != NULL, NULL);
- if (obj->parent.app && !(obj->cached_properties & ATSPI_CACHE_PARENT))
+ if (obj->parent.app &&
+ !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
{
DBusMessage *message, *reply;
DBusMessageIter iter, iter_variant;
@@ -406,7 +407,7 @@ atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
{
g_return_val_if_fail (obj != NULL, -1);
- if (!(obj->cached_properties & ATSPI_CACHE_CHILDREN))
+ if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
{
dbus_int32_t ret;
if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
@@ -437,7 +438,7 @@ atspi_accessible_get_child_at_index (AtspiAccessible *obj,
g_return_val_if_fail (obj != NULL, NULL);
- if (!(obj->cached_properties & ATSPI_CACHE_CHILDREN))
+ if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
{
DBusMessage *reply;
reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
@@ -470,7 +471,8 @@ atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
g_return_val_if_fail (obj != NULL, -1);
if (!obj->accessible_parent) return -1;
- if (!(obj->accessible_parent->cached_properties & ATSPI_CACHE_CHILDREN))
+ if (!_atspi_accessible_test_cache (obj->accessible_parent,
+ ATSPI_CACHE_CHILDREN))
{
dbus_uint32_t ret = -1;
_atspi_dbus_call (obj, atspi_interface_accessible,
@@ -547,7 +549,7 @@ atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
{
g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
- if (!(obj->cached_properties & ATSPI_CACHE_ROLE))
+ if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
{
dbus_uint32_t role;
/* TODO: Make this a property */
@@ -636,7 +638,7 @@ atspi_accessible_get_state_set (AtspiAccessible *obj)
return defunct_set ();
- if (!(obj->cached_properties & ATSPI_CACHE_STATES))
+ if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
{
DBusMessage *reply;
DBusMessageIter iter;
@@ -821,7 +823,7 @@ _atspi_accessible_is_a (AtspiAccessible *accessible,
return FALSE;
}
- if (!(accessible->cached_properties & ATSPI_CACHE_INTERFACES))
+ if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
{
DBusMessage *reply;
DBusMessageIter iter;
@@ -1351,7 +1353,7 @@ atspi_accessible_new (AtspiApplication *app, const gchar *path)
*
* @accessible: The #AtspiAccessible to operate on. Must be the desktop or
* the root of an application.
- * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
+ * @mask: (type int): An #AtspiCache specifying a bit mask of the types of data to cache.
*
* Sets the type of data to cache for accessibles.
* If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
@@ -1360,8 +1362,6 @@ atspi_accessible_new (AtspiApplication *app, const gchar *path)
* be cached.
* This function is intended to work around bugs in toolkits where the proper
* events are not raised / to aid in testing for such bugs.
- *
- * Note: This function has no effect on data that has already been cached.
**/
void
atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
@@ -1372,11 +1372,15 @@ atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
accessible->parent.app->cache = mask;
}
-void
-_atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
+static AtspiCache
+_atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
{
- AtspiCache mask = accessible->parent.app->cache;
+ AtspiCache mask;
+
+ if (!accessible->parent.app)
+ return ATSPI_CACHE_NONE;
+ mask = accessible->parent.app->cache;
if (mask == ATSPI_CACHE_UNDEFINED &&
accessible->parent.app->root &&
accessible->parent.app->root->accessible_parent)
@@ -1389,5 +1393,21 @@ _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
if (mask == ATSPI_CACHE_UNDEFINED)
mask = ATSPI_CACHE_ALL;
+ return mask;
+}
+
+gboolean
+_atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
+{
+ AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
+ AtspiCache result = accessible->cached_properties & mask & flag;
+ return (result != 0);
+}
+
+void
+_atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
+{
+ AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
+
accessible->cached_properties |= flag & mask;
}
diff --git a/atspi/atspi-accessible.h b/atspi/atspi-accessible.h
index 3dca620..72c2bbe 100644
--- a/atspi/atspi-accessible.h
+++ b/atspi/atspi-accessible.h
@@ -131,4 +131,5 @@ void atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache ma
/* private */
void _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag);
+gboolean _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag);
#endif /* _ATSPI_ACCESSIBLE_H_ */
diff --git a/atspi/atspi-constants.h b/atspi/atspi-constants.h
index 7c1a1f8..d69a84d 100644
--- a/atspi/atspi-constants.h
+++ b/atspi/atspi-constants.h
@@ -761,7 +761,7 @@ typedef enum {
typedef enum
{
- ATSPI_CACHE_NONE = 0x0001,
+ ATSPI_CACHE_NONE = 0x0000,
ATSPI_CACHE_PARENT = 0x0001,
ATSPI_CACHE_CHILDREN = 0x0002,
ATSPI_CACHE_NAME = 0x0004,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]