Commit f5b9f7d1 authored by xan@webkit.org's avatar xan@webkit.org

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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b4c9fbe8
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.
......@@ -610,6 +610,15 @@ static gint webkit_accessible_text_get_offset_at_point(AtkText* text, gint x, gi
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);
......@@ -617,19 +626,28 @@ static gint webkit_accessible_text_get_n_selections(AtkText* 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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment