[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 16:04:04 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7f2ccff4c5e05c42cd4a337d1a8a86bbcae2339d
Author: mario at webkit.org <mario at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 18 12:42:08 2010 +0000

    2010-11-18  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [Gtk]  atk_text_get_selection returns the wrong offsets after a link
            https://bugs.webkit.org/show_bug.cgi?id=49514
    
            Consider possible embedded objects to calculate startOffset.
    
            So far we were using offsetInContainerNode() to calculate the
            value of startOffset when checking the offsets for the current
            selection, which was wrong because that wouldn't work ok if any
            embedded object was present in the paragraph before the
            selection. Thus, we need to consider this fact when calculating
            the startOffset from the point of view of the object this function
            is called on, in order to return the right and actual values.
    
            * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
            (getSelectionOffsetsForObject): Check range length from the first
            position in the object the function is called on until the first
            position of current selection, and use it as startOffset.
    2010-11-18  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [Gtk]  atk_text_get_selection returns the wrong offsets after a link
            https://bugs.webkit.org/show_bug.cgi?id=49514
    
            Updated test case to also chech this specific subcase.
    
            We need to explicitly check the case of having a selection in a
            paragraph after an embedded object (i.e. a link) to make sure the
            right calculations are being done when the paragraph is composed
            of more than just one text object, and the current selection is
            made only in one of them.
    
            * tests/testatk.c:
            (testWebkitAtkTextSelections): Make sure that a selection after a
            link in a paragraph is working ok when asking for the text
            selection from the point of view of the paragraph.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72284 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4745bc1..e4d2274 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-11-18  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [Gtk]  atk_text_get_selection returns the wrong offsets after a link
+        https://bugs.webkit.org/show_bug.cgi?id=49514
+
+        Consider possible embedded objects to calculate startOffset.
+
+        So far we were using offsetInContainerNode() to calculate the
+        value of startOffset when checking the offsets for the current
+        selection, which was wrong because that wouldn't work ok if any
+        embedded object was present in the paragraph before the
+        selection. Thus, we need to consider this fact when calculating
+        the startOffset from the point of view of the object this function
+        is called on, in order to return the right and actual values.
+
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+        (getSelectionOffsetsForObject): Check range length from the first
+        position in the object the function is called on until the first
+        position of current selection, and use it as startOffset.
+
 2010-11-12  Stephen White  <senorblanco at chromium.org>
 
         Reviewed by Simon Fraser.
diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
index 726cdb1..3d4345a 100644
--- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
+++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
@@ -1433,13 +1433,13 @@ static void getSelectionOffsetsForObject(AccessibilityObject* coreObject, Visibl
     if (!coreObject->isAccessibilityRenderObject())
         return;
 
-    // Early return if the selection doesn't affect the selected node
+    // Early return if the selection doesn't affect the selected node.
     if (!selectionBelongsToObject(coreObject, selection))
         return;
 
     // We need to find the exact start and end positions in the
     // selected node that intersects the selection, to later on get
-    // the right values for the effective start and end offsets
+    // the right values for the effective start and end offsets.
     ExceptionCode ec = 0;
     Position nodeRangeStart;
     Position nodeRangeEnd;
@@ -1449,7 +1449,7 @@ static void getSelectionOffsetsForObject(AccessibilityObject* coreObject, Visibl
     // If the selection affects the selected node and its first
     // possible position is also in the selection, we must set
     // nodeRangeStart to that position, otherwise to the selection's
-    // start position (it would belong to the node anyway)
+    // start position (it would belong to the node anyway).
     Node* firstLeafNode = node->firstDescendant();
     if (selRange->isPointInRange(firstLeafNode, 0, ec))
         nodeRangeStart = firstPositionInNode(firstLeafNode);
@@ -1459,16 +1459,20 @@ static void getSelectionOffsetsForObject(AccessibilityObject* coreObject, Visibl
     // If the selection affects the selected node and its last
     // possible position is also in the selection, we must set
     // nodeRangeEnd to that position, otherwise to the selection's
-    // end position (it would belong to the node anyway)
+    // end position (it would belong to the node anyway).
     Node* lastLeafNode = node->lastDescendant();
     if (selRange->isPointInRange(lastLeafNode, lastOffsetInNode(lastLeafNode), ec))
         nodeRangeEnd = lastPositionInNode(lastLeafNode);
     else
         nodeRangeEnd = selRange->endPosition();
 
-    // Set values for start and end offsets
+    // Calculate position of the selected range inside the object.
+    Position parentFirstPosition = firstPositionInNode(node);
+    RefPtr<Range> rangeInParent = Range::create(node->document(), parentFirstPosition, nodeRangeStart);
+
+    // Set values for start and end offsets.
+    startOffset = TextIterator::rangeLength(rangeInParent.get());
     RefPtr<Range> nodeRange = Range::create(node->document(), nodeRangeStart, nodeRangeEnd);
-    startOffset = nodeRangeStart.offsetInContainerNode();
     endOffset = startOffset + TextIterator::rangeLength(nodeRange.get());
 }
 
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index ff765d3..97df3b3 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,23 @@
+2010-11-18  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [Gtk]  atk_text_get_selection returns the wrong offsets after a link
+        https://bugs.webkit.org/show_bug.cgi?id=49514
+
+        Updated test case to also chech this specific subcase.
+
+        We need to explicitly check the case of having a selection in a
+        paragraph after an embedded object (i.e. a link) to make sure the
+        right calculations are being done when the paragraph is composed
+        of more than just one text object, and the current selection is
+        made only in one of them.
+
+        * tests/testatk.c:
+        (testWebkitAtkTextSelections): Make sure that a selection after a
+        link in a paragraph is working ok when asking for the text
+        selection from the point of view of the paragraph.
+
 2010-11-17  Martin Robinson  <mrobinson at igalia.com>
 
         Reviewed by Gustavo Noronha Silva.
diff --git a/WebKit/gtk/tests/testatk.c b/WebKit/gtk/tests/testatk.c
index 509cb86..f098f62 100644
--- a/WebKit/gtk/tests/testatk.c
+++ b/WebKit/gtk/tests/testatk.c
@@ -776,6 +776,16 @@ static void testWebkitAtkTextSelections()
     g_assert_cmpstr(selectedText, ==, "a li");
     g_free (selectedText);
 
+    /* Make a selection after the link and check selection for the whole paragraph. */
+    result = atk_text_set_selection(paragraph2, 0, 27, 37);
+    g_assert(result);
+    g_assert_cmpint(atk_text_get_n_selections(paragraph2), ==, 1);
+    selectedText = atk_text_get_selection(paragraph2, 0, &startOffset, &endOffset);
+    g_assert_cmpint(startOffset, ==, 27);
+    g_assert_cmpint(endOffset, ==, 37);
+    g_assert_cmpstr(selectedText, ==, "the middle");
+    g_free (selectedText);
+
     /* Remove selections and text everything again. */
     result = atk_text_remove_selection(paragraph2, 0);
     g_assert(result);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list