[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
hamaji at chromium.org
hamaji at chromium.org
Tue Jan 5 23:51:40 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 188dbf1419be759629e3dcf9a065c55c1a307483
Author: hamaji at chromium.org <hamaji at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Dec 17 06:30:20 2009 +0000
2009-12-15 MORITA Hajime <morrita at gmail.com>
Reviewed by Eric Seidel.
Bug 28306: double-clicking a word inside <b> beside newline select two words
https://bugs.webkit.org/show_bug.cgi?id=28306
SimplifiedBackwardsTextIterator missed trailing whitespaces just
before folding line-break, which is used to detect word
boundaries. This fix checks strings on RenderText and expand text
range on SimplifiedBackwardsTextIterator to include trailing
whitespaces if availble.
Test: editing/selection/doubleclick-beside-cr-span.html
* editing/TextIterator.cpp:
(WebCore::collapsedSpaceLength):
(WebCore::maxOffsetIncludingCollapsedSpaces):
(WebCore::SimplifiedBackwardsTextIterator::advance):
2009-12-16 MORITA Hajime <morrita at gmail.com>
Reviewed by Eric Seidel.
Bug 28306: double-clicking a word inside <b> beside newline select two words
https://bugs.webkit.org/show_bug.cgi?id=28306
SimplifiedBackwardsTextIterator missed trailing whitespaces just
before folding line-break, which is used to detect word
boundaries. This fix checks strings on RenderText and expand text
range on SimplifiedBackwardsTextIterator to include trailing
whitespaces if availble.
* editing/selection/doubleclick-beside-cr-span-expected.txt: Added.
* editing/selection/doubleclick-beside-cr-span.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52235 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b74fd6b..d51171c 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2009-12-16 MORITA Hajime <morrita at gmail.com>
+
+ Reviewed by Eric Seidel.
+
+ Bug 28306: double-clicking a word inside <b> beside newline select two words
+ https://bugs.webkit.org/show_bug.cgi?id=28306
+
+ SimplifiedBackwardsTextIterator missed trailing whitespaces just
+ before folding line-break, which is used to detect word
+ boundaries. This fix checks strings on RenderText and expand text
+ range on SimplifiedBackwardsTextIterator to include trailing
+ whitespaces if availble.
+
+ * editing/selection/doubleclick-beside-cr-span-expected.txt: Added.
+ * editing/selection/doubleclick-beside-cr-span.html: Added.
+
2009-12-16 Jon Honeycutt <jhoneycutt at apple.com>
MSAA: Accessibility role of text nodes is wrong
diff --git a/LayoutTests/editing/selection/doubleclick-beside-cr-span-expected.txt b/LayoutTests/editing/selection/doubleclick-beside-cr-span-expected.txt
new file mode 100644
index 0000000..36e482e
--- /dev/null
+++ b/LayoutTests/editing/selection/doubleclick-beside-cr-span-expected.txt
@@ -0,0 +1,87 @@
+This tests that double-clicking a word that follows newline and span
+
+cases for white-space: pre
+
+Note: Here for pre, we change width value to 200 to prevent layout change on contentEditable enabled.
+
+cases for white-space: pre-wrap
+
+cases for white-space: pre-line
+
+cases for white-space: nowrap
+
+Note: Although following cases have no line-breaks that had caused problem reported bug28036, we add these for comprehensiveness.
+
+Passed totest_minimum
+Passed totest_minimum (with contentEditable)
+Passed totest_before_after
+Passed totest_before_after (with contentEditable)
+Passed totest_linebreak_out
+Passed totest_linebreak_out (with contentEditable)
+Passed totest_tab_out
+Passed totest_tab_out (with contentEditable)
+Passed totest_multiple_whitespaces_out
+Passed totest_multiple_whitespaces_out (with contentEditable)
+Passed totest_linebreak_in
+Passed totest_linebreak_in (with contentEditable)
+Passed totest_tab_in
+Passed totest_tab_in (with contentEditable)
+Passed totest_multiple_whitespaces_in
+Passed totest_multiple_whitespaces_in (with contentEditable)
+Passed totest_multiple_word_in_span
+Passed totest_multiple_word_in_span (with contentEditable)
+Passed totest_word_before_here_in_line
+Passed totest_word_before_here_in_line (with contentEditable)
+Passed totest_span_first_half
+Passed totest_span_first_half (with contentEditable)
+Passed totest_span_second_half
+Passed totest_span_second_half (with contentEditable)
+Passed totest_linebreak_out_pre
+Passed totest_linebreak_out_pre (with contentEditable)
+Passed totest_tab_out_pre
+Passed totest_tab_out_pre (with contentEditable)
+Passed totest_multiple_whitespaces_out_pre
+Passed totest_multiple_whitespaces_out_pre (with contentEditable)
+Passed totest_linebreak_in_pre
+Passed totest_linebreak_in_pre (with contentEditable)
+Passed totest_tab_in_pre
+Passed totest_tab_in_pre (with contentEditable)
+Passed totest_multiple_whitespaces_in_pre
+Passed totest_multiple_whitespaces_in_pre (with contentEditable)
+Passed totest_linebreak_out_prewrap
+Passed totest_linebreak_out_prewrap (with contentEditable)
+Passed totest_tab_out_prewrap
+Passed totest_tab_out_prewrap (with contentEditable)
+Passed totest_multiple_whitespaces_out_prewrap
+Passed totest_multiple_whitespaces_out_prewrap (with contentEditable)
+Passed totest_linebreak_in_prewrap
+Passed totest_linebreak_in_prewrap (with contentEditable)
+Passed totest_tab_in_prewrap
+Passed totest_tab_in_prewrap (with contentEditable)
+Passed totest_multiple_whitespaces_in_prewrap
+Passed totest_multiple_whitespaces_in_prewrap (with contentEditable)
+Passed totest_linebreak_out_preline
+Passed totest_linebreak_out_preline (with contentEditable)
+Passed totest_tab_out_preline
+Passed totest_tab_out_preline (with contentEditable)
+Passed totest_multiple_whitespaces_out_preline
+Passed totest_multiple_whitespaces_out_preline (with contentEditable)
+Passed totest_linebreak_in_preline
+Passed totest_linebreak_in_preline (with contentEditable)
+Passed totest_tab_in_preline
+Passed totest_tab_in_preline (with contentEditable)
+Passed totest_multiple_whitespaces_in_preline
+Passed totest_multiple_whitespaces_in_preline (with contentEditable)
+Passed totest_linebreak_out_nowrap
+Passed totest_linebreak_out_nowrap (with contentEditable)
+Passed totest_tab_out_nowrap
+Passed totest_tab_out_nowrap (with contentEditable)
+Passed totest_multiple_whitespaces_out_nowrap
+Passed totest_multiple_whitespaces_out_nowrap (with contentEditable)
+Passed totest_linebreak_in_nowrap
+Passed totest_linebreak_in_nowrap (with contentEditable)
+Passed totest_tab_in_nowrap
+Passed totest_tab_in_nowrap (with contentEditable)
+Passed totest_multiple_whitespaces_in_nowrap
+Passed totest_multiple_whitespaces_in_nowrap (with contentEditable)
+
diff --git a/LayoutTests/editing/selection/doubleclick-beside-cr-span.html b/LayoutTests/editing/selection/doubleclick-beside-cr-span.html
new file mode 100644
index 0000000..bd7f2f9
--- /dev/null
+++ b/LayoutTests/editing/selection/doubleclick-beside-cr-span.html
@@ -0,0 +1,531 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setSmartInsertDeleteEnabled(false);
+ layoutTestController.setSelectTrailingWhitespaceEnabled(true);
+}
+
+function getPositionOfNode(id)
+{
+ var n = document.getElementById(id);
+ var pos = {x: 0, y: 0};
+
+ while (n) {
+ pos.x += n.offsetLeft + n.clientLeft;
+ pos.y += n.offsetTop + n.clientTop;
+ n = n.offsetParent;
+ }
+ return pos;
+}
+
+function doubleClickPosition(pos)
+{
+ eventSender.mouseMoveTo(pos.x + 2, pos.y + 2);
+ eventSender.mouseDown();
+ eventSender.leapForward(1);
+ eventSender.mouseUp();
+ eventSender.leapForward(100);
+ eventSender.mouseDown();
+ eventSender.leapForward(1);
+ eventSender.mouseUp();
+}
+
+function defocus()
+{
+ doubleClickPosition({x:0, y:0});
+}
+
+function findParentDiv(spanId)
+{
+ var n = document.getElementById(spanId);
+ while (n) {
+ var parent = n.parentNode;
+ if (parent && parent.tagName == "DIV")
+ return parent;
+ n = parent;
+ }
+
+ return null;
+}
+
+function makeParentBlockEditable(spanId)
+{
+ var parent = findParentDiv(spanId);
+ parent.contentEditable = true;
+}
+
+function hideCaseBlockFor(spanId)
+{
+ var n = document.getElementById(spanId);
+ while (n) {
+ n = n.parentNode;
+ if (n && n.className == "case") {
+ n.style.display = "none";
+ n.style.offsetTop;
+ return;
+ }
+ }
+}
+
+function doTest(testId, expectedText, givenClickPosition)
+{
+ // Simulate a double click.
+ defocus()
+ var pos = givenClickPosition || getPositionOfNode(testId);
+ doubleClickPosition(pos);
+
+ // Get the text of the current selection.
+ var sel = window.getSelection();
+ var actualText = sel.getRangeAt(0).toString();
+
+ if (expectedText == actualText) {
+ log("Passed " + testId);
+ } else {
+ log("Failed " + testId);
+ log(" Expected: " + expectedText);
+ log(" Actual: " + actualText);
+ }
+
+ // Run the same case with contentEditable enabled.
+ makeParentBlockEditable(testId);
+
+ defocus();
+ doubleClickPosition(pos);
+
+ sel = window.getSelection();
+ actualText = sel.getRangeAt(0).toString();
+
+ if (expectedText == actualText) {
+ log("Passed " + testId + " (with contentEditable)");
+ } else {
+ log("Failed " + testId + " (with contentEditable)");
+ log(" Expected: " + expectedText);
+ log(" Actual: " + actualText);
+ }
+
+ // Hide a container for the case to workaround limited window size
+ hideCaseBlockFor(testId);
+}
+
+function log(msg)
+{
+ var l = document.getElementById('log');
+ l.appendChild(document.createTextNode(msg));
+ l.appendChild(document.createElement('br'));
+}
+
+function initConstants()
+{
+ var heightMeasure = document.getElementById("heightMeasure");
+ LINE_HEIGHT = heightMeasure.offsetHeight;
+ LINE_LEFT = heightMeasure.offsetLeft + heightMeasure.clientLeft;
+ CHAR_WIDTH = heightMeasure.offsetWidth;
+ heightMeasure.style.display = "none"; // hide for readable test result
+}
+
+function getPositionOfNextLineHeadOf(spanId)
+{
+ var pos = getPositionOfNode(spanId)
+ pos.x = LINE_LEFT;
+ pos.y += LINE_HEIGHT;
+ return pos;
+}
+
+function getPositionForward(spanId, ncharacters)
+{
+ var pos = getPositionOfNode(spanId)
+ pos.x += CHAR_WIDTH*ncharacters;
+ return pos;
+}
+
+function runTests()
+{
+ initConstants();
+
+ if (window.layoutTestController) {
+ doTest("totest_minimum", "select1");
+ // We may have to make EditorClient::isSelectTrailingWhitespaceEnabled false on
+ // DumpRenderTree to clarify cases...
+ doTest("totest_before_after", "select2 ");
+
+ doTest("totest_linebreak_out", "select3\n");
+ doTest("totest_tab_out", "select4\t");
+ doTest("totest_multiple_whitespaces_out", "select5 ");
+ doTest("totest_linebreak_in", "select6\n");
+ doTest("totest_tab_in", "select7\t");
+ doTest("totest_multiple_whitespaces_in", "select8 ");
+
+ doTest("totest_multiple_word_in_span", "select9 ");
+ doTest("totest_word_before_here_in_line", "select10 ");
+ doTest("totest_span_first_half", "select11 ");
+ doTest("totest_span_second_half", "select12 ");
+
+ doTest("totest_linebreak_out_pre", "select1");
+ doTest("totest_tab_out_pre", "select2\t");
+ doTest("totest_multiple_whitespaces_out_pre", "select3 ");
+ doTest("totest_linebreak_in_pre", "select4", getPositionOfNextLineHeadOf("totest_linebreak_in_pre"));
+ doTest("totest_tab_in_pre", "select5\t");
+ doTest("totest_multiple_whitespaces_in_pre", "select6 ", getPositionForward("totest_multiple_whitespaces_in_pre", " ".length));
+
+ doTest("totest_linebreak_out_prewrap", "select1");
+ doTest("totest_tab_out_prewrap", "select2\t");
+ doTest("totest_multiple_whitespaces_out_prewrap", "select3 ");
+ doTest("totest_linebreak_in_prewrap", "select4", getPositionOfNextLineHeadOf("totest_linebreak_in_prewrap"));
+ doTest("totest_tab_in_prewrap", "select5\t", getPositionOfNextLineHeadOf("totest_tab_in_prewrap"));
+ doTest("totest_multiple_whitespaces_in_prewrap", "select6 ", getPositionOfNextLineHeadOf("totest_multiple_whitespaces_in_prewrap"));
+
+ doTest("totest_linebreak_out_preline", "select1\n");
+ doTest("totest_tab_out_preline", "select2\t");
+ doTest("totest_multiple_whitespaces_out_preline", "select3 ");
+ doTest("totest_linebreak_in_preline", "select4\n", getPositionOfNextLineHeadOf("totest_linebreak_in_preline"));
+ doTest("totest_tab_in_preline", "select5\t");
+ doTest("totest_multiple_whitespaces_in_preline", "select6 ");
+
+ doTest("totest_linebreak_out_nowrap", "select1\n");
+ doTest("totest_tab_out_nowrap", "select2\t");
+ doTest("totest_multiple_whitespaces_out_nowrap", "select3 ");
+ doTest("totest_linebreak_in_nowrap", "select4\n", getPositionForward("totest_linebreak_in_nowrap", 1));
+ doTest("totest_tab_in_nowrap", "select5\t", getPositionForward("totest_tab_in_nowrap", 1));
+ doTest("totest_multiple_whitespaces_in_nowrap", "select6 ", getPositionForward("totest_multiple_whitespaces_in_nowrap", 1));
+
+ }
+}
+
+
+</script>
+</head>
+<body onload="runTests()">
+
+<p>
+This tests that double-clicking a word that follows newline and span
+</p>
+
+<div class="case">
+<h3>minimum case</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop <b id="totest_minimum">select1</b>
+</div>
+</div>
+
+<div class="case">
+<h3>with another word after the span</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop <b id="totest_before_after">select2</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use linebreak as word separator (outside element)</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop
+<b id="totest_linebreak_out">select3</b>
+nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (outside element)</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop <b id="totest_tab_out">select4</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (outside element)</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop <b id="totest_multiple_whitespaces_out">select5</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use linebreak as word separator (inside element)</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop<b id="totest_linebreak_in">
+select6
+</b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (inside element)</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop<b id="totest_tab_in"> select7 </b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (inside element)</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop<b id="totest_multiple_whitespaces_in"> select8 </b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>with another word in same the span</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop <b id="totest_multiple_word_in_span">select9 not</b> notyet
+</div>
+</div>
+
+<div class="case">
+<h3>with another word before the span, in the same line</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop qrst <b id="totest_word_before_here_in_line">select10</b> notyet
+</div>
+</div>
+
+<div class="case">
+<h3>a first half of word is inside b element</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop qrst <b id="totest_span_first_half">sel</b>ect11 notyet
+</div>
+</div>
+
+<div class="case">
+<h3>a second half of word is inside b element</h3>
+<div style="width:100pt">
+abcd efgh ijkl mnop qrst sel<b id="totest_span_second_half">ect12</b> notyet
+</div>
+</div>
+
+<h2>cases for white-space: pre</h2>
+<p>
+Note: Here for pre, we change width value to 200 to prevent layout change on contentEditable enabled.
+</p>
+
+<div class="case">
+<h3>use linebreak as word separator (outside element, white-space:pre)</h3>
+<div style="width:200pt;white-space:pre;">
+abcd efgh ijkl mnop
+<b id="totest_linebreak_out_pre">select1</b>
+nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (outside element, white-space:pre)</h3>
+<div style="width:200pt;white-space:pre;">
+abcd efgh ijkl mnop <b id="totest_tab_out_pre">select2</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (outside element, white-space:pre)</h3>
+<div style="width:200pt;white-space:pre;">
+abcd efgh ijkl mnop <b id="totest_multiple_whitespaces_out_pre">select3</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use linebreak as word separator (inside element, white-space:pre)</h3>
+<div style="width:200pt;white-space:pre;">
+abcd efgh ijkl mnop<b id="totest_linebreak_in_pre">
+select4
+</b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (inside element, white-space:pre)</h3>
+<div style="width:200pt;white-space:pre;">
+abcd efgh ijkl mnop<b id="totest_tab_in_pre"> select5 </b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (inside element, white-space:pre)</h3>
+<div style="width:200pt;white-space:pre;">
+abcd efgh ijkl mnop<b id="totest_multiple_whitespaces_in_pre"> select6 </b>nottoselect
+</div>
+</div>
+
+<h2>cases for white-space: pre-wrap</h2>
+
+<div class="case">
+<h3>use linebreak as word separator (outside element, white-space:pre-wrap)</h3>
+<div style="width:100pt;white-space:pre-wrap;">
+abcd efgh ijkl mnop
+<b id="totest_linebreak_out_prewrap">select1</b>
+nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (outside element, white-space:pre-wrap)</h3>
+<div style="width:100pt;white-space:pre-wrap;">
+abcd efgh ijkl mnop <b id="totest_tab_out_prewrap">select2</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (outside element, white-space:pre-wrap)</h3>
+<div style="width:100pt;white-space:pre-wrap;">
+abcd efgh ijkl mnop <b id="totest_multiple_whitespaces_out_prewrap">select3</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use linebreak as word separator (inside element, white-space:pre-wrap)</h3>
+<div style="width:100pt;white-space:pre-wrap;">
+abcd efgh ijkl mnop<b id="totest_linebreak_in_prewrap">
+select4
+</b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (inside element, white-space:pre-wrap)</h3>
+<div style="width:100pt;white-space:pre-wrap;">
+abcd efgh ijkl mnop<b id="totest_tab_in_prewrap"> select5 </b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (inside element, white-space:pre-wrap)</h3>
+<div style="width:100pt;white-space:pre-wrap;">
+abcd efgh ijkl mnop<b id="totest_multiple_whitespaces_in_prewrap"> select6 </b>nottoselect
+</div>
+</div>
+
+
+
+<h2>cases for white-space: pre-line</h2>
+
+<div class="case">
+<h3>use linebreak as word separator (outside element, white-space:pre-line)</h3>
+<div style="width:100pt;white-space:pre-line;">
+abcd efgh ijkl mnop
+<b id="totest_linebreak_out_preline">select1</b>
+nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (outside element, white-space:pre-line)</h3>
+<div style="width:100pt;white-space:pre-line;">
+abcd efgh ijkl mnop <b id="totest_tab_out_preline">select2</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (outside element, white-space:pre-line)</h3>
+<div style="width:100pt;white-space:pre-line;">
+abcd efgh ijkl mnop <b id="totest_multiple_whitespaces_out_preline">select3</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use linebreak as word separator (inside element, white-space:pre-line)</h3>
+<div style="width:100pt;white-space:pre-line;">
+abcd efgh ijkl mnop<b id="totest_linebreak_in_preline">
+select4
+</b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (inside element, white-space:pre-line)</h3>
+<div style="width:100pt;white-space:pre-line;">
+abcd efgh ijkl mnop<b id="totest_tab_in_preline"> select5 </b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (inside element, white-space:pre-line)</h3>
+<div style="width:100pt;white-space:pre-line;">
+abcd efgh ijkl mnop<b id="totest_multiple_whitespaces_in_preline"> select6 </b>nottoselect
+</div>
+</div>
+
+<h2>cases for white-space: nowrap</h2>
+<p>
+Note: Although following cases have no line-breaks that had caused problem reported bug28036,
+we add these for comprehensiveness.
+</p>
+
+<div class="case">
+<h3>use linebreak as word separator (outside element, white-space:nowrap)</h3>
+<div style="width:100pt;white-space:nowrap;">
+abcd efgh ijkl mnop
+<b id="totest_linebreak_out_nowrap">select1</b>
+nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (outside element, white-space:nowrap)</h3>
+<div style="width:100pt;white-space:nowrap;">
+abcd efgh ijkl mnop <b id="totest_tab_out_nowrap">select2</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (outside element, white-space:nowrap)</h3>
+<div style="width:100pt;white-space:nowrap;">
+abcd efgh ijkl mnop <b id="totest_multiple_whitespaces_out_nowrap">select3</b> nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use linebreak as word separator (inside element, white-space:nowrap)</h3>
+<div style="width:100pt;white-space:nowrap;">
+abcd efgh ijkl mnop<b id="totest_linebreak_in_nowrap">
+select4
+</b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use tab as word separator (inside element, white-space:nowrap)</h3>
+<div style="width:100pt;white-space:nowrap;">
+abcd efgh ijkl mnop<b id="totest_tab_in_nowrap"> select5 </b>nottoselect
+</div>
+</div>
+
+<div class="case">
+<h3>use multiple whitespaces as word separator (inside element, white-space:nowrap)</h3>
+<div style="width:100pt;white-space:nowrap;">
+abcd efgh ijkl mnop<b id="totest_multiple_whitespaces_in_nowrap"> select6 </b>nottoselect
+</div>
+</div>
+
+<!--
+
+<h2>cases for source-originated line-breaks with white-space: pre-* family</h2>
+
+<div class="case">
+<h3>white-space:pre</h3>
+<div style="width:200pt;white-space:pre;background-color:lightgray;">
+abcd efgh ijkl mnop
+<b id="totest_sourcebreak_pre">select1</b>
+nottoselect
+</div>
+</div>
+
+<h3>white-space:pre-wrap</h3>
+<div style="width:200pt;white-space:pre-wrap;background-color:lightgray;">
+abcd efgh ijkl mnop
+<b id="totest_sourcebreak_prewrap">select2</b>
+nottoselect
+</div>
+</div>
+
+<h3>white-space:pre-line</h3>
+<div style="width:200pt;white-space:pre-line;background-color:lightgray;">
+abcd efgh ijkl mnop
+<b id="totest_sourcebreak_preline">select3</b>
+nottoselect
+</div>
+</div>
+
+-->
+
+<div><span id="heightMeasure">x</span></div>
+
+<pre id="log">
+</pre>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8e5fc9c..f43f4d0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2009-12-15 MORITA Hajime <morrita at gmail.com>
+
+ Reviewed by Eric Seidel.
+
+ Bug 28306: double-clicking a word inside <b> beside newline select two words
+ https://bugs.webkit.org/show_bug.cgi?id=28306
+
+ SimplifiedBackwardsTextIterator missed trailing whitespaces just
+ before folding line-break, which is used to detect word
+ boundaries. This fix checks strings on RenderText and expand text
+ range on SimplifiedBackwardsTextIterator to include trailing
+ whitespaces if availble.
+
+ Test: editing/selection/doubleclick-beside-cr-span.html
+
+ * editing/TextIterator.cpp:
+ (WebCore::collapsedSpaceLength):
+ (WebCore::maxOffsetIncludingCollapsedSpaces):
+ (WebCore::SimplifiedBackwardsTextIterator::advance):
+
2009-12-16 Fumitoshi Ukai <ukai at chromium.org>
Reviewed by Alexey Proskuryakov.
diff --git a/WebCore/editing/TextIterator.cpp b/WebCore/editing/TextIterator.cpp
index df271b6..1a75fcf 100644
--- a/WebCore/editing/TextIterator.cpp
+++ b/WebCore/editing/TextIterator.cpp
@@ -705,6 +705,28 @@ static bool shouldEmitExtraNewlineForNode(Node* node)
return false;
}
+static int collapsedSpaceLength(RenderText* renderer, int textEnd)
+{
+ const UChar* characters = renderer->text()->characters();
+ int length = renderer->text()->length();
+ for (int i = textEnd; i < length; ++i) {
+ if (!renderer->style()->isCollapsibleWhiteSpace(characters[i]))
+ return i - textEnd;
+ }
+
+ return length - textEnd;
+}
+
+static int maxOffsetIncludingCollapsedSpaces(Node* node)
+{
+ int offset = caretMaxOffset(node);
+
+ if (node->renderer() && node->renderer()->isText())
+ offset += collapsedSpaceLength(toRenderText(node->renderer()), offset);
+
+ return offset;
+}
+
// 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).
bool TextIterator::shouldRepresentNodeOffsetZero()
{
@@ -1029,7 +1051,9 @@ void SimplifiedBackwardsTextIterator::advance()
m_node = next;
if (m_node)
pushFullyClippedState(m_fullyClippedStack, m_node);
- m_offset = m_node ? caretMaxOffset(m_node) : 0;
+ // For the purpose of word boundary detection,
+ // we should iterate all visible text and trailing (collapsed) whitespaces.
+ m_offset = m_node ? maxOffsetIncludingCollapsedSpaces(m_node) : 0;
m_handledNode = false;
m_handledChildren = false;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list