Changeset 152396 in webkit


Ignore:
Timestamp:
Jul 4, 2013 3:03:42 AM (11 years ago)
Author:
mario@webkit.org
Message:

[ATK] Do not expose '\n' for wrapped lines with ATK_TEXT_BOUNDARY_CHAR
https://bugs.webkit.org/show_bug.cgi?id=118359

Reviewed by Carlos Garcia Campos.

Source/WebCore:

Do not expose a '\n' character for every visual line break.

  • accessibility/atk/WebKitAccessibleInterfaceText.cpp:

(webkitAccessibleTextGetChar): Removed wrong code.

Source/WebKit/gtk:

Added new unit test to make sure we exposed line breaks properly.

  • tests/testatk.c:

(testWebkitAtkGetTextAtOffsetWithWrappedLines): New unit test.
(main): Added new test to the test suite.

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152392 r152396  
     12013-07-04  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        [ATK] Do not expose '\n' for wrapped lines with ATK_TEXT_BOUNDARY_CHAR
     4        https://bugs.webkit.org/show_bug.cgi?id=118359
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Do not expose a '\n' character for every visual line break.
     9
     10        * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
     11        (webkitAccessibleTextGetChar): Removed wrong code.
     12
    1132013-07-04  Patrick Gansterer  <paroga@webkit.org>
    214
  • trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp

    r152232 r152396  
    603603        return g_strdup("");
    604604
    605     // Make sure we return the line break if we are at the visual end of a line.
    606     VisiblePosition visiblePosition = coreObject->visiblePositionForIndex(actualOffset);
    607     if (isEndOfLine(visiblePosition))
    608         return g_strdup("\n");
    609 
    610605    return g_utf8_substring(textData.get(), *startOffset, *endOffset);
    611606}
  • trunk/Source/WebKit/gtk/ChangeLog

    r152275 r152396  
     12013-07-04  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        [ATK] Do not expose '\n' for wrapped lines with ATK_TEXT_BOUNDARY_CHAR
     4        https://bugs.webkit.org/show_bug.cgi?id=118359
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Added new unit test to make sure we exposed line breaks properly.
     9
     10        * tests/testatk.c:
     11        (testWebkitAtkGetTextAtOffsetWithWrappedLines): New unit test.
     12        (main): Added new test to the test suite.
     13
    1142013-07-01  Gustavo Noronha Silva  <gustavo.noronha@collabora.com>
    215
  • trunk/Source/WebKit/gtk/tests/testatk.c

    r149952 r152396  
    5151static const char* contentsWithExtraneousWhiteSpaces = "<html><head><body><p>This\n                          paragraph\n                                                      is\n                                                                                                                                                                                                                                                                                                                                                                            borked!</p></body></html>";
    5252
     53static const char* contentsWithWrappedLines = "<html><body><p style='max-width:150px;'>This is one line wrapped because of the maximum width of its container.</p><p>This is another line wrapped<br>because of one forced<br>line break in the middle.</body></html>";
     54
    5355static const char* comboBoxSelector = "<html><body><select><option selected value='foo'>foo</option><option value='bar'>bar</option></select></body></html>";
    5456
     
    942944}
    943945
     946static void testWebkitAtkGetTextAtOffsetWithWrappedLines()
     947{
     948    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
     949    g_object_ref_sink(webView);
     950    GtkAllocation allocation = { 0, 0, 800, 600 };
     951    gtk_widget_size_allocate(GTK_WIDGET(webView), &allocation);
     952    webkit_web_view_load_string(webView, contentsWithWrappedLines, 0, 0, 0);
     953
     954    /* Enable caret browsing. */
     955    WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
     956    g_object_set(settings, "enable-caret-browsing", TRUE, NULL);
     957    webkit_web_view_set_settings(webView, settings);
     958
     959    /* Get to the inner AtkText object. */
     960    AtkObject* object = getWebAreaObject(webView);
     961    g_assert(object);
     962
     963    /* Check the paragraph with the text wrapped because of max-width. */
     964    AtkText* paragraph1 = ATK_TEXT(atk_object_ref_accessible_child(object, 0));
     965    g_assert(ATK_IS_TEXT(paragraph1));
     966
     967    gchar* text = atk_text_get_text(paragraph1, 0, -1);
     968    g_assert_cmpstr(text, ==, "This is one line wrapped because of the maximum width of its container.");
     969    g_free(text);
     970
     971    testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_CHAR, 16, "e", 15, 16);
     972    testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_CHAR, 16, " ", 16, 17);
     973    testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_CHAR, 16, "w", 17, 18);
     974
     975    testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_WORD_START, 16, "one ", 8, 12);
     976    testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_WORD_START, 16, "line ", 12, 17);
     977    testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_WORD_START, 16, "wrapped ", 17, 25);
     978
     979    testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_WORD_END, 16, " line", 11, 16);
     980    testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_WORD_END, 16, " wrapped", 16, 24);
     981    testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_WORD_END, 16, " because", 24, 32);
     982
     983    testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_LINE_START, 17, "This is one line ", 0, 17);
     984    testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 17, "wrapped because ", 17, 33);
     985    testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_LINE_START, 17, "of the maximum ", 33, 48);
     986
     987    /* The following line won't work at the moment because of a bug in GailTextUtil.
     988       see https://bugzilla.gnome.org/show_bug.cgi?id=703554
     989       testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_LINE_END, 17, "This is one line", 0, 16); */
     990    testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 17, " wrapped because", 16, 32);
     991    testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_LINE_END, 17, " of the maximum", 32, 47);
     992
     993    g_object_unref(paragraph1);
     994
     995    /* Check the paragraph with the text wrapped because of <br> elements. */
     996    AtkText* paragraph2 = ATK_TEXT(atk_object_ref_accessible_child(object, 1));
     997    g_assert(ATK_IS_TEXT(paragraph2));
     998
     999    text = atk_text_get_text(paragraph2, 0, -1);
     1000    g_assert_cmpstr(text, ==, "This is another line wrapped\nbecause of one forced\nline break in the middle.");
     1001    g_free(text);
     1002
     1003    testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_CHAR, 28, "d", 27, 28);
     1004    testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_CHAR, 28, "\n", 28, 29);
     1005    testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_CHAR, 28, "b", 29, 30);
     1006
     1007    testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_WORD_START, 28, "line ", 16, 21);
     1008    testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_WORD_START, 28, "wrapped\n", 21, 29);
     1009    testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_WORD_START, 28, "because ", 29, 37);
     1010
     1011    testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_WORD_END, 28, " wrapped", 20, 28);
     1012    testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_WORD_END, 28, "\nbecause", 28, 36);
     1013    testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_WORD_END, 28, " of", 36, 39);
     1014
     1015    testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_LINE_START, 30, "This is another line wrapped\n", 0, 29);
     1016    testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 30, "because of one forced\n", 29, 51);
     1017    testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_LINE_START, 30, "line break in the middle.", 51, 76);
     1018
     1019    /* The following line won't work at the moment because of a bug in GailTextUtil.
     1020       see https://bugzilla.gnome.org/show_bug.cgi?id=703554
     1021       testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_LINE_END, 30, "This is another line wrapped", 0, 28); */
     1022    testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 30, "\nbecause of one forced", 28, 50);
     1023    testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_LINE_END, 30, "\nline break in the middle.", 50, 76);
     1024
     1025    g_object_unref(paragraph2);
     1026
     1027    g_object_unref(webView);
     1028}
     1029
    9441030static void testWebkitAtkGetTextInParagraphAndBodySimple()
    9451031{
     
    20122098    g_test_add_func("/webkit/atk/getTextAtOffsetWithPreformattedText", testWebkitAtkGetTextAtOffsetWithPreformattedText);
    20132099    g_test_add_func("/webkit/atk/getTextAtOffsetWithSpecialCharacters", testWebkitAtkGetTextAtOffsetWithSpecialCharacters);
     2100    g_test_add_func("/webkit/atk/getTextAtOffsetWithWrappedLines", testWebkitAtkGetTextAtOffsetWithWrappedLines);
    20142101    g_test_add_func("/webkit/atk/getTextInParagraphAndBodySimple", testWebkitAtkGetTextInParagraphAndBodySimple);
    20152102    g_test_add_func("/webkit/atk/getTextInParagraphAndBodyModerate", testWebkitAtkGetTextInParagraphAndBodyModerate);
Note: See TracChangeset for help on using the changeset viewer.