Changeset 83493 in webkit
- Timestamp:
- Apr 11, 2011 2:02:23 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r83492 r83493 1 2011-04-11 Mario Sanchez Prada <msanchez@igalia.com> 2 3 Reviewed by Chris Fleizach. 4 5 [Gtk] Implement support for Embedded Objects 6 https://bugs.webkit.org/show_bug.cgi?id=52148 7 8 Expose special OBJECT character for replaced elements, implementing 9 AtkText and AtkHyperlink when required. 10 11 * accessibility/AccessibilityRenderObject.cpp: 12 (WebCore::textIteratorBehaviorForTextRange): New helper function, 13 to return the right behavior, depending on the platform, so it 14 ensures that object replacement characters get emitted for GTK. 15 (WebCore::AccessibilityRenderObject::textUnderElement): Use the 16 new helper function textIteratorBehaviorForTextRange. 17 (WebCore::AccessibilityRenderObject::stringValue): Ditto. 18 (WebCore::AccessibilityRenderObject::indexForVisiblePosition): 19 Consider replaced elements when calculating range length in GTK. 20 21 * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: 22 (textForRenderer): Ouput the 'object replacement character' for 23 replaced objects. 24 (getSelectionOffsetsForObject): Consider replaced elements when 25 calculating range length in GTK. 26 (webkitAccessibleHypertextGetLink): Remove wrong extra check that 27 were causing only links to be considered. 28 (webkitAccessibleHypertextGetNLinks): Replace wrong 'isLink()' 29 check with the right one, by checking that the right ATK interface 30 is being implemented by the AtkObject. 31 (getInterfaceMaskFromObject): Implement the Hyperlink interface 32 both for links and replaced objects. 33 (objectAndOffsetUnignored): Consider replaced elements when 34 calculating range length in GTK. 35 36 * accessibility/gtk/WebKitAccessibleHyperlink.cpp: 37 (getRangeLengthForObject): Ensure spaces are used for replaced 38 elements when calling to TextIterator::rangeLength(). 39 40 * editing/TextIterator.h: New value in the TextIteratorBehavior 41 enumeration (TextIteratorEmitsObjectReplacementCharacters) and new 42 private variable to consider that new option internally. 43 * editing/TextIterator.cpp: 44 (WebCore::TextIterator::TextIterator): Initialize the new private 45 attribute m_emitsObjectReplacementCharacters in constructors. 46 (WebCore::TextIterator::handleReplacedElement): Emit the 'object 47 replacement character' when m_emitsObjectReplacementCharacters. 48 1 49 2011-04-11 Jia Pu <jpu@apple.com> 2 50 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r82934 r83493 1012 1012 } 1013 1013 1014 static TextIteratorBehavior textIteratorBehaviorForTextRange() 1015 { 1016 TextIteratorBehavior behavior = TextIteratorIgnoresStyleVisibility; 1017 1018 #if PLATFORM(GTK) 1019 // We need to emit replaced elements for GTK, and present 1020 // them with the 'object replacement character' (0xFFFC). 1021 behavior = static_cast<TextIteratorBehavior>(behavior | TextIteratorEmitsObjectReplacementCharacters); 1022 #endif 1023 1024 return behavior; 1025 } 1026 1014 1027 String AccessibilityRenderObject::textUnderElement() const 1015 1028 { … … 1026 1039 if (frame->document() != node->document()) 1027 1040 return String(); 1028 return plainText(rangeOfContents(node).get(), TextIteratorIgnoresStyleVisibility); 1041 1042 return plainText(rangeOfContents(node).get(), textIteratorBehaviorForTextRange()); 1029 1043 } 1030 1044 } … … 1140 1154 if (startVisiblePosition.isNull() || endVisiblePosition.isNull()) 1141 1155 return String(); 1142 1143 return plainText(makeRange(startVisiblePosition, endVisiblePosition).get(), TextIteratorIgnoresStyleVisibility); 1156 1157 return plainText(makeRange(startVisiblePosition, endVisiblePosition).get(), 1158 textIteratorBehaviorForTextRange()); 1144 1159 } 1145 1160 … … 2493 2508 range->setStart(node, 0, ec); 2494 2509 range->setEnd(indexPosition.anchorNode(), indexPosition.deprecatedEditingOffset(), ec); 2510 2511 #if PLATFORM(GTK) 2512 // We need to consider replaced elements for GTK, as they will be 2513 // presented with the 'object replacement character' (0xFFFC). 2514 return TextIterator::rangeLength(range.get(), true); 2515 #else 2495 2516 return TextIterator::rangeLength(range.get()); 2517 #endif 2496 2518 } 2497 2519 -
trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
r83450 r83493 42 42 #include "AccessibilityTableColumn.h" 43 43 #include "AccessibilityTableRow.h" 44 #include "CharacterNames.h" 44 45 #include "Document.h" 45 46 #include "DocumentType.h" … … 1054 1055 renderText = toRenderText(object); 1055 1056 else { 1057 if (object->isReplaced()) 1058 g_string_append_unichar(resultText, objectReplacementCharacter); 1059 1056 1060 // We need to check children, if any, to consider when 1057 1061 // current object is not a text object but some of its … … 1064 1068 } 1065 1069 1066 InlineTextBox* box = renderText ->firstTextBox();1070 InlineTextBox* box = renderText ? renderText->firstTextBox() : 0; 1067 1071 while (box) { 1068 1072 gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end()); … … 1623 1627 1624 1628 // Set values for start and end offsets. 1625 startOffset = TextIterator::rangeLength(rangeInParent.get() );1629 startOffset = TextIterator::rangeLength(rangeInParent.get(), true); 1626 1630 1627 1631 // We need to adjust the offsets for the list item marker. … … 1633 1637 1634 1638 RefPtr<Range> nodeRange = Range::create(node->document(), nodeRangeStart, nodeRangeEnd); 1635 endOffset = startOffset + TextIterator::rangeLength(nodeRange.get() );1639 endOffset = startOffset + TextIterator::rangeLength(nodeRange.get(), true); 1636 1640 } 1637 1641 … … 2167 2171 for (unsigned i = 0; i < children.size(); i++) { 2168 2172 AccessibilityObject* coreChild = children.at(i).get(); 2169 if (!coreChild->accessibilityIsIgnored() && coreChild->isLink()) { 2173 if (!coreChild->accessibilityIsIgnored()) { 2174 AtkObject* axObject = coreChild->wrapper(); 2175 if (!axObject || !ATK_IS_HYPERLINK_IMPL(axObject)) 2176 continue; 2177 2170 2178 currentLink++; 2171 2179 if (index != currentLink) 2172 2180 continue; 2173 2181 2174 AtkObject* axObject = coreChild->wrapper();2175 if (!axObject || !ATK_IS_HYPERLINK_IMPL(axObject))2176 return 0;2177 2178 2182 return atk_hyperlink_impl_get_hyperlink(ATK_HYPERLINK_IMPL(axObject)); 2179 2183 } … … 2192 2196 for (size_t i = 0; i < children.size(); i++) { 2193 2197 AccessibilityObject* coreChild = children.at(i).get(); 2194 if (!coreChild->accessibilityIsIgnored() && coreChild->isLink()) 2195 linksFound++; 2198 if (!coreChild->accessibilityIsIgnored()) { 2199 AtkObject* axObject = coreChild->wrapper(); 2200 if (axObject && ATK_IS_HYPERLINK_IMPL(axObject)) 2201 linksFound++; 2202 } 2196 2203 } 2197 2204 … … 2440 2447 interfaceMask |= 1 << WAI_ACTION; 2441 2448 2442 // Hyperlink2443 if (coreObject->isLink())2444 interfaceMask |= 1 << WAI_HYPERLINK;2445 2446 2449 // Selection 2447 2450 if (coreObject->isListBox() || coreObject->isMenuList()) 2448 2451 interfaceMask |= 1 << WAI_SELECTION; 2449 2452 2453 // Get renderer if available. 2454 RenderObject* renderer = 0; 2455 if (coreObject->isAccessibilityRenderObject()) 2456 renderer = coreObject->renderer(); 2457 2458 // Hyperlink (links and embedded objects). 2459 if (coreObject->isLink() || (renderer && renderer->isReplaced())) 2460 interfaceMask |= 1 << WAI_HYPERLINK; 2461 2450 2462 // Text & Editable Text 2451 2463 if (role == StaticTextRole || coreObject->isMenuListOption()) 2452 2464 interfaceMask |= 1 << WAI_TEXT; 2453 else if (coreObject->isAccessibilityRenderObject()){2465 else { 2454 2466 if (coreObject->isTextControl()) { 2455 2467 interfaceMask |= 1 << WAI_TEXT; … … 2457 2469 interfaceMask |= 1 << WAI_EDITABLE_TEXT; 2458 2470 } else { 2459 AccessibilityRenderObject* axRenderObject = static_cast<AccessibilityRenderObject*>(coreObject);2460 RenderObject* renderer = axRenderObject->renderer();2461 2471 if (role != TableRole) { 2462 2472 interfaceMask |= 1 << WAI_HYPERTEXT; … … 2606 2616 else if (!isStartOfLine(endPosition)) { 2607 2617 RefPtr<Range> range = makeRange(startPosition, endPosition.previous()); 2608 offset = TextIterator::rangeLength(range.get() ) + 1;2618 offset = TextIterator::rangeLength(range.get(), true) + 1; 2609 2619 } else { 2610 2620 RefPtr<Range> range = makeRange(startPosition, endPosition); 2611 offset = TextIterator::rangeLength(range.get() );2621 offset = TextIterator::rangeLength(range.get(), true); 2612 2622 } 2613 2623 -
trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleHyperlink.cpp
r83064 r83493 199 199 { 200 200 // This is going to be the actual length in most of the cases 201 int baseLength = TextIterator::rangeLength(range );201 int baseLength = TextIterator::rangeLength(range, true); 202 202 203 203 // Check whether the current hyperlink belongs to a list item. -
trunk/Source/WebCore/editing/TextIterator.cpp
r83081 r83493 258 258 , m_handledFirstLetter(false) 259 259 , m_ignoresStyleVisibility(false) 260 , m_emitsObjectReplacementCharacters(false) 260 261 { 261 262 } … … 276 277 , m_handledFirstLetter(false) 277 278 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) 279 , m_emitsObjectReplacementCharacters(behavior & TextIteratorEmitsObjectReplacementCharacters) 278 280 { 279 281 if (!r) … … 639 641 640 642 m_hasEmitted = true; 643 644 if (m_emitsObjectReplacementCharacters && renderer && renderer->isReplaced()) { 645 emitCharacter(objectReplacementCharacter, m_node->parentNode(), m_node, 0, 1); 646 return true; 647 } 641 648 642 649 if (m_emitsCharactersBetweenAllVisiblePositions) { -
trunk/Source/WebCore/editing/TextIterator.h
r83081 r83493 42 42 TextIteratorEntersTextControls = 1 << 1, 43 43 TextIteratorEmitsTextsWithoutTranscoding = 1 << 2, 44 TextIteratorIgnoresStyleVisibility = 1 << 3 44 TextIteratorIgnoresStyleVisibility = 1 << 3, 45 TextIteratorEmitsObjectReplacementCharacters = 1 << 4 45 46 }; 46 47 … … 180 181 // Used when the visibility of the style should not affect text gathering. 181 182 bool m_ignoresStyleVisibility; 183 // Used when emitting the special 0xFFFC character is required. 184 bool m_emitsObjectReplacementCharacters; 182 185 }; 183 186 -
trunk/Source/WebKit/gtk/ChangeLog
r83333 r83493 1 2011-04-11 Mario Sanchez Prada <msanchez@igalia.com> 2 3 Reviewed by Chris Fleizach. 4 5 [Gtk] Implement support for Embedded Objects 6 https://bugs.webkit.org/show_bug.cgi?id=52148 7 8 New accessibility unit test for embedded objects. 9 10 * tests/testatk.c: 11 (testWebkitAtkEmbeddedObjects): New unit test. 12 (main): Added the new unit test. 13 1 14 2011-04-08 Dominic Cooney <dominicc@google.com> 2 15 -
trunk/Source/WebKit/gtk/tests/testatk.c
r81587 r83493 51 51 static const char* comboBoxSelector = "<html><body><select><option selected value='foo'>foo</option><option value='bar'>bar</option></select></body></html>"; 52 52 53 static const char* embeddedObjects = "<html><body><p>Choose: <input value='foo' type='checkbox'/>foo <input value='bar' type='checkbox'/>bar (pick one)</p><p>Choose: <select name='foo'><option>bar</option><option>baz</option></select> (pick one)</p><p><input name='foobarbutton' value='foobar' type='button'/></p></body></html>"; 54 53 55 static const char* formWithTextInputs = "<html><body><form><input type='text' name='entry' /></form></body></html>"; 54 56 … … 478 480 g_object_unref(item1); 479 481 g_object_unref(item2); 482 g_object_unref(webView); 483 } 484 485 static void testWebkitAtkEmbeddedObjects() 486 { 487 WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); 488 g_object_ref_sink(webView); 489 GtkAllocation allocation = { 0, 0, 800, 600 }; 490 gtk_widget_size_allocate(GTK_WIDGET(webView), &allocation); 491 webkit_web_view_load_string(webView, embeddedObjects, 0, 0, 0); 492 493 /* Wait for the accessible objects to be created. */ 494 waitForAccessibleObjects(); 495 496 AtkObject* object = gtk_widget_get_accessible(GTK_WIDGET(webView)); 497 g_assert(object); 498 499 AtkText* paragraph1 = ATK_TEXT(atk_object_ref_accessible_child(object, 0)); 500 g_assert(ATK_IS_TEXT(paragraph1)); 501 g_assert(ATK_IS_HYPERTEXT(paragraph1)); 502 503 const gchar* expectedText = "Choose: \357\277\274foo \357\277\274bar (pick one)"; 504 char* text = atk_text_get_text(paragraph1, 0, -1); 505 g_assert_cmpstr(text, ==, expectedText); 506 g_free(text); 507 508 gint nLinks = atk_hypertext_get_n_links(ATK_HYPERTEXT(paragraph1)); 509 g_assert_cmpint(nLinks, ==, 2); 510 511 AtkHyperlink* hLink = atk_hypertext_get_link(ATK_HYPERTEXT(paragraph1), 0); 512 g_assert(ATK_HYPERLINK(hLink)); 513 AtkObject* hLinkObject = atk_hyperlink_get_object(hLink, 0); 514 g_assert(ATK_OBJECT(hLinkObject)); 515 g_assert(atk_object_get_role(hLinkObject) == ATK_ROLE_CHECK_BOX); 516 g_assert_cmpint(atk_hyperlink_get_start_index(hLink), ==, 8); 517 g_assert_cmpint(atk_hyperlink_get_end_index(hLink), ==, 9); 518 g_assert_cmpint(atk_hyperlink_get_n_anchors(hLink), ==, 1); 519 g_assert_cmpstr(atk_hyperlink_get_uri(hLink, 0), ==, 0); 520 521 AtkText* paragraph2 = ATK_TEXT(atk_object_ref_accessible_child(object, 1)); 522 g_assert(ATK_IS_TEXT(paragraph2)); 523 g_assert(ATK_IS_HYPERTEXT(paragraph2)); 524 525 expectedText = "Choose: \357\277\274 (pick one)"; 526 text = atk_text_get_text(paragraph2, 0, -1); 527 g_assert_cmpstr(text, ==, expectedText); 528 g_free(text); 529 530 nLinks = atk_hypertext_get_n_links(ATK_HYPERTEXT(paragraph2)); 531 g_assert_cmpint(nLinks, ==, 1); 532 533 hLink = atk_hypertext_get_link(ATK_HYPERTEXT(paragraph2), 0); 534 g_assert(ATK_HYPERLINK(hLink)); 535 hLinkObject = atk_hyperlink_get_object(hLink, 0); 536 g_assert(ATK_OBJECT(hLinkObject)); 537 g_assert(atk_object_get_role(hLinkObject) == ATK_ROLE_COMBO_BOX); 538 g_assert_cmpint(atk_hyperlink_get_start_index(hLink), ==, 8); 539 g_assert_cmpint(atk_hyperlink_get_end_index(hLink), ==, 9); 540 g_assert_cmpint(atk_hyperlink_get_n_anchors(hLink), ==, 1); 541 g_assert_cmpstr(atk_hyperlink_get_uri(hLink, 0), ==, 0); 542 543 AtkText* paragraph3 = ATK_TEXT(atk_object_ref_accessible_child(object, 2)); 544 g_assert(ATK_IS_TEXT(paragraph3)); 545 g_assert(ATK_IS_HYPERTEXT(paragraph3)); 546 547 expectedText = "\357\277\274"; 548 text = atk_text_get_text(paragraph3, 0, -1); 549 g_assert_cmpstr(text, ==, expectedText); 550 g_free(text); 551 552 nLinks = atk_hypertext_get_n_links(ATK_HYPERTEXT(paragraph3)); 553 g_assert_cmpint(nLinks, ==, 1); 554 555 hLink = atk_hypertext_get_link(ATK_HYPERTEXT(paragraph3), 0); 556 g_assert(ATK_HYPERLINK(hLink)); 557 hLinkObject = atk_hyperlink_get_object(hLink, 0); 558 g_assert(ATK_OBJECT(hLinkObject)); 559 g_assert(atk_object_get_role(hLinkObject) == ATK_ROLE_PUSH_BUTTON); 560 g_assert_cmpint(atk_hyperlink_get_start_index(hLink), ==, 0); 561 g_assert_cmpint(atk_hyperlink_get_end_index(hLink), ==, 1); 562 g_assert_cmpint(atk_hyperlink_get_n_anchors(hLink), ==, 1); 563 g_assert_cmpstr(atk_hyperlink_get_uri(hLink, 0), ==, 0); 564 565 g_object_unref(paragraph1); 566 g_object_unref(paragraph2); 567 g_object_unref(paragraph3); 480 568 g_object_unref(webView); 481 569 } … … 1580 1668 g_test_add_func("/webkit/atk/caretOffsetsAndExtranousWhiteSpaces", testWebkitAtkCaretOffsetsAndExtranousWhiteSpaces); 1581 1669 g_test_add_func("/webkit/atk/comboBox", testWebkitAtkComboBox); 1670 g_test_add_func("/webkit/atk/embeddedObjects", testWebkitAtkEmbeddedObjects); 1582 1671 g_test_add_func("/webkit/atk/getTextAtOffset", testWebkitAtkGetTextAtOffset); 1583 1672 g_test_add_func("/webkit/atk/getTextAtOffsetForms", testWebkitAtkGetTextAtOffsetForms);
Note: See TracChangeset
for help on using the changeset viewer.