Changeset 51768 in webkit


Ignore:
Timestamp:
Dec 7, 2009 7:38:48 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-07 Joanmarie Diggs <joanmarie.diggs@gmail.com>

Reviewed by Xan Lopez.

https://bugs.webkit.org/show_bug.cgi?id=25415
[GTK][ATK] Please implement support for get_text_at_offset

Eliminate the segfaults which occur when accessing the text interface now
implemented by text controls.

  • accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: (getPangoLayoutForAtk):

2009-12-07 Joanmarie Diggs <joanmarie.diggs@gmail.com>

Reviewed by Xan Lopez.

https://bugs.webkit.org/show_bug.cgi?id=25415
[GTK][ATK] Please implement support for get_text_at_offset

Eliminate the segfaults which occur when accessing the text interface now
implemented by text controls.

  • tests/testatk.c (test_webkit_atk_get_text_at_offset_textarea): (test_webkit_atk_get_text_at_offset_text_input): (main):
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51764 r51768  
     12009-12-07  Joanmarie Diggs  <joanmarie.diggs@gmail.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=25415
     6        [GTK][ATK] Please implement support for get_text_at_offset
     7
     8        Eliminate the segfaults which occur when accessing the text interface now
     9        implemented by text controls.
     10
     11        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
     12        (getPangoLayoutForAtk):
     13
    1142009-12-07  Gustavo Noronha Silva  <gns@gnome.org>
    215
  • trunk/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp

    r51762 r51768  
    909909
    910910    // Create a string with the layout as it appears on the screen
    911     InlineTextBox* box = renderText->firstTextBox();
    912     while (box) {
    913         gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
    914         g_string_append(str, text);
    915         // Newline chars in the source result in separate text boxes, so check
    916         // before adding a newline in the layout. See bug 25415 comment #78.
    917         if (!box->nextOnLineExists())
     911    if (accObject->isTextControl()) {
     912        unsigned textLength = accObject->textLength();
     913        int lineNumber = 0;
     914        PlainTextRange range = accObject->doAXRangeForLine(lineNumber);
     915        while (range.length) {
     916            // When a line of text wraps in a text area, the final space is removed.
     917            if (range.start + range.length < textLength)
     918                range.length -= 1;
     919            String lineText = accObject->doAXStringForRange(range);
     920            g_string_append(str, lineText.utf8().data());
    918921            g_string_append(str, "\n");
    919         box = box->nextTextBox();
     922            range = accObject->doAXRangeForLine(++lineNumber);
     923        }
     924    } else {
     925        InlineTextBox* box = renderText->firstTextBox();
     926        while (box) {
     927            gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
     928            g_string_append(str, text);
     929            // Newline chars in the source result in separate text boxes, so check
     930            // before adding a newline in the layout. See bug 25415 comment #78.
     931            if (!box->nextOnLineExists())
     932                g_string_append(str, "\n");
     933            box = box->nextTextBox();
     934        }
    920935    }
    921936
  • trunk/WebKit/gtk/ChangeLog

    r51764 r51768  
     12009-12-07  Joanmarie Diggs  <joanmarie.diggs@gmail.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=25415
     6        [GTK][ATK] Please implement support for get_text_at_offset
     7
     8        Eliminate the segfaults which occur when accessing the text interface now
     9        implemented by text controls.
     10
     11        * tests/testatk.c
     12        (test_webkit_atk_get_text_at_offset_textarea):
     13        (test_webkit_atk_get_text_at_offset_text_input):
     14        (main):
     15
    1162009-12-06  Gustavo Noronha Silva  <gns@gnome.org>
    217
  • trunk/WebKit/gtk/tests/testatk.c

    r51342 r51768  
    3131static const char* contentsWithNewlines = "<html><body><p>This is a test. \n\nThis\n is the second sentence. And this the third.</p></body></html>";
    3232
     33static const char* contentsInTextarea = "<html><body><textarea cols='80'>This is a test. This is the second sentence. And this the third.</textarea></body></html>";
     34
     35static const char* contentsInTextInput = "<html><body><input type='text' size='80' value='This is a test. This is the second sentence. And this the third.'/></body></html>";
     36
    3337static gboolean bail_out(GMainLoop* loop)
    3438{
     
    295299}
    296300
     301static void test_webkit_atk_get_text_at_offset_textarea(void)
     302{
     303    WebKitWebView* webView;
     304    AtkObject* obj;
     305    GMainLoop* loop;
     306    AtkText* text_obj;
     307
     308    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
     309    g_object_ref_sink(webView);
     310    GtkAllocation alloc = { 0, 0, 800, 600 };
     311    gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
     312    webkit_web_view_load_string(webView, contentsInTextarea, NULL, NULL, NULL);
     313    loop = g_main_loop_new(NULL, TRUE);
     314
     315    g_timeout_add(100, (GSourceFunc)bail_out, loop);
     316    g_main_loop_run(loop);
     317
     318    /* Get to the inner AtkText object */
     319    obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
     320    g_assert(obj);
     321    obj = atk_object_ref_accessible_child(obj, 0);
     322    g_assert(obj);
     323    obj = atk_object_ref_accessible_child(obj, 0);
     324    g_assert(obj);
     325
     326    text_obj = ATK_TEXT(obj);
     327    g_assert(ATK_IS_TEXT(text_obj));
     328
     329    run_get_text_tests(text_obj);
     330
     331    g_object_unref(webView);
     332}
     333
     334static void test_webkit_atk_get_text_at_offset_text_input(void)
     335{
     336    WebKitWebView* webView;
     337    AtkObject* obj;
     338    GMainLoop* loop;
     339    AtkText* text_obj;
     340
     341    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
     342    g_object_ref_sink(webView);
     343    GtkAllocation alloc = { 0, 0, 800, 600 };
     344    gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
     345    webkit_web_view_load_string(webView, contentsInTextInput, NULL, NULL, NULL);
     346    loop = g_main_loop_new(NULL, TRUE);
     347
     348    g_timeout_add(100, (GSourceFunc)bail_out, loop);
     349    g_main_loop_run(loop);
     350
     351    /* Get to the inner AtkText object */
     352    obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
     353    g_assert(obj);
     354    obj = atk_object_ref_accessible_child(obj, 0);
     355    g_assert(obj);
     356    obj = atk_object_ref_accessible_child(obj, 0);
     357    g_assert(obj);
     358
     359    text_obj = ATK_TEXT(obj);
     360    g_assert(ATK_IS_TEXT(text_obj));
     361
     362    run_get_text_tests(text_obj);
     363
     364    g_object_unref(webView);
     365}
     366
    297367int main(int argc, char** argv)
    298368{
     
    304374    g_test_add_func("/webkit/atk/get_text_at_offset_forms", test_webkit_atk_get_text_at_offset_forms);
    305375    g_test_add_func("/webkit/atk/get_text_at_offset_newlines", test_webkit_atk_get_text_at_offset_newlines);
     376    g_test_add_func("/webkit/atk/get_text_at_offset_textarea", test_webkit_atk_get_text_at_offset_textarea);
     377    g_test_add_func("/webkit/atk/get_text_at_offset_text_input", test_webkit_atk_get_text_at_offset_text_input);
    306378    return g_test_run ();
    307379}
Note: See TracChangeset for help on using the changeset viewer.