[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e
rniwa at webkit.org
rniwa at webkit.org
Fri Jan 21 14:54:41 UTC 2011
The following commit has been merged in the debian/experimental branch:
commit 09ad1617894e0c3e1db0d7eea08dfa1c41b9b4b0
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 4 17:21:13 2011 +0000
2011-01-04 Ryosuke Niwa <rniwa at webkit.org>
Reviewed by Dan Bernstein.
Clicking on the first or the last letter of LTR/RTL text in a RTL/LTR block puts caret on the opposite side.
https://bugs.webkit.org/show_bug.cgi?id=50992
Fixed the bug by interchanging the offset when the direction of inline text box and the containing block
does not match. Reused the code added by http://trac.webkit.org/changeset/73553.
Test: editing/selection/caret-bidi-first-and-last-letters.html
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::offsetForPosition):
2011-01-04 Ryosuke Niwa <rniwa at webkit.org>
Reviewed by Dan Bernstein.
Clicking on the first or the last letter of LTR/RTL text in a RTL/LTR block puts caret on the opposite side.
https://bugs.webkit.org/show_bug.cgi?id=50992
Added a test to ensure WebKit places the caret on the side user clicked even when text's natural direction
and the containing block's direction do not match.
* editing/selection/caret-bidi-first-and-last-letters-expected.txt: Added.
* editing/selection/caret-bidi-first-and-last-letters.html: Added.
* editing/selection/resources/caret-edge-shared.js: Avoid calling verify() outside of DRT.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74971 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0e3a597..f14b5bb 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2011-01-04 Ryosuke Niwa <rniwa at webkit.org>
+
+ Reviewed by Dan Bernstein.
+
+ Clicking on the first or the last letter of LTR/RTL text in a RTL/LTR block puts caret on the opposite side.
+ https://bugs.webkit.org/show_bug.cgi?id=50992
+
+ Added a test to ensure WebKit places the caret on the side user clicked even when text's natural direction
+ and the containing block's direction do not match.
+
+ * editing/selection/caret-bidi-first-and-last-letters-expected.txt: Added.
+ * editing/selection/caret-bidi-first-and-last-letters.html: Added.
+ * editing/selection/resources/caret-edge-shared.js: Avoid calling verify() outside of DRT.
+
2011-01-04 Sheriff Bot <webkit.review.bot at gmail.com>
Unreviewed, rolling out r74960.
diff --git a/LayoutTests/editing/selection/caret-bidi-first-and-last-letters-expected.txt b/LayoutTests/editing/selection/caret-bidi-first-and-last-letters-expected.txt
new file mode 100644
index 0000000..9cf4c26
--- /dev/null
+++ b/LayoutTests/editing/selection/caret-bidi-first-and-last-letters-expected.txt
@@ -0,0 +1,10 @@
+This tests that clicking in a contenteditable div will set the caret in the right position for LTR/RTL text in a RTL/LTR block.
+
+Clicking the first letter of RTL text in a LTR block
+PASS
+Clicking the last letter of RTL text in a LTR block
+PASS
+Clicking the first letter of LTR text in a RTL block
+PASS
+Clicking the last letter of LTR text in a RTL block
+PASS
diff --git a/LayoutTests/editing/selection/caret-bidi-first-and-last-letters.html b/LayoutTests/editing/selection/caret-bidi-first-and-last-letters.html
new file mode 100644
index 0000000..f2b5a1b
--- /dev/null
+++ b/LayoutTests/editing/selection/caret-bidi-first-and-last-letters.html
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>
+This tests that clicking in a contenteditable div will set the caret in the right position for LTR/RTL text in a RTL/LTR block.
+</p>
+<dl>
+ <dt>Clicking the first letter of RTL text in a LTR block</dt>
+ <dd><div id="rtl-in-ltr-first" style="font-size: 70px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>שדה בור</div></dd>
+ <dt>Clicking the last letter of RTL text in a LTR block</dt>
+ <dd><div id="rtl-in-ltr-last" style="font-size: 70px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>שדה בור</div></dd>
+ <dt>Clicking the first letter of LTR text in a RTL block</dt>
+ <dd><div id="ltr-in-rtl-first" style="direction: rtl; font-size: 70px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>WebKitW</div></dd>
+ <dt>Clicking the last letter of LTR text in a RTL block</dt>
+ <dd><div id="ltr-in-rtl-last" style="direction: rtl; font-size: 70px; width: 20ex; border: solid thin black; padding: 10px;" contenteditable>WebKitW</div></dd>
+</dl>
+<script src="resources/caret-edge-shared.js"></script>
+<script>
+
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function runTest(div, clickOn, expectedOffset) {
+ var elementToCalulateTextWidth = document.createElement('span');
+ elementToCalulateTextWidth.appendChild(div.firstChild.cloneNode());
+ document.body.appendChild(elementToCalulateTextWidth);
+ elementToCalulateTextWidth.style.fontSize = '70px';
+
+ var inRTLBlock = div.style.direction == 'rtl';
+ var x = 20;
+ if ((!inRTLBlock && clickOn == 'last') || (inRTLBlock && clickOn == 'first'))
+ x = elementToCalulateTextWidth.offsetWidth;
+ if (inRTLBlock)
+ x = div.offsetWidth - x;
+
+ document.body.removeChild(elementToCalulateTextWidth);
+
+ var verify = function() {
+ if (!window.getSelection().isCollapsed)
+ return log(div, 'FAIL: selection not collapsed');
+
+ var range = window.getSelection().getRangeAt(0);
+ if (range.startContainer != div.firstChild)
+ return log(div, 'FAIL: wrong container');
+ if (range.startOffset != expectedOffset)
+ return log(div, 'FAIL: wrong offset ' + range.startOffset + ', expected ' + expectedOffset);
+
+ return log(div, 'PASS');
+ }
+
+ if (!window.layoutTestController) {
+ div.addEventListener('mouseup', verify);
+ return;
+ }
+
+ eventSender.mouseMoveTo(div.offsetLeft + x, div.offsetTop + div.offsetHeight / 2);
+ eventSender.leapForward(200);
+ eventSender.mouseDown();
+ eventSender.leapForward(200);
+ eventSender.mouseUp();
+ verify({target: div});
+}
+
+function log(div, message) {
+ div.innerHTML = message;
+}
+
+runTest(document.getElementById('rtl-in-ltr-first'), 'first', 0);
+runTest(document.getElementById('rtl-in-ltr-last'), 'last', 7);
+runTest(document.getElementById('ltr-in-rtl-first'), 'first', 7);
+runTest(document.getElementById('ltr-in-rtl-last'), 'last', 0);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/resources/caret-edge-shared.js b/LayoutTests/editing/selection/resources/caret-edge-shared.js
index 6ee364c..7a2a92c 100644
--- a/LayoutTests/editing/selection/resources/caret-edge-shared.js
+++ b/LayoutTests/editing/selection/resources/caret-edge-shared.js
@@ -2,10 +2,8 @@
function runTest() {
var div = document.getElementsByTagName('div')[0];
- if (!window.layoutTestController) {
- div.addEventListener('mouseup', verify);
+ if (!window.layoutTestController)
return;
- }
if (clickOn == 'left')
x = 5;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 41deb1f..2863c18 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-04 Ryosuke Niwa <rniwa at webkit.org>
+
+ Reviewed by Dan Bernstein.
+
+ Clicking on the first or the last letter of LTR/RTL text in a RTL/LTR block puts caret on the opposite side.
+ https://bugs.webkit.org/show_bug.cgi?id=50992
+
+ Fixed the bug by interchanging the offset when the direction of inline text box and the containing block
+ does not match. Reused the code added by http://trac.webkit.org/changeset/73553.
+
+ Test: editing/selection/caret-bidi-first-and-last-letters.html
+
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::offsetForPosition):
+
2010-12-29 Tony Gentilcore <tonyg at chromium.org>
Reviewed by Darin Adler.
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp
index c839ae7..3745261 100644
--- a/WebCore/rendering/InlineTextBox.cpp
+++ b/WebCore/rendering/InlineTextBox.cpp
@@ -1147,7 +1147,8 @@ int InlineTextBox::offsetForPosition(int lineOffset, bool includePartialGlyphs)
int leftOffset = isLeftToRightDirection() ? 0 : m_len;
int rightOffset = isLeftToRightDirection() ? m_len : 0;
- if (renderer()->containingBlock()->style()->isLeftToRightDirection() != isLeftToRightDirection())
+ bool blockIsInOppositeDirection = renderer()->containingBlock()->style()->isLeftToRightDirection() != isLeftToRightDirection();
+ if (blockIsInOppositeDirection)
swap(leftOffset, rightOffset);
if (lineOffset - logicalLeft() > logicalWidth())
@@ -1158,8 +1159,12 @@ int InlineTextBox::offsetForPosition(int lineOffset, bool includePartialGlyphs)
RenderText* text = toRenderText(renderer());
RenderStyle* style = text->style(m_firstLine);
const Font* f = &style->font();
- return f->offsetForPosition(TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
+ int offset = f->offsetForPosition(TextRun(textRenderer()->text()->characters() + m_start, m_len,
+ textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
lineOffset - logicalLeft(), includePartialGlyphs);
+ if (blockIsInOppositeDirection && (!offset || offset == m_len))
+ return !offset ? m_len : 0;
+ return offset;
}
int InlineTextBox::positionForOffset(int offset) const
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list