Skip to content
Permalink
Browse files
[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.

Canonical link: https://commits.webkit.org/136390@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@152396 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
mariospr committed Jul 4, 2013
1 parent 683d9b3 commit e3e7bd777c12e14eb988baa4d6207973d4a0a0a7
Showing with 112 additions and 5 deletions.
  1. +12 −0 Source/WebCore/ChangeLog
  2. +0 −5 Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp
  3. +13 −0 Source/WebKit/gtk/ChangeLog
  4. +87 −0 Source/WebKit/gtk/tests/testatk.c
@@ -1,3 +1,15 @@
2013-07-04 Mario Sanchez Prada <mario.prada@samsung.com>

[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.

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

* accessibility/atk/WebKitAccessibleInterfaceText.cpp:
(webkitAccessibleTextGetChar): Removed wrong code.

2013-07-04 Patrick Gansterer <paroga@webkit.org>

Port FileSystemWin.cpp to WinCE
@@ -602,11 +602,6 @@ static gchar* webkitAccessibleTextGetChar(AtkText* text, gint offset, GetTextRel
if (*startOffset == *endOffset)
return g_strdup("");

// Make sure we return the line break if we are at the visual end of a line.
VisiblePosition visiblePosition = coreObject->visiblePositionForIndex(actualOffset);
if (isEndOfLine(visiblePosition))
return g_strdup("\n");

return g_utf8_substring(textData.get(), *startOffset, *endOffset);
}

@@ -1,3 +1,16 @@
2013-07-04 Mario Sanchez Prada <mario.prada@samsung.com>

[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.

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.

2013-07-01 Gustavo Noronha Silva <gustavo.noronha@collabora.com>

[GTK] Remove unsupported AC backends
@@ -50,6 +50,8 @@ static const char* contentsInTableWithHeaders = "<html><body><table><tr><th>foo<

static const char* contentsWithExtraneousWhiteSpaces = "<html><head><body><p>This\n paragraph\n is\n borked!</p></body></html>";

static 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>";

static const char* comboBoxSelector = "<html><body><select><option selected value='foo'>foo</option><option value='bar'>bar</option></select></body></html>";

static const char* embeddedObjects = "<html><body><p>Choose: <input value='foo' type='checkbox'/>foo <input value='bar' type='checkbox'/>bar (pick one)</p><p>Choose: <select name='foo'><option>bar</option><option>baz</option></select> (pick one)</p><p><input name='foobarbutton' value='foobar' type='button'/></p></body></html>";
@@ -941,6 +943,90 @@ static void testWebkitAtkGetTextAtOffsetWithSpecialCharacters()
g_object_unref(webView);
}

static void testWebkitAtkGetTextAtOffsetWithWrappedLines()
{
WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_object_ref_sink(webView);
GtkAllocation allocation = { 0, 0, 800, 600 };
gtk_widget_size_allocate(GTK_WIDGET(webView), &allocation);
webkit_web_view_load_string(webView, contentsWithWrappedLines, 0, 0, 0);

/* Enable caret browsing. */
WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
g_object_set(settings, "enable-caret-browsing", TRUE, NULL);
webkit_web_view_set_settings(webView, settings);

/* Get to the inner AtkText object. */
AtkObject* object = getWebAreaObject(webView);
g_assert(object);

/* Check the paragraph with the text wrapped because of max-width. */
AtkText* paragraph1 = ATK_TEXT(atk_object_ref_accessible_child(object, 0));
g_assert(ATK_IS_TEXT(paragraph1));

gchar* text = atk_text_get_text(paragraph1, 0, -1);
g_assert_cmpstr(text, ==, "This is one line wrapped because of the maximum width of its container.");
g_free(text);

testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_CHAR, 16, "e", 15, 16);
testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_CHAR, 16, " ", 16, 17);
testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_CHAR, 16, "w", 17, 18);

testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_WORD_START, 16, "one ", 8, 12);
testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_WORD_START, 16, "line ", 12, 17);
testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_WORD_START, 16, "wrapped ", 17, 25);

testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_WORD_END, 16, " line", 11, 16);
testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_WORD_END, 16, " wrapped", 16, 24);
testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_WORD_END, 16, " because", 24, 32);

testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_LINE_START, 17, "This is one line ", 0, 17);
testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 17, "wrapped because ", 17, 33);
testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_LINE_START, 17, "of the maximum ", 33, 48);

/* The following line won't work at the moment because of a bug in GailTextUtil.
see https://bugzilla.gnome.org/show_bug.cgi?id=703554
testGetTextFunction(paragraph1, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_LINE_END, 17, "This is one line", 0, 16); */
testGetTextFunction(paragraph1, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 17, " wrapped because", 16, 32);
testGetTextFunction(paragraph1, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_LINE_END, 17, " of the maximum", 32, 47);

g_object_unref(paragraph1);

/* Check the paragraph with the text wrapped because of <br> elements. */
AtkText* paragraph2 = ATK_TEXT(atk_object_ref_accessible_child(object, 1));
g_assert(ATK_IS_TEXT(paragraph2));

text = atk_text_get_text(paragraph2, 0, -1);
g_assert_cmpstr(text, ==, "This is another line wrapped\nbecause of one forced\nline break in the middle.");
g_free(text);

testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_CHAR, 28, "d", 27, 28);
testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_CHAR, 28, "\n", 28, 29);
testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_CHAR, 28, "b", 29, 30);

testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_WORD_START, 28, "line ", 16, 21);
testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_WORD_START, 28, "wrapped\n", 21, 29);
testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_WORD_START, 28, "because ", 29, 37);

testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_WORD_END, 28, " wrapped", 20, 28);
testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_WORD_END, 28, "\nbecause", 28, 36);
testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_WORD_END, 28, " of", 36, 39);

testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_LINE_START, 30, "This is another line wrapped\n", 0, 29);
testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 30, "because of one forced\n", 29, 51);
testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_LINE_START, 30, "line break in the middle.", 51, 76);

/* The following line won't work at the moment because of a bug in GailTextUtil.
see https://bugzilla.gnome.org/show_bug.cgi?id=703554
testGetTextFunction(paragraph2, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_LINE_END, 30, "This is another line wrapped", 0, 28); */
testGetTextFunction(paragraph2, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 30, "\nbecause of one forced", 28, 50);
testGetTextFunction(paragraph2, atk_text_get_text_after_offset, ATK_TEXT_BOUNDARY_LINE_END, 30, "\nline break in the middle.", 50, 76);

g_object_unref(paragraph2);

g_object_unref(webView);
}

static void testWebkitAtkGetTextInParagraphAndBodySimple()
{
WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
@@ -2011,6 +2097,7 @@ int main(int argc, char** argv)
g_test_add_func("/webkit/atk/getTextAtOffsetTextInput", testWebkitAtkGetTextAtOffsetTextInput);
g_test_add_func("/webkit/atk/getTextAtOffsetWithPreformattedText", testWebkitAtkGetTextAtOffsetWithPreformattedText);
g_test_add_func("/webkit/atk/getTextAtOffsetWithSpecialCharacters", testWebkitAtkGetTextAtOffsetWithSpecialCharacters);
g_test_add_func("/webkit/atk/getTextAtOffsetWithWrappedLines", testWebkitAtkGetTextAtOffsetWithWrappedLines);
g_test_add_func("/webkit/atk/getTextInParagraphAndBodySimple", testWebkitAtkGetTextInParagraphAndBodySimple);
g_test_add_func("/webkit/atk/getTextInParagraphAndBodyModerate", testWebkitAtkGetTextInParagraphAndBodyModerate);
g_test_add_func("/webkit/atk/getTextInTable", testWebkitAtkGetTextInTable);

0 comments on commit e3e7bd7

Please sign in to comment.