[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 13:48:43 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit bc94151bbc1d9ce2b74d37d6530dfc6d8f121782
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 27 19:35:10 2010 +0000

    2010-09-27  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Chris Fleizach.
    
            [Gtk] Adjust atk_text_get_text_at_offset to account for bullets/numbers in list items
            https://bugs.webkit.org/show_bug.cgi?id=45381
    
            Ensure list markers are consistently used in the Atk wrapper.
    
            This patch does two things (both needed to fix the bug): It
            improves the way list items markers are exposed through the Atk
            Wrapper (by exposing the exact text in the marker, including the
            marker suffix, if any) and makes sure the marker is consistently
            considered and treated in those methods of the AtkText interface
            that would need it (like atk_text_get_character_count or
            atk_text_get_run_attributes, for instance).
    
            * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
            (textForObject):
               Append/prepend list marker when needed.
            (webkit_accessible_text_get_text):
               Use the new function markerTextWithSuffix() to expose a more
               accurate value.
            (accessibilityObjectLength):
               Consider list items marker to return the length of an object,
               if needed. Also, added some extra checks.
            (webkit_accessible_text_get_character_count):
               Just delegate on accessibilityObjectLength, to make it
               cleaner and more consistent.
    
            * rendering/RenderListItem.cpp:
            (WebCore::RenderListItem::markerTextWithSuffix):
               New public function to return a single string with the
               marker associated to the item and its suffix, considering
               text direction (LTR or RTL).
            * rendering/RenderListItem.h:
            * rendering/RenderListMarker.cpp:
            (WebCore::RenderListMarker::suffix):
               New public function to return a String with the suffix
               associated to the marker.
            * rendering/RenderListMarker.h:
    2010-09-27  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Chris Fleizach.
    
            [Gtk] Adjust atk_text_get_text_at_offset to account for bullets/numbers in list items
            https://bugs.webkit.org/show_bug.cgi?id=45381
    
            Updated test to match the new exposure of list item markers.
    
            Also, added some extra assertions in that test to make sure the
            accessible objects associated to the items implement AtkText.
    
            * tests/testatk.c:
            (testWebkitAtkListsOfItems):
            (main):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68415 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 56fa8d3..9272758 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2010-09-27  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Chris Fleizach.
+
+        [Gtk] Adjust atk_text_get_text_at_offset to account for bullets/numbers in list items
+        https://bugs.webkit.org/show_bug.cgi?id=45381
+
+        Ensure list markers are consistently used in the Atk wrapper.
+
+        This patch does two things (both needed to fix the bug): It
+        improves the way list items markers are exposed through the Atk
+        Wrapper (by exposing the exact text in the marker, including the
+        marker suffix, if any) and makes sure the marker is consistently
+        considered and treated in those methods of the AtkText interface
+        that would need it (like atk_text_get_character_count or
+        atk_text_get_run_attributes, for instance).
+
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+        (textForObject):
+           Append/prepend list marker when needed.
+        (webkit_accessible_text_get_text):
+           Use the new function markerTextWithSuffix() to expose a more
+           accurate value.
+        (accessibilityObjectLength):
+           Consider list items marker to return the length of an object,
+           if needed. Also, added some extra checks.
+        (webkit_accessible_text_get_character_count):
+           Just delegate on accessibilityObjectLength, to make it
+           cleaner and more consistent.
+
+        * rendering/RenderListItem.cpp:
+        (WebCore::RenderListItem::markerTextWithSuffix):
+           New public function to return a single string with the
+           marker associated to the item and its suffix, considering
+           text direction (LTR or RTL).
+        * rendering/RenderListItem.h:
+        * rendering/RenderListMarker.cpp:
+        (WebCore::RenderListMarker::suffix):
+           New public function to return a String with the suffix
+           associated to the marker.
+        * rendering/RenderListMarker.h:
+
 2010-09-27  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r68389.
diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
index f34a03e..3575afe 100644
--- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
+++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
@@ -55,6 +55,7 @@
 #include "InlineTextBox.h"
 #include "IntRect.h"
 #include "NotImplemented.h"
+#include "RenderListItem.h"
 #include "RenderListMarker.h"
 #include "RenderText.h"
 #include "TextEncoding.h"
@@ -878,9 +879,13 @@ gchar* textForObject(AccessibilityRenderObject* accObject)
             g_string_append(str, "\n");
             range = accObject->doAXRangeForLine(++lineNumber);
         }
-    } else if (accObject->renderer()) {
+    } else {
+        RenderObject* renderer = accObject->renderer();
+        if (!renderer)
+            return g_string_free(str, FALSE);
+
         // For RenderBlocks, piece together the text from the RenderText objects they contain.
-        for (RenderObject* obj = accObject->renderer()->firstChild(); obj; obj = obj->nextSibling()) {
+        for (RenderObject* obj = renderer->firstChild(); obj; obj = obj->nextSibling()) {
             if (obj->isBR()) {
                 g_string_append(str, "\n");
                 continue;
@@ -907,7 +912,17 @@ gchar* textForObject(AccessibilityRenderObject* accObject)
                 box = box->nextTextBox();
             }
         }
+
+        // Insert the text of the marker for list item in the right place, if present
+        if (renderer->isListItem()) {
+            String markerText = toRenderListItem(renderer)->markerTextWithSuffix();
+            if (renderer->style()->direction() == LTR)
+                g_string_prepend(str, markerText.utf8().data());
+            else
+                g_string_append(str, markerText.utf8().data());
+        }
     }
+
     return g_string_free(str, FALSE);
 }
 
@@ -939,10 +954,9 @@ static gchar* webkit_accessible_text_get_text(AtkText* text, gint startOffset, g
     // Prefix a item number/bullet if needed
     if (coreObject->roleValue() == ListItemRole) {
         RenderObject* objRenderer = static_cast<AccessibilityRenderObject*>(coreObject)->renderer();
-        RenderObject* markerRenderer = objRenderer ? objRenderer->firstChild() : 0;
-        if (markerRenderer && markerRenderer->isListMarker()) {
-            String markerTxt = toRenderListMarker(markerRenderer)->text();
-            ret = markerTxt.length() > 0 ? markerTxt + " " + ret : ret;
+        if (objRenderer && objRenderer->isListItem()) {
+            String markerText = toRenderListItem(objRenderer)->markerTextWithSuffix();
+            ret = objRenderer->style()->direction() == LTR ? markerText + ret : ret + markerText;
         }
     }
 
@@ -1185,8 +1199,29 @@ static AtkAttributeSet* attributeSetDifference(AtkAttributeSet* a1, AtkAttribute
 
 static guint accessibilityObjectLength(const AccessibilityObject* object)
 {
-    GOwnPtr<gchar> text(webkit_accessible_text_get_text(ATK_TEXT(object->wrapper()), 0, -1));
-    return g_utf8_strlen(text.get(), -1);
+    // Non render objects are not taken into account
+    if (!object->isAccessibilityRenderObject())
+        return 0;
+
+    // For those objects implementing the AtkText interface we use the
+    // well known API to always get the text in a consistent way
+    AtkObject* atkObj = ATK_OBJECT(object->wrapper());
+    if (ATK_IS_TEXT(atkObj)) {
+        GOwnPtr<gchar> text(webkit_accessible_text_get_text(ATK_TEXT(atkObj), 0, -1));
+        return g_utf8_strlen(text.get(), -1);
+    }
+
+    // Even if we don't expose list markers to Assistive
+    // Technologies, we need to have a way to measure their length
+    // for those cases when it's needed to take it into account
+    // separately (as in getAccessibilityObjectForOffset)
+    RenderObject* renderer = static_cast<const AccessibilityRenderObject*>(object)->renderer();
+    if (renderer && renderer->isListMarker()) {
+        RenderListMarker* marker = toRenderListMarker(renderer);
+        return marker->text().length() + marker->suffix().length();
+    }
+
+    return 0;
 }
 
 static const AccessibilityObject* getAccessibilityObjectForOffset(const AccessibilityObject* object, guint offset, gint* startOffset, gint* endOffset)
@@ -1321,12 +1356,7 @@ static void webkit_accessible_text_get_range_extents(AtkText* text, gint startOf
 
 static gint webkit_accessible_text_get_character_count(AtkText* text)
 {
-    AccessibilityObject* coreObject = core(text);
-
-    if (coreObject->isTextControl())
-        return coreObject->textLength();
-    else
-        return coreObject->textUnderElement().length();
+    return accessibilityObjectLength(core(text));
 }
 
 static gint webkit_accessible_text_get_offset_at_point(AtkText* text, gint x, gint y, AtkCoordType coords)
diff --git a/WebCore/rendering/RenderListItem.cpp b/WebCore/rendering/RenderListItem.cpp
index 708e4da..b414f38 100644
--- a/WebCore/rendering/RenderListItem.cpp
+++ b/WebCore/rendering/RenderListItem.cpp
@@ -314,6 +314,29 @@ const String& RenderListItem::markerText() const
     return staticNullString;
 }
 
+String RenderListItem::markerTextWithSuffix() const
+{
+    if (!m_marker)
+        return String();
+
+    // Append the suffix for the marker in the right place depending
+    // on the direction of the text (right-to-left or left-to-right).
+
+    const String& markerText = m_marker->text();
+    const String markerSuffix = m_marker->suffix();
+    Vector<UChar> resultVector;
+
+    if (m_marker->style()->direction() == RTL)
+        resultVector.append(markerSuffix.characters(), markerSuffix.length());
+
+    resultVector.append(markerText.characters(), markerText.length());
+
+    if (m_marker->style()->direction() == LTR)
+        resultVector.append(markerSuffix.characters(), markerSuffix.length());
+
+    return String::adopt(resultVector);
+}
+
 void RenderListItem::explicitValueChanged()
 {
     if (m_marker)
diff --git a/WebCore/rendering/RenderListItem.h b/WebCore/rendering/RenderListItem.h
index 19695d6..f7bd661 100644
--- a/WebCore/rendering/RenderListItem.h
+++ b/WebCore/rendering/RenderListItem.h
@@ -45,6 +45,7 @@ public:
     bool notInList() const { return m_notInList; }
 
     const String& markerText() const;
+    String markerTextWithSuffix() const;
 
     void updateListMarkerNumbers();
 
diff --git a/WebCore/rendering/RenderListMarker.cpp b/WebCore/rendering/RenderListMarker.cpp
index d9ded9d..18811df 100644
--- a/WebCore/rendering/RenderListMarker.cpp
+++ b/WebCore/rendering/RenderListMarker.cpp
@@ -1522,6 +1522,25 @@ int RenderListMarker::baselinePosition(bool, bool) const
     return height();
 }
 
+String RenderListMarker::suffix() const
+{
+    EListStyleType type = style()->listStyleType();
+    const UChar suffix = listMarkerSuffix(type, m_listItem->value());
+
+    Vector<UChar> resultVector;
+    resultVector.append(suffix);
+
+    // If the suffix is not ' ', an extra space is needed
+    if (suffix != ' ') {
+        if (style()->direction() == LTR)
+            resultVector.append(' ');
+        else
+            resultVector.prepend(' ');
+    }
+
+    return String::adopt(resultVector);
+}
+
 bool RenderListMarker::isInside() const
 {
     return m_listItem->notInList() || style()->listStylePosition() == INSIDE;
diff --git a/WebCore/rendering/RenderListMarker.h b/WebCore/rendering/RenderListMarker.h
index ed59ab9..1e55898 100644
--- a/WebCore/rendering/RenderListMarker.h
+++ b/WebCore/rendering/RenderListMarker.h
@@ -41,6 +41,7 @@ public:
     virtual void computePreferredLogicalWidths();
 
     const String& text() const { return m_text; }
+    String suffix() const;
 
     bool isInside() const;
 
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 1ea6827..4e1997c 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,19 @@
+2010-09-27  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Chris Fleizach.
+
+        [Gtk] Adjust atk_text_get_text_at_offset to account for bullets/numbers in list items
+        https://bugs.webkit.org/show_bug.cgi?id=45381
+
+        Updated test to match the new exposure of list item markers.
+
+        Also, added some extra assertions in that test to make sure the
+        accessible objects associated to the items implement AtkText.
+
+        * tests/testatk.c:
+        (testWebkitAtkListsOfItems):
+        (main):
+
 2010-09-27  Philippe Normand  <pnormand at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebKit/gtk/tests/testatk.c b/WebKit/gtk/tests/testatk.c
index 19a525a..c8df4ef 100644
--- a/WebKit/gtk/tests/testatk.c
+++ b/WebKit/gtk/tests/testatk.c
@@ -966,38 +966,32 @@ static void testWebkitAtkGetExtents(void)
 
 static void testWebkitAtkListsOfItems(void)
 {
-    WebKitWebView* webView;
-    AtkObject* obj;
-    AtkObject* uList;
-    AtkObject* oList;
-    AtkObject* item1;
-    AtkObject* item2;
-    AtkObject* item3;
-    GMainLoop* loop;
-
-    webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
     g_object_ref_sink(webView);
     GtkAllocation alloc = { 0, 0, 800, 600 };
     gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
     webkit_web_view_load_string(webView, listsOfItems, NULL, NULL, NULL);
-    loop = g_main_loop_new(NULL, TRUE);
+    GMainLoop* loop = g_main_loop_new(NULL, TRUE);
 
     g_idle_add((GSourceFunc)bail_out, loop);
     g_main_loop_run(loop);
 
-    obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
+    AtkObject* obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
     g_assert(obj);
 
     // Unordered list
 
-    uList = atk_object_ref_accessible_child(obj, 0);
+    AtkObject* uList = atk_object_ref_accessible_child(obj, 0);
     g_assert(ATK_OBJECT(uList));
     g_assert(atk_object_get_role(uList) == ATK_ROLE_LIST);
     g_assert_cmpint(atk_object_get_n_accessible_children(uList), ==, 3);
 
-    item1 = atk_object_ref_accessible_child(uList, 0);
-    item2 = atk_object_ref_accessible_child(uList, 1);
-    item3 = atk_object_ref_accessible_child(uList, 2);
+    AtkObject* item1 = atk_object_ref_accessible_child(uList, 0);
+    g_assert(ATK_IS_TEXT(item1));
+    AtkObject* item2 = atk_object_ref_accessible_child(uList, 1);
+    g_assert(ATK_IS_TEXT(item2));
+    AtkObject* item3 = atk_object_ref_accessible_child(uList, 2);
+    g_assert(ATK_IS_TEXT(item3));
 
     g_assert_cmpint(atk_object_get_n_accessible_children(item1), ==, 0);
     g_assert_cmpint(atk_object_get_n_accessible_children(item2), ==, 1);
@@ -1013,18 +1007,21 @@ static void testWebkitAtkListsOfItems(void)
 
     // Ordered list
 
-    oList = atk_object_ref_accessible_child(obj, 1);
+    AtkObject* oList = atk_object_ref_accessible_child(obj, 1);
     g_assert(ATK_OBJECT(oList));
     g_assert(atk_object_get_role(oList) == ATK_ROLE_LIST);
     g_assert_cmpint(atk_object_get_n_accessible_children(oList), ==, 3);
 
     item1 = atk_object_ref_accessible_child(oList, 0);
+    g_assert(ATK_IS_TEXT(item1));
     item2 = atk_object_ref_accessible_child(oList, 1);
+    g_assert(ATK_IS_TEXT(item2));
     item3 = atk_object_ref_accessible_child(oList, 2);
+    g_assert(ATK_IS_TEXT(item3));
 
-    g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item1), 0, -1), ==, "1 text only");
-    g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item2), 0, -1), ==, "2 link only");
-    g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item3), 0, -1), ==, "3 text and a link");
+    g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item1), 0, -1), ==, "1. text only");
+    g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item2), 0, -1), ==, "2. link only");
+    g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item3), 0, -1), ==, "3. text and a link");
 
     g_assert_cmpint(atk_object_get_n_accessible_children(item1), ==, 0);
     g_assert_cmpint(atk_object_get_n_accessible_children(item2), ==, 1);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list