Changeset 101349 in webkit
- Timestamp:
- Nov 29, 2011 3:04:43 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r101348 r101349 1 2011-11-29 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 Chris Fleizach. 7 8 Replace the emission of the old (and now deprecated) AtkObject's 9 'text-changed:insert' and 'text-changed:remove' signals with the 10 new 'text-insert' and 'text-remove' ones, which are better and 11 less fragile since they emit the modified text too, along with the 12 typical 'offset' and 'count' values associated to the change. 13 14 Also, change the signature of the nodeTextChangeNotification() and 15 nodeTextChangePlatformNotification() to allow specifying the text 16 being modified from the place we better know about it, that is, 17 the text editing commands. 18 19 * accessibility/gtk/AXObjectCacheAtk.cpp: 20 (WebCore::emitTextChanged): Emit 'text-insert' and 'text-remove', 21 instead of the old and now deprecated 'text-changed' signal. 22 (WebCore::AXObjectCache::nodeTextChangePlatformNotification): 23 Update this function to receive a String with the text being 24 modified, instead of just the number of characters. 25 26 * accessibility/AXObjectCache.cpp: 27 (WebCore::AXObjectCache::nodeTextChangeNotification): Update this 28 function to receive a String with the text being modified. 29 * accessibility/AXObjectCache.h: 30 (WebCore::AXObjectCache::nodeTextChangeNotification): Ditto. 31 (WebCore::AXObjectCache::nodeTextChangePlatformNotification): Ditto. 32 33 Adapt the text editing commants to pass the whole text string 34 being modified, instead of just its number of characters. 35 36 * editing/AppendNodeCommand.cpp: 37 (WebCore::sendAXTextChangedIgnoringLineBreaks): Adapt to the new 38 signature of nodeTextChangeNotification(), so pass the whole text. 39 * editing/DeleteFromTextNodeCommand.cpp: 40 (WebCore::DeleteFromTextNodeCommand::doApply): Ditto. 41 (WebCore::DeleteFromTextNodeCommand::doUnapply): Ditto. 42 * editing/InsertIntoTextNodeCommand.cpp: 43 (WebCore::InsertIntoTextNodeCommand::doApply): Ditto. 44 (WebCore::InsertIntoTextNodeCommand::doUnapply): Ditto. 45 * editing/InsertNodeBeforeCommand.cpp: 46 (WebCore::InsertNodeBeforeCommand::doApply): Ditto. 47 (WebCore::InsertNodeBeforeCommand::doUnapply): Ditto. 48 49 Update mac, win and chromium's specific parts of AXObjectCache to 50 match the new signature for nodeTextChangePlatformNotification(), 51 which won't affect their behaviour as they were not implementing 52 that method anyway. 53 54 * accessibility/chromium/AXObjectCacheChromium.cpp: 55 (WebCore::AXObjectCache::nodeTextChangePlatformNotification): 56 * accessibility/mac/AXObjectCacheMac.mm: 57 (WebCore::AXObjectCache::nodeTextChangePlatformNotification): 58 * accessibility/win/AXObjectCacheWin.cpp: 59 (WebCore::AXObjectCache::nodeTextChangePlatformNotification): 60 1 61 2011-11-29 Mario Sanchez Prada <msanchez@igalia.com> 2 62 -
trunk/Source/WebCore/accessibility/AXObjectCache.cpp
r97759 r101349 531 531 } 532 532 533 void AXObjectCache::nodeTextChangeNotification(RenderObject* renderer, AXTextChange textChange, unsigned offset, unsigned count)533 void AXObjectCache::nodeTextChangeNotification(RenderObject* renderer, AXTextChange textChange, unsigned offset, const String& text) 534 534 { 535 535 if (!renderer) … … 538 538 // Delegate on the right platform 539 539 AccessibilityObject* obj = getOrCreate(renderer); 540 nodeTextChangePlatformNotification(obj, textChange, offset, count);540 nodeTextChangePlatformNotification(obj, textChange, offset, text); 541 541 } 542 542 #endif -
trunk/Source/WebCore/accessibility/AXObjectCache.h
r100057 r101349 147 147 }; 148 148 149 void nodeTextChangeNotification(RenderObject*, AXTextChange, unsigned offset, unsigned count);149 void nodeTextChangeNotification(RenderObject*, AXTextChange, unsigned offset, const String&); 150 150 151 151 bool nodeHasRole(Node*, const AtomicString& role); … … 153 153 protected: 154 154 void postPlatformNotification(AccessibilityObject*, AXNotification); 155 void nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned offset, unsigned count);155 void nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned offset, const String&); 156 156 157 157 private: … … 186 186 inline void AXObjectCache::postNotification(AccessibilityObject*, Document*, AXNotification, bool postToElement, PostType) { } 187 187 inline void AXObjectCache::postPlatformNotification(AccessibilityObject*, AXNotification) { } 188 inline void AXObjectCache::nodeTextChangeNotification(RenderObject*, AXTextChange, unsigned, unsigned) { }189 inline void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, unsigned) { }188 inline void AXObjectCache::nodeTextChangeNotification(RenderObject*, AXTextChange, unsigned, const String&) { } 189 inline void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&) { } 190 190 inline void AXObjectCache::handleFocusedUIElementChanged(RenderObject*, RenderObject*) { } 191 191 inline void AXObjectCache::handleScrolledToAnchor(const Node*) { } -
trunk/Source/WebCore/accessibility/chromium/AXObjectCacheChromium.cpp
r95901 r101349 104 104 } 105 105 106 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, unsigned)106 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&) 107 107 { 108 108 } -
trunk/Source/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp
r97539 r101349 159 159 } 160 160 161 static void emitTextChanged(AccessibilityObject* object, AXObjectCache::AXTextChange textChange, unsigned offset, unsigned count) 162 { 163 // Get the axObject for the parent object 161 static void emitTextChanged(AccessibilityObject* object, AXObjectCache::AXTextChange textChange, unsigned offset, const String& text) 162 { 164 163 AtkObject* wrapper = object->parentObjectUnignored()->wrapper(); 165 164 if (!wrapper || !ATK_IS_TEXT(wrapper)) … … 170 169 switch (textChange) { 171 170 case AXObjectCache::AXTextInserted: 172 detail = "text- changed::insert";171 detail = "text-insert"; 173 172 break; 174 173 case AXObjectCache::AXTextDeleted: 175 detail = "text- changed::delete";174 detail = "text-remove"; 176 175 break; 177 176 } 178 177 179 178 if (!detail.isNull()) 180 g_signal_emit_by_name(wrapper, detail.data(), offset, count);181 } 182 183 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject* object, AXTextChange textChange, unsigned offset, unsigned count)179 g_signal_emit_by_name(wrapper, detail.data(), offset, text.length(), text.utf8().data()); 180 } 181 182 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject* object, AXTextChange textChange, unsigned offset, const String& text) 184 183 { 185 184 // Sanity check 186 if ( count < 1 || !object || !object->isAccessibilityRenderObject())185 if (!object || !object->isAccessibilityRenderObject() || text.isEmpty()) 187 186 return; 188 187 189 188 Node* node = object->node(); 190 189 RefPtr<Range> range = Range::create(node->document(), node->parentNode(), 0, node, 0); 191 emitTextChanged(object, textChange, offset + TextIterator::rangeLength(range.get()), count);190 emitTextChanged(object, textChange, offset + TextIterator::rangeLength(range.get()), text); 192 191 } 193 192 -
trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm
r95448 r101349 129 129 } 130 130 131 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, unsigned)131 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&) 132 132 { 133 133 } -
trunk/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp
r95901 r101349 108 108 } 109 109 110 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, unsigned)110 void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&) 111 111 { 112 112 } -
trunk/Source/WebCore/editing/AppendNodeCommand.cpp
r86135 r101349 48 48 { 49 49 String nodeValue = node->nodeValue(); 50 unsigned len = nodeValue.length();51 50 // Don't consider linebreaks in this command 52 51 if (nodeValue == "\n") 53 52 return; 54 53 55 node->document()->axObjectCache()->nodeTextChangeNotification(node->renderer(), textChange, 0, len);54 node->document()->axObjectCache()->nodeTextChangeNotification(node->renderer(), textChange, 0, nodeValue); 56 55 } 57 56 -
trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp
r86135 r101349 58 58 // Need to notify this before actually deleting the text 59 59 if (AXObjectCache::accessibilityEnabled()) 60 document()->axObjectCache()->nodeTextChangeNotification(m_node->renderer(), AXObjectCache::AXTextDeleted, m_offset, m_ count);60 document()->axObjectCache()->nodeTextChangeNotification(m_node->renderer(), AXObjectCache::AXTextDeleted, m_offset, m_text); 61 61 62 62 m_node->deleteData(m_offset, m_count, ec); … … 74 74 75 75 if (AXObjectCache::accessibilityEnabled()) 76 document()->axObjectCache()->nodeTextChangeNotification(m_node->renderer(), AXObjectCache::AXTextInserted, m_offset, m_ count);76 document()->axObjectCache()->nodeTextChangeNotification(m_node->renderer(), AXObjectCache::AXTextInserted, m_offset, m_text); 77 77 } 78 78 -
trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp
r93656 r101349 61 61 62 62 if (AXObjectCache::accessibilityEnabled()) 63 document()->axObjectCache()->nodeTextChangeNotification(m_node->renderer(), AXObjectCache::AXTextInserted, m_offset, m_text .length());63 document()->axObjectCache()->nodeTextChangeNotification(m_node->renderer(), AXObjectCache::AXTextInserted, m_offset, m_text); 64 64 } 65 65 … … 71 71 // Need to notify this before actually deleting the text 72 72 if (AXObjectCache::accessibilityEnabled()) 73 document()->axObjectCache()->nodeTextChangeNotification(m_node->renderer(), AXObjectCache::AXTextDeleted, m_offset, m_text .length());73 document()->axObjectCache()->nodeTextChangeNotification(m_node->renderer(), AXObjectCache::AXTextDeleted, m_offset, m_text); 74 74 75 75 ExceptionCode ec; -
trunk/Source/WebCore/editing/InsertNodeBeforeCommand.cpp
r86135 r101349 56 56 57 57 if (AXObjectCache::accessibilityEnabled()) 58 document()->axObjectCache()->nodeTextChangeNotification(m_insertChild->renderer(), AXObjectCache::AXTextInserted, 0, m_insertChild->nodeValue() .length());58 document()->axObjectCache()->nodeTextChangeNotification(m_insertChild->renderer(), AXObjectCache::AXTextInserted, 0, m_insertChild->nodeValue()); 59 59 } 60 60 … … 66 66 // Need to notify this before actually deleting the text 67 67 if (AXObjectCache::accessibilityEnabled()) 68 document()->axObjectCache()->nodeTextChangeNotification(m_insertChild->renderer(), AXObjectCache::AXTextDeleted, 0, m_insertChild->nodeValue() .length());68 document()->axObjectCache()->nodeTextChangeNotification(m_insertChild->renderer(), AXObjectCache::AXTextDeleted, 0, m_insertChild->nodeValue()); 69 69 70 70 ExceptionCode ec; -
trunk/Source/WebKit/gtk/ChangeLog
r101271 r101349 1 2011-11-29 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 Chris Fleizach. 7 8 Updated unit test to handle the new 'text-insert' and 9 'text-remove' signals, instead of the 'text-changed' one. 10 11 * tests/testatk.c: 12 (textChangedCb): Update a global variable with the result of the 13 text change, so we can check its value later. 14 (testWebkitAtkTextChangedNotifications): Connect to the 15 'text-insert' and 'text-remove' signals and check, in a way more 16 carefully way than it was done before, that the signals are being 17 properly emitted, and that the information attached to them is the 18 right one for each case (insert/remove, offset, count and text). 19 1 20 2011-11-28 Stefan Zwanenburg <stefanhetzwaantje@gmail.com> 2 21 -
trunk/Source/WebKit/gtk/tests/testatk.c
r101271 r101349 1549 1549 } 1550 1550 1551 static gboolean textInserted = FALSE; 1552 static gboolean textDeleted = FALSE; 1553 1554 static void textChangedCb(AtkText* text, gint pos, gint len, const gchar* detail) 1551 typedef enum { 1552 TEXT_CHANGE_INSERT = 1, 1553 TEXT_CHANGE_REMOVE = 2 1554 } TextChangeType; 1555 1556 static gchar* textChangedResult = 0; 1557 1558 static void textChangedCb(AtkText* text, gint pos, gint len, gchar* modifiedText, gpointer data) 1555 1559 { 1556 1560 g_assert(text && ATK_IS_OBJECT(text)); 1557 1561 1558 if (!g_strcmp0(detail, "insert")) 1559 textInserted = TRUE; 1560 else if (!g_strcmp0(detail, "delete")) 1561 textDeleted = TRUE; 1562 } 1563 1564 static gboolean checkTextChanges(gpointer unused) 1565 { 1566 g_assert_cmpint(textInserted, ==, TRUE); 1567 g_assert_cmpint(textDeleted, ==, TRUE); 1568 return FALSE; 1562 TextChangeType type = GPOINTER_TO_INT(data); 1563 g_free(textChangedResult); 1564 textChangedResult = g_strdup_printf("|%d|%d|%d|'%s'|", type, pos, len, modifiedText); 1569 1565 } 1570 1566 … … 1587 1583 g_assert(atk_object_get_role(ATK_OBJECT(textEntry)) == ATK_ROLE_ENTRY); 1588 1584 1589 g_signal_connect(textEntry, "text- changed::insert",1585 g_signal_connect(textEntry, "text-insert", 1590 1586 G_CALLBACK(textChangedCb), 1591 (gpointer)"insert");1592 g_signal_connect(textEntry, "text- changed::delete",1587 GINT_TO_POINTER(TEXT_CHANGE_INSERT)); 1588 g_signal_connect(textEntry, "text-remove", 1593 1589 G_CALLBACK(textChangedCb), 1594 (gpointer)"delete");1590 GINT_TO_POINTER(TEXT_CHANGE_REMOVE)); 1595 1591 1596 1592 gint pos = 0; 1597 1593 atk_editable_text_insert_text(ATK_EDITABLE_TEXT(textEntry), "foo bar baz", 11, &pos); 1594 char* text = atk_text_get_text(ATK_TEXT(textEntry), 0, -1); 1595 g_assert_cmpstr(text, ==, "foo bar baz"); 1596 g_assert_cmpstr(textChangedResult, ==, "|1|0|11|'foo bar baz'|"); 1597 g_free(text); 1598 1598 1599 atk_editable_text_delete_text(ATK_EDITABLE_TEXT(textEntry), 4, 7); 1599 textInserted = FALSE; 1600 textDeleted = FALSE; 1601 1602 g_idle_add((GSourceFunc)checkTextChanges, 0); 1600 text = atk_text_get_text(ATK_TEXT(textEntry), 0, -1); 1601 g_assert_cmpstr(text, ==, "foo baz"); 1602 g_assert_cmpstr(textChangedResult, ==, "|2|4|3|'bar'|"); 1603 g_free(text); 1604 1605 pos = 4; 1606 atk_editable_text_insert_text(ATK_EDITABLE_TEXT(textEntry), "qux quux", 8, &pos); 1607 text = atk_text_get_text(ATK_TEXT(textEntry), 0, -1); 1608 g_assert_cmpstr(text, ==, "foo qux quux baz"); 1609 g_assert_cmpstr(textChangedResult, ==, "|1|4|8|'qux quux'|"); 1610 g_free(text); 1611 1612 g_free(textChangedResult); 1603 1613 1604 1614 g_object_unref(form);
Note: See TracChangeset
for help on using the changeset viewer.