Commit 10e02f83 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2010-01-06 Joanmarie Diggs <joanmarie.diggs@gmail.com>

        Reviewed by Xan Lopez.

        https://bugs.webkit.org/show_bug.cgi?id=30883
        [Gtk] Implement AtkText for HTML elements which contain text

        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
        (getInterfaceMaskFromObject):
        (getPangoLayoutForAtk):
        (webkit_accessible_text_get_text):
        * accessibility/gtk/AccessibilityObjectAtk.cpp:
        (AccessibilityObject::accessibilityPlatformIncludesObject):
2010-01-06  Joanmarie Diggs  <joanmarie.diggs@gmail.com>

        Reviewed by Xan Lopez.

        https://bugs.webkit.org/show_bug.cgi?id=30883
        [Gtk] Implement AtkText for HTML elements which contain text

        * tests/testatk.c
        (test_webkit_atk_get_text_at_offset):
        (test_webkit_atk_get_text_at_offset_forms):
        (test_webkit_atk_get_text_at_offset_newlines):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52890 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fa13fccd
2010-01-06 Joanmarie Diggs <joanmarie.diggs@gmail.com>
Reviewed by Xan Lopez.
https://bugs.webkit.org/show_bug.cgi?id=30883
[Gtk] Implement AtkText for HTML elements which contain text
* accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
(getInterfaceMaskFromObject):
(getPangoLayoutForAtk):
(webkit_accessible_text_get_text):
* accessibility/gtk/AccessibilityObjectAtk.cpp:
(AccessibilityObject::accessibilityPlatformIncludesObject):
2010-01-06 Dan Bernstein <mitz@apple.com>
 
Reviewed by Sam Weinig.
......@@ -47,6 +47,10 @@ AccessibilityObjectPlatformInclusion AccessibilityObject::accessibilityPlatformI
if (parent->isPasswordField() || parent->isTextControl())
return IgnoreObject;
// The object containing the text should implement AtkText itself.
if (roleValue() == StaticTextRole)
return IgnoreObject;
return DefaultBehavior;
}
......
......@@ -820,8 +820,11 @@ static gchar* webkit_accessible_text_get_text(AtkText* text, gint startOffset, g
AccessibilityObject* coreObject = core(text);
String ret;
unsigned start = startOffset;
if (endOffset == -1)
if (endOffset == -1) {
endOffset = coreObject->stringValue().length();
if (!endOffset)
endOffset = coreObject->textUnderElement().length();
}
int length = endOffset - startOffset;
if (coreObject->isTextControl())
......@@ -903,11 +906,9 @@ static PangoLayout* getPangoLayoutForAtk(AtkText* textObject)
AccessibilityRenderObject* accObject = static_cast<AccessibilityRenderObject*>(coreObject);
if (!accObject)
return 0;
RenderText* renderText = toRenderText(accObject->renderer());
if (!renderText)
return 0;
// Create a string with the layout as it appears on the screen
// For text controls, we can get the text line by line.
if (accObject->isTextControl()) {
unsigned textLength = accObject->textLength();
int lineNumber = 0;
......@@ -922,15 +923,32 @@ static PangoLayout* getPangoLayoutForAtk(AtkText* textObject)
range = accObject->doAXRangeForLine(++lineNumber);
}
} else {
InlineTextBox* box = renderText->firstTextBox();
while (box) {
gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
g_string_append(str, text);
// Newline chars in the source result in separate text boxes, so check
// before adding a newline in the layout. See bug 25415 comment #78.
if (!box->nextOnLineExists())
// For RenderBlocks, piece together the text from the RenderText objects they contain.
for (RenderObject* obj = accObject->renderer()->firstChild(); obj; obj = obj->nextSibling()) {
if (obj->isBR()) {
g_string_append(str, "\n");
box = box->nextTextBox();
continue;
}
RenderText* renderText = toRenderText(obj);
// Be sure we have a RenderText object we can work with.
if (!renderText || !obj->isText()) {
// Handle RenderInlines (and any other similiar RenderObjects).
renderText = toRenderText(obj->firstChild());
if (!renderText)
continue;
}
InlineTextBox* box = renderText->firstTextBox();
while (box) {
gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
g_string_append(str, text);
// Newline chars in the source result in separate text boxes, so check
// before adding a newline in the layout. See bug 25415 comment #78.
if (!box->nextOnLineExists())
g_string_append(str, "\n");
box = box->nextTextBox();
}
}
}
......@@ -1610,11 +1628,13 @@ static guint16 getInterfaceMaskFromObject(AccessibilityObject* coreObject)
if (role == StaticTextRole)
interfaceMask |= 1 << WAI_TEXT;
else if (coreObject->isAccessibilityRenderObject() && coreObject->isTextControl()) {
interfaceMask |= 1 << WAI_TEXT;
if (!coreObject->isReadOnly())
interfaceMask |= 1 << WAI_EDITABLE_TEXT;
}
else if (coreObject->isAccessibilityRenderObject())
if (coreObject->isTextControl()) {
interfaceMask |= 1 << WAI_TEXT;
if (!coreObject->isReadOnly())
interfaceMask |= 1 << WAI_EDITABLE_TEXT;
} else if (static_cast<AccessibilityRenderObject*>(coreObject)->renderer()->childrenInline())
interfaceMask |= 1 << WAI_TEXT;
// Image
if (coreObject->isImage())
......
2010-01-06 Joanmarie Diggs <joanmarie.diggs@gmail.com>
Reviewed by Xan Lopez.
https://bugs.webkit.org/show_bug.cgi?id=30883
[Gtk] Implement AtkText for HTML elements which contain text
* tests/testatk.c
(test_webkit_atk_get_text_at_offset):
(test_webkit_atk_get_text_at_offset_forms):
(test_webkit_atk_get_text_at_offset_newlines):
2010-01-05 Gustavo Noronha Silva <gns@gnome.org>
Updated docs for 1.1.18 release.
......
......@@ -221,8 +221,6 @@ static void test_webkit_atk_get_text_at_offset_forms(void)
g_assert(obj);
obj = atk_object_ref_accessible_child(obj, 0);
g_assert(obj);
obj = atk_object_ref_accessible_child(obj, 0);
g_assert(obj);
text_obj = ATK_TEXT(obj);
g_assert(ATK_IS_TEXT(text_obj));
......@@ -254,8 +252,6 @@ static void test_webkit_atk_get_text_at_offset(void)
g_assert(obj);
obj = atk_object_ref_accessible_child(obj, 0);
g_assert(obj);
obj = atk_object_ref_accessible_child(obj, 0);
g_assert(obj);
text_obj = ATK_TEXT(obj);
g_assert(ATK_IS_TEXT(text_obj));
......@@ -287,8 +283,6 @@ static void test_webkit_atk_get_text_at_offset_newlines(void)
g_assert(obj);
obj = atk_object_ref_accessible_child(obj, 0);
g_assert(obj);
obj = atk_object_ref_accessible_child(obj, 0);
g_assert(obj);
text_obj = ATK_TEXT(obj);
g_assert(ATK_IS_TEXT(text_obj));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment