Changeset 127367 in webkit


Ignore:
Timestamp:
Sep 1, 2012 1:43:04 AM (12 years ago)
Author:
zandobersek@gmail.com
Message:

[Gtk] Incorrect/unexpected characters in the text of certain accessibles
https://bugs.webkit.org/show_bug.cgi?id=95180

Patch by Joanmarie Diggs <jdiggs@igalia.com> on 2012-09-01
Reviewed by Chris Fleizach.

Source/WebCore:

The bug was caused by failing to properly handle anonymous block text
which had object replacement characters (multibyte) in it. Calculating
the string length based on the UTF-8 string meant that we were returning
more characters than were there and in danger of splitting a multibyte
character.

Tests: platform/gtk/accessibility/entry-and-password.html

platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html

  • accessibility/gtk/WebKitAccessibleInterfaceText.cpp:

(webkitAccessibleTextGetText): Convert the text returned by textForObject()
to Unicode before calculating its length.

Source/WebKit/gtk:

Corrected a unit test in which the expected accessible text was wrong as
a result of this bug. In particular, the AtkText inserted into an empty
text field is expected to be the same text atk_text_get_text() returns.
That was not happening -- and presumably not noticed as a result of the
hard to read textual representation of the multibyte password field
bullets.

  • tests/testatk.c:

(testWebkitAtkTextChangedNotifications): Corrected the test and added a
comment so that one knows what the multibyte character is.

Tools:

The bug that was fixed stood in the way of fully implementing stringValue().
Testing that the bug is fixed requires stringValue() to be fully implemented
and object replacement characters to be printable.

  • DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp:

(replaceCharactersForResults): New method which turns object replacement
characters into "<obj>" so that the characters can be properly shown in
Layout Test results. Also turns "\n" into "<
n>" so that printing the
accessible text of a single object in the accessible tree doesn't mess up
the readibility of the results.
(AccessibilityUIElement::stringValue): Remove the code that immediately
returned upon encountering an object of ATK_ROLE_PANEL and call the new
replaceCharactersForResults() prior to returning the accessible string
value.

LayoutTests:

Two new layout tests, plus one updated one.

  • platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt: Indicated replaced objects.
  • platform/gtk/accessibility/entry-and-password-expected.txt: Added.
  • platform/gtk/accessibility/entry-and-password.html: Added.
  • platform/gtk/accessibility/replaced-objects-in-anonymous-blocks-expected.txt: Added.
  • platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html: Added.
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r127365 r127367  
     12012-09-01  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        [Gtk] Incorrect/unexpected characters in the text of certain accessibles
     4        https://bugs.webkit.org/show_bug.cgi?id=95180
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Two new layout tests, plus one updated one.
     9
     10        * platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt: Indicated replaced objects.
     11        * platform/gtk/accessibility/entry-and-password-expected.txt: Added.
     12        * platform/gtk/accessibility/entry-and-password.html: Added.
     13        * platform/gtk/accessibility/replaced-objects-in-anonymous-blocks-expected.txt: Added.
     14        * platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html: Added.
     15
    1162012-09-01  Tommy Widenflycht  <tommyw@google.com>
    217
  • trunk/LayoutTests/platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt

    r126941 r127367  
    1515    AXRole: document frame
    1616        AXRole: paragraph AXValue: Before
    17         AXRole: panel
     17        AXRole: panel AXValue: <obj>
    1818            AXRole: scroll pane
    1919                AXRole: document frame
    20                     AXRole: panel
     20                    AXRole: panel AXValue: <obj>Click me
    2121                        AXRole: push button
    2222        AXRole: paragraph AXValue: After
     
    2727    AXRole: document frame
    2828        AXRole: paragraph AXValue: Before
    29         AXRole: panel
     29        AXRole: panel AXValue:
    3030        AXRole: paragraph AXValue: After
    3131        AXRole: paragraph AXValue: End of test
  • trunk/Source/WebCore/ChangeLog

    r127366 r127367  
     12012-09-01  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        [Gtk] Incorrect/unexpected characters in the text of certain accessibles
     4        https://bugs.webkit.org/show_bug.cgi?id=95180
     5
     6        Reviewed by Chris Fleizach.
     7
     8        The bug was caused by failing to properly handle anonymous block text
     9        which had object replacement characters (multibyte) in it. Calculating
     10        the string length based on the UTF-8 string meant that we were returning
     11        more characters than were there and in danger of splitting a multibyte
     12        character.
     13
     14        Tests: platform/gtk/accessibility/entry-and-password.html
     15               platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html
     16
     17        * accessibility/gtk/WebKitAccessibleInterfaceText.cpp:
     18        (webkitAccessibleTextGetText): Convert the text returned by textForObject()
     19        to Unicode before calculating its length.
     20
    1212012-09-01  Adam Barth  <abarth@webkit.org>
    222
  • trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceText.cpp

    r126359 r127367  
    538538    if (!ret.length()) {
    539539        // This can happen at least with anonymous RenderBlocks (e.g. body text amongst paragraphs)
    540         ret = String(textForObject(coreObject));
     540        // In such instances, there may also be embedded objects. The object replacement character
     541        // is something ATs want included and we have to account for the fact that it is multibyte.
     542        ret = String::fromUTF8(textForObject(coreObject));
    541543        if (!end)
    542544            end = ret.length();
  • trunk/Source/WebKit/gtk/ChangeLog

    r127328 r127367  
     12012-09-01  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        [Gtk] Incorrect/unexpected characters in the text of certain accessibles
     4        https://bugs.webkit.org/show_bug.cgi?id=95180
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Corrected a unit test in which the expected accessible text was wrong as
     9        a result of this bug. In particular, the AtkText inserted into an empty
     10        text field is expected to be the same text atk_text_get_text() returns.
     11        That was not happening -- and presumably not noticed as a result of the
     12        hard to read textual representation of the multibyte password field
     13        bullets.
     14
     15        * tests/testatk.c:
     16        (testWebkitAtkTextChangedNotifications): Corrected the test and added a
     17        comment so that one knows what the multibyte character is.
     18
    1192012-08-31  José Dapena Paz  <jdapena@igalia.com>
    220
  • trunk/Source/WebKit/gtk/tests/testatk.c

    r126243 r127367  
    18681868
    18691869    pos = 0;
     1870    /* A single bullet character is '\342\200\242' */
    18701871    atk_editable_text_insert_text(ATK_EDITABLE_TEXT(passwordEntry), "foobar", 6, &pos);
    18711872    g_assert_cmpstr(textChangedResult, ==, "|1|0|6|'\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242'|");
    18721873    text = atk_text_get_text(ATK_TEXT(passwordEntry), 0, -1);
    1873     g_assert_cmpstr(text, ==, "\303\242\302\200\302\242\303\242\302\200\302\242");
     1874    g_assert_cmpstr(text, ==, "\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242");
    18741875    g_free(text);
    18751876
     
    18781879
    18791880    text = atk_text_get_text(ATK_TEXT(passwordEntry), 0, -1);
    1880     g_assert_cmpstr(text, ==, "\303\242\302\200\302\242\303\242");
     1881    g_assert_cmpstr(text, ==, "\342\200\242\342\200\242\342\200\242\342\200\242");
    18811882    g_free(text);
    18821883
     
    18861887
    18871888    text = atk_text_get_text(ATK_TEXT(passwordEntry), 0, -1);
    1888     g_assert_cmpstr(text, ==, "\303\242\302\200\302\242\303\242\302\200\302\242\303\242");
     1889    g_assert_cmpstr(text, ==, "\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242");
    18891890    g_free(text);
    18901891
  • trunk/Tools/ChangeLog

    r127365 r127367  
     12012-09-01  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        [Gtk] Incorrect/unexpected characters in the text of certain accessibles
     4        https://bugs.webkit.org/show_bug.cgi?id=95180
     5
     6        Reviewed by Chris Fleizach.
     7
     8        The bug that was fixed stood in the way of fully implementing stringValue().
     9        Testing that the bug is fixed requires stringValue() to be fully implemented
     10        and object replacement characters to be printable.
     11
     12        * DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp:
     13        (replaceCharactersForResults): New method which turns object replacement
     14        characters into "<obj>" so that the characters can be properly shown in
     15        Layout Test results. Also turns "\n" into "<\\n>" so that printing the
     16        accessible text of a single object in the accessible tree doesn't mess up
     17        the readibility of the results.
     18        (AccessibilityUIElement::stringValue): Remove the code that immediately
     19        returned upon encountering an object of ATK_ROLE_PANEL and call the new
     20        replaceCharactersForResults() prior to returning the accessible string
     21        value.
     22
    1232012-09-01  Tommy Widenflycht  <tommyw@google.com>
    224
  • trunk/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp

    r126941 r127367  
    3535#include <wtf/gobject/GOwnPtr.h>
    3636#include <wtf/gobject/GRefPtr.h>
     37#include <wtf/text/WTFString.h>
     38#include <wtf/unicode/CharacterNames.h>
     39
     40static inline gchar* replaceCharactersForResults(gchar* str)
     41{
     42    String uString = String::fromUTF8(str);
     43
     44    // The object replacement character is passed along to ATs so we need to be
     45    // able to test for their presence and do so without causing test failures.
     46    uString.replace(objectReplacementCharacter, "<obj>");
     47
     48    // The presence of newline characters in accessible text of a single object
     49    // is appropriate, but it makes test results (especially the accessible tree)
     50    // harder to read.
     51    uString.replace("\n", "<\\n>");
     52
     53    return g_strdup(uString.utf8().data());
     54}
    3755
    3856AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
     
    275293        return JSStringCreateWithCharacters(0, 0);
    276294
    277     // FIXME: implement properly for ATK_ROLE_PANEL. Prior to doing so, we need
    278     // to fix bug 95180 as well as determine which panels we wish to keep in the
    279     // accessible hierarchy. See, for instance, bug 72811.
    280     AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
    281     if (role == ATK_ROLE_PANEL)
    282         return JSStringCreateWithCharacters(0, 0);
    283 
    284     gchar* text =text = atk_text_get_text(ATK_TEXT(m_element), 0, -1);
    285     GOwnPtr<gchar> axValue(g_strdup_printf("AXValue: %s", text));
     295    gchar* text = atk_text_get_text(ATK_TEXT(m_element), 0, -1);
     296    GOwnPtr<gchar> axValue(g_strdup_printf("AXValue: %s", replaceCharactersForResults(text)));
    286297    g_free(text);
    287298
Note: See TracChangeset for help on using the changeset viewer.