- Tests for http://bugzilla.opendarwin.org/show_bug.cgi?id=8158
REGRESSION: Clicking past RTL text in a new text field puts the caret on the wrong side of the text
* editing/selection/caret-rtl-expected.checksum: Added.
* editing/selection/caret-rtl-expected.png: Added.
* editing/selection/caret-rtl-expected.txt: Added.
* editing/selection/caret-rtl.html: Added.
* editing/selection/caret-rtl-2-expected.checksum: Added.
* editing/selection/caret-rtl-2-expected.png: Added.
* editing/selection/caret-rtl-2-expected.txt: Added.
* editing/selection/caret-rtl-2.html: Added.
WebCore:
Reviewed by Justin.
- Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8158
REGRESSION: Clicking past RTL text in a new text field puts the caret on the wrong side of the text
Tests:
editing/selection/caret-rtl.html
editing/selection/caret-rtl-2.html
* rendering/RenderText.cpp: (WebCore::RenderText::positionForCoordinates):
When calculating the position for the beginning or end of an InlineTextBox,
we now use offsetForPosition instead of just using m_start and m_len, because
offsetForPosition will take rtl text into account. I also made some formatting
changes.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13696
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-04-04 Adele Peterson <adele@apple.com>
+
+ - Tests for http://bugzilla.opendarwin.org/show_bug.cgi?id=8158
+ REGRESSION: Clicking past RTL text in a new text field puts the caret on the wrong side of the text
+
+ * editing/selection/caret-rtl-expected.checksum: Added.
+ * editing/selection/caret-rtl-expected.png: Added.
+ * editing/selection/caret-rtl-expected.txt: Added.
+ * editing/selection/caret-rtl.html: Added.
+ * editing/selection/caret-rtl-2-expected.checksum: Added.
+ * editing/selection/caret-rtl-2-expected.png: Added.
+ * editing/selection/caret-rtl-2-expected.txt: Added.
+ * editing/selection/caret-rtl-2.html: Added.
+
2006-04-04 Adele Peterson <adele@apple.com>
New results for
--- /dev/null
+0469b8fccf17f3df252e64a69b637346
\ No newline at end of file
--- /dev/null
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock (anonymous) at (0,0) size 784x18
+ RenderText {TEXT} at (0,0) size 596x18
+ text run at (0,0) width 596: "This tests that clicking in a contenteditable div will set the caret in the right position for rtl text. "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderBlock {P} at (0,34) size 784x18
+ RenderText {TEXT} at (0,0) size 649x18
+ text run at (0,0) width 200: "Click in the middle of the field. "
+ text run at (200,0) width 449: "The caret should be on the edge of the text closer to where you clicked."
+layer at (10,70) size 152x20
+ RenderBlock (positioned) {DIV} at (10,70) size 152x20 [border: (1px solid #000000)]
+ RenderText {TEXT} at (1,1) size 58x18
+ text run at (1,1) width 58 RTL: "\x{5E9}\x{5D3}\x{5D4} \x{5D1}\x{5D5}\x{5E8}"
+caret: position 0 of child 0 {TEXT} of child 5 {DIV} of child 1 {BODY} of child 0 {HTML} of document
--- /dev/null
+<html>
+<head>
+<script>
+function test()
+{
+ if (window.layoutTestController) {
+ eventSender.mouseMoveTo(145, 75);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+}
+</script>
+</head>
+<body onload="test()">
+This tests that clicking in a contenteditable div will set the caret in the right position for rtl text.
+<br>
+<p>
+ Click in the middle of the field. The caret should be on the edge of the text closer to where you clicked.
+</p>
+<div style="width:150px; border: solid thin black; position: absolute; top: 70; left: 10;" contenteditable>שדה בור</div>
+</body>
+</html>
+
--- /dev/null
+cdd88ee6dd6cdd32a9d5e46847a641d6
\ No newline at end of file
--- /dev/null
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock (anonymous) at (0,0) size 784x18
+ RenderText {TEXT} at (0,0) size 596x18
+ text run at (0,0) width 596: "This tests that clicking in a contenteditable div will set the caret in the right position for rtl text. "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderBlock {P} at (0,34) size 784x18
+ RenderText {TEXT} at (0,0) size 649x18
+ text run at (0,0) width 200: "Click in the middle of the field. "
+ text run at (200,0) width 449: "The caret should be on the edge of the text closer to where you clicked."
+layer at (10,70) size 152x20
+ RenderBlock (positioned) {DIV} at (10,70) size 152x20 [border: (1px solid #000000)]
+ RenderText {TEXT} at (93,1) size 58x18
+ text run at (93,1) width 58 RTL: "\x{5E9}\x{5D3}\x{5D4} \x{5D1}\x{5D5}\x{5E8}"
+caret: position 7 of child 0 {TEXT} of child 5 {DIV} of child 1 {BODY} of child 0 {HTML} of document
--- /dev/null
+<html>
+<head>
+<script>
+function test()
+{
+ if (window.layoutTestController) {
+ eventSender.mouseMoveTo(25, 75);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+}
+</script>
+</head>
+<body onload="test()">
+This tests that clicking in a contenteditable div will set the caret in the right position for rtl text.
+<br>
+<p>
+ Click in the middle of the field. The caret should be on the edge of the text closer to where you clicked.
+</p>
+<div style="direction: rtl; width:150px; border: solid thin black; position: absolute; top: 70; left: 10;" contenteditable>שדה בור</div>
+</body>
+</html>
+
+2006-04-04 Adele Peterson <adele@apple.com>
+
+ Reviewed by Justin.
+
+ - Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8158
+ REGRESSION: Clicking past RTL text in a new text field puts the caret on the wrong side of the text
+
+ Tests:
+ editing/selection/caret-rtl.html
+ editing/selection/caret-rtl-2.html
+
+ * rendering/RenderText.cpp: (WebCore::RenderText::positionForCoordinates):
+ When calculating the position for the beginning or end of an InlineTextBox,
+ we now use offsetForPosition instead of just using m_start and m_len, because
+ offsetForPosition will take rtl text into account. I also made some formatting
+ changes.
+
2006-04-04 David Hyatt <hyatt@apple.com>
Fix for bug 8065, inline blocks incorrectly loses spaces between them.
if (cb->hasOverflowClip())
cb->layer()->subtractScrollOffset(absx, absy);
+ // Get the offset for the position, since this will take rtl text into account.
+ int offset;
+
+ // FIXME: We should be able to roll these special cases into the general cases in the loop below.
if (firstTextBox() && _y < absy + firstTextBox()->root()->bottomOverflow() && _x < absx + firstTextBox()->m_x) {
// at the y coordinate of the first line or above
// and the x coordinate is to the left than the first text box left edge
- return VisiblePosition(element(), firstTextBox()->m_start, DOWNSTREAM);
+ offset = firstTextBox()->offsetForPosition(_x - absx);
+ return VisiblePosition(element(), offset + firstTextBox()->m_start, DOWNSTREAM);
}
-
if (lastTextBox() && _y >= absy + lastTextBox()->root()->topOverflow() && _x >= absx + lastTextBox()->m_x + lastTextBox()->m_width) {
// at the y coordinate of the last line or below
// and the x coordinate is to the right than the last text box right edge
- return VisiblePosition(element(), lastTextBox()->m_start + lastTextBox()->m_len, DOWNSTREAM);
+ offset = lastTextBox()->offsetForPosition(_x - absx);
+ return VisiblePosition(element(), offset + lastTextBox()->m_start, DOWNSTREAM);
}
for (InlineTextBox *box = firstTextBox(); box; box = box->nextTextBox()) {
if (_y >= absy + box->root()->topOverflow() && _y < absy + box->root()->bottomOverflow()) {
- if (_x < absx + box->m_x + box->m_width) {
+ offset = box->offsetForPosition(_x - absx);
+
+ if (_x < absx + box->m_x + box->m_width)
// and the x coordinate is to the left of the right edge of this box
// check to see if position goes in this box
- int offset = box->offsetForPosition(_x - absx);
- if (offset != -1)
- return VisiblePosition(element(), offset + box->m_start, VP_UPSTREAM_IF_POSSIBLE);
- }
- else if (!box->prevOnLine() && _x < absx + box->m_x) {
+ return VisiblePosition(element(), offset + box->m_start, VP_UPSTREAM_IF_POSSIBLE);
+
+ if (!box->prevOnLine() && _x < absx + box->m_x)
// box is first on line
// and the x coordinate is to the left of the first text box left edge
- return VisiblePosition(element(), box->m_start, DOWNSTREAM);
- }
- else if (!box->nextOnLine() && _x >= absx + box->m_x + box->m_width) {
+ return VisiblePosition(element(), offset + box->m_start, DOWNSTREAM);
+
+ if (!box->nextOnLine())
// box is last on line
// and the x coordinate is to the right of the last text box right edge
// generate VisiblePosition, use UPSTREAM affinity if possible
- return VisiblePosition(element(), box->m_start + box->m_len, VP_UPSTREAM_IF_POSSIBLE);
- }
+ return VisiblePosition(element(), offset + box->m_start, VP_UPSTREAM_IF_POSSIBLE);
}
}