Changeset 72284 in webkit


Ignore:
Timestamp:
Nov 18, 2010 4:42:08 AM (13 years ago)
Author:
mario@webkit.org
Message:

2010-11-18 Mario Sanchez Prada <msanchez@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@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.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r72282 r72284  
     12010-11-18  Mario Sanchez Prada  <msanchez@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [Gtk]  atk_text_get_selection returns the wrong offsets after a link
     6        https://bugs.webkit.org/show_bug.cgi?id=49514
     7
     8        Consider possible embedded objects to calculate startOffset.
     9
     10        So far we were using offsetInContainerNode() to calculate the
     11        value of startOffset when checking the offsets for the current
     12        selection, which was wrong because that wouldn't work ok if any
     13        embedded object was present in the paragraph before the
     14        selection. Thus, we need to consider this fact when calculating
     15        the startOffset from the point of view of the object this function
     16        is called on, in order to return the right and actual values.
     17
     18        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
     19        (getSelectionOffsetsForObject): Check range length from the first
     20        position in the object the function is called on until the first
     21        position of current selection, and use it as startOffset.
     22
    1232010-11-12  Stephen White  <senorblanco@chromium.org>
    224
  • trunk/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp

    r71026 r72284  
    14341434        return;
    14351435
    1436     // Early return if the selection doesn't affect the selected node
     1436    // Early return if the selection doesn't affect the selected node.
    14371437    if (!selectionBelongsToObject(coreObject, selection))
    14381438        return;
     
    14401440    // We need to find the exact start and end positions in the
    14411441    // selected node that intersects the selection, to later on get
    1442     // the right values for the effective start and end offsets
     1442    // the right values for the effective start and end offsets.
    14431443    ExceptionCode ec = 0;
    14441444    Position nodeRangeStart;
     
    14501450    // possible position is also in the selection, we must set
    14511451    // nodeRangeStart to that position, otherwise to the selection's
    1452     // start position (it would belong to the node anyway)
     1452    // start position (it would belong to the node anyway).
    14531453    Node* firstLeafNode = node->firstDescendant();
    14541454    if (selRange->isPointInRange(firstLeafNode, 0, ec))
     
    14601460    // possible position is also in the selection, we must set
    14611461    // nodeRangeEnd to that position, otherwise to the selection's
    1462     // end position (it would belong to the node anyway)
     1462    // end position (it would belong to the node anyway).
    14631463    Node* lastLeafNode = node->lastDescendant();
    14641464    if (selRange->isPointInRange(lastLeafNode, lastOffsetInNode(lastLeafNode), ec))
     
    14671467        nodeRangeEnd = selRange->endPosition();
    14681468
    1469     // Set values for start and end offsets
     1469    // Calculate position of the selected range inside the object.
     1470    Position parentFirstPosition = firstPositionInNode(node);
     1471    RefPtr<Range> rangeInParent = Range::create(node->document(), parentFirstPosition, nodeRangeStart);
     1472
     1473    // Set values for start and end offsets.
     1474    startOffset = TextIterator::rangeLength(rangeInParent.get());
    14701475    RefPtr<Range> nodeRange = Range::create(node->document(), nodeRangeStart, nodeRangeEnd);
    1471     startOffset = nodeRangeStart.offsetInContainerNode();
    14721476    endOffset = startOffset + TextIterator::rangeLength(nodeRange.get());
    14731477}
  • trunk/WebKit/gtk/ChangeLog

    r72275 r72284  
     12010-11-18  Mario Sanchez Prada  <msanchez@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [Gtk]  atk_text_get_selection returns the wrong offsets after a link
     6        https://bugs.webkit.org/show_bug.cgi?id=49514
     7
     8        Updated test case to also chech this specific subcase.
     9
     10        We need to explicitly check the case of having a selection in a
     11        paragraph after an embedded object (i.e. a link) to make sure the
     12        right calculations are being done when the paragraph is composed
     13        of more than just one text object, and the current selection is
     14        made only in one of them.
     15
     16        * tests/testatk.c:
     17        (testWebkitAtkTextSelections): Make sure that a selection after a
     18        link in a paragraph is working ok when asking for the text
     19        selection from the point of view of the paragraph.
     20
    1212010-11-17  Martin Robinson  <mrobinson@igalia.com>
    222
  • trunk/WebKit/gtk/tests/testatk.c

    r71052 r72284  
    775775    g_assert_cmpint(endOffset, ==, 4);
    776776    g_assert_cmpstr(selectedText, ==, "a li");
     777    g_free (selectedText);
     778
     779    /* Make a selection after the link and check selection for the whole paragraph. */
     780    result = atk_text_set_selection(paragraph2, 0, 27, 37);
     781    g_assert(result);
     782    g_assert_cmpint(atk_text_get_n_selections(paragraph2), ==, 1);
     783    selectedText = atk_text_get_selection(paragraph2, 0, &startOffset, &endOffset);
     784    g_assert_cmpint(startOffset, ==, 27);
     785    g_assert_cmpint(endOffset, ==, 37);
     786    g_assert_cmpstr(selectedText, ==, "the middle");
    777787    g_free (selectedText);
    778788
Note: See TracChangeset for help on using the changeset viewer.