Changeset 68415 in webkit
- Timestamp:
- Sep 27, 2010 12:35:10 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r68412 r68415 1 2010-09-27 Mario Sanchez Prada <msanchez@igalia.com> 2 3 Reviewed by Chris Fleizach. 4 5 [Gtk] Adjust atk_text_get_text_at_offset to account for bullets/numbers in list items 6 https://bugs.webkit.org/show_bug.cgi?id=45381 7 8 Ensure list markers are consistently used in the Atk wrapper. 9 10 This patch does two things (both needed to fix the bug): It 11 improves the way list items markers are exposed through the Atk 12 Wrapper (by exposing the exact text in the marker, including the 13 marker suffix, if any) and makes sure the marker is consistently 14 considered and treated in those methods of the AtkText interface 15 that would need it (like atk_text_get_character_count or 16 atk_text_get_run_attributes, for instance). 17 18 * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: 19 (textForObject): 20 Append/prepend list marker when needed. 21 (webkit_accessible_text_get_text): 22 Use the new function markerTextWithSuffix() to expose a more 23 accurate value. 24 (accessibilityObjectLength): 25 Consider list items marker to return the length of an object, 26 if needed. Also, added some extra checks. 27 (webkit_accessible_text_get_character_count): 28 Just delegate on accessibilityObjectLength, to make it 29 cleaner and more consistent. 30 31 * rendering/RenderListItem.cpp: 32 (WebCore::RenderListItem::markerTextWithSuffix): 33 New public function to return a single string with the 34 marker associated to the item and its suffix, considering 35 text direction (LTR or RTL). 36 * rendering/RenderListItem.h: 37 * rendering/RenderListMarker.cpp: 38 (WebCore::RenderListMarker::suffix): 39 New public function to return a String with the suffix 40 associated to the marker. 41 * rendering/RenderListMarker.h: 42 1 43 2010-09-27 Sheriff Bot <webkit.review.bot@gmail.com> 2 44 -
trunk/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
r68023 r68415 56 56 #include "IntRect.h" 57 57 #include "NotImplemented.h" 58 #include "RenderListItem.h" 58 59 #include "RenderListMarker.h" 59 60 #include "RenderText.h" … … 879 880 range = accObject->doAXRangeForLine(++lineNumber); 880 881 } 881 } else if (accObject->renderer()) { 882 } else { 883 RenderObject* renderer = accObject->renderer(); 884 if (!renderer) 885 return g_string_free(str, FALSE); 886 882 887 // For RenderBlocks, piece together the text from the RenderText objects they contain. 883 for (RenderObject* obj = accObject->renderer()->firstChild(); obj; obj = obj->nextSibling()) {888 for (RenderObject* obj = renderer->firstChild(); obj; obj = obj->nextSibling()) { 884 889 if (obj->isBR()) { 885 890 g_string_append(str, "\n"); … … 908 913 } 909 914 } 910 } 915 916 // Insert the text of the marker for list item in the right place, if present 917 if (renderer->isListItem()) { 918 String markerText = toRenderListItem(renderer)->markerTextWithSuffix(); 919 if (renderer->style()->direction() == LTR) 920 g_string_prepend(str, markerText.utf8().data()); 921 else 922 g_string_append(str, markerText.utf8().data()); 923 } 924 } 925 911 926 return g_string_free(str, FALSE); 912 927 } … … 940 955 if (coreObject->roleValue() == ListItemRole) { 941 956 RenderObject* objRenderer = static_cast<AccessibilityRenderObject*>(coreObject)->renderer(); 942 RenderObject* markerRenderer = objRenderer ? objRenderer->firstChild() : 0; 943 if (markerRenderer && markerRenderer->isListMarker()) { 944 String markerTxt = toRenderListMarker(markerRenderer)->text(); 945 ret = markerTxt.length() > 0 ? markerTxt + " " + ret : ret; 957 if (objRenderer && objRenderer->isListItem()) { 958 String markerText = toRenderListItem(objRenderer)->markerTextWithSuffix(); 959 ret = objRenderer->style()->direction() == LTR ? markerText + ret : ret + markerText; 946 960 } 947 961 } … … 1186 1200 static guint accessibilityObjectLength(const AccessibilityObject* object) 1187 1201 { 1188 GOwnPtr<gchar> text(webkit_accessible_text_get_text(ATK_TEXT(object->wrapper()), 0, -1)); 1189 return g_utf8_strlen(text.get(), -1); 1202 // Non render objects are not taken into account 1203 if (!object->isAccessibilityRenderObject()) 1204 return 0; 1205 1206 // For those objects implementing the AtkText interface we use the 1207 // well known API to always get the text in a consistent way 1208 AtkObject* atkObj = ATK_OBJECT(object->wrapper()); 1209 if (ATK_IS_TEXT(atkObj)) { 1210 GOwnPtr<gchar> text(webkit_accessible_text_get_text(ATK_TEXT(atkObj), 0, -1)); 1211 return g_utf8_strlen(text.get(), -1); 1212 } 1213 1214 // Even if we don't expose list markers to Assistive 1215 // Technologies, we need to have a way to measure their length 1216 // for those cases when it's needed to take it into account 1217 // separately (as in getAccessibilityObjectForOffset) 1218 RenderObject* renderer = static_cast<const AccessibilityRenderObject*>(object)->renderer(); 1219 if (renderer && renderer->isListMarker()) { 1220 RenderListMarker* marker = toRenderListMarker(renderer); 1221 return marker->text().length() + marker->suffix().length(); 1222 } 1223 1224 return 0; 1190 1225 } 1191 1226 … … 1322 1357 static gint webkit_accessible_text_get_character_count(AtkText* text) 1323 1358 { 1324 AccessibilityObject* coreObject = core(text); 1325 1326 if (coreObject->isTextControl()) 1327 return coreObject->textLength(); 1328 else 1329 return coreObject->textUnderElement().length(); 1359 return accessibilityObjectLength(core(text)); 1330 1360 } 1331 1361 -
trunk/WebCore/rendering/RenderListItem.cpp
r68408 r68415 315 315 } 316 316 317 String RenderListItem::markerTextWithSuffix() const 318 { 319 if (!m_marker) 320 return String(); 321 322 // Append the suffix for the marker in the right place depending 323 // on the direction of the text (right-to-left or left-to-right). 324 325 const String& markerText = m_marker->text(); 326 const String markerSuffix = m_marker->suffix(); 327 Vector<UChar> resultVector; 328 329 if (m_marker->style()->direction() == RTL) 330 resultVector.append(markerSuffix.characters(), markerSuffix.length()); 331 332 resultVector.append(markerText.characters(), markerText.length()); 333 334 if (m_marker->style()->direction() == LTR) 335 resultVector.append(markerSuffix.characters(), markerSuffix.length()); 336 337 return String::adopt(resultVector); 338 } 339 317 340 void RenderListItem::explicitValueChanged() 318 341 { -
trunk/WebCore/rendering/RenderListItem.h
r68276 r68415 46 46 47 47 const String& markerText() const; 48 String markerTextWithSuffix() const; 48 49 49 50 void updateListMarkerNumbers(); -
trunk/WebCore/rendering/RenderListMarker.cpp
r68408 r68415 1523 1523 } 1524 1524 1525 String RenderListMarker::suffix() const 1526 { 1527 EListStyleType type = style()->listStyleType(); 1528 const UChar suffix = listMarkerSuffix(type, m_listItem->value()); 1529 1530 Vector<UChar> resultVector; 1531 resultVector.append(suffix); 1532 1533 // If the suffix is not ' ', an extra space is needed 1534 if (suffix != ' ') { 1535 if (style()->direction() == LTR) 1536 resultVector.append(' '); 1537 else 1538 resultVector.prepend(' '); 1539 } 1540 1541 return String::adopt(resultVector); 1542 } 1543 1525 1544 bool RenderListMarker::isInside() const 1526 1545 { -
trunk/WebCore/rendering/RenderListMarker.h
r68276 r68415 42 42 43 43 const String& text() const { return m_text; } 44 String suffix() const; 44 45 45 46 bool isInside() const; -
trunk/WebKit/gtk/ChangeLog
r68404 r68415 1 2010-09-27 Mario Sanchez Prada <msanchez@igalia.com> 2 3 Reviewed by Chris Fleizach. 4 5 [Gtk] Adjust atk_text_get_text_at_offset to account for bullets/numbers in list items 6 https://bugs.webkit.org/show_bug.cgi?id=45381 7 8 Updated test to match the new exposure of list item markers. 9 10 Also, added some extra assertions in that test to make sure the 11 accessible objects associated to the items implement AtkText. 12 13 * tests/testatk.c: 14 (testWebkitAtkListsOfItems): 15 (main): 16 1 17 2010-09-27 Philippe Normand <pnormand@igalia.com> 2 18 -
trunk/WebKit/gtk/tests/testatk.c
r68111 r68415 967 967 static void testWebkitAtkListsOfItems(void) 968 968 { 969 WebKitWebView* webView; 970 AtkObject* obj; 971 AtkObject* uList; 972 AtkObject* oList; 973 AtkObject* item1; 974 AtkObject* item2; 975 AtkObject* item3; 976 GMainLoop* loop; 977 978 webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); 969 WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); 979 970 g_object_ref_sink(webView); 980 971 GtkAllocation alloc = { 0, 0, 800, 600 }; 981 972 gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); 982 973 webkit_web_view_load_string(webView, listsOfItems, NULL, NULL, NULL); 983 loop = g_main_loop_new(NULL, TRUE);984 985 g_idle_add((GSourceFunc)bail_out, loop); 986 g_main_loop_run(loop); 987 988 obj = gtk_widget_get_accessible(GTK_WIDGET(webView));974 GMainLoop* loop = g_main_loop_new(NULL, TRUE); 975 976 g_idle_add((GSourceFunc)bail_out, loop); 977 g_main_loop_run(loop); 978 979 AtkObject* obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); 989 980 g_assert(obj); 990 981 991 982 // Unordered list 992 983 993 uList = atk_object_ref_accessible_child(obj, 0);984 AtkObject* uList = atk_object_ref_accessible_child(obj, 0); 994 985 g_assert(ATK_OBJECT(uList)); 995 986 g_assert(atk_object_get_role(uList) == ATK_ROLE_LIST); 996 987 g_assert_cmpint(atk_object_get_n_accessible_children(uList), ==, 3); 997 988 998 item1 = atk_object_ref_accessible_child(uList, 0); 999 item2 = atk_object_ref_accessible_child(uList, 1); 1000 item3 = atk_object_ref_accessible_child(uList, 2); 989 AtkObject* item1 = atk_object_ref_accessible_child(uList, 0); 990 g_assert(ATK_IS_TEXT(item1)); 991 AtkObject* item2 = atk_object_ref_accessible_child(uList, 1); 992 g_assert(ATK_IS_TEXT(item2)); 993 AtkObject* item3 = atk_object_ref_accessible_child(uList, 2); 994 g_assert(ATK_IS_TEXT(item3)); 1001 995 1002 996 g_assert_cmpint(atk_object_get_n_accessible_children(item1), ==, 0); … … 1014 1008 // Ordered list 1015 1009 1016 oList = atk_object_ref_accessible_child(obj, 1);1010 AtkObject* oList = atk_object_ref_accessible_child(obj, 1); 1017 1011 g_assert(ATK_OBJECT(oList)); 1018 1012 g_assert(atk_object_get_role(oList) == ATK_ROLE_LIST); … … 1020 1014 1021 1015 item1 = atk_object_ref_accessible_child(oList, 0); 1016 g_assert(ATK_IS_TEXT(item1)); 1022 1017 item2 = atk_object_ref_accessible_child(oList, 1); 1018 g_assert(ATK_IS_TEXT(item2)); 1023 1019 item3 = atk_object_ref_accessible_child(oList, 2); 1024 1025 g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item1), 0, -1), ==, "1 text only"); 1026 g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item2), 0, -1), ==, "2 link only"); 1027 g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item3), 0, -1), ==, "3 text and a link"); 1020 g_assert(ATK_IS_TEXT(item3)); 1021 1022 g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item1), 0, -1), ==, "1. text only"); 1023 g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item2), 0, -1), ==, "2. link only"); 1024 g_assert_cmpstr(atk_text_get_text(ATK_TEXT(item3), 0, -1), ==, "3. text and a link"); 1028 1025 1029 1026 g_assert_cmpint(atk_object_get_n_accessible_children(item1), ==, 0);
Note: See TracChangeset
for help on using the changeset viewer.