+2009-06-12 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25609
+ [GTK] Implement support for get_selection and get_n_selections
+
+ Only use the VisibleSelection object if it actually belongs to the
+ object we are using.
+
+ This is pretty hacky-ish, but I can't seem to find a direct API to
+ get the VisibleSelection for a given object, only the global one.
+
+ * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+ (selectionBelongsToObject):
+ (webkit_accessible_text_get_n_selections):
+ (webkit_accessible_text_get_selection):
+
2009-06-03 Eric Seidel <eric@webkit.org>
Reviewed by Darin Adler.
return range.start;
}
+static bool selectionBelongsToObject(AccessibilityObject *coreObject, VisibleSelection& selection)
+{
+ if (!coreObject->isAccessibilityRenderObject())
+ return false;
+
+ Node* node = static_cast<AccessibilityRenderObject*>(coreObject)->renderer()->node();
+ return node == selection.base().containerNode();
+}
+
static gint webkit_accessible_text_get_n_selections(AtkText* text)
{
AccessibilityObject* coreObject = core(text);
// We don't support multiple selections for now, so there's only
// two possibilities
- return selection.isNone() ? 0 : 1;
+ // Also, we don't want to do anything if the selection does not
+ // belong to the currently selected object. We have to check since
+ // there's no way to get the selection for a given object, only
+ // the global one (the API is a bit confusing)
+ return !selectionBelongsToObject(coreObject, selection) || selection.isNone() ? 0 : 1;
}
static gchar* webkit_accessible_text_get_selection(AtkText* text, gint selection_num, gint* start_offset, gint* end_offset)
{
- if (selection_num != 0) {
- // WebCore does not support multiple selection, so anything but 0 does not make sense for now.
+ AccessibilityObject* coreObject = core(text);
+ VisibleSelection selection = coreObject->selection();
+
+ // WebCore does not support multiple selection, so anything but 0 does not make sense for now.
+ // Also, we don't want to do anything if the selection does not
+ // belong to the currently selected object. We have to check since
+ // there's no way to get the selection for a given object, only
+ // the global one (the API is a bit confusing)
+ if (selection_num != 0 || !selectionBelongsToObject(coreObject, selection)) {
*start_offset = *end_offset = 0;
return NULL;
}
- AccessibilityObject* coreObject = core(text);
- VisibleSelection selection = coreObject->selection();
*start_offset = selection.start().offsetInContainerNode();
*end_offset = selection.end().offsetInContainerNode();