LayoutTests:
New layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5826
* fast/overflow/overflow-rtl-expected.checksum: Added.
* fast/overflow/overflow-rtl-expected.png: Added.
* fast/overflow/overflow-rtl-expected.txt: Added.
* fast/overflow/overflow-rtl.html: Added.
WebCore:
Reviewed by Hyatt, landed by Darin.
- fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5826
Blocks with direction:rtl and overflow:auto or scroll have incorrect scrollbars
* khtml/rendering/render_block.cpp: (khtml::RenderBlock::leftmostPosition):
* khtml/rendering/render_layer.cpp:
(khtml::RenderLayer::RenderLayer): Initialize
(khtml::RenderLayer::scrollOffset):
(khtml::RenderLayer::subtractScrollOffset):
(khtml::RenderLayer::scrollToOffset):
(khtml::RenderLayer::scrollRectToVisible):
(khtml::RenderLayer::updateScrollPositionFromScrollbars):
(khtml::RenderLayer::computeScrollDimensions):
(khtml::RenderLayer::updateScrollInfoAfterLayout):
* khtml/rendering/render_layer.h:
(khtml::RenderLayer::scrollXOffset):
(khtml::RenderLayer::scrollToYOffset):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11521 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a3527a4..c1d4192 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,14 @@
2005-12-10 Darin Adler <darin@apple.com>
+ New layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5826
+
+ * fast/overflow/overflow-rtl-expected.checksum: Added.
+ * fast/overflow/overflow-rtl-expected.png: Added.
+ * fast/overflow/overflow-rtl-expected.txt: Added.
+ * fast/overflow/overflow-rtl.html: Added.
+
+2005-12-10 Darin Adler <darin@apple.com>
+
New layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=3983
* fast/css/outline-auto-location-expected.checksum: Added.
diff --git a/LayoutTests/fast/overflow/overflow-rtl-expected.checksum b/LayoutTests/fast/overflow/overflow-rtl-expected.checksum
new file mode 100644
index 0000000..ccaedab
--- /dev/null
+++ b/LayoutTests/fast/overflow/overflow-rtl-expected.checksum
@@ -0,0 +1,2 @@
+b2858b2cc7b04004a69f2ee90b229e6b
+\ No newline at end of file
diff --git a/LayoutTests/fast/overflow/overflow-rtl-expected.png b/LayoutTests/fast/overflow/overflow-rtl-expected.png
new file mode 100644
index 0000000..12130b2
--- /dev/null
+++ b/LayoutTests/fast/overflow/overflow-rtl-expected.png
Binary files differ
diff --git a/LayoutTests/fast/overflow/overflow-rtl-expected.txt b/LayoutTests/fast/overflow/overflow-rtl-expected.txt
new file mode 100644
index 0000000..792e40e
--- /dev/null
+++ b/LayoutTests/fast/overflow/overflow-rtl-expected.txt
@@ -0,0 +1,91 @@
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x453
+ RenderBlock {HTML} at (0,0) size 800x453
+ RenderBody {BODY} at (8,16) size 784x429
+ RenderBlock {P} at (0,0) size 784x36
+ RenderText {TEXT} at (0,0) size 135x18
+ text run at (0,0) width 135: "This is a test case for "
+ RenderInline {I} at (0,0) size 777x36
+ RenderText {TEXT} at (135,0) size 777x36
+ text run at (135,0) width 642: "http://bugzilla.opendarwin.org/show_bug.cgi?id=5826 Blocks with direction:rtl and overflow:auto or"
+ text run at (0,18) width 197: "scroll have incorrect scrollbars"
+ RenderText {TEXT} at (197,18) size 4x18
+ text run at (197,18) width 4: "."
+ RenderBlock (anonymous) at (0,52) size 784x18
+ RenderText {TEXT} at (0,0) size 457x18
+ text run at (0,0) width 457: "The right column should be a mirror-image of the left column in terms of"
+ RenderBlock {UL} at (0,86) size 784x72
+ RenderListItem {LI} at (40,0) size 744x18
+ RenderListMarker at (0,0) size 0x14
+ RenderText {TEXT} at (0,0) size 164x18
+ text run at (0,0) width 164: "the presence of a scrollbar"
+ RenderListItem {LI} at (40,18) size 744x18
+ RenderListMarker at (0,0) size 0x14
+ RenderText {TEXT} at (0,0) size 234x18
+ text run at (0,0) width 234: "the initial position of the scroll thumb"
+ RenderListItem {LI} at (40,36) size 744x18
+ RenderListMarker at (0,0) size 0x14
+ RenderText {TEXT} at (0,0) size 451x18
+ text run at (0,0) width 451: "which letters are visible initially and when you scroll (in the top 3 rows)"
+ RenderListItem {LI} at (40,54) size 744x18
+ RenderListMarker at (0,0) size 0x14
+ RenderText {TEXT} at (0,0) size 578x18
+ text run at (0,0) width 578: "the position of the blue and olive boxes, initially and when you scroll (in the bottom 2 rows)"
+ RenderTable {TABLE} at (0,174) size 256x255
+ RenderTableSection {TBODY} at (0,0) size 0x255
+ RenderTableRow {TR} at (0,0) size 0x0
+ RenderTableCell {TD} at (2,2) size 125x251 [r=0 c=0 rs=1 cs=1]
+ RenderTableCell {TD} at (129,2) size 125x251 [r=0 c=1 rs=1 cs=1]
+layer at (15,197) size 115x45 clip at (25,197) size 100x30 scrollWidth 188
+ RenderBlock {DIV} at (5,5) size 115x45 [bgcolor=#FFFF00] [border: (5px solid #008000) none (10px solid #FF0000)]
+ RenderText {TEXT} at (10,0) size 188x18
+ text run at (10,0) width 188: "abcdefghijklmnopqrstuvwxyz"
+layer at (15,246) size 115x45 clip at (25,246) size 100x45
+ RenderBlock {DIV} at (5,54) size 115x45 [bgcolor=#FFFF00] [border: (5px solid #008000) none (10px solid #FF0000)]
+ RenderBlock {DIV} at (10,0) size 100x18 [bgcolor=#D3D3D3]
+ RenderText {TEXT} at (-88,0) size 188x18
+ text run at (-88,0) width 188: "abcdefghijklmnopqrstuvwxyz"
+layer at (15,295) size 115x45 clip at (25,295) size 100x30 scrollWidth 188
+ RenderBlock {DIV} at (5,103) size 115x45 [bgcolor=#FFFF00] [border: (5px solid #008000) none (10px solid #FF0000)]
+ RenderBlock {DIV} at (10,0) size 100x18 [bgcolor=#D3D3D3]
+ RenderText {TEXT} at (0,0) size 188x18
+ text run at (0,0) width 188: "abcdefghijklmnopqrstuvwxyz"
+layer at (15,344) size 115x45 clip at (25,344) size 100x45
+ RenderBlock (relative positioned) {DIV} at (5,152) size 115x45 [bgcolor=#FFFF00] [border: (5px solid #008000) none (10px solid #FF0000)]
+layer at (71,364) size 8x4
+ RenderBlock (positioned) {DIV} at (56,20) size 8x4 [bgcolor=#0000FF]
+layer at (-25,344) size 70x20 backgroundClip at (25,344) size 100x45 clip at (25,344) size 100x45 outlineClip at (25,344) size 100x45
+ RenderBlock (positioned) {DIV} at (-40,0) size 70x20 [bgcolor=#808000]
+layer at (15,393) size 115x45 clip at (25,393) size 100x30 scrollWidth 150
+ RenderBlock (relative positioned) {DIV} at (5,201) size 115x45 [bgcolor=#FFFF00] [border: (5px solid #008000) none (10px solid #FF0000)]
+layer at (71,413) size 8x4
+ RenderBlock (positioned) {DIV} at (56,20) size 8x4 [bgcolor=#0000FF]
+layer at (105,393) size 70x20 backgroundClip at (25,393) size 100x30 clip at (25,393) size 100x30 outlineClip at (25,393) size 100x30
+ RenderBlock (positioned) {DIV} at (90,0) size 70x20 [bgcolor=#808000]
+layer at (142,197) size 115x45 clip at (147,197) size 100x30 scrollX 88 scrollWidth 188
+ RenderBlock {DIV} at (5,5) size 115x45 [bgcolor=#FFFF00] [border: (10px solid #FF0000) none (5px solid #008000)]
+ RenderText {TEXT} at (-83,0) size 188x18
+ text run at (-83,0) width 188: "zyxwvutsrqponmlkjihgfedcba"
+layer at (142,246) size 115x45 clip at (147,246) size 100x45
+ RenderBlock {DIV} at (5,54) size 115x45 [bgcolor=#FFFF00] [border: (10px solid #FF0000) none (5px solid #008000)]
+ RenderBlock {DIV} at (5,0) size 100x18 [bgcolor=#D3D3D3]
+ RenderText {TEXT} at (0,0) size 188x18
+ text run at (0,0) width 188: "zyxwvutsrqponmlkjihgfedcba"
+layer at (142,295) size 115x45 clip at (147,295) size 100x30 scrollX 88 scrollWidth 188
+ RenderBlock {DIV} at (5,103) size 115x45 [bgcolor=#FFFF00] [border: (10px solid #FF0000) none (5px solid #008000)]
+ RenderBlock {DIV} at (5,0) size 100x18 [bgcolor=#D3D3D3]
+ RenderText {TEXT} at (-88,0) size 188x18
+ text run at (-88,0) width 188: "zyxwvutsrqponmlkjihgfedcba"
+layer at (142,344) size 115x45 clip at (147,344) size 100x45
+ RenderBlock (relative positioned) {DIV} at (5,152) size 115x45 [bgcolor=#FFFF00] [border: (10px solid #FF0000) none (5px solid #008000)]
+layer at (193,364) size 8x4
+ RenderBlock (positioned) {DIV} at (51,20) size 8x4 [bgcolor=#0000FF]
+layer at (227,344) size 70x20 backgroundClip at (147,344) size 100x45 clip at (147,344) size 100x45 outlineClip at (147,344) size 100x45
+ RenderBlock (positioned) {DIV} at (85,0) size 70x20 [bgcolor=#808000]
+layer at (142,393) size 115x45 clip at (147,393) size 100x30 scrollX 50 scrollWidth 150
+ RenderBlock (relative positioned) {DIV} at (5,201) size 115x45 [bgcolor=#FFFF00] [border: (10px solid #FF0000) none (5px solid #008000)]
+layer at (193,413) size 8x4
+ RenderBlock (positioned) {DIV} at (51,20) size 8x4 [bgcolor=#0000FF]
+layer at (97,393) size 70x20 backgroundClip at (147,393) size 100x30 clip at (147,393) size 100x30 outlineClip at (147,393) size 100x30
+ RenderBlock (positioned) {DIV} at (-45,0) size 70x20 [bgcolor=#808000]
diff --git a/LayoutTests/fast/overflow/overflow-rtl.html b/LayoutTests/fast/overflow/overflow-rtl.html
new file mode 100644
index 0000000..6c977e5
--- /dev/null
+++ b/LayoutTests/fast/overflow/overflow-rtl.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>overflow:auto with direction:rtl</title>
+<style type="text/css">
+div.test { background: yellow; height: 6ex; width: 100px; overflow: auto;
+ border-left: 10px solid red; border-right: 5px solid green; margin: 4px; }
+div.rtl { direction: rtl; border-right: 10px solid red; border-left: 5px solid green; }
+</style>
+</head>
+<body>
+<p>
+This is a test case for <i>http://bugzilla.opendarwin.org/show_bug.cgi?id=5826 Blocks with direction:rtl and overflow:auto or scroll have incorrect scrollbars</i>.
+</p>
+The right column should be a mirror-image of the left column in terms of
+<ul>
+ <li>the presence of a scrollbar</li>
+ <li>the initial position of the scroll thumb</li>
+ <li>which letters are visible initially and when you scroll (in the top 3 rows)</li>
+ <li>the position of the blue and olive boxes, initially and when you scroll (in the bottom 2 rows)</li>
+</ul>
+<table>
+<tr>
+<td>
+<div class="test">
+abcdefghijklmnopqrstuvwxyz
+</div>
+
+<div class="test">
+<div style="direction:rtl; background:lightgray;">abcdefghijklmnopqrstuvwxyz</div>
+</div>
+
+<div class="test">
+<div style="direction:ltr; background:lightgray;">abcdefghijklmnopqrstuvwxyz</div>
+</div>
+
+<div class="test" style="position:relative;">
+<div style="width:8px; height:4px; background:blue; position: absolute; left:46px; top:20px;"></div>
+<div style="width:70px; height:20px; background:olive; position: absolute; left:-50px;"></div>
+</div>
+
+<div class="test" style="position:relative;">
+<div style="width:8px; height:4px; background:blue; position: absolute; left:46px; top:20px;"></div>
+<div style="width:70px; height:20px; background:olive; position: absolute; left:80px;"></div>
+</div>
+</td>
+<td>
+<div class="test rtl">
+zyxwvutsrqponmlkjihgfedcba
+</div>
+
+<div class="test rtl">
+<div style="direction:ltr; background:lightgray;">zyxwvutsrqponmlkjihgfedcba</div>
+</div>
+
+<div class="test rtl">
+<div style="direction:rtl; background:lightgray;">zyxwvutsrqponmlkjihgfedcba</div>
+</div>
+
+<div class="test rtl" style="position:relative;">
+<div style="width:8px; height:4px; background:blue; position: absolute; left:46px; top:20px;"></div>
+<div style="width:70px; height:20px; background:olive; position: absolute; left:80px;"></div>
+</div>
+
+<div class="test rtl" style="position:relative;">
+<div style="width:8px; height:4px; background:blue; position: absolute; left:46px; top:20px;"></div>
+<div style="width:70px; height:20px; background:olive; position: absolute; left:-50px;"></div>
+</div>
+</td>
+</tr>
+</table>
+</body>
+</html>
diff --git a/WebCore/ChangeLog-2005-12-19 b/WebCore/ChangeLog-2005-12-19
index 8a79467..cefcbbd 100644
--- a/WebCore/ChangeLog-2005-12-19
+++ b/WebCore/ChangeLog-2005-12-19
@@ -1,3 +1,24 @@
+2005-12-10 Mitz Pettel <opendarwin.org@mitzpettel.com>
+
+ Reviewed by Hyatt, landed by Darin.
+
+ - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5826
+ Blocks with direction:rtl and overflow:auto or scroll have incorrect scrollbars
+
+ * khtml/rendering/render_block.cpp: (khtml::RenderBlock::leftmostPosition):
+ * khtml/rendering/render_layer.cpp:
+ (khtml::RenderLayer::RenderLayer): Initialize
+ (khtml::RenderLayer::scrollOffset):
+ (khtml::RenderLayer::subtractScrollOffset):
+ (khtml::RenderLayer::scrollToOffset):
+ (khtml::RenderLayer::scrollRectToVisible):
+ (khtml::RenderLayer::updateScrollPositionFromScrollbars):
+ (khtml::RenderLayer::computeScrollDimensions):
+ (khtml::RenderLayer::updateScrollInfoAfterLayout):
+ * khtml/rendering/render_layer.h:
+ (khtml::RenderLayer::scrollXOffset):
+ (khtml::RenderLayer::scrollToYOffset):
+
2005-12-10 Graham Dennis <Graham.Dennis@gmail.com>
Reviewed by Hyatt, landed by Darin.
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index ac31b8f..c6511d6 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -2159,8 +2159,8 @@
int left = RenderFlow::leftmostPosition(includeOverflowInterior, includeSelf);
if (!includeOverflowInterior && hasOverflowClip())
return left;
-
- // FIXME: Check left overflow when we eventually support it.
+ if (includeSelf && m_overflowLeft < left)
+ left = m_overflowLeft;
if (m_floatingObjects) {
FloatingObject* r;
diff --git a/WebCore/khtml/rendering/render_layer.cpp b/WebCore/khtml/rendering/render_layer.cpp
index 9a2b81c..d583674 100644
--- a/WebCore/khtml/rendering/render_layer.cpp
+++ b/WebCore/khtml/rendering/render_layer.cpp
@@ -124,6 +124,8 @@
m_height( 0 ),
m_scrollX( 0 ),
m_scrollY( 0 ),
+m_scrollOriginX( 0 ),
+m_scrollLeftOverflow( 0 ),
m_scrollWidth( 0 ),
m_scrollHeight( 0 ),
m_hBar( 0 ),
@@ -488,14 +490,14 @@
void
RenderLayer::scrollOffset(int& x, int& y)
{
- x += scrollXOffset();
+ x += scrollXOffset() + m_scrollLeftOverflow;
y += scrollYOffset();
}
void
RenderLayer::subtractScrollOffset(int& x, int& y)
{
- x -= scrollXOffset();
+ x -= scrollXOffset() + m_scrollLeftOverflow;
y -= scrollYOffset();
}
@@ -520,7 +522,7 @@
// complicated (since it will involve testing whether our layer
// is either occluded by another layer or clipped by an enclosing
// layer or contains fixed backgrounds, etc.).
- m_scrollX = x;
+ m_scrollX = x - m_scrollOriginX;
m_scrollY = y;
// Update the positions of our child layers.
@@ -545,7 +547,7 @@
if (updateScrollbars) {
if (m_hBar)
- m_hBar->setValue(m_scrollX);
+ m_hBar->setValue(scrollXOffset());
if (m_vBar)
m_vBar->setValue(m_scrollY);
}
@@ -557,8 +559,8 @@
QRect newRect = rect;
if (m_object->hasOverflowClip()) {
- QRect layerBounds = QRect(m_x + m_scrollX, m_y + m_scrollY, m_width, m_height);
- QRect exposeRect = QRect(rect.x() + m_scrollX, rect.y() + m_scrollY, rect.width(), rect.height());
+ QRect layerBounds = QRect(m_x + scrollXOffset(), m_y + m_scrollY, m_width, m_height);
+ QRect exposeRect = QRect(rect.x() + scrollXOffset(), rect.y() + m_scrollY, rect.width(), rect.height());
QRect r = getRectToExpose(layerBounds, exposeRect, alignX, alignY);
int xOffset = r.x() - m_x;
@@ -567,11 +569,11 @@
xOffset = kMax(0, kMin(m_scrollWidth - m_width, xOffset));
yOffset = kMax(0, kMin(m_scrollHeight - m_height, yOffset));
- if (xOffset != m_scrollX || yOffset != m_scrollY) {
- int diffX = m_scrollX;
+ if (xOffset != scrollXOffset() || yOffset != m_scrollY) {
+ int diffX = scrollXOffset();
int diffY = m_scrollY;
scrollToOffset(xOffset, yOffset);
- diffX = m_scrollX - diffX;
+ diffX = scrollXOffset() - diffX;
diffY = m_scrollY - diffY;
newRect.setX(rect.x() - diffX);
newRect.setY(rect.y() - diffY);
@@ -668,12 +670,12 @@
void RenderLayer::updateScrollPositionFromScrollbars()
{
bool needUpdate = false;
- int newX = m_scrollX;
+ int newX = scrollXOffset();
int newY = m_scrollY;
if (m_hBar) {
newX = m_hBar->value();
- if (newX != m_scrollX)
+ if (newX != scrollXOffset())
needUpdate = true;
}
@@ -795,15 +797,23 @@
void RenderLayer::computeScrollDimensions(bool* needHBar, bool* needVBar)
{
m_scrollDimensionsDirty = false;
-
- int rightPos = m_object->rightmostPosition(true, false) - m_object->borderLeft();
- int bottomPos = m_object->lowestPosition(true, false) - m_object->borderTop();
+
+ bool ltr = m_object->style()->direction() == LTR;
int clientWidth = m_object->clientWidth();
int clientHeight = m_object->clientHeight();
+ m_scrollLeftOverflow = ltr ? 0 : kMin(0, m_object->leftmostPosition(true, false) - m_object->borderLeft());
+
+ int rightPos = ltr ?
+ m_object->rightmostPosition(true, false) - m_object->borderLeft() :
+ clientWidth - m_scrollLeftOverflow;
+ int bottomPos = m_object->lowestPosition(true, false) - m_object->borderTop();
+
m_scrollWidth = kMax(rightPos, clientWidth);
m_scrollHeight = kMax(bottomPos, clientHeight);
+
+ m_scrollOriginX = ltr ? 0 : m_scrollWidth - clientWidth;
if (needHBar)
*needHBar = rightPos > clientWidth;
@@ -824,9 +834,9 @@
if (m_object->style()->overflow() != OMARQUEE) {
// Layout may cause us to be in an invalid scroll position. In this case we need
// to pull our scroll offsets back to the max (or push them up to the min).
- int newX = kMax(0, kMin(m_scrollX, scrollWidth() - m_object->clientWidth()));
+ int newX = kMax(0, kMin(scrollXOffset(), scrollWidth() - m_object->clientWidth()));
int newY = kMax(0, kMin(m_scrollY, scrollHeight() - m_object->clientHeight()));
- if (newX != m_scrollX || newY != m_scrollY)
+ if (newX != scrollXOffset() || newY != m_scrollY)
scrollToOffset(newX, newY);
}
@@ -869,6 +879,7 @@
if (pageStep < 0) pageStep = clientWidth;
m_hBar->setSteps(LINE_STEP, pageStep);
m_hBar->setKnobProportion(clientWidth, m_scrollWidth);
+ m_hBar->setValue(scrollXOffset());
}
if (m_vBar) {
int clientHeight = m_object->clientHeight();
diff --git a/WebCore/khtml/rendering/render_layer.h b/WebCore/khtml/rendering/render_layer.h
index 4632260..32f2bd2 100644
--- a/WebCore/khtml/rendering/render_layer.h
+++ b/WebCore/khtml/rendering/render_layer.h
@@ -240,11 +240,11 @@
// Scrolling methods for layers that can scroll their overflow.
void scrollOffset(int& x, int& y);
void subtractScrollOffset(int& x, int& y);
- int scrollXOffset() const { return m_scrollX; }
+ int scrollXOffset() const { return m_scrollX + m_scrollOriginX; }
int scrollYOffset() const { return m_scrollY; }
void scrollToOffset(int x, int y, bool updateScrollbars = true, bool repaint = true);
void scrollToXOffset(int x) { scrollToOffset(x, m_scrollY); }
- void scrollToYOffset(int y) { scrollToOffset(m_scrollX, y); }
+ void scrollToYOffset(int y) { scrollToOffset(m_scrollX + m_scrollOriginX, y); }
void scrollRectToVisible(const QRect &r, const ScrollAlignment& alignX = gAlignCenterIfNeeded, const ScrollAlignment& alignY = gAlignCenterIfNeeded);
QRect getRectToExpose(const QRect &visibleRect, const QRect &exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
void setHasHorizontalScrollbar(bool hasScrollbar);
@@ -368,6 +368,8 @@
// Our scroll offsets if the view is scrolled.
int m_scrollX;
int m_scrollY;
+ int m_scrollOriginX;
+ int m_scrollLeftOverflow;
// The width/height of our scrolled area.
int m_scrollWidth;