Changeset 104446 in webkit
- Timestamp:
- Jan 9, 2012 2:16:20 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r104445 r104446 1 2012-01-09 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [Gtk] Regression: text-inserted events lack text inserted and current line 4 https://bugs.webkit.org/show_bug.cgi?id=72830 5 6 Reviewed by Martin Robinson. 7 8 Fix issue getting the exposed text for an accessibility object at, 9 before of after a given offset, after changing it at least once. 10 11 * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: 12 (webkit_accessible_class_init): Don't initialize 13 gailTextUtilQuark, it won't be used anymore. 14 (getGailTextUtilForAtk): Don't cache the GailTextUtil as object 15 data, but create a new one each time this function is called. 16 (webkit_accessible_text_get_caret_offset): Simplified code by 17 using the new focusedObjectAndCaretOffsetUnignored function, 18 instead of the old objectAndOffsetUnignored function. 19 (focusedObjectAndCaretOffsetUnignored): Rewrite of the old 20 objectAndOffsetUnignored function so it now needs less 21 parameters than before and takes care of carefully selecting the 22 start and end visible positions to calculate the position of the 23 caret from the point of view of the accessibility object of 24 reference passed as the only input parameter now. Updated callers. 25 * accessibility/gtk/AccessibilityObjectWrapperAtk.h: 26 27 * editing/gtk/FrameSelectionGtk.cpp: 28 (WebCore::FrameSelection::notifyAccessibilityForSelectionChange): 29 Simplified code by calling to focusedObjectAndCaretOffsetUnignored 30 function, instead of the old objectAndOffsetUnignored function. 31 1 32 2012-01-09 Antti Koivisto <antti@apple.com> 2 33 -
trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
r101348 r104446 77 77 using namespace WebCore; 78 78 79 static GQuark gailTextUtilQuark = 0;80 79 static GQuark hyperlinkObjectQuark = 0; 81 80 … … 847 846 klass->ref_relation_set = webkit_accessible_ref_relation_set; 848 847 849 gailTextUtilQuark = g_quark_from_static_string("webkit-accessible-gail-text-util");850 848 hyperlinkObjectQuark = g_quark_from_static_string("webkit-accessible-hyperlink-object"); 851 849 } … … 1294 1292 static GailTextUtil* getGailTextUtilForAtk(AtkText* textObject) 1295 1293 { 1296 gpointer data = g_object_get_qdata(G_OBJECT(textObject), gailTextUtilQuark);1297 if (data)1298 return static_cast<GailTextUtil*>(data);1299 1300 1294 GailTextUtil* gailTextUtil = gail_text_util_new(); 1301 1295 gail_text_util_text_setup(gailTextUtil, webkit_accessible_text_get_text(textObject, 0, -1)); 1302 g_object_set_qdata_full(G_OBJECT(textObject), gailTextUtilQuark, gailTextUtil, g_object_unref);1303 1296 return gailTextUtil; 1304 1297 } … … 1353 1346 return 0; 1354 1347 1355 Document* document = coreObject->document();1356 if (!document)1357 return 0;1358 1359 Node* focusedNode = coreObject->selection().end().deprecatedNode();1360 if (!focusedNode)1361 return 0;1362 1363 RenderObject* focusedRenderer = focusedNode->renderer();1364 AccessibilityObject* focusedObject = document->axObjectCache()->getOrCreate(focusedRenderer);1365 1366 1348 int offset; 1367 // Don't ignore links if the offset is being requested for a link. 1368 if (!objectAndOffsetUnignored(focusedObject, offset, !coreObject->isLink())) 1349 if (!objectFocusedAndCaretOffsetUnignored(coreObject, offset)) 1369 1350 return 0; 1370 1351 … … 2734 2715 } 2735 2716 2736 AccessibilityObject* object AndOffsetUnignored(AccessibilityObject* coreObject, int& offset, bool ignoreLinks)2717 AccessibilityObject* objectFocusedAndCaretOffsetUnignored(AccessibilityObject* referenceObject, int& offset) 2737 2718 { 2738 2719 // Indication that something bogus has transpired. 2739 2720 offset = -1; 2740 2721 2741 AccessibilityObject* realObject = coreObject; 2742 if (realObject->accessibilityIsIgnored()) 2743 realObject = realObject->parentObjectUnignored(); 2744 if (!realObject) 2745 return 0; 2746 2747 if (ignoreLinks && realObject->isLink()) 2748 realObject = realObject->parentObjectUnignored(); 2749 if (!realObject) 2750 return 0; 2751 2752 Node* node = realObject->node(); 2753 if (node) { 2754 VisiblePosition startPosition = VisiblePosition(positionBeforeNode(node), DOWNSTREAM); 2755 VisiblePosition endPosition = realObject->selection().visibleEnd(); 2756 2757 if (startPosition == endPosition) 2758 offset = 0; 2759 else if (!isStartOfLine(endPosition)) { 2760 RefPtr<Range> range = makeRange(startPosition, endPosition.previous()); 2761 offset = TextIterator::rangeLength(range.get(), true) + 1; 2762 } else { 2763 RefPtr<Range> range = makeRange(startPosition, endPosition); 2764 offset = TextIterator::rangeLength(range.get(), true); 2765 } 2766 2767 } 2768 2769 return realObject; 2722 Document* document = referenceObject->document(); 2723 if (!document) 2724 return 0; 2725 2726 Node* focusedNode = referenceObject->selection().end().containerNode(); 2727 if (!focusedNode) 2728 return 0; 2729 2730 RenderObject* focusedRenderer = focusedNode->renderer(); 2731 if (!focusedRenderer) 2732 return 0; 2733 2734 AccessibilityObject* focusedObject = document->axObjectCache()->getOrCreate(focusedRenderer); 2735 if (!focusedObject) 2736 return 0; 2737 2738 // Look for the actual (not ignoring accessibility) selected object. 2739 if (focusedObject->accessibilityIsIgnored()) 2740 focusedObject = focusedObject->parentObjectUnignored(); 2741 if (!focusedObject) 2742 return 0; 2743 2744 // Don't ignore links if the offset is being requested for a link. 2745 if (!referenceObject->isLink() && focusedObject->isLink()) 2746 focusedObject = focusedObject->parentObjectUnignored(); 2747 if (!focusedObject) 2748 return 0; 2749 2750 Node* startNode = 0; 2751 if (focusedObject != referenceObject || focusedObject->isTextControl()) { 2752 // We need to use the first child's node of the reference 2753 // object as the start point to calculate the caret offset 2754 // because we want it to be relative to the object of 2755 // reference, not just to the focused object (which could have 2756 // previous siblings which should be taken into account too). 2757 AccessibilityObject* axFirstChild = referenceObject->firstChild(); 2758 if (axFirstChild) 2759 startNode = axFirstChild->node(); 2760 } 2761 if (!startNode) 2762 startNode = focusedObject->node(); 2763 2764 VisiblePosition startPosition = VisiblePosition(firstPositionInNode(startNode), DOWNSTREAM); 2765 VisiblePosition endPosition = focusedObject->selection().visibleEnd(); 2766 2767 if (startPosition == endPosition) 2768 offset = 0; 2769 else if (!isStartOfLine(endPosition)) { 2770 RefPtr<Range> range = makeRange(startPosition, endPosition.previous()); 2771 offset = TextIterator::rangeLength(range.get(), true) + 1; 2772 } else { 2773 RefPtr<Range> range = makeRange(startPosition, endPosition); 2774 offset = TextIterator::rangeLength(range.get(), true); 2775 } 2776 2777 return focusedObject; 2770 2778 } 2771 2779 -
trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.h
r95901 r104446 61 61 AtkObject* webkit_accessible_get_focused_element(WebKitAccessible* accessible); 62 62 63 WebCore::AccessibilityObject* object AndOffsetUnignored(WebCore::AccessibilityObject* coreObject, int& offset, bool ignoreLinks);63 WebCore::AccessibilityObject* objectFocusedAndCaretOffsetUnignored(WebCore::AccessibilityObject*, int& offset); 64 64 65 65 G_END_DECLS -
trunk/Source/WebCore/editing/gtk/FrameSelectionGtk.cpp
r95901 r104446 81 81 return; 82 82 83 // Re set lastFocuseNode and return for no valid selections.83 // Return for no valid selections. 84 84 if (!m_selection.start().isNotNull() || !m_selection.end().isNotNull()) 85 85 return; 86 86 87 RenderObject* focusedNode = m_selection.end().deprecatedNode()->renderer(); 88 AccessibilityObject* accessibilityObject = m_frame->document()->axObjectCache()->getOrCreate(focusedNode); 89 90 // Need to check this as getOrCreate could return 0, 87 // Look for the accessibility object for the Frame. 88 AccessibilityObject* accessibilityObject = m_frame->document()->axObjectCache()->rootObjectForFrame(m_frame); 91 89 if (!accessibilityObject) 92 90 return; 93 91 94 92 int offset; 95 // Always report the events w.r.t. the non-linked unignored parent. (i.e. ignoreLinks == true). 96 RefPtr<AccessibilityObject> object = objectAndOffsetUnignored(accessibilityObject, offset, true); 93 RefPtr<AccessibilityObject> object = objectFocusedAndCaretOffsetUnignored(accessibilityObject, offset); 97 94 if (!object) 98 95 return; -
trunk/Source/WebKit/gtk/ChangeLog
r104194 r104446 1 2012-01-09 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [Gtk] Regression: text-inserted events lack text inserted and current line 4 https://bugs.webkit.org/show_bug.cgi?id=72830 5 6 Reviewed by Martin Robinson. 7 8 Updated unit tests to check that both getting the current position 9 for the caret and the exposed text at, before or after a given 10 offset for an accessible object works as expected. 11 12 * tests/testatk.c: 13 (runGetTextTests): For objects implementing AtkEditableText, try 14 to change the exposed text and retrieve it again as a full line. 15 (testWebkitAtkCaretOffsets): For a text control (a text entry), 16 set the caret offset to a value greater than 1 and retrieve it. 17 1 18 2012-01-05 Martin Robinson <mrobinson@igalia.com> 2 19 -
trunk/Source/WebKit/gtk/tests/testatk.c
r101960 r104446 64 64 static const char* listsOfItems = "<html><body><ul><li>text only</li><li><a href='foo'>link only</a></li><li>text and a <a href='bar'>link</a></li></ul><ol><li>text only</li><li><a href='foo'>link only</a></li><li>text and a <a href='bar'>link</a></li></ol></body></html>"; 65 65 66 static const char* textForCaretBrowsing = "<html><body><h1>A text header</h1><p>A paragraph <a href='http://foo.bar.baz/'>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>";66 static const char* textForCaretBrowsing = "<html><body><h1>A text header</h1><p>A paragraph <a href='http://foo.bar.baz/'>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>"; 67 67 68 68 static const char* textForSelections = "<html><body><p>A paragraph with plain text</p><p>A paragraph with <a href='http://webkit.org'>a link</a> in the middle</p><ol><li>A list item</li></ol><select></body></html>"; … … 235 235 44, " This is the second sentence.", 15, 44); 236 236 237 /* It's trick to test these properly right now, since our a11y237 /* It's tricky to test these properly right now, since our a11y 238 238 implementation splits different lines in different a11y items. */ 239 239 /* ATK_TEXT_BOUNDARY_LINE_START */ … … 244 244 testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 245 245 0, "This is a test. This is the second sentence. And this the third.", 0, 64); 246 247 /* For objects implementing AtkEditableText, try to change the 248 exposed text and retrieve it again as a full line. 249 (see https://bugs.webkit.org/show_bug.cgi?id=72830) */ 250 if (ATK_IS_EDITABLE_TEXT(textObject)) { 251 atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(textObject), "foo bar baz"); 252 testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 0, "foo bar baz", 0, 11); 253 testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 0, "foo bar baz", 0, 11); 254 } 246 255 } 247 256 … … 334 343 result = atk_text_set_caret_offset(ATK_TEXT(comboBoxOption), 1); 335 344 g_assert_cmpint(result, ==, FALSE); 345 346 AtkObject* textEntry = atk_object_ref_accessible_child(panel, 1); 347 g_assert(ATK_IS_OBJECT(textEntry)); 348 g_assert(atk_object_get_role(textEntry) == ATK_ROLE_ENTRY); 349 g_assert(ATK_IS_TEXT(textEntry)); 350 text = atk_text_get_text(ATK_TEXT(textEntry), 0, -1); 351 g_assert_cmpstr(text, ==, "foo bar baz"); 352 353 result = atk_text_set_caret_offset(ATK_TEXT(textEntry), 5); 354 g_assert_cmpint(result, ==, TRUE); 355 offset = atk_text_get_caret_offset(ATK_TEXT(textEntry)); 356 g_assert_cmpint(offset, ==, 5); 336 357 337 358 g_object_unref(header); … … 343 364 g_object_unref(menuPopup); 344 365 g_object_unref(comboBoxOption); 366 g_object_unref(textEntry); 345 367 g_object_unref(webView); 346 368 }
Note: See TracChangeset
for help on using the changeset viewer.