2009-02-04 Jeremy Moskovich <jeremy@chromium.org>
Reviewed by Dave Hyatt.
https://bugs.webkit.org/show_bug.cgi?id=23471
Fix text-overflow:ellipsis; for RTL case.
Test: fast/css/text-overflow-ellipses.html
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::placeEllipsisBox): Add support for rtl placement.
(WebCore::InlineTextBox::paintDecoration): Correctly draw decorations
for rtl truncation.
LayoutTests:
2009-02-04 Jeremy Moskovich <jeremy@chromium.org>
Reviewed by Dave Hyatt.
https://bugs.webkit.org/show_bug.cgi?id=23471
Fix text-overflow:ellipsis; for RTL case.
Rebaseline LayoutTests/editing/spelling/inline_spelling_markers.html to reflect correct behavior.
* fast/css/text-overflow-ellipses.html: Added.
* platform/mac/editing/spelling/inline_spelling_markers-expected.checksum:
* platform/mac/editing/spelling/inline_spelling_markers-expected.png:
* platform/mac/fast/css/text-overflow-ellipses-expected.checksum: Added.
* platform/mac/fast/css/text-overflow-ellipses-expected.png: Added.
* platform/mac/fast/css/text-overflow-ellipses-expected.txt: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@40620
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2009-02-04 Jeremy Moskovich <jeremy@chromium.org>
+
+ Reviewed by Dave Hyatt.
+
+ https://bugs.webkit.org/show_bug.cgi?id=23471
+ Fix text-overflow:ellipsis; for RTL case.
+
+ Rebaseline LayoutTests/editing/spelling/inline_spelling_markers.html to reflect correct behavior.
+
+ * fast/css/text-overflow-ellipses.html: Added.
+ * platform/mac/editing/spelling/inline_spelling_markers-expected.checksum:
+ * platform/mac/editing/spelling/inline_spelling_markers-expected.png:
+ * platform/mac/fast/css/text-overflow-ellipses-expected.checksum: Added.
+ * platform/mac/fast/css/text-overflow-ellipses-expected.png: Added.
+ * platform/mac/fast/css/text-overflow-ellipses-expected.txt: Added.
+
2009-02-03 Brad Garcia <bgarcia@google.com>
Reviewed by Eric Seidel.
--- /dev/null
+<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=utf8">
+<head>
+<style>
+.testDiv {
+ width: 180px;
+ height: 20px;
+ border: 1px solid black;
+ white-space: nowrap;
+ overflow: hidden;
+ margin: 0 0 20px 0;
+}
+
+.rtl {
+ direction: rtl;
+}
+
+.forcertl {
+ direction: rtl;
+ unicode-bidi: bidi-override;
+}
+
+.ellipses {
+ text-overflow:ellipsis;
+}
+</style>
+</head>
+<body>
+
+This tests checks that the text-overflow:ellipses property is handled correctly
+for bidi text.<br><br>
+
+Pass if the ellipses do not overlap the text and the underlines for the links are
+placed under the text and not the ellipses.
+<br><br>
+
+LTR:
+<div class="testDiv ellipses">
+Lorem ipsum dolor sit amet, consectetur adipiscing
+</div>
+
+RTL:
+<div class="testDiv rtl ellipses">
+כשהטקסט ערוך מדי נרצה להוסיף אליפסות בסוף שורה
+</div>
+
+RTL Override:
+<div class="testDiv forcertl ellipses">
+Lorem ipsum dolor sit amet, consectetur adipiscing
+</div>
+
+
+LTR link:
+<div class="testDiv ellipses">
+<a href=#>Lorem ipsum dolor sit amet, consectetur adipiscing</a>
+</div>
+
+RTL link:
+<div class="testDiv forcertl ellipses">
+<a href=#>Lorem ipsum dolor sit amet, consectetur adipiscing</a>
+</div>
-1c042c1538d5632e99eb61ef474793f2
\ No newline at end of file
+a4b423f9dcc5433b5dd0288d92d9ae5c
\ No newline at end of file
--- /dev/null
+4e41c58061a489acb8bb50facb8c8f66
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x572
+ RenderBlock (anonymous) at (0,0) size 784x90
+ RenderText {#text} at (0,0) size 560x18
+ text run at (0,0) width 560: "This tests checks that the text-overflow:ellipses property is handled correctly for bidi text."
+ RenderBR {BR} at (560,14) size 0x0
+ RenderBR {BR} at (0,18) size 0x18
+ RenderText {#text} at (0,36) size 747x18
+ text run at (0,36) width 747: "Pass if the ellipses do not overlap the text and the underlines for the links are placed under the text and not the ellipses. "
+ RenderBR {BR} at (747,50) size 0x0
+ RenderBR {BR} at (0,54) size 0x18
+ RenderText {#text} at (0,72) size 35x18
+ text run at (0,72) width 35: "LTR:"
+ RenderBlock (anonymous) at (0,132) size 784x18
+ RenderText {#text} at (0,0) size 35x18
+ text run at (0,0) width 35: "RTL:"
+ RenderBlock (anonymous) at (0,192) size 784x18
+ RenderText {#text} at (0,0) size 95x18
+ text run at (0,0) width 95: "RTL Override:"
+ RenderBlock (anonymous) at (0,252) size 784x18
+ RenderText {#text} at (0,0) size 63x18
+ text run at (0,0) width 63: "LTR link:"
+ RenderBlock (anonymous) at (0,312) size 784x18
+ RenderText {#text} at (0,0) size 63x18
+ text run at (0,0) width 63: "RTL link:"
+layer at (8,98) size 182x22 clip at (9,99) size 180x20 scrollWidth 320
+ RenderBlock {DIV} at (0,90) size 182x22 [border: (1px solid #000000)]
+ RenderText {#text} at (1,1) size 320x18
+ text run at (1,1) width 320: "Lorem ipsum dolor sit amet, consectetur adipiscing"
+layer at (8,158) size 182x22 clip at (9,159) size 180x20 scrollX 196 scrollWidth 376
+ RenderBlock {DIV} at (0,150) size 182x22 [border: (1px solid #000000)]
+ RenderText {#text} at (-195,1) size 376x18
+ text run at (-195,1) width 376 RTL: "\x{5DB}\x{5E9}\x{5D4}\x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5E2}\x{5E8}\x{5D5}\x{5DA} \x{5DE}\x{5D3}\x{5D9} \x{5E0}\x{5E8}\x{5E6}\x{5D4} \x{5DC}\x{5D4}\x{5D5}\x{5E1}\x{5D9}\x{5E3} \x{5D0}\x{5DC}\x{5D9}\x{5E4}\x{5E1}\x{5D5}\x{5EA} \x{5D1}\x{5E1}\x{5D5}\x{5E3} \x{5E9}\x{5D5}\x{5E8}\x{5D4}"
+layer at (8,218) size 182x22 clip at (9,219) size 180x20 scrollX 140 scrollWidth 320
+ RenderBlock {DIV} at (0,210) size 182x22 [border: (1px solid #000000)]
+ RenderText {#text} at (-139,1) size 320x18
+ text run at (-139,1) width 320 RTL override: "Lorem ipsum dolor sit amet, consectetur adipiscing"
+layer at (8,278) size 182x22 clip at (9,279) size 180x20 scrollWidth 320
+ RenderBlock {DIV} at (0,270) size 182x22 [border: (1px solid #000000)]
+ RenderInline {A} at (0,0) size 320x18 [color=#0000EE]
+ RenderText {#text} at (1,1) size 320x18
+ text run at (1,1) width 320: "Lorem ipsum dolor sit amet, consectetur adipiscing"
+ RenderText {#text} at (0,0) size 0x0
+layer at (8,338) size 182x22 clip at (9,339) size 180x20 scrollX 140 scrollWidth 320
+ RenderBlock {DIV} at (0,330) size 182x22 [border: (1px solid #000000)]
+ RenderInline {A} at (0,0) size 320x18 [color=#0000EE]
+ RenderText {#text} at (-139,1) size 320x18
+ text run at (-139,1) width 320 RTL override: "Lorem ipsum dolor sit amet, consectetur adipiscing"
+ RenderText {#text} at (0,0) size 0x0
+2009-02-04 Jeremy Moskovich <jeremy@chromium.org>
+
+ Reviewed by Dave Hyatt.
+
+ https://bugs.webkit.org/show_bug.cgi?id=23471
+ Fix text-overflow:ellipsis; for RTL case.
+
+ Test: fast/css/text-overflow-ellipses.html
+
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::placeEllipsisBox): Add support for rtl placement.
+ (WebCore::InlineTextBox::paintDecoration): Correctly draw decorations
+ for rtl truncation.
+
2009-02-02 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Darin Adler.
int ellipsisX = ltr ? blockEdge - ellipsisWidth : blockEdge + ellipsisWidth;
- // For LTR, if the left edge of the ellipsis is to the left of our text run, then we are the run that will get truncated.
- if (ltr) {
- if (ellipsisX <= m_x) {
- // Too far. Just set full truncation, but return -1 and let the ellipsis just be placed at the edge of the box.
- m_truncation = cFullTruncation;
- foundBox = true;
- return -1;
- }
+ // Criteria for full truncation:
+ // LTR: the left edge of the ellipsis is to the left of our text run.
+ // RTL: the right edge of the ellipsis is to the right of our text run.
+ bool ltrFullTruncation = ltr && ellipsisX <= m_x;
+ bool rtlFullTruncation = !ltr && ellipsisX >= (m_x + m_width);
+ if (ltrFullTruncation || rtlFullTruncation) {
+ // Too far. Just set full truncation, but return -1 and let the ellipsis just be placed at the edge of the box.
+ m_truncation = cFullTruncation;
+ foundBox = true;
+ return -1;
+ }
- if (ellipsisX < m_x + m_width) {
- if (direction() == RTL)
- return -1; // FIXME: Support LTR truncation when the last run is RTL someday.
+ bool ltrEllipsisWithinBox = ltr && (ellipsisX < m_x + m_width);
+ bool rtlEllipsisWithinBox = !ltr && (ellipsisX > m_x);
+ if (ltrEllipsisWithinBox || rtlEllipsisWithinBox) {
+ if (ltr && direction() == RTL || !ltr && direction() == LTR)
+ return -1; // FIXME: Support cases in which the last run's directionality differs from the context.
- foundBox = true;
+ foundBox = true;
- int offset = offsetForPosition(ellipsisX, false);
- if (offset == 0) {
- // No characters should be rendered. Set ourselves to full truncation and place the ellipsis at the min of our start
- // and the ellipsis edge.
- m_truncation = cFullTruncation;
- return min(ellipsisX, m_x);
- }
-
- // Set the truncation index on the text run. The ellipsis needs to be placed just after the last visible character.
- m_truncation = offset;
- return m_x + toRenderText(m_object)->width(m_start, offset, textPos(), m_firstLine);
+ int offset = offsetForPosition(ellipsisX, false);
+ if (offset == 0) {
+ // No characters should be rendered. Set ourselves to full truncation and place the ellipsis at the min of our start
+ // and the ellipsis edge.
+ m_truncation = cFullTruncation;
+ return min(ellipsisX, m_x);
}
- }
- else {
- // FIXME: Support RTL truncation someday, including both modes (when the leftmost run on the line is either RTL or LTR)
+
+ // Set the truncation index on the text run. The ellipsis needs to be placed just after the last visible character.
+ m_truncation = offset;
+ if (ltr)
+ return m_x + toRenderText(m_object)->width(m_start, offset, textPos(), m_firstLine);
+ else
+ return m_x + (m_width - toRenderText(m_object)->width(m_start, offset, textPos(), m_firstLine)) - ellipsisWidth;
}
return -1;
}
if (m_truncation == cFullTruncation)
return;
-
- int width = (m_truncation == cNoTruncation) ? m_width
- : toRenderText(m_object)->width(m_start, m_truncation, textPos(), m_firstLine);
+
+ int width = m_width;
+ if (m_truncation != cNoTruncation) {
+ width = toRenderText(m_object)->width(m_start, m_truncation, textPos(), m_firstLine);
+ if (direction() == RTL)
+ tx += (m_width - width);
+ }
// Get the text decoration colors.
Color underline, overline, linethrough;