Changeset 44622 in webkit


Ignore:
Timestamp:
Jun 11, 2009 11:46:17 PM (15 years ago)
Author:
xan@webkit.org
Message:

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):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r44617 r44622  
     12009-06-12  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Gustavo Noronha.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=25609
     6        [GTK] Implement support for get_selection and get_n_selections
     7
     8        Only use the VisibleSelection object if it actually belongs to the
     9        object we are using.
     10
     11        This is pretty hacky-ish, but I can't seem to find a direct API to
     12        get the VisibleSelection for a given object, only the global one.
     13
     14        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
     15        (selectionBelongsToObject):
     16        (webkit_accessible_text_get_n_selections):
     17        (webkit_accessible_text_get_selection):
     18
    1192009-06-03  Eric Seidel  <eric@webkit.org>
    220
  • trunk/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp

    r44592 r44622  
    611611}
    612612
     613static bool selectionBelongsToObject(AccessibilityObject *coreObject, VisibleSelection& selection)
     614{
     615    if (!coreObject->isAccessibilityRenderObject())
     616        return false;
     617
     618    Node* node = static_cast<AccessibilityRenderObject*>(coreObject)->renderer()->node();
     619    return node == selection.base().containerNode();
     620}
     621
    613622static gint webkit_accessible_text_get_n_selections(AtkText* text)
    614623{
     
    618627    // We don't support multiple selections for now, so there's only
    619628    // two possibilities
    620     return selection.isNone() ? 0 : 1;
     629    // Also, we don't want to do anything if the selection does not
     630    // belong to the currently selected object. We have to check since
     631    // there's no way to get the selection for a given object, only
     632    // the global one (the API is a bit confusing)
     633    return !selectionBelongsToObject(coreObject, selection) || selection.isNone() ? 0 : 1;
    621634}
    622635
    623636static gchar* webkit_accessible_text_get_selection(AtkText* text, gint selection_num, gint* start_offset, gint* end_offset)
    624637{
    625     if (selection_num != 0) {
    626         // WebCore does not support multiple selection, so anything but 0 does not make sense for now.
     638    AccessibilityObject* coreObject = core(text);
     639    VisibleSelection selection = coreObject->selection();
     640
     641    // WebCore does not support multiple selection, so anything but 0 does not make sense for now.
     642    // Also, we don't want to do anything if the selection does not
     643    // belong to the currently selected object. We have to check since
     644    // there's no way to get the selection for a given object, only
     645    // the global one (the API is a bit confusing)
     646    if (selection_num != 0 || !selectionBelongsToObject(coreObject, selection)) {
    627647        *start_offset = *end_offset = 0;
    628648        return NULL;
    629649    }
    630650
    631     AccessibilityObject* coreObject = core(text);
    632     VisibleSelection selection = coreObject->selection();
    633651    *start_offset = selection.start().offsetInContainerNode();
    634652    *end_offset = selection.end().offsetInContainerNode();
Note: See TracChangeset for help on using the changeset viewer.