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
diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
index 16ea948..dc96f4a 100644
--- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
+++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
@@ -820,8 +820,11 @@
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 @@
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 @@
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 @@
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())