Title: [104446] trunk/Source
Revision
104446
Author
[email protected]
Date
2012-01-09 02:16:20 -0800 (Mon, 09 Jan 2012)

Log Message

[Gtk] Regression: text-inserted events lack text inserted and current line
https://bugs.webkit.org/show_bug.cgi?id=72830

Reviewed by Martin Robinson.

Source/WebCore:

Fix issue getting the exposed text for an accessibility object at,
before of after a given offset, after changing it at least once.

* accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
(webkit_accessible_class_init): Don't initialize
gailTextUtilQuark, it won't be used anymore.
(getGailTextUtilForAtk): Don't cache the GailTextUtil as object
data, but create a new one each time this function is called.
(webkit_accessible_text_get_caret_offset): Simplified code by
using the new focusedObjectAndCaretOffsetUnignored function,
instead of the old objectAndOffsetUnignored function.
(focusedObjectAndCaretOffsetUnignored): Rewrite of the old
objectAndOffsetUnignored function so it now needs less
parameters than before and takes care of carefully selecting the
start and end visible positions to calculate the position of the
caret from the point of view of the accessibility object of
reference passed as the only input parameter now. Updated callers.
* accessibility/gtk/AccessibilityObjectWrapperAtk.h:

* editing/gtk/FrameSelectionGtk.cpp:
(WebCore::FrameSelection::notifyAccessibilityForSelectionChange):
Simplified code by calling to focusedObjectAndCaretOffsetUnignored
function, instead of the old objectAndOffsetUnignored function.

Source/WebKit/gtk:

Updated unit tests to check that both getting the current position
for the caret and the exposed text at, before or after a given
offset for an accessible object works as expected.

* tests/testatk.c:
(runGetTextTests): For objects implementing AtkEditableText, try
to change the exposed text and retrieve it again as a full line.
(testWebkitAtkCaretOffsets): For a text control (a text entry),
set the caret offset to a value greater than 1 and retrieve it.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104445 => 104446)


--- trunk/Source/WebCore/ChangeLog	2012-01-09 10:00:51 UTC (rev 104445)
+++ trunk/Source/WebCore/ChangeLog	2012-01-09 10:16:20 UTC (rev 104446)
@@ -1,3 +1,34 @@
+2012-01-09  Mario Sanchez Prada  <[email protected]>
+
+        [Gtk] Regression: text-inserted events lack text inserted and current line
+        https://bugs.webkit.org/show_bug.cgi?id=72830
+
+        Reviewed by Martin Robinson.
+
+        Fix issue getting the exposed text for an accessibility object at,
+        before of after a given offset, after changing it at least once.
+
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+        (webkit_accessible_class_init): Don't initialize
+        gailTextUtilQuark, it won't be used anymore.
+        (getGailTextUtilForAtk): Don't cache the GailTextUtil as object
+        data, but create a new one each time this function is called.
+        (webkit_accessible_text_get_caret_offset): Simplified code by
+        using the new focusedObjectAndCaretOffsetUnignored function,
+        instead of the old objectAndOffsetUnignored function.
+        (focusedObjectAndCaretOffsetUnignored): Rewrite of the old
+        objectAndOffsetUnignored function so it now needs less
+        parameters than before and takes care of carefully selecting the
+        start and end visible positions to calculate the position of the
+        caret from the point of view of the accessibility object of
+        reference passed as the only input parameter now. Updated callers.
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.h:
+
+        * editing/gtk/FrameSelectionGtk.cpp:
+        (WebCore::FrameSelection::notifyAccessibilityForSelectionChange):
+        Simplified code by calling to focusedObjectAndCaretOffsetUnignored
+        function, instead of the old objectAndOffsetUnignored function.
+
 2012-01-09  Antti Koivisto  <[email protected]>
 
         Subtree invalidation on stylesheet change

Modified: trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp (104445 => 104446)


--- trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp	2012-01-09 10:00:51 UTC (rev 104445)
+++ trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp	2012-01-09 10:16:20 UTC (rev 104446)
@@ -76,7 +76,6 @@
 
 using namespace WebCore;
 
-static GQuark gailTextUtilQuark = 0;
 static GQuark hyperlinkObjectQuark = 0;
 
 static AccessibilityObject* fallbackObject()
@@ -846,7 +845,6 @@
     klass->get_attributes = webkit_accessible_get_attributes;
     klass->ref_relation_set = webkit_accessible_ref_relation_set;
 
-    gailTextUtilQuark = g_quark_from_static_string("webkit-accessible-gail-text-util");
     hyperlinkObjectQuark = g_quark_from_static_string("webkit-accessible-hyperlink-object");
 }
 
@@ -1293,13 +1291,8 @@
 
 static GailTextUtil* getGailTextUtilForAtk(AtkText* textObject)
 {
-    gpointer data = "" gailTextUtilQuark);
-    if (data)
-        return static_cast<GailTextUtil*>(data);
-
     GailTextUtil* gailTextUtil = gail_text_util_new();
     gail_text_util_text_setup(gailTextUtil, webkit_accessible_text_get_text(textObject, 0, -1));
-    g_object_set_qdata_full(G_OBJECT(textObject), gailTextUtilQuark, gailTextUtil, g_object_unref);
     return gailTextUtil;
 }
 
@@ -1352,20 +1345,8 @@
     if (!coreObject->isAccessibilityRenderObject())
         return 0;
 
-    Document* document = coreObject->document();
-    if (!document)
-        return 0;
-
-    Node* focusedNode = coreObject->selection().end().deprecatedNode();
-    if (!focusedNode)
-        return 0;
-
-    RenderObject* focusedRenderer = focusedNode->renderer();
-    AccessibilityObject* focusedObject = document->axObjectCache()->getOrCreate(focusedRenderer);
-
     int offset;
-    // Don't ignore links if the offset is being requested for a link.
-    if (!objectAndOffsetUnignored(focusedObject, offset, !coreObject->isLink()))
+    if (!objectFocusedAndCaretOffsetUnignored(coreObject, offset))
         return 0;
 
     RenderObject* renderer = coreObject->renderer();
@@ -2733,40 +2714,67 @@
     return focusedObj->wrapper();
 }
 
-AccessibilityObject* objectAndOffsetUnignored(AccessibilityObject* coreObject, int& offset, bool ignoreLinks)
+AccessibilityObject* objectFocusedAndCaretOffsetUnignored(AccessibilityObject* referenceObject, int& offset)
 {
     // Indication that something bogus has transpired.
     offset = -1;
 
-    AccessibilityObject* realObject = coreObject;
-    if (realObject->accessibilityIsIgnored())
-        realObject = realObject->parentObjectUnignored();
-    if (!realObject)
+    Document* document = referenceObject->document();
+    if (!document)
         return 0;
 
-    if (ignoreLinks && realObject->isLink())
-        realObject = realObject->parentObjectUnignored();
-    if (!realObject)
+    Node* focusedNode = referenceObject->selection().end().containerNode();
+    if (!focusedNode)
         return 0;
 
-    Node* node = realObject->node();
-    if (node) {
-        VisiblePosition startPosition = VisiblePosition(positionBeforeNode(node), DOWNSTREAM);
-        VisiblePosition endPosition = realObject->selection().visibleEnd();
+    RenderObject* focusedRenderer = focusedNode->renderer();
+    if (!focusedRenderer)
+        return 0;
 
-        if (startPosition == endPosition)
-            offset = 0;
-        else if (!isStartOfLine(endPosition)) {
-            RefPtr<Range> range = makeRange(startPosition, endPosition.previous());
-            offset = TextIterator::rangeLength(range.get(), true) + 1;
-        } else {
-            RefPtr<Range> range = makeRange(startPosition, endPosition);
-            offset = TextIterator::rangeLength(range.get(), true);
-        }
+    AccessibilityObject* focusedObject = document->axObjectCache()->getOrCreate(focusedRenderer);
+    if (!focusedObject)
+        return 0;
 
+    // Look for the actual (not ignoring accessibility) selected object.
+    if (focusedObject->accessibilityIsIgnored())
+        focusedObject = focusedObject->parentObjectUnignored();
+    if (!focusedObject)
+        return 0;
+
+    // Don't ignore links if the offset is being requested for a link.
+    if (!referenceObject->isLink() && focusedObject->isLink())
+        focusedObject = focusedObject->parentObjectUnignored();
+    if (!focusedObject)
+        return 0;
+
+    Node* startNode = 0;
+    if (focusedObject != referenceObject || focusedObject->isTextControl()) {
+        // We need to use the first child's node of the reference
+        // object as the start point to calculate the caret offset
+        // because we want it to be relative to the object of
+        // reference, not just to the focused object (which could have
+        // previous siblings which should be taken into account too).
+        AccessibilityObject* axFirstChild = referenceObject->firstChild();
+        if (axFirstChild)
+            startNode = axFirstChild->node();
     }
+    if (!startNode)
+        startNode = focusedObject->node();
 
-    return realObject;
+    VisiblePosition startPosition = VisiblePosition(firstPositionInNode(startNode), DOWNSTREAM);
+    VisiblePosition endPosition = focusedObject->selection().visibleEnd();
+
+    if (startPosition == endPosition)
+        offset = 0;
+    else if (!isStartOfLine(endPosition)) {
+        RefPtr<Range> range = makeRange(startPosition, endPosition.previous());
+        offset = TextIterator::rangeLength(range.get(), true) + 1;
+    } else {
+        RefPtr<Range> range = makeRange(startPosition, endPosition);
+        offset = TextIterator::rangeLength(range.get(), true);
+    }
+
+    return focusedObject;
 }
 
 #endif // HAVE(ACCESSIBILITY)

Modified: trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.h (104445 => 104446)


--- trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.h	2012-01-09 10:00:51 UTC (rev 104445)
+++ trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.h	2012-01-09 10:16:20 UTC (rev 104446)
@@ -60,7 +60,7 @@
 
 AtkObject* webkit_accessible_get_focused_element(WebKitAccessible* accessible);
 
-WebCore::AccessibilityObject* objectAndOffsetUnignored(WebCore::AccessibilityObject* coreObject, int& offset, bool ignoreLinks);
+WebCore::AccessibilityObject* objectFocusedAndCaretOffsetUnignored(WebCore::AccessibilityObject*, int& offset);
 
 G_END_DECLS
 

Modified: trunk/Source/WebCore/editing/gtk/FrameSelectionGtk.cpp (104445 => 104446)


--- trunk/Source/WebCore/editing/gtk/FrameSelectionGtk.cpp	2012-01-09 10:00:51 UTC (rev 104445)
+++ trunk/Source/WebCore/editing/gtk/FrameSelectionGtk.cpp	2012-01-09 10:16:20 UTC (rev 104446)
@@ -80,20 +80,17 @@
     if (!AXObjectCache::accessibilityEnabled())
         return;
 
-    // Reset lastFocuseNode and return for no valid selections.
+    // Return for no valid selections.
     if (!m_selection.start().isNotNull() || !m_selection.end().isNotNull())
         return;
 
-    RenderObject* focusedNode = m_selection.end().deprecatedNode()->renderer();
-    AccessibilityObject* accessibilityObject = m_frame->document()->axObjectCache()->getOrCreate(focusedNode);
-
-    // Need to check this as getOrCreate could return 0,
+    // Look for the accessibility object for the Frame.
+    AccessibilityObject* accessibilityObject = m_frame->document()->axObjectCache()->rootObjectForFrame(m_frame);
     if (!accessibilityObject)
         return;
 
     int offset;
-    // Always report the events w.r.t. the non-linked unignored parent. (i.e. ignoreLinks == true).
-    RefPtr<AccessibilityObject> object = objectAndOffsetUnignored(accessibilityObject, offset, true);
+    RefPtr<AccessibilityObject> object = objectFocusedAndCaretOffsetUnignored(accessibilityObject, offset);
     if (!object)
         return;
 

Modified: trunk/Source/WebKit/gtk/ChangeLog (104445 => 104446)


--- trunk/Source/WebKit/gtk/ChangeLog	2012-01-09 10:00:51 UTC (rev 104445)
+++ trunk/Source/WebKit/gtk/ChangeLog	2012-01-09 10:16:20 UTC (rev 104446)
@@ -1,3 +1,20 @@
+2012-01-09  Mario Sanchez Prada  <[email protected]>
+
+        [Gtk] Regression: text-inserted events lack text inserted and current line
+        https://bugs.webkit.org/show_bug.cgi?id=72830
+
+        Reviewed by Martin Robinson.
+
+        Updated unit tests to check that both getting the current position
+        for the caret and the exposed text at, before or after a given
+        offset for an accessible object works as expected.
+
+        * tests/testatk.c:
+        (runGetTextTests): For objects implementing AtkEditableText, try
+        to change the exposed text and retrieve it again as a full line.
+        (testWebkitAtkCaretOffsets): For a text control (a text entry),
+        set the caret offset to a value greater than 1 and retrieve it.
+
 2012-01-05  Martin Robinson  <[email protected]>
 
         [GTK] [AC] Introduce AcceleratedCompositingContext to isolate different accelerated compositing implementations

Modified: trunk/Source/WebKit/gtk/tests/testatk.c (104445 => 104446)


--- trunk/Source/WebKit/gtk/tests/testatk.c	2012-01-09 10:00:51 UTC (rev 104445)
+++ trunk/Source/WebKit/gtk/tests/testatk.c	2012-01-09 10:16:20 UTC (rev 104446)
@@ -63,7 +63,7 @@
 
 static const char* listsOfItems = "<html><body><ul><li>text only</li><li><a href=''>link only</a></li><li>text and a <a href=''>link</a></li></ul><ol><li>text only</li><li><a href=''>link only</a></li><li>text and a <a href=''>link</a></li></ol></body></html>";
 
-static const char* textForCaretBrowsing = "<html><body><h1>A text header</h1><p>A paragraph <a href=''>with a link</a> in the middle</p><ol><li>A list item</li></ol><select><option selected value='foo'>An option in a combo box</option></select></body></html>";
+static const char* textForCaretBrowsing = "<html><body><h1>A text header</h1><p>A paragraph <a href=''>with a link</a> in the middle</p><ol><li>A list item</li></ol><select><option selected value='foo'>An option in a combo box</option></select><input type='text'' name='foo'' value='foo bar baz' /></body></html>";
 
 static const char* textForSelections = "<html><body><p>A paragraph with plain text</p><p>A paragraph with <a href=''>a link</a> in the middle</p><ol><li>A list item</li></ol><select></body></html>";
 
@@ -234,7 +234,7 @@
     testGetTextFunction(textObject, atk_text_get_text_before_offset, ATK_TEXT_BOUNDARY_SENTENCE_END,
                         44, " This is the second sentence.", 15, 44);
 
-    /* It's trick to test these properly right now, since our a11y
+    /* It's tricky to test these properly right now, since our a11y
        implementation splits different lines in different a11y items. */
     /* ATK_TEXT_BOUNDARY_LINE_START */
     testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START,
@@ -243,6 +243,15 @@
     /* ATK_TEXT_BOUNDARY_LINE_END */
     testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END,
                         0, "This is a test. This is the second sentence. And this the third.", 0, 64);
+
+    /* For objects implementing AtkEditableText, try to change the
+       exposed text and retrieve it again as a full line.
+       (see https://bugs.webkit.org/show_bug.cgi?id=72830) */
+    if (ATK_IS_EDITABLE_TEXT(textObject)) {
+        atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(textObject), "foo bar baz");
+        testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 0, "foo bar baz", 0, 11);
+        testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 0, "foo bar baz", 0, 11);
+    }
 }
 
 static void testWebkitAtkCaretOffsets()
@@ -334,6 +343,18 @@
     result = atk_text_set_caret_offset(ATK_TEXT(comboBoxOption), 1);
     g_assert_cmpint(result, ==, FALSE);
 
+    AtkObject* textEntry = atk_object_ref_accessible_child(panel, 1);
+    g_assert(ATK_IS_OBJECT(textEntry));
+    g_assert(atk_object_get_role(textEntry) == ATK_ROLE_ENTRY);
+    g_assert(ATK_IS_TEXT(textEntry));
+    text = atk_text_get_text(ATK_TEXT(textEntry), 0, -1);
+    g_assert_cmpstr(text, ==, "foo bar baz");
+
+    result = atk_text_set_caret_offset(ATK_TEXT(textEntry), 5);
+    g_assert_cmpint(result, ==, TRUE);
+    offset = atk_text_get_caret_offset(ATK_TEXT(textEntry));
+    g_assert_cmpint(offset, ==, 5);
+
     g_object_unref(header);
     g_object_unref(paragraph);
     g_object_unref(list);
@@ -342,6 +363,7 @@
     g_object_unref(comboBox);
     g_object_unref(menuPopup);
     g_object_unref(comboBoxOption);
+    g_object_unref(textEntry);
     g_object_unref(webView);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to