| Differences between
and this patch
- a/Source/WebCore/ChangeLog +48 lines
Lines 2-7 a/Source/WebCore/ChangeLog_sec1
2
2
3
        Reviewed by NOBODY (OOPS!).
3
        Reviewed by NOBODY (OOPS!).
4
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
49
2011-04-06  Mario Sanchez Prada  <msanchez@igalia.com>
50
51
        Reviewed by NOBODY (OOPS!).
52
5
        [GTK] Do not reference AccessibilityRenderObject from platform dependent code
53
        [GTK] Do not reference AccessibilityRenderObject from platform dependent code
6
        https://bugs.webkit.org/show_bug.cgi?id=57955
54
        https://bugs.webkit.org/show_bug.cgi?id=57955
7
55
- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp -3 / +25 lines
Lines 1011-1016 unsigned AccessibilityRenderObject::hierarchicalLevel() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec1
1011
    return level;
1011
    return level;
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
String AccessibilityRenderObject::textUnderElement() const
1027
String AccessibilityRenderObject::textUnderElement() const
1015
{
1028
{
1016
    if (!m_renderer)
1029
    if (!m_renderer)
Lines 1025-1031 String AccessibilityRenderObject::textUnderElement() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec2
1025
            // catch stale WebCoreAXObject (see <rdar://problem/3960196>)
1038
            // catch stale WebCoreAXObject (see <rdar://problem/3960196>)
1026
            if (frame->document() != node->document())
1039
            if (frame->document() != node->document())
1027
                return String();
1040
                return String();
1028
            return plainText(rangeOfContents(node).get(), TextIteratorIgnoresStyleVisibility);
1041
1042
            return plainText(rangeOfContents(node).get(), textIteratorBehaviorForTextRange());
1029
        }
1043
        }
1030
    }
1044
    }
1031
    
1045
    
Lines 1139-1146 String AccessibilityRenderObject::stringValue() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec3
1139
        VisiblePosition endVisiblePosition = m_renderer->positionForCoordinates(INT_MAX, INT_MAX);
1153
        VisiblePosition endVisiblePosition = m_renderer->positionForCoordinates(INT_MAX, INT_MAX);
1140
        if (startVisiblePosition.isNull() || endVisiblePosition.isNull())
1154
        if (startVisiblePosition.isNull() || endVisiblePosition.isNull())
1141
            return String();
1155
            return String();
1142
        
1156
1143
        return plainText(makeRange(startVisiblePosition, endVisiblePosition).get(), TextIteratorIgnoresStyleVisibility);
1157
        return plainText(makeRange(startVisiblePosition, endVisiblePosition).get(),
1158
                         textIteratorBehaviorForTextRange());
1144
    }
1159
    }
1145
    
1160
    
1146
    if (isTextControl())
1161
    if (isTextControl())
Lines 2492-2498 int AccessibilityRenderObject::indexForVisiblePosition(const VisiblePosition& po a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec4
2492
    RefPtr<Range> range = Range::create(m_renderer->document());
2507
    RefPtr<Range> range = Range::create(m_renderer->document());
2493
    range->setStart(node, 0, ec);
2508
    range->setStart(node, 0, ec);
2494
    range->setEnd(indexPosition.anchorNode(), indexPosition.deprecatedEditingOffset(), ec);
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
    return TextIterator::rangeLength(range.get());
2516
    return TextIterator::rangeLength(range.get());
2517
#endif
2496
}
2518
}
2497
2519
2498
IntRect AccessibilityRenderObject::boundsForVisiblePositionRange(const VisiblePositionRange& visiblePositionRange) const
2520
IntRect AccessibilityRenderObject::boundsForVisiblePositionRange(const VisiblePositionRange& visiblePositionRange) const
- a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp -19 / +29 lines
Lines 41-46 a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec1
41
#include "AccessibilityTableCell.h"
41
#include "AccessibilityTableCell.h"
42
#include "AccessibilityTableColumn.h"
42
#include "AccessibilityTableColumn.h"
43
#include "AccessibilityTableRow.h"
43
#include "AccessibilityTableRow.h"
44
#include "CharacterNames.h"
44
#include "Document.h"
45
#include "Document.h"
45
#include "DocumentType.h"
46
#include "DocumentType.h"
46
#include "Editor.h"
47
#include "Editor.h"
Lines 1051-1056 gchar* textForRenderer(RenderObject* renderer) a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec2
1051
        if (object->isText())
1052
        if (object->isText())
1052
            renderText = toRenderText(object);
1053
            renderText = toRenderText(object);
1053
        else {
1054
        else {
1055
            if (object->isReplaced())
1056
                g_string_append_unichar(resultText, objectReplacementCharacter);
1057
1054
            // We need to check children, if any, to consider when
1058
            // We need to check children, if any, to consider when
1055
            // current object is not a text object but some of its
1059
            // current object is not a text object but some of its
1056
            // children are, in order not to miss those portions of
1060
            // children are, in order not to miss those portions of
Lines 1061-1067 gchar* textForRenderer(RenderObject* renderer) a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec3
1061
            continue;
1065
            continue;
1062
        }
1066
        }
1063
1067
1064
        InlineTextBox* box = renderText->firstTextBox();
1068
        InlineTextBox* box = renderText ? renderText->firstTextBox() : 0;
1065
        while (box) {
1069
        while (box) {
1066
            gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
1070
            gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
1067
            g_string_append(resultText, text);
1071
            g_string_append(resultText, text);
Lines 1620-1626 static void getSelectionOffsetsForObject(AccessibilityObject* coreObject, Visibl a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec4
1620
    RefPtr<Range> rangeInParent = Range::create(node->document(), parentFirstPosition, nodeRangeStart);
1624
    RefPtr<Range> rangeInParent = Range::create(node->document(), parentFirstPosition, nodeRangeStart);
1621
1625
1622
    // Set values for start and end offsets.
1626
    // Set values for start and end offsets.
1623
    startOffset = TextIterator::rangeLength(rangeInParent.get());
1627
    startOffset = TextIterator::rangeLength(rangeInParent.get(), true);
1624
1628
1625
    // We need to adjust the offsets for the list item marker.
1629
    // We need to adjust the offsets for the list item marker.
1626
    RenderObject* renderer = coreObject->renderer();
1630
    RenderObject* renderer = coreObject->renderer();
Lines 1630-1636 static void getSelectionOffsetsForObject(AccessibilityObject* coreObject, Visibl a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec5
1630
    }
1634
    }
1631
1635
1632
    RefPtr<Range> nodeRange = Range::create(node->document(), nodeRangeStart, nodeRangeEnd);
1636
    RefPtr<Range> nodeRange = Range::create(node->document(), nodeRangeStart, nodeRangeEnd);
1633
    endOffset = startOffset + TextIterator::rangeLength(nodeRange.get());
1637
    endOffset = startOffset + TextIterator::rangeLength(nodeRange.get(), true);
1634
}
1638
}
1635
1639
1636
static gint webkit_accessible_text_get_n_selections(AtkText* text)
1640
static gint webkit_accessible_text_get_n_selections(AtkText* text)
Lines 2164-2178 static AtkHyperlink* webkitAccessibleHypertextGetLink(AtkHypertext* hypertext, g a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec6
2164
    gint currentLink = -1;
2168
    gint currentLink = -1;
2165
    for (unsigned i = 0; i < children.size(); i++) {
2169
    for (unsigned i = 0; i < children.size(); i++) {
2166
        AccessibilityObject* coreChild = children.at(i).get();
2170
        AccessibilityObject* coreChild = children.at(i).get();
2167
        if (!coreChild->accessibilityIsIgnored() && coreChild->isLink()) {
2171
        if (!coreChild->accessibilityIsIgnored()) {
2172
            AtkObject* axObject = coreChild->wrapper();
2173
            if (!axObject || !ATK_IS_HYPERLINK_IMPL(axObject))
2174
                continue;
2175
2168
            currentLink++;
2176
            currentLink++;
2169
            if (index != currentLink)
2177
            if (index != currentLink)
2170
                continue;
2178
                continue;
2171
2179
2172
            AtkObject* axObject = coreChild->wrapper();
2173
            if (!axObject || !ATK_IS_HYPERLINK_IMPL(axObject))
2174
                return 0;
2175
2176
            return atk_hyperlink_impl_get_hyperlink(ATK_HYPERLINK_IMPL(axObject));
2180
            return atk_hyperlink_impl_get_hyperlink(ATK_HYPERLINK_IMPL(axObject));
2177
        }
2181
        }
2178
    }
2182
    }
Lines 2189-2196 static gint webkitAccessibleHypertextGetNLinks(AtkHypertext* hypertext) a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec7
2189
    gint linksFound = 0;
2193
    gint linksFound = 0;
2190
    for (size_t i = 0; i < children.size(); i++) {
2194
    for (size_t i = 0; i < children.size(); i++) {
2191
        AccessibilityObject* coreChild = children.at(i).get();
2195
        AccessibilityObject* coreChild = children.at(i).get();
2192
        if (!coreChild->accessibilityIsIgnored() && coreChild->isLink())
2196
        if (!coreChild->accessibilityIsIgnored()) {
2193
            linksFound++;
2197
            AtkObject* axObject = coreChild->wrapper();
2198
            if (axObject && ATK_IS_HYPERLINK_IMPL(axObject))
2199
                linksFound++;
2200
        }
2194
    }
2201
    }
2195
2202
2196
    return linksFound;
2203
    return linksFound;
Lines 2437-2461 static guint16 getInterfaceMaskFromObject(AccessibilityObject* coreObject) a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec8
2437
    // the WebKitAccessible class and let WebCore decide what to do.
2444
    // the WebKitAccessible class and let WebCore decide what to do.
2438
    interfaceMask |= 1 << WAI_ACTION;
2445
    interfaceMask |= 1 << WAI_ACTION;
2439
2446
2440
    // Hyperlink
2441
    if (coreObject->isLink())
2442
        interfaceMask |= 1 << WAI_HYPERLINK;
2443
2444
    // Selection
2447
    // Selection
2445
    if (coreObject->isListBox() || coreObject->isMenuList())
2448
    if (coreObject->isListBox() || coreObject->isMenuList())
2446
        interfaceMask |= 1 << WAI_SELECTION;
2449
        interfaceMask |= 1 << WAI_SELECTION;
2447
2450
2451
    // Get renderer if available.
2452
    RenderObject* renderer = 0;
2453
    if (coreObject->isAccessibilityRenderObject())
2454
        renderer = coreObject->renderer();
2455
2456
    // Hyperlink (links and embedded objects).
2457
    if (coreObject->isLink() || (renderer && renderer->isReplaced()))
2458
        interfaceMask |= 1 << WAI_HYPERLINK;
2459
2448
    // Text & Editable Text
2460
    // Text & Editable Text
2449
    if (role == StaticTextRole || coreObject->isMenuListOption())
2461
    if (role == StaticTextRole || coreObject->isMenuListOption())
2450
        interfaceMask |= 1 << WAI_TEXT;
2462
        interfaceMask |= 1 << WAI_TEXT;
2451
    else if (coreObject->isAccessibilityRenderObject()) {
2463
    else {
2452
        if (coreObject->isTextControl()) {
2464
        if (coreObject->isTextControl()) {
2453
            interfaceMask |= 1 << WAI_TEXT;
2465
            interfaceMask |= 1 << WAI_TEXT;
2454
            if (!coreObject->isReadOnly())
2466
            if (!coreObject->isReadOnly())
2455
                interfaceMask |= 1 << WAI_EDITABLE_TEXT;
2467
                interfaceMask |= 1 << WAI_EDITABLE_TEXT;
2456
        } else {
2468
        } else {
2457
            AccessibilityRenderObject* axRenderObject = static_cast<AccessibilityRenderObject*>(coreObject);
2458
            RenderObject* renderer = axRenderObject->renderer();
2459
            if (role != TableRole) {
2469
            if (role != TableRole) {
2460
                interfaceMask |= 1 << WAI_HYPERTEXT;
2470
                interfaceMask |= 1 << WAI_HYPERTEXT;
2461
                if (renderer && renderer->childrenInline())
2471
                if (renderer && renderer->childrenInline())
Lines 2603-2612 AccessibilityObject* objectAndOffsetUnignored(AccessibilityObject* coreObject, i a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp_sec9
2603
            offset = 0;
2613
            offset = 0;
2604
        else if (!isStartOfLine(endPosition)) {
2614
        else if (!isStartOfLine(endPosition)) {
2605
            RefPtr<Range> range = makeRange(startPosition, endPosition.previous());
2615
            RefPtr<Range> range = makeRange(startPosition, endPosition.previous());
2606
            offset = TextIterator::rangeLength(range.get()) + 1;
2616
            offset = TextIterator::rangeLength(range.get(), true) + 1;
2607
        } else {
2617
        } else {
2608
            RefPtr<Range> range = makeRange(startPosition, endPosition);
2618
            RefPtr<Range> range = makeRange(startPosition, endPosition);
2609
            offset = TextIterator::rangeLength(range.get());
2619
            offset = TextIterator::rangeLength(range.get(), true);
2610
        }
2620
        }
2611
2621
2612
    }
2622
    }
- a/Source/WebCore/accessibility/gtk/WebKitAccessibleHyperlink.cpp -1 / +1 lines
Lines 198-204 static AtkObject* webkitAccessibleHyperlinkGetObject(AtkHyperlink* link, gint in a/Source/WebCore/accessibility/gtk/WebKitAccessibleHyperlink.cpp_sec1
198
static gint getRangeLengthForObject(AccessibilityObject* obj, Range* range)
198
static gint getRangeLengthForObject(AccessibilityObject* obj, Range* range)
199
{
199
{
200
    // This is going to be the actual length in most of the cases
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
    // Check whether the current hyperlink belongs to a list item.
203
    // Check whether the current hyperlink belongs to a list item.
204
    // If so, we need to consider the length of the item's marker
204
    // If so, we need to consider the length of the item's marker
- a/Source/WebCore/editing/TextIterator.cpp +7 lines
Lines 256-261 TextIterator::TextIterator() a/Source/WebCore/editing/TextIterator.cpp_sec1
256
    , m_emitsTextWithoutTranscoding(false)
256
    , m_emitsTextWithoutTranscoding(false)
257
    , m_handledFirstLetter(false)
257
    , m_handledFirstLetter(false)
258
    , m_ignoresStyleVisibility(false)
258
    , m_ignoresStyleVisibility(false)
259
    , m_emitsObjectReplacementCharacters(false)
259
{
260
{
260
}
261
}
261
262
Lines 274-279 TextIterator::TextIterator(const Range* r, TextIteratorBehavior behavior) a/Source/WebCore/editing/TextIterator.cpp_sec2
274
    , m_emitsTextWithoutTranscoding(behavior & TextIteratorEmitsTextsWithoutTranscoding)
275
    , m_emitsTextWithoutTranscoding(behavior & TextIteratorEmitsTextsWithoutTranscoding)
275
    , m_handledFirstLetter(false)
276
    , m_handledFirstLetter(false)
276
    , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility)
277
    , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility)
278
    , m_emitsObjectReplacementCharacters(behavior & TextIteratorEmitsObjectReplacementCharacters)
277
{
279
{
278
    if (!r)
280
    if (!r)
279
        return;
281
        return;
Lines 638-643 bool TextIterator::handleReplacedElement() a/Source/WebCore/editing/TextIterator.cpp_sec3
638
640
639
    m_hasEmitted = true;
641
    m_hasEmitted = true;
640
642
643
    if (m_emitsObjectReplacementCharacters && renderer && renderer->isReplaced()) {
644
        emitCharacter(objectReplacementCharacter, m_node->parentNode(), m_node, 0, 1);
645
        return true;
646
    }
647
641
    if (m_emitsCharactersBetweenAllVisiblePositions) {
648
    if (m_emitsCharactersBetweenAllVisiblePositions) {
642
        // We want replaced elements to behave like punctuation for boundary 
649
        // We want replaced elements to behave like punctuation for boundary 
643
        // finding, and to simply take up space for the selection preservation 
650
        // finding, and to simply take up space for the selection preservation 
- a/Source/WebCore/editing/TextIterator.h -1 / +4 lines
Lines 41-47 enum TextIteratorBehavior { a/Source/WebCore/editing/TextIterator.h_sec1
41
    TextIteratorEmitsCharactersBetweenAllVisiblePositions = 1 << 0,
41
    TextIteratorEmitsCharactersBetweenAllVisiblePositions = 1 << 0,
42
    TextIteratorEntersTextControls = 1 << 1,
42
    TextIteratorEntersTextControls = 1 << 1,
43
    TextIteratorEmitsTextsWithoutTranscoding = 1 << 2,
43
    TextIteratorEmitsTextsWithoutTranscoding = 1 << 2,
44
    TextIteratorIgnoresStyleVisibility = 1 << 3
44
    TextIteratorIgnoresStyleVisibility = 1 << 3,
45
    TextIteratorEmitsObjectReplacementCharacters = 1 << 4
45
};
46
};
46
    
47
    
47
// FIXME: Can't really answer this question correctly without knowing the white-space mode.
48
// FIXME: Can't really answer this question correctly without knowing the white-space mode.
Lines 178-183 private: a/Source/WebCore/editing/TextIterator.h_sec2
178
    bool m_handledFirstLetter;
179
    bool m_handledFirstLetter;
179
    // Used when the visibility of the style should not affect text gathering.
180
    // Used when the visibility of the style should not affect text gathering.
180
    bool m_ignoresStyleVisibility;
181
    bool m_ignoresStyleVisibility;
182
    // Used when emitting the special 0xFFFC character is required.
183
    bool m_emitsObjectReplacementCharacters;
181
};
184
};
182
185
183
// Iterates through the DOM range, returning all the text, and 0-length boundaries
186
// Iterates through the DOM range, returning all the text, and 0-length boundaries
- a/Source/WebKit/gtk/ChangeLog +13 lines
Lines 1-3 a/Source/WebKit/gtk/ChangeLog_sec1
1
2011-04-06  Mario Sanchez Prada  <msanchez@igalia.com>
2
3
        Reviewed by NOBODY (OOPS!).
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
2011-04-05  Martin Robinson  <mrobinson@igalia.com>
14
2011-04-05  Martin Robinson  <mrobinson@igalia.com>
2
15
3
        Reviewed by Eric Seidel.
16
        Reviewed by Eric Seidel.
- a/Source/WebKit/gtk/tests/testatk.c -1 / +89 lines
Lines 50-55 static const char* contentsWithExtraneousWhiteSpaces = "<html><head><body><p>Thi a/Source/WebKit/gtk/tests/testatk.c_sec1
50
50
51
static const char* comboBoxSelector = "<html><body><select><option selected value='foo'>foo</option><option value='bar'>bar</option></select></body></html>";
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
static const char* formWithTextInputs = "<html><body><form><input type='text' name='entry' /></form></body></html>";
55
static const char* formWithTextInputs = "<html><body><form><input type='text' name='entry' /></form></body></html>";
54
56
55
static const char* hypertextAndHyperlinks = "<html><body><p>A paragraph with no links at all</p><p><a href='http://foo.bar.baz/'>A line</a> with <a href='http://bar.baz.foo/'>a link in the middle</a> as well as at the beginning and <a href='http://baz.foo.bar/'>at the end</a></p><ol><li>List item with a <span><a href='http://foo.bar.baz/'>link inside a span node</a></span></li></ol></body></html>";
57
static const char* hypertextAndHyperlinks = "<html><body><p>A paragraph with no links at all</p><p><a href='http://foo.bar.baz/'>A line</a> with <a href='http://bar.baz.foo/'>a link in the middle</a> as well as at the beginning and <a href='http://baz.foo.bar/'>at the end</a></p><ol><li>List item with a <span><a href='http://foo.bar.baz/'>link inside a span node</a></span></li></ol></body></html>";
Lines 480-485 static void testWebkitAtkComboBox() a/Source/WebKit/gtk/tests/testatk.c_sec2
480
    g_object_unref(webView);
482
    g_object_unref(webView);
481
}
483
}
482
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);
568
    g_object_unref(webView);
569
}
570
483
static void testWebkitAtkGetTextAtOffsetForms()
571
static void testWebkitAtkGetTextAtOffsetForms()
484
{
572
{
485
    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
573
    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
Lines 1579-1584 int main(int argc, char** argv) a/Source/WebKit/gtk/tests/testatk.c_sec3
1579
    g_test_add_func("/webkit/atk/caretOffsets", testWebkitAtkCaretOffsets);
1667
    g_test_add_func("/webkit/atk/caretOffsets", testWebkitAtkCaretOffsets);
1580
    g_test_add_func("/webkit/atk/caretOffsetsAndExtranousWhiteSpaces", testWebkitAtkCaretOffsetsAndExtranousWhiteSpaces);
1668
    g_test_add_func("/webkit/atk/caretOffsetsAndExtranousWhiteSpaces", testWebkitAtkCaretOffsetsAndExtranousWhiteSpaces);
1581
    g_test_add_func("/webkit/atk/comboBox", testWebkitAtkComboBox);
1669
    g_test_add_func("/webkit/atk/comboBox", testWebkitAtkComboBox);
1670
    g_test_add_func("/webkit/atk/embeddedObjects", testWebkitAtkEmbeddedObjects);
1582
    g_test_add_func("/webkit/atk/getTextAtOffset", testWebkitAtkGetTextAtOffset);
1671
    g_test_add_func("/webkit/atk/getTextAtOffset", testWebkitAtkGetTextAtOffset);
1583
    g_test_add_func("/webkit/atk/getTextAtOffsetForms", testWebkitAtkGetTextAtOffsetForms);
1672
    g_test_add_func("/webkit/atk/getTextAtOffsetForms", testWebkitAtkGetTextAtOffsetForms);
1584
    g_test_add_func("/webkit/atk/getTextAtOffsetNewlines", testWebkitAtkGetTextAtOffsetNewlines);
1673
    g_test_add_func("/webkit/atk/getTextAtOffsetNewlines", testWebkitAtkGetTextAtOffsetNewlines);
1585
- 

Return to Bug 52148