[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
eric at webkit.org
eric at webkit.org
Wed Jan 20 22:29:30 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 82e702a1908e633bd7b9cfa8887ad57a1128c15c
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 19 21:31:01 2010 +0000
2010-01-19 Joanmarie Diggs <joanmarie.diggs at gmail.com>
Reviewed by Xan Lopez.
https://bugs.webkit.org/show_bug.cgi?id=30883
[Gtk] Implement AtkText for HTML elements which contain text
Moves the text assembling functionality from getPangoLayoutForAtk to
textForObject, which webkit_accessible_text_get_text now falls back on
when it comes up empty.
Adds a check in textForObject so that we don't double-add newlines
when we have a BR.
* accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
(textForObject):
(getPangoLayoutForAtk):
(webkit_accessible_text_get_text):
2010-01-19 Joanmarie Diggs <joanmarie.diggs at gmail.com>
Reviewed by Xan Lopez.
https://bugs.webkit.org/show_bug.cgi?id=30883
[Gtk] Implement AtkText for HTML elements which contain text
Adds two news tests.
* tests/testatk.c
(testWebkitAtkGetTextInParagraphAndBodySimple):
(testWebkitAtkGetTextInParagraphAndBodyModerate):
(main):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53487 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ef7caec..4bf3fd0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-01-19 Joanmarie Diggs <joanmarie.diggs at gmail.com>
+
+ Reviewed by Xan Lopez.
+
+ https://bugs.webkit.org/show_bug.cgi?id=30883
+ [Gtk] Implement AtkText for HTML elements which contain text
+
+ Moves the text assembling functionality from getPangoLayoutForAtk to
+ textForObject, which webkit_accessible_text_get_text now falls back on
+ when it comes up empty.
+
+ Adds a check in textForObject so that we don't double-add newlines
+ when we have a BR.
+
+ * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+ (textForObject):
+ (getPangoLayoutForAtk):
+ (webkit_accessible_text_get_text):
+
2010-01-19 Eric Carlson <eric.carlson at apple.com>
Reviewed by Adam Roben.
diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
index d1b463c..87070cd 100644
--- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
+++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
@@ -815,38 +815,6 @@ static void atk_selection_interface_init(AtkSelectionIface* iface)
// Text
-static gchar* webkit_accessible_text_get_text(AtkText* text, gint startOffset, gint endOffset)
-{
- AccessibilityObject* coreObject = core(text);
- String ret;
- unsigned start = startOffset;
- if (endOffset == -1) {
- endOffset = coreObject->stringValue().length();
- if (!endOffset)
- endOffset = coreObject->textUnderElement().length();
- }
- int length = endOffset - startOffset;
-
- if (coreObject->isTextControl())
- ret = coreObject->doAXStringForRange(PlainTextRange(start, length));
- else
- ret = coreObject->textUnderElement().substring(start, length);
-
- return g_strdup(ret.utf8().data());
-}
-
-static GailTextUtil* getGailTextUtilForAtk(AtkText* textObject)
-{
- gpointer data = g_object_get_data(G_OBJECT(textObject), "webkit-accessible-gail-text-util");
- if (data)
- return static_cast<GailTextUtil*>(data);
-
- GailTextUtil* gailTextUtil = gail_text_util_new();
- gail_text_util_text_setup(gailTextUtil, webkit_accessible_text_get_text(textObject, 0, -1));
- g_object_set_data_full(G_OBJECT(textObject), "webkit-accessible-gail-text-util", gailTextUtil, g_object_unref);
- return gailTextUtil;
-}
-
static gchar* utf8Substr(const gchar* string, gint start, gint end)
{
ASSERT(string);
@@ -890,24 +858,10 @@ static gchar* convertUniCharToUTF8(const UChar* characters, gint length, int fro
return g_string_free(ret, FALSE);
}
-static PangoLayout* getPangoLayoutForAtk(AtkText* textObject)
+gchar* textForObject(AccessibilityRenderObject* accObject)
{
- AccessibilityObject* coreObject = core(textObject);
-
- HostWindow* hostWindow = coreObject->document()->view()->hostWindow();
- if (!hostWindow)
- return 0;
- PlatformPageClient webView = hostWindow->platformPageClient();
- if (!webView)
- return 0;
-
GString* str = g_string_new(0);
- AccessibilityRenderObject* accObject = static_cast<AccessibilityRenderObject*>(coreObject);
- if (!accObject)
- 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();
@@ -945,14 +899,73 @@ static PangoLayout* getPangoLayoutForAtk(AtkText* textObject)
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())
+ // If the next sibling is a BR, we'll add the newline when we examine that child.
+ if (!box->nextOnLineExists() && (!obj->nextSibling() || !obj->nextSibling()->isBR()))
g_string_append(str, "\n");
box = box->nextTextBox();
}
}
}
+ return g_string_free(str, FALSE);
+}
+
+static gchar* webkit_accessible_text_get_text(AtkText* text, gint startOffset, gint endOffset)
+{
+ AccessibilityObject* coreObject = core(text);
+ String ret;
+ unsigned start = startOffset;
+ if (endOffset == -1) {
+ endOffset = coreObject->stringValue().length();
+ if (!endOffset)
+ endOffset = coreObject->textUnderElement().length();
+ }
+ int length = endOffset - startOffset;
+
+ if (coreObject->isTextControl())
+ ret = coreObject->doAXStringForRange(PlainTextRange(start, length));
+ else
+ ret = coreObject->textUnderElement().substring(start, length);
+
+ if (!ret.length()) {
+ // This can happen at least with anonymous RenderBlocks (e.g. body text amongst paragraphs)
+ ret = String(textForObject(static_cast<AccessibilityRenderObject*>(coreObject)));
+ if (!endOffset)
+ endOffset = ret.length();
+ ret = ret.substring(start, endOffset - startOffset);
+ }
+
+ return g_strdup(ret.utf8().data());
+}
+
+static GailTextUtil* getGailTextUtilForAtk(AtkText* textObject)
+{
+ gpointer data = g_object_get_data(G_OBJECT(textObject), "webkit-accessible-gail-text-util");
+ if (data)
+ return static_cast<GailTextUtil*>(data);
- PangoLayout* layout = gtk_widget_create_pango_layout(static_cast<GtkWidget*>(webView), g_string_free(str, FALSE));
+ GailTextUtil* gailTextUtil = gail_text_util_new();
+ gail_text_util_text_setup(gailTextUtil, webkit_accessible_text_get_text(textObject, 0, -1));
+ g_object_set_data_full(G_OBJECT(textObject), "webkit-accessible-gail-text-util", gailTextUtil, g_object_unref);
+ return gailTextUtil;
+}
+
+static PangoLayout* getPangoLayoutForAtk(AtkText* textObject)
+{
+ AccessibilityObject* coreObject = core(textObject);
+
+ HostWindow* hostWindow = coreObject->document()->view()->hostWindow();
+ if (!hostWindow)
+ return 0;
+ PlatformPageClient webView = hostWindow->platformPageClient();
+ if (!webView)
+ return 0;
+
+ AccessibilityRenderObject* accObject = static_cast<AccessibilityRenderObject*>(coreObject);
+ if (!accObject)
+ return 0;
+
+ // Create a string with the layout as it appears on the screen
+ PangoLayout* layout = gtk_widget_create_pango_layout(static_cast<GtkWidget*>(webView), textForObject(accObject));
g_object_set_data_full(G_OBJECT(textObject), "webkit-accessible-pango-layout", layout, g_object_unref);
return layout;
}
@@ -1747,6 +1760,8 @@ AccessibilityObject* objectAndOffsetUnignored(AccessibilityObject* coreObject, i
{
Node* endNode = static_cast<AccessibilityRenderObject*>(coreObject)->renderer()->node();
int endOffset = coreObject->selection().end().computeOffsetInContainerNode();
+ // Indication that something bogus has transpired.
+ offset = -1;
AccessibilityObject* realObject = coreObject;
if (realObject->accessibilityIsIgnored())
@@ -1755,11 +1770,16 @@ AccessibilityObject* objectAndOffsetUnignored(AccessibilityObject* coreObject, i
if (ignoreLinks && realObject->isLink())
realObject = realObject->parentObjectUnignored();
- RefPtr<Range> range = rangeOfContents(static_cast<AccessibilityRenderObject*>(realObject)->renderer()->node());
- ExceptionCode ec = 0;
- range->setEndBefore(endNode, ec);
- offset = range->text().length() + endOffset;
-
+ Node* node = static_cast<AccessibilityRenderObject*>(realObject)->renderer()->node();
+ if (node) {
+ RefPtr<Range> range = rangeOfContents(node);
+ if (range->ownerDocument() == node->document()) {
+ ExceptionCode ec = 0;
+ range->setEndBefore(endNode, ec);
+ if (range->boundaryPointsValid())
+ offset = range->text().length() + endOffset;
+ }
+ }
return realObject;
}
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index be39c83..a71fc89 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,17 @@
+2010-01-19 Joanmarie Diggs <joanmarie.diggs at gmail.com>
+
+ Reviewed by Xan Lopez.
+
+ https://bugs.webkit.org/show_bug.cgi?id=30883
+ [Gtk] Implement AtkText for HTML elements which contain text
+
+ Adds two news tests.
+
+ * tests/testatk.c
+ (testWebkitAtkGetTextInParagraphAndBodySimple):
+ (testWebkitAtkGetTextInParagraphAndBodyModerate):
+ (main):
+
2010-01-19 Gustavo Noronha Silva <gns at gnome.org>
Reviewed by Xan Lopez.
diff --git a/WebKit/gtk/tests/testatk.c b/WebKit/gtk/tests/testatk.c
index 7f87bdc..7db274a 100644
--- a/WebKit/gtk/tests/testatk.c
+++ b/WebKit/gtk/tests/testatk.c
@@ -34,6 +34,10 @@ static const char* contentsInTextarea = "<html><body><textarea cols='80'>This is
static const char* contentsInTextInput = "<html><body><input type='text' size='80' value='This is a test. This is the second sentence. And this the third.'/></body></html>";
+static const char* contentsInParagraphAndBodySimple = "<html><body><p>This is a test.</p>Hello world.</body></html>";
+
+static const char* contentsInParagraphAndBodyModerate = "<html><body><p>This is a test.</p>Hello world.<br /><font color='#00cc00'>This sentence is green.</font><br />This one is not.</body></html>";
+
static gboolean bail_out(GMainLoop* loop)
{
if (g_main_loop_is_running(loop))
@@ -358,6 +362,94 @@ static void test_webkit_atk_get_text_at_offset_text_input(void)
g_object_unref(webView);
}
+static void testWebkitAtkGetTextInParagraphAndBodySimple(void)
+{
+ WebKitWebView* webView;
+ AtkObject* obj;
+ AtkObject* obj1;
+ AtkObject* obj2;
+ GMainLoop* loop;
+ AtkText* textObj1;
+ AtkText* textObj2;
+
+ webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_object_ref_sink(webView);
+ GtkAllocation alloc = { 0, 0, 800, 600 };
+ gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
+ webkit_web_view_load_string(webView, contentsInParagraphAndBodySimple, NULL, NULL, NULL);
+ loop = g_main_loop_new(NULL, TRUE);
+
+ g_timeout_add(100, (GSourceFunc)bail_out, loop);
+ g_main_loop_run(loop);
+
+ /* Get to the inner AtkText object */
+ obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
+ g_assert(obj);
+ obj1 = atk_object_ref_accessible_child(obj, 0);
+ g_assert(obj1);
+ obj2 = atk_object_ref_accessible_child(obj, 1);
+ g_assert(obj2);
+
+ textObj1 = ATK_TEXT(obj1);
+ g_assert(ATK_IS_TEXT(textObj1));
+ textObj2 = ATK_TEXT(obj2);
+ g_assert(ATK_IS_TEXT(textObj2));
+
+ char *text = atk_text_get_text(textObj1, 0, -1);
+ g_assert_cmpstr(text, ==, "This is a test.");
+
+ text = atk_text_get_text(textObj2, 0, 12);
+ g_assert_cmpstr(text, ==, "Hello world.");
+
+ g_object_unref(obj1);
+ g_object_unref(obj2);
+ g_object_unref(webView);
+}
+
+static void testWebkitAtkGetTextInParagraphAndBodyModerate(void)
+{
+ WebKitWebView* webView;
+ AtkObject* obj;
+ AtkObject* obj1;
+ AtkObject* obj2;
+ GMainLoop* loop;
+ AtkText* textObj1;
+ AtkText* textObj2;
+
+ webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_object_ref_sink(webView);
+ GtkAllocation alloc = { 0, 0, 800, 600 };
+ gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
+ webkit_web_view_load_string(webView, contentsInParagraphAndBodyModerate, NULL, NULL, NULL);
+ loop = g_main_loop_new(NULL, TRUE);
+
+ g_timeout_add(100, (GSourceFunc)bail_out, loop);
+ g_main_loop_run(loop);
+
+ /* Get to the inner AtkText object */
+ obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
+ g_assert(obj);
+ obj1 = atk_object_ref_accessible_child(obj, 0);
+ g_assert(obj1);
+ obj2 = atk_object_ref_accessible_child(obj, 1);
+ g_assert(obj2);
+
+ textObj1 = ATK_TEXT(obj1);
+ g_assert(ATK_IS_TEXT(textObj1));
+ textObj2 = ATK_TEXT(obj2);
+ g_assert(ATK_IS_TEXT(textObj2));
+
+ char *text = atk_text_get_text(textObj1, 0, -1);
+ g_assert_cmpstr(text, ==, "This is a test.");
+
+ text = atk_text_get_text(textObj2, 0, 53);
+ g_assert_cmpstr(text, ==, "Hello world.\nThis sentence is green.\nThis one is not.");
+
+ g_object_unref(obj1);
+ g_object_unref(obj2);
+ g_object_unref(webView);
+}
+
int main(int argc, char** argv)
{
g_thread_init(NULL);
@@ -369,6 +461,8 @@ int main(int argc, char** argv)
g_test_add_func("/webkit/atk/get_text_at_offset_newlines", test_webkit_atk_get_text_at_offset_newlines);
g_test_add_func("/webkit/atk/get_text_at_offset_textarea", test_webkit_atk_get_text_at_offset_textarea);
g_test_add_func("/webkit/atk/get_text_at_offset_text_input", test_webkit_atk_get_text_at_offset_text_input);
+ g_test_add_func("/webkit/atk/getTextInParagraphAndBodySimple", testWebkitAtkGetTextInParagraphAndBodySimple);
+ g_test_add_func("/webkit/atk/getTextInParagraphAndBodyModerate", testWebkitAtkGetTextInParagraphAndBodyModerate);
return g_test_run ();
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list