[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

mario at webkit.org mario at webkit.org
Wed Dec 22 15:00:48 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a2d3ce7680b6593cc63a2448b629824c7e6d0c45
Author: mario at webkit.org <mario at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 27 11:15:15 2010 +0000

    2010-10-27  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Martin Robinson.
    
            getTextAtOffset returns incorrect results if a link includes text and an image
            https://bugs.webkit.org/show_bug.cgi?id=47365
    
            Properly consider text under a non-text renderer in textForObject.
    
            We need to check all the children under a non-text renderer, if
            any, to consider when current object is not a text object but some
            of its children are, in order not to miss those portions of text
            by not properly handling those situations.
    
            * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
            (textForRenderer): New. Get the text for a RenderObject's children.
            (textForObject): Use the new textForRenderer function.
    
    2010-10-27  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Martin Robinson.
    
            getTextAtOffset returns incorrect results if a link includes text and an image
            https://bugs.webkit.org/show_bug.cgi?id=47365
    
            New test to make sure this bug is actually fixed.
    
            * tests/testatk.c:
            (testWebkitAtkLinksWithInlineImages): New test.
            (main): Added new test.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70634 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2931e76..de62f32 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-10-27  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        getTextAtOffset returns incorrect results if a link includes text and an image
+        https://bugs.webkit.org/show_bug.cgi?id=47365
+
+        Properly consider text under a non-text renderer in textForObject.
+
+        We need to check all the children under a non-text renderer, if
+        any, to consider when current object is not a text object but some
+        of its children are, in order not to miss those portions of text
+        by not properly handling those situations.
+
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+        (textForRenderer): New. Get the text for a RenderObject's children.
+        (textForObject): Use the new textForRenderer function.
+
 2010-10-26  Nikolas Zimmermann  <nzimmermann at rim.com>
 
         Reviewed by Rob Buis.
diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
index b52ad16..283b2de 100644
--- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
+++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
@@ -870,6 +870,59 @@ static gchar* convertUniCharToUTF8(const UChar* characters, gint length, int fro
     return g_string_free(ret, FALSE);
 }
 
+gchar* textForRenderer(RenderObject* renderer)
+{
+    GString* resultText = g_string_new(0);
+
+    if (!renderer)
+        return g_string_free(resultText, FALSE);
+
+    // For RenderBlocks, piece together the text from the RenderText objects they contain.
+    for (RenderObject* object = renderer->firstChild(); object; object = object->nextSibling()) {
+        if (object->isBR()) {
+            g_string_append(resultText, "\n");
+            continue;
+        }
+
+        RenderText* renderText;
+        if (object->isText())
+            renderText = toRenderText(object);
+        else {
+            // We need to check children, if any, to consider when
+            // current object is not a text object but some of its
+            // children are, in order not to miss those portions of
+            // text by not properly handling those situations
+            if (object->firstChild())
+                g_string_append(resultText, textForRenderer(object));
+
+            continue;
+        }
+
+        InlineTextBox* box = renderText->firstTextBox();
+        while (box) {
+            gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
+            g_string_append(resultText, 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 the next sibling is a BR, we'll add the newline when we examine that child.
+            if (!box->nextOnLineExists() && (!object->nextSibling() || !object->nextSibling()->isBR()))
+                g_string_append(resultText, "\n");
+            box = box->nextTextBox();
+        }
+    }
+
+    // Insert the text of the marker for list item in the right place, if present
+    if (renderer->isListItem()) {
+        String markerText = toRenderListItem(renderer)->markerTextWithSuffix();
+        if (renderer->style()->direction() == LTR)
+            g_string_prepend(resultText, markerText.utf8().data());
+        else
+            g_string_append(resultText, markerText.utf8().data());
+    }
+
+    return g_string_free(resultText, FALSE);
+}
+
 gchar* textForObject(AccessibilityRenderObject* accObject)
 {
     GString* str = g_string_new(0);
@@ -888,48 +941,9 @@ gchar* textForObject(AccessibilityRenderObject* accObject)
             g_string_append(str, "\n");
             range = accObject->doAXRangeForLine(++lineNumber);
         }
-    } else {
-        RenderObject* renderer = accObject->renderer();
-        if (!renderer)
-            return g_string_free(str, FALSE);
-
-        // For RenderBlocks, piece together the text from the RenderText objects they contain.
-        for (RenderObject* obj = renderer->firstChild(); obj; obj = obj->nextSibling()) {
-            if (obj->isBR()) {
-                g_string_append(str, "\n");
-                continue;
-            }
-
-            RenderText* renderText;
-            if (obj->isText())
-                renderText = toRenderText(obj);
-            else if (obj->firstChild() && obj->firstChild()->isText()) {
-                // Handle RenderInlines (and any other similiar RenderObjects).
-                renderText = toRenderText(obj->firstChild());
-            } else
-                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 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();
-            }
-        }
-
-        // Insert the text of the marker for list item in the right place, if present
-        if (renderer->isListItem()) {
-            String markerText = toRenderListItem(renderer)->markerTextWithSuffix();
-            if (renderer->style()->direction() == LTR)
-                g_string_prepend(str, markerText.utf8().data());
-            else
-                g_string_append(str, markerText.utf8().data());
-        }
+    } else if (accObject->isAccessibilityRenderObject()) {
+        GOwnPtr<gchar> rendererText(textForRenderer(accObject->renderer()));
+        g_string_append(str, rendererText.get());
     }
 
     return g_string_free(str, FALSE);
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index bfb970c..57c3e27 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,16 @@
+2010-10-27  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        getTextAtOffset returns incorrect results if a link includes text and an image
+        https://bugs.webkit.org/show_bug.cgi?id=47365
+
+        New test to make sure this bug is actually fixed.
+
+        * tests/testatk.c:
+        (testWebkitAtkLinksWithInlineImages): New test.
+        (main): Added new test.
+
 2010-10-26  Antonio Gomes  <agomes at rim.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebKit/gtk/tests/testatk.c b/WebKit/gtk/tests/testatk.c
index 8f21fff..fad92bc 100644
--- a/WebKit/gtk/tests/testatk.c
+++ b/WebKit/gtk/tests/testatk.c
@@ -48,6 +48,8 @@ static const char* formWithTextInputs = "<html><body><form><input type='text' na
 
 static const char* layoutAndDataTables = "<html><body><table><tr><th>Odd</th><th>Even</th></tr><tr><td>1</td><td>2</td></tr></table><table><tr><td>foo</td><td>bar</td></tr></table></body></html>";
 
+static const char* linksWithInlineImages = "<html><head><style>a.http:before {content: url(no-image.png);}</style><body><p><a class='http' href='foo'>foo</a> bar baz</p><p>foo <a class='http' href='bar'>bar</a> baz</p><p>foo bar <a class='http' href='baz'>baz</a></p></body></html>";
+
 static const char* listsOfItems = "<html><body><ul><li>text only</li><li><a href='foo'>link only</a></li><li>text and a <a href='bar'>link</a></li></ul><ol><li>text only</li><li><a href='foo'>link only</a></li><li>text and a <a href='bar'>link</a></li></ol></body></html>";
 
 static const char* textForSelections = "<html><body><p>A paragraph with plain text</p><p>A paragraph with <a href='http://webkit.org'>a link</a> in the middle</p></body></html>";
@@ -1015,6 +1017,59 @@ static void testWebkitAtkLayoutAndDataTables(void)
     g_object_unref(webView);
 }
 
+static void testWebkitAtkLinksWithInlineImages(void)
+{
+    WebKitWebView* 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, linksWithInlineImages, 0, 0, 0);
+
+    // Manually spin the main context to get the accessible objects
+    while (g_main_context_pending(0))
+        g_main_context_iteration(0, TRUE);
+
+    AtkObject* object = gtk_widget_get_accessible(GTK_WIDGET(webView));
+    g_assert(object);
+
+    // First paragraph (link at the beginning)
+    AtkObject* paragraph = atk_object_ref_accessible_child(object, 0);
+    g_assert(ATK_IS_TEXT(paragraph));
+    gint startOffset;
+    gint endOffset;
+    gchar* text = atk_text_get_text_at_offset(ATK_TEXT(paragraph), 0, ATK_TEXT_BOUNDARY_LINE_START, &startOffset, &endOffset);
+    g_assert(text);
+    g_assert_cmpstr(text, ==, "foo bar baz");
+    g_assert_cmpint(startOffset, ==, 0);
+    g_assert_cmpint(endOffset, ==, 11);
+    g_free(text);
+    g_object_unref(paragraph);
+
+    // Second paragraph (link in the middle)
+    paragraph = atk_object_ref_accessible_child(object, 1);
+    g_assert(ATK_IS_TEXT(paragraph));
+    text = atk_text_get_text_at_offset(ATK_TEXT(paragraph), 0, ATK_TEXT_BOUNDARY_LINE_START, &startOffset, &endOffset);
+    g_assert(text);
+    g_assert_cmpstr(text, ==, "foo bar baz");
+    g_assert_cmpint(startOffset, ==, 0);
+    g_assert_cmpint(endOffset, ==, 11);
+    g_free(text);
+    g_object_unref(paragraph);
+
+    // Third paragraph (link at the end)
+    paragraph = atk_object_ref_accessible_child(object, 2);
+    g_assert(ATK_IS_TEXT(paragraph));
+    text = atk_text_get_text_at_offset(ATK_TEXT(paragraph), 0, ATK_TEXT_BOUNDARY_LINE_START, &startOffset, &endOffset);
+    g_assert(text);
+    g_assert_cmpstr(text, ==, "foo bar baz");
+    g_assert_cmpint(startOffset, ==, 0);
+    g_assert_cmpint(endOffset, ==, 11);
+    g_free(text);
+    g_object_unref(paragraph);
+
+    g_object_unref(webView);
+}
+
 static void testWebkitAtkListsOfItems(void)
 {
     WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list