| Differences between
and this patch
- a/LayoutTests/ChangeLog +16 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2009-11-26  MORITA Hajime <morrita@gmail.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Bug 28306: double-clicking a word inside <b> beside newline select two words
6
        https://bugs.webkit.org/show_bug.cgi?id=28306
7
	
8
        SimplifiedBackwardsTextIterator missed trailing whitespaces just
9
        before folding line-break, which is used to detect word
10
        boundaries. This fix checks strings on RenderText and expand text
11
        range on SimplifiedBackwardsTextIterator to include trailing
12
        whitespaces if availble.
13
14
        * editing/selection/doubleclick-beside-cr-span-expected.txt: Added.
15
        * editing/selection/doubleclick-beside-cr-span.html: Added.
16
1
2009-11-22  Chris Fleizach  <cfleizach@apple.com>
17
2009-11-22  Chris Fleizach  <cfleizach@apple.com>
2
18
3
        Reviewed by Oliver Hunt.
19
        Reviewed by Oliver Hunt.
- a/LayoutTests/editing/selection/doubleclick-beside-cr-span-expected.txt +19 lines
Line 0 a/LayoutTests/editing/selection/doubleclick-beside-cr-span-expected.txt_sec1
1
This tests that double-clicking a word that follows newline and span
2
3
minimum case
4
5
abcd efgh select1
6
with another word after the span
7
8
abcd efgh ijkl mnop select2 nottoselect
9
with another word in same the span
10
11
abcd efgh ijkl mnop select3 not notyet
12
with another word before the span, in the same line
13
14
abcd efgh ijkl mnop qrst select4 notyet
15
Passed totest1
16
Passed totest2
17
Passed totest3
18
Passed totest4
19
- a/LayoutTests/editing/selection/doubleclick-beside-cr-span.html +107 lines
Line 0 a/LayoutTests/editing/selection/doubleclick-beside-cr-span.html_sec1
1
<html>
2
<head>
3
<script>
4
if (window.layoutTestController) {
5
     layoutTestController.dumpAsText();
6
     layoutTestController.setSmartInsertDeleteEnabled(false);
7
     layoutTestController.setSelectTrailingWhitespaceEnabled(true);
8
}
9
10
function getPositionOfNode(id)
11
{
12
    var n = document.getElementById(id);
13
    var pos = {x: 0, y: 0};
14
15
    while (n) {
16
        pos.x += n.offsetLeft + n.clientLeft;
17
        pos.y += n.offsetTop + n.clientTop;
18
        n = n.offsetParent;
19
    }
20
    return pos;
21
}
22
23
function doubleClickNode(id)
24
{
25
    var pos = getPositionOfNode(id);
26
    eventSender.mouseMoveTo(pos.x + 2, pos.y + 2);
27
    eventSender.mouseDown();
28
    eventSender.leapForward(1);
29
    eventSender.mouseUp();
30
    eventSender.leapForward(100);
31
    eventSender.mouseDown();
32
    eventSender.leapForward(1);
33
    eventSender.mouseUp();
34
}
35
36
function doTest(testId, expectedText)
37
{
38
    // Simulate a double click.
39
    doubleClickNode(testId);
40
41
    // Get the text of the current selection.
42
    var sel = window.getSelection();
43
    var actualText = sel.getRangeAt(0).toString();
44
45
    if (expectedText == actualText) {
46
        log("Passed " + testId);
47
    } else {
48
        log("Failed " + testId);
49
        log("  Expected: " + expectedText);
50
        log("  Actual: " + actualText);
51
    }
52
53
}
54
55
function log(msg)
56
{
57
    var l = document.getElementById('log');
58
    l.appendChild(document.createTextNode(msg));
59
    l.appendChild(document.createElement('br'));
60
}
61
62
function runTests()
63
{
64
    if (window.layoutTestController) {
65
        doTest("totest1", "select1");
66
        // trailing whitespaces are ugly, but these are preexisting 
67
        // behaviour - although could be filed as a bug.
68
        doTest("totest2", "select2 ");
69
        doTest("totest3", "select3 ");
70
        doTest("totest4", "select4 ");
71
    }
72
}
73
74
75
</script>
76
</head>
77
<body onload="runTests()">
78
79
<p>
80
This tests that double-clicking a word that follows newline and span
81
</p>
82
83
<h3>minimum case</h3>
84
<div style="width:10pt">
85
abcd efgh <b id="totest1">select1</b>
86
</div>
87
88
<h3>with another word after the span</h3>
89
<div style="width:100pt">
90
abcd efgh ijkl mnop <b id="totest2">select2</b> nottoselect
91
</div>
92
93
<h3>with another word in same the span</h3>
94
<div style="width:100pt">
95
abcd efgh ijkl mnop <b id="totest3">select3 not</b> notyet
96
</div>
97
98
<h3>with another word before the span, in the same line</h3>
99
<div style="width:100pt">
100
abcd efgh ijkl mnop qrst <b id="totest4">select4</b> notyet
101
</div>
102
103
<pre id="log">
104
</pre>
105
106
</body>
107
</html>
- a/WebCore/ChangeLog +19 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2009-11-26  MORITA Hajime <morrita@gmail.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
	Bug 28306: double-clicking a word inside <b> beside newline select two words
6
        https://bugs.webkit.org/show_bug.cgi?id=28306
7
	
8
        SimplifiedBackwardsTextIterator missed trailing whitespaces just
9
        before folding line-break, which is used to detect word
10
        boundaries. This fix checks strings on RenderText and expand text
11
        range on SimplifiedBackwardsTextIterator to include trailing
12
        whitespaces if availble.
13
14
        Test: editing/selection/doubleclick-beside-cr-span.html
15
16
        * editing/TextIterator.cpp:
17
        (WebCore::collapsedSpaceLength):
18
        (WebCore::SimplifiedBackwardsTextIterator::handleTextNode):
19
1
2009-11-22  Chris Fleizach  <cfleizach@apple.com>
20
2009-11-22  Chris Fleizach  <cfleizach@apple.com>
2
21
3
        Reviewed by Oliver Hunt.
22
        Reviewed by Oliver Hunt.
- a/WebCore/editing/TextIterator.cpp +15 lines
Lines 705-710 static bool shouldEmitExtraNewlineForNode(Node* node) a/WebCore/editing/TextIterator.cpp_sec1
705
    return false;
705
    return false;
706
}
706
}
707
707
708
static int collapsedSpaceLength(Node* textNode, int textEnd)
709
{
710
    RenderText* renderer = toRenderText(textNode->renderer());
711
    String str = renderer->text();
712
    int strLength = static_cast<int>(str.length());
713
    for (int i = textEnd; i < strLength; ++i)
714
        if (!isCollapsibleWhitespace(str[i]))
715
            return i - textEnd;
716
    return strLength - textEnd;
717
}
718
708
// Whether or not we should emit a character as we enter m_node (if it's a container) or as we hit it (if it's atomic).
719
// Whether or not we should emit a character as we enter m_node (if it's a container) or as we hit it (if it's atomic).
709
bool TextIterator::shouldRepresentNodeOffsetZero()
720
bool TextIterator::shouldRepresentNodeOffsetZero()
710
{
721
{
Lines 1049-1054 bool SimplifiedBackwardsTextIterator::handleTextNode() a/WebCore/editing/TextIterator.cpp_sec2
1049
        return true;
1060
        return true;
1050
1061
1051
    m_positionEndOffset = m_offset;
1062
    m_positionEndOffset = m_offset;
1063
    // We expand range to include trailing (collapsed) whitespaces, 
1064
    // which is required for word-boundary detection.
1065
    if (m_node != m_endNode)
1066
        m_positionEndOffset += collapsedSpaceLength(m_node, m_positionEndOffset);
1052
1067
1053
    m_offset = (m_node == m_startNode) ? m_startOffset : 0;
1068
    m_offset = (m_node == m_startNode) ? m_startOffset : 0;
1054
    m_positionNode = m_node;
1069
    m_positionNode = m_node;

Return to Bug 28306