[RTL Scrollbars] Position: absolute divs are covered by vertical scrollbar
https://bugs.webkit.org/show_bug.cgi?id=155531

Reviewed by Darin Adler.

Source/WebCore:

This patch updates ScrollView::documentScrollPositionRelativeToViewOrigin(), which is
a helper function primarily used by WebCore::ScrollView::viewToContents() and
WebCore::ScrollView::contentsToView().

Tests: fast/scrolling/rtl-scrollbars-elementFromPoint-static.html
       fast/scrolling/rtl-scrollbars-elementFromPoint.html
       fast/scrolling/rtl-scrollbars-iframe-offset.html
       fast/scrolling/rtl-scrollbars-iframe-position-absolute.html
       fast/scrolling/rtl-scrollbars-iframe-scrolled.html
       fast/scrolling/rtl-scrollbars-iframe.html
       fast/scrolling/rtl-scrollbars-overflow-elementFromPoint.html
       fast/scrolling/rtl-scrollbars-overflow-position-absolute.html
       fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled.html
       fast/scrolling/rtl-scrollbars-position-absolute.html
       fast/scrolling/rtl-scrollbars-position-fixed.html
       fast/scrolling/rtl-scrollbars-text-selection-scrolled.html
       fast/scrolling/rtl-scrollbars-text-selection.html

* platform/ScrollView.cpp:
(WebCore::ScrollView::documentScrollPositionRelativeToViewOrigin):

LayoutTests:

Add a bunch of tests. Also, this patch adds some tests that caught
https://bugs.webkit.org/show_bug.cgi?id=155533 (but they are disabled).

* fast/scrolling/rtl-scrollbars-elementFromPoint-expected.txt: Added.
* fast/scrolling/rtl-scrollbars-elementFromPoint-static-expected.txt: Added.
* fast/scrolling/rtl-scrollbars-elementFromPoint-static.html: Added.
* fast/scrolling/rtl-scrollbars-elementFromPoint.html: Added.
* fast/scrolling/rtl-scrollbars-iframe-expected.txt: Added.
* fast/scrolling/rtl-scrollbars-iframe-offset-expected.html: Added.
* fast/scrolling/rtl-scrollbars-iframe-offset.html: Added.
* fast/scrolling/rtl-scrollbars-iframe-position-absolute-expected.txt: Added.
* fast/scrolling/rtl-scrollbars-iframe-position-absolute.html: Added.
* fast/scrolling/rtl-scrollbars-iframe-scrolled-expected.html: Added.
* fast/scrolling/rtl-scrollbars-iframe-scrolled.html: Added.
* fast/scrolling/rtl-scrollbars-iframe.html: Added.
* fast/scrolling/rtl-scrollbars-overflow-elementFromPoint-expected.txt: Added.
* fast/scrolling/rtl-scrollbars-overflow-elementFromPoint.html: Added.
* fast/scrolling/rtl-scrollbars-overflow-position-absolute-expected.html: Added.
* fast/scrolling/rtl-scrollbars-overflow-position-absolute.html: Added.
* fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled-expected.html: Added.
* fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled.html: Added.
* fast/scrolling/rtl-scrollbars-position-absolute-expected.html: Added.
* fast/scrolling/rtl-scrollbars-position-absolute.html: Added.
* fast/scrolling/rtl-scrollbars-position-fixed-expected.html: Added.
* fast/scrolling/rtl-scrollbars-position-fixed.html: Added.
* fast/scrolling/rtl-scrollbars-text-selection-expected.html: Added.
* fast/scrolling/rtl-scrollbars-text-selection-scrolled-expected.html: Added.
* fast/scrolling/rtl-scrollbars-text-selection-scrolled.html: Added.
* fast/scrolling/rtl-scrollbars-text-selection.html: Added.
* TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@198369 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 4ac669e..0a6991a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,41 @@
+2016-03-17  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [RTL Scrollbars] Position: absolute divs are covered by vertical scrollbar
+        https://bugs.webkit.org/show_bug.cgi?id=155531
+
+        Reviewed by Darin Adler.
+
+        Add a bunch of tests. Also, this patch adds some tests that caught
+        https://bugs.webkit.org/show_bug.cgi?id=155533 (but they are disabled).
+
+        * fast/scrolling/rtl-scrollbars-elementFromPoint-expected.txt: Added.
+        * fast/scrolling/rtl-scrollbars-elementFromPoint-static-expected.txt: Added.
+        * fast/scrolling/rtl-scrollbars-elementFromPoint-static.html: Added.
+        * fast/scrolling/rtl-scrollbars-elementFromPoint.html: Added.
+        * fast/scrolling/rtl-scrollbars-iframe-expected.txt: Added.
+        * fast/scrolling/rtl-scrollbars-iframe-offset-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-iframe-offset.html: Added.
+        * fast/scrolling/rtl-scrollbars-iframe-position-absolute-expected.txt: Added.
+        * fast/scrolling/rtl-scrollbars-iframe-position-absolute.html: Added.
+        * fast/scrolling/rtl-scrollbars-iframe-scrolled-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-iframe-scrolled.html: Added.
+        * fast/scrolling/rtl-scrollbars-iframe.html: Added.
+        * fast/scrolling/rtl-scrollbars-overflow-elementFromPoint-expected.txt: Added.
+        * fast/scrolling/rtl-scrollbars-overflow-elementFromPoint.html: Added.
+        * fast/scrolling/rtl-scrollbars-overflow-position-absolute-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-overflow-position-absolute.html: Added.
+        * fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled.html: Added.
+        * fast/scrolling/rtl-scrollbars-position-absolute-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-position-absolute.html: Added.
+        * fast/scrolling/rtl-scrollbars-position-fixed-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-position-fixed.html: Added.
+        * fast/scrolling/rtl-scrollbars-text-selection-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-text-selection-scrolled-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-text-selection-scrolled.html: Added.
+        * fast/scrolling/rtl-scrollbars-text-selection.html: Added.
+        * TestExpectations:
+
 2016-03-17  Brady Eidson  <beidson@apple.com>
 
         Don't try to restore deleted MemoryIndexes if their owning object store is not restored.
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index 1292207..c57002e 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -988,3 +988,22 @@
 
 ### END OF IndexedDB failures
 ########################################
+
+# RTL Scrollbars are only implemented on certain versions of OS X
+fast/scrolling/rtl-scrollbars.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-simple.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-overflow-contents.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-overflow-dir-rtl.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-overflow-padding.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-overflow-simple.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-overflow.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-overflow-elementFromPoint.html [ Failure ]
+fast/scrolling/rtl-scrollbars-overflow-position-absolute.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-position-absolute.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-position-fixed.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-text-selection-scrolled.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-text-selection.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-iframe-offset.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-elementFromPoint-static.html [ Failure ]
+fast/scrolling/rtl-scrollbars-iframe-scrolled.html [ ImageOnlyFailure ]
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-expected.txt b/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-expected.txt
new file mode 100644
index 0000000..f585d3e
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-expected.txt
@@ -0,0 +1,10 @@
+This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.elementFromPoint(7, 7).id is "a"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-static-expected.txt b/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-static-expected.txt
new file mode 100644
index 0000000..a173841
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-static-expected.txt
@@ -0,0 +1,10 @@
+This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.elementFromPoint(22, 7).id is "a"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-static.html b/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-static.html
new file mode 100644
index 0000000..354cdd9
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint-static.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<div style="overflow: scroll; position: absolute; width: 100px; height: 100px; left: 0px; top: 0px;">
+<div id="a" style="width: 15px; height: 15px; background: green; display: inline-block;"></div><div id="b" style="width: 15px; height: 15px; background: red; display: inline-block;"></div>
+<div style="width: 1px; height: 3000px; position: absolute; left: 0px; top: 0px;"></div>
+</div>
+<script>
+description("This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.");
+shouldBeEqualToString("document.elementFromPoint(22, 7).id", "a");
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint.html b/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint.html
new file mode 100644
index 0000000..e3a8659
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-elementFromPoint.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<div id="a" style="width: 15px; height: 15px; position: absolute; left: 0px; top: 0px; background: green;"></div>
+<div id="b" style="width: 15px; height: 15px; position: absolute; left: 15px; top: 0px; background: red;"></div>
+<div style="width: 1px; height: 3000px; position: absolute; left: 0px; top: 0px;"></div>
+<script>
+description("This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.");
+shouldBeEqualToString("document.elementFromPoint(7, 7).id", "a");
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-expected.txt b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-expected.txt
new file mode 100644
index 0000000..5c30994
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-expected.txt
@@ -0,0 +1,10 @@
+This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS iframeDocument.elementFromPoint(7, 7).id is "a"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-offset-expected.html b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-offset-expected.html
new file mode 100644
index 0000000..28d1766
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-offset-expected.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body>
+<div id="text" style='position: absolute; left: 0px; top: 0px;'>ABCD</div>
+<div style='position: absolute; left: 0px; top: 25px;'>DEFG</div>
+<div style="position: absolute; left: 8px; top: 100px;">This test makes sure that contents of iframes are not covered by an rtl scrollbar.</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-offset.html b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-offset.html
new file mode 100644
index 0000000..c36ff86
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-offset.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body>
+<iframe id="iframe" style="position: absolute; width: 100px; height: 100px; left: -15px; top: 0px; margin: 0px; border: solid black 0px; padding: 0px;"
+srcdoc="<!DOCTYPE html>
+<head>
+</head>
+<body style='margin: 0px;'>
+ABCD
+<div style='position: absolute; left: 0px; top: 25px;'>DEFG</div>
+<div style='width: 1px; height: 2000px; position: absolute; left: 0px; top: 0px;'></div>
+</body>
+</html>"></iframe>
+<div style="position: absolute; left: 8px; top: 100px;">This test makes sure that contents of iframes are not covered by an rtl scrollbar.</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-position-absolute-expected.txt b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-position-absolute-expected.txt
new file mode 100644
index 0000000..5c30994
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-position-absolute-expected.txt
@@ -0,0 +1,10 @@
+This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS iframeDocument.elementFromPoint(7, 7).id is "a"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-position-absolute.html b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-position-absolute.html
new file mode 100644
index 0000000..3279521a
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-position-absolute.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+<script src='../../resources/js-test-pre.js'></script>
+</head>
+<body>
+<iframe id="iframe" style="position: absolute; width: 100px; height: 100px; left: 0px; top: 0px; margin: 0px; border: solid black 0px; padding: 0px;"
+srcdoc="<!DOCTYPE html>
+<head>
+</head>
+<body style='margin: 0px;'>
+<div id='a' style='width: 15px; height: 15px; background: green; position: absolute; left: 0px; top: 0px;'></div><div id='b' style='width: 15px; height: 15px; background: red; position: absolute; left: 15px; top: 0px;'></div>
+<div style='width: 1px; height: 2000px; position: absolute; left: 0px; top: 0px;'></div>
+</body>
+</html>"></iframe>
+<script>
+window.jsTestIsAsync = true;
+var iframe = document.getElementById("iframe");
+var iframeDocument;
+description('This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.');
+iframe.addEventListener("load", function() {
+	window.setTimeout(function() {
+		iframeDocument = iframe.contentDocument;
+		shouldBeEqualToString('iframeDocument.elementFromPoint(7, 7).id', 'a');
+		finishJSTest();
+	}, 0);
+});
+</script>
+<script src='../../resources/js-test-post.js'></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-scrolled-expected.html b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-scrolled-expected.html
new file mode 100644
index 0000000..27ef87e
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-scrolled-expected.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body>
+<iframe id="iframe" style="position: absolute; width: 100px; height: 100px; left: 0px; top: 0px; margin: 0px; border: solid black 0px; padding: 0px;"
+srcdoc="<!DOCTYPE html>
+<head>
+</head>
+<body style='margin: 0px;'>
+<div id='text' style='font: 20px Ahem;'><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>ppp</div>
+<div style='width: 1px; height: 2000px; position: absolute; left: 0px; top: 0px;'></div>
+<script>
+window.scrollTo(0, 1000);
+var text = document.getElementById('text').childNodes[50];
+var selection = window.getSelection();
+selection.removeAllRanges();
+var range = document.createRange();
+range.setStart(text, 0);
+range.setEnd(text, 1);
+selection.addRange(range);
+</script>
+</body>
+</html>"></iframe>
+<script>
+document.getElementById("iframe").focus();
+</script>
+<div style="position: absolute; left: 8px; top: 100px;">This test makes sure that hit testing in iframes works correctly.</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-scrolled.html b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-scrolled.html
new file mode 100644
index 0000000..61ffcdf
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe-scrolled.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body>
+<iframe id="iframe" style="position: absolute; width: 100px; height: 100px; left: 0px; top: 0px; margin: 0px; border: solid black 0px; padding: 0px;"
+srcdoc="<!DOCTYPE html>
+<head>
+</head>
+<body style='margin: 0px;'>
+<div style='font: 20px Ahem;'><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>ppp</div>
+<div style='width: 1px; height: 2000px; position: absolute; left: 0px; top: 0px;'></div>
+<script>
+window.scrollTo(0, 1000);
+if (window.eventSender) {
+    eventSender.mouseMoveTo(17, 10);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(28, 10);
+    eventSender.mouseUp();
+}
+</script>
+</body>
+</html>"></iframe>
+<div style="position: absolute; left: 8px; top: 100px;">This test makes sure that hit testing in iframes works correctly.</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-iframe.html b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe.html
new file mode 100644
index 0000000..384b0bd
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-iframe.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+<script src='../../resources/js-test-pre.js'></script>
+</head>
+<body>
+<iframe id="iframe" style="position: absolute; width: 100px; height: 100px; left: 0px; top: 0px; margin: 0px; border: solid black 0px; padding: 0px;"
+srcdoc="<!DOCTYPE html>
+<head>
+</head>
+<body style='margin: 0px;'>
+<div id='a' style='width: 15px; height: 15px; background: green; display: inline-block;'></div><div id='b' style='width: 15px; height: 15px; background: red; display: inline-block;'></div>
+<div style='width: 1px; height: 2000px; position: absolute; left: 0px; top: 0px;'></div>
+</body>
+</html>"></iframe>
+<script>
+window.jsTestIsAsync = true;
+var iframe = document.getElementById("iframe");
+var iframeDocument;
+description('This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.');
+iframe.addEventListener("load", function() {
+	window.setTimeout(function() {
+		iframeDocument = iframe.contentDocument;
+		shouldBeEqualToString('iframeDocument.elementFromPoint(7, 7).id', 'a');
+		finishJSTest();
+	}, 0);
+});
+</script>
+<script src='../../resources/js-test-post.js'></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-elementFromPoint-expected.txt b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-elementFromPoint-expected.txt
new file mode 100644
index 0000000..a173841
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-elementFromPoint-expected.txt
@@ -0,0 +1,10 @@
+This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.elementFromPoint(22, 7).id is "a"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-elementFromPoint.html b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-elementFromPoint.html
new file mode 100644
index 0000000..d29e275
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-elementFromPoint.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<div style="overflow: scroll; position: absolute; width: 100px; height: 100px; left: 0px; top: 0px;">
+<div id="a" style="width: 15px; height: 15px; position: absolute; left: 0px; top: 0px; background: green;"></div>
+<div id="b" style="width: 15px; height: 15px; position: absolute; left: 15px; top: 0px; background: red;"></div>
+<div style="width: 1px; height: 3000px; position: absolute; left: 0px; top: 0px;"></div>
+</div>
+<script>
+description("This test makes sure that document.elementFromPoint() works correctly with RTL scrollbars.");
+shouldBeEqualToString("document.elementFromPoint(22, 7).id", "a");
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-position-absolute-expected.html b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-position-absolute-expected.html
new file mode 100644
index 0000000..0cc7360
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-position-absolute-expected.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body>
+This test makes sure that position: absolute elements do not overlap the vertical scrollbar on RTL machines. The test passes if you see a green square and a red square below.
+<div style="overflow: hidden; position: relative; width: 85px; height: 85px;">
+<div id="a" style="width: 15px; height: 15px; position: absolute; left: 0px; top: 0px; background: green;"></div>
+<div id="b" style="width: 15px; height: 15px; position: absolute; left: 15px; top: 0px; background: red;"></div>
+<div style="width: 1px; height: 3000px; position: absolute; left: 0px; top: 0px;"></div>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-position-absolute.html b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-position-absolute.html
new file mode 100644
index 0000000..e58617a
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-position-absolute.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body>
+This test makes sure that position: absolute elements do not overlap the vertical scrollbar on RTL machines. The test passes if you see a green square and a red square below.
+<div style="overflow: hidden; position: relative; width: 85px; height: 85px;">
+<div style="overflow: scroll; position: absolute; width: 100px; height: 100px; left: -15px; bottom: -15px;">
+<div id="a" style="width: 15px; height: 15px; position: absolute; left: 0px; top: 0px; background: green;"></div>
+<div id="b" style="width: 15px; height: 15px; position: absolute; left: 15px; top: 0px; background: red;"></div>
+<div style="width: 1px; height: 3000px; position: absolute; left: 0px; top: 0px;"></div>
+</div>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled-expected.html b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled-expected.html
new file mode 100644
index 0000000..43ecb07
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled-expected.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div id="text" style="font: 20px Ahem; width: 700px;">pppppppppppppp
+<div style="font-family: Times;">This test makes sure that hit-testing in a scrolled overflow:scroll area works as expected. The test succeeds if the first character is selected.</div>
+</div>
+<script>
+var text = document.getElementById("text").childNodes[0];
+var selection = window.getSelection();
+selection.removeAllRanges();
+var range = document.createRange();
+range.setStart(text, 0);
+range.setEnd(text, 1);
+selection.addRange(range);
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled.html b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled.html
new file mode 100644
index 0000000..599bb8b5
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div style="overflow: hidden; width: 100%; height: 485px; position: absolute; left: -15px;">
+<div id="element" style="overflow: scroll; width: 700px; height: 500px; position: relative;">
+<div id="text" style="font: 20px Ahem;"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>pppppppppppppp
+<div style="font-family: Times;">This test makes sure that hit-testing in a scrolled overflow:scroll area works as expected. The test succeeds if the first character is selected.</div>
+<div style="width: 1px; height: 2000px; position: absolute; left: 0px; top: 0px;"></div>
+</div>
+</div>
+<script>
+var element = document.getElementById("element");
+element.scrollTop = 1000;
+if (window.eventSender) {
+    eventSender.mouseMoveTo(1, 10);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(19, 10);
+    eventSender.mouseUp();
+}
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-position-absolute-expected.html b/LayoutTests/fast/scrolling/rtl-scrollbars-position-absolute-expected.html
new file mode 100644
index 0000000..4f26609
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-position-absolute-expected.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div id="text" style="font: 20px Ahem; position: absolute; left: 100px;">pppppppppppppp</div>
+<div style="position: absolute; left: 0px; top: 20px;">This test makes sure that hit testing works with rtl scrollbars. The test passes if the first character above (it looks like an underline) is selected.</div>
+<div style="width: 1px; height: 1000px;"></div>
+<script>
+var text = document.getElementById("text").childNodes[0];
+var selection = window.getSelection();
+selection.removeAllRanges();
+var range = document.createRange();
+range.setStart(text, 0);
+range.setEnd(text, 1);
+selection.addRange(range);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-position-absolute.html b/LayoutTests/fast/scrolling/rtl-scrollbars-position-absolute.html
new file mode 100644
index 0000000..96c1679
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-position-absolute.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div id="text" style="font: 20px Ahem; position: absolute; left: 100px;">pppppppppppppp</div>
+<div style="position: absolute; left: 0px; top: 20px;">This test makes sure that hit testing works with rtl scrollbars. The test passes if the first character above (it looks like an underline) is selected.</div>
+<div style="width: 1px; height: 1000px;"></div>
+<script>
+if (window.eventSender) {
+    eventSender.mouseMoveTo(117, 10);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(128, 10);
+    eventSender.mouseUp();
+}
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-position-fixed-expected.html b/LayoutTests/fast/scrolling/rtl-scrollbars-position-fixed-expected.html
new file mode 100644
index 0000000..41017ad
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-position-fixed-expected.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div id="text" style="font: 20px Ahem; position: fixed; left: 100px;">pppppppppppppp</div>
+<div style="position: absolute; left: 0px; top: 20px;">This test makes sure that hit testing works with rtl scrollbars. The test passes if the first character above (it looks like an underline) is selected.</div>
+<div style="width: 1px; height: 1000px;"></div>
+<script>
+var text = document.getElementById("text").childNodes[0];
+var selection = window.getSelection();
+selection.removeAllRanges();
+var range = document.createRange();
+range.setStart(text, 0);
+range.setEnd(text, 1);
+selection.addRange(range);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-position-fixed.html b/LayoutTests/fast/scrolling/rtl-scrollbars-position-fixed.html
new file mode 100644
index 0000000..e7f01b3
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-position-fixed.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div id="text" style="font: 20px Ahem; position: fixed; left: 100px;">pppppppppppppp</div>
+<div style="position: absolute; left: 0px; top: 20px;">This test makes sure that hit testing works with rtl scrollbars. The test passes if the first character above (it looks like an underline) is selected.</div>
+<div style="width: 1px; height: 1000px;"></div>
+<script>
+if (window.eventSender) {
+    eventSender.mouseMoveTo(117, 10);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(128, 10);
+    eventSender.mouseUp();
+}
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-expected.html b/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-expected.html
new file mode 100644
index 0000000..7ef5e3e
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-expected.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div id="text" style="font: 20px Ahem;">pppppppppppppp</div>
+This test makes sure that hit testing works with rtl scrollbars. The test passes if the first character above (it looks like an underline) is selected.
+<div style="width: 1px; height: 1000px;"></div>
+<script>
+var text = document.getElementById("text").childNodes[0];
+var selection = window.getSelection();
+selection.removeAllRanges();
+var range = document.createRange();
+range.setStart(text, 0);
+range.setEnd(text, 1);
+selection.addRange(range);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-scrolled-expected.html b/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-scrolled-expected.html
new file mode 100644
index 0000000..ed6b3d4
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-scrolled-expected.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div id="text" style="font: 20px Ahem;"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>pppppppppppppp</div>
+<div style="position: absolute; top: 0px; left: 0px;">This test makes sure that hit testing works with rtl scrollbars. The test passes if the first character above (it looks like an underline) is selected.</div>
+<div style="position: absolute; top: 0px; left: 0px; width: 1px; height: 2000px;"></div>
+<script>
+window.scrollTo(0, 1000);
+var text = document.getElementById("text").childNodes[50];
+var selection = window.getSelection();
+selection.removeAllRanges();
+var range = document.createRange();
+range.setStart(text, 0);
+range.setEnd(text, 1);
+selection.addRange(range);
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-scrolled.html b/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-scrolled.html
new file mode 100644
index 0000000..557b23b
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection-scrolled.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div style="font: 20px Ahem;"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>pppppppppppppp</div>
+<div style="position: absolute; top: 0px; left: 0px;">This test makes sure that hit testing works with rtl scrollbars. The test passes if the first character above (it looks like an underline) is selected.</div>
+<div style="position: absolute; top: 0px; left: 0px; width: 1px; height: 2000px;"></div>
+<script>
+window.scrollTo(0, 1000);
+if (window.eventSender) {
+    eventSender.mouseMoveTo(17, 10);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(28, 10);
+    eventSender.mouseUp();
+}
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection.html b/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection.html
new file mode 100644
index 0000000..4dbc88a
--- /dev/null
+++ b/LayoutTests/fast/scrolling/rtl-scrollbars-text-selection.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+</head>
+<body style="margin: 0px;">
+<div style="font: 20px Ahem;">pppppppppppppp</div>
+This test makes sure that hit testing works with rtl scrollbars. The test passes if the first character above (it looks like an underline) is selected.
+<div style="width: 1px; height: 1000px;"></div>
+<script>
+if (window.eventSender) {
+    eventSender.mouseMoveTo(17, 10);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(28, 10);
+    eventSender.mouseUp();
+}
+</script>
+</body>
+</html>
diff --git a/LayoutTests/platform/efl/TestExpectations b/LayoutTests/platform/efl/TestExpectations
index df9db6c..351ce0e 100644
--- a/LayoutTests/platform/efl/TestExpectations
+++ b/LayoutTests/platform/efl/TestExpectations
@@ -2957,14 +2957,6 @@
 
 webkit.org/b/153772 fast/shadow-dom/slot-removal-crash-2.html [ Timeout ]
 
-# RTL Scrollbars are only implemented on OS X
-fast/scrolling/rtl-scrollbars.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-contents.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-dir-rtl.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-padding.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow.html [ ImageOnlyFailure ]
-
 webkit.org/b/155505 http/tests/security/contentSecurityPolicy/userAgentShadowDOM/allow-audio.html [ Skip ]
 webkit.org/b/155505 webkit.org/b/153866 http/tests/security/contentSecurityPolicy/userAgentShadowDOM/allow-video.html [ Skip ]
+
diff --git a/LayoutTests/platform/gtk/TestExpectations b/LayoutTests/platform/gtk/TestExpectations
index dbff94e..31222d5 100644
--- a/LayoutTests/platform/gtk/TestExpectations
+++ b/LayoutTests/platform/gtk/TestExpectations
@@ -2705,12 +2705,3 @@
 
 # This test relies on iOS-specific font fallback.
 fast/text/arabic-blacklisted-expected.html [ Pass ImageOnlyFailure ]
-
-# RTL Scrollbars are only implemented on OS X
-fast/scrolling/rtl-scrollbars.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-contents.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-dir-rtl.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-padding.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow.html [ ImageOnlyFailure ]
diff --git a/LayoutTests/platform/ios-simulator/TestExpectations b/LayoutTests/platform/ios-simulator/TestExpectations
index 846db4c..d9888f4 100644
--- a/LayoutTests/platform/ios-simulator/TestExpectations
+++ b/LayoutTests/platform/ios-simulator/TestExpectations
@@ -2993,15 +2993,6 @@
 
 webkit.org/b/155271 [ Debug ] js/regress/getter-richards-try-catch.html [ Skip ]
 
-# RTL Scrollbars are only implemented on OS X.
-fast/scrolling/rtl-scrollbars.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-contents.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-dir-rtl.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-padding.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow.html [ ImageOnlyFailure ]
-
 webkit.org/b/155372 [ Debug ] css3/masking/mask-luminance-svg.html [ Pass Crash ]
 webkit.org/b/155372 [ Debug ] css3/masking/mask-svg-script-none-to-png.html [ Pass Crash ]
 
diff --git a/LayoutTests/platform/mac-wk1/TestExpectations b/LayoutTests/platform/mac-wk1/TestExpectations
index 557cf80..2abaca9 100644
--- a/LayoutTests/platform/mac-wk1/TestExpectations
+++ b/LayoutTests/platform/mac-wk1/TestExpectations
@@ -197,12 +197,3 @@
 
 # This test checks ScrollAnimator events only for main frame scrollbars that use native widgets in WK1.
 fast/scrolling/scroll-animator-overlay-scrollbars-hovered.html [ Skip ]
-
-# RTL Scrollbars are only implemented in WK2
-fast/scrolling/rtl-scrollbars.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-contents.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-dir-rtl.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-padding.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow.html [ ImageOnlyFailure ]
diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations
index a61e3de..6c592b1 100644
--- a/LayoutTests/platform/mac/TestExpectations
+++ b/LayoutTests/platform/mac/TestExpectations
@@ -1334,15 +1334,6 @@
 
 webkit.org/b/155140 js/promises-tests/promises-tests-2-3-3.html [ Pass Failure ]
 
-# RTL Scrollbars are only implemented on certain OSes.
-[ Yosemite ElCapitan ] fast/scrolling/rtl-scrollbars.html [ ImageOnlyFailure ]
-[ Yosemite ElCapitan ] fast/scrolling/rtl-scrollbars-simple.html [ ImageOnlyFailure ]
-[ Yosemite ElCapitan ] fast/scrolling/rtl-scrollbars-overflow-contents.html [ ImageOnlyFailure ]
-[ Yosemite ElCapitan ] fast/scrolling/rtl-scrollbars-overflow-dir-rtl.html [ ImageOnlyFailure ]
-[ Yosemite ElCapitan ] fast/scrolling/rtl-scrollbars-overflow-padding.html [ ImageOnlyFailure ]
-[ Yosemite ElCapitan ] fast/scrolling/rtl-scrollbars-overflow-simple.html [ ImageOnlyFailure ]
-[ Yosemite ElCapitan ] fast/scrolling/rtl-scrollbars-overflow.html [ ImageOnlyFailure ]
-
 # Content Security Policy for media redirects is not supported on some OSes.
 [ Yosemite ElCapitan ] http/tests/security/contentSecurityPolicy/audio-redirect-blocked.html [ Failure ]
 [ Yosemite ElCapitan ] http/tests/security/contentSecurityPolicy/video-redirect-blocked.html [ Failure ]
@@ -1351,3 +1342,4 @@
 webkit.org/b/155505 [ ElCapitan+ ] http/tests/security/contentSecurityPolicy/userAgentShadowDOM/allow-video.html [ Skip ]
 
 webkit.org/b/154688 inspector/controller/runtime-controller.html [ Pass Timeout ]
+
diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations
index 66812a8..a91750f 100644
--- a/LayoutTests/platform/win/TestExpectations
+++ b/LayoutTests/platform/win/TestExpectations
@@ -3360,12 +3360,3 @@
 
 # This test relies on iOS-specific font fallback.
 fast/text/arabic-blacklisted-expected.html [ Pass ImageOnlyFailure ]
-
-# RTL Scrollbars are only implemented on OS X
-fast/scrolling/rtl-scrollbars.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-contents.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-dir-rtl.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-padding.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow-simple.html [ ImageOnlyFailure ]
-fast/scrolling/rtl-scrollbars-overflow.html [ ImageOnlyFailure ]
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index b0d0d0d..3b0df95 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2016-03-17  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [RTL Scrollbars] Position: absolute divs are covered by vertical scrollbar
+        https://bugs.webkit.org/show_bug.cgi?id=155531
+
+        Reviewed by Darin Adler.
+
+        This patch updates ScrollView::documentScrollPositionRelativeToViewOrigin(), which is
+        a helper function primarily used by WebCore::ScrollView::viewToContents() and
+        WebCore::ScrollView::contentsToView().
+
+        Tests: fast/scrolling/rtl-scrollbars-elementFromPoint-static.html
+               fast/scrolling/rtl-scrollbars-elementFromPoint.html
+               fast/scrolling/rtl-scrollbars-iframe-offset.html
+               fast/scrolling/rtl-scrollbars-iframe-position-absolute.html
+               fast/scrolling/rtl-scrollbars-iframe-scrolled.html
+               fast/scrolling/rtl-scrollbars-iframe.html
+               fast/scrolling/rtl-scrollbars-overflow-elementFromPoint.html
+               fast/scrolling/rtl-scrollbars-overflow-position-absolute.html
+               fast/scrolling/rtl-scrollbars-overflow-text-selection-scrolled.html
+               fast/scrolling/rtl-scrollbars-position-absolute.html
+               fast/scrolling/rtl-scrollbars-position-fixed.html
+               fast/scrolling/rtl-scrollbars-text-selection-scrolled.html
+               fast/scrolling/rtl-scrollbars-text-selection.html
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::documentScrollPositionRelativeToViewOrigin):
+
 2016-03-17  Filip Pizlo  <fpizlo@apple.com>
 
         Replace all of the various non-working and non-compiling sampling profiler hacks with a single super hack
diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp
index 22251b5..bb7f835 100644
--- a/Source/WebCore/platform/ScrollView.cpp
+++ b/Source/WebCore/platform/ScrollView.cpp
@@ -404,7 +404,9 @@
 
 ScrollPosition ScrollView::documentScrollPositionRelativeToViewOrigin() const
 {
-    return scrollPosition() - IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset));
+    return scrollPosition() - IntSize(
+        verticalScrollbarIsOnLeft() && m_verticalScrollbar ? m_verticalScrollbar->occupiedWidth() : 0,
+        headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset));
 }
 
 ScrollPosition ScrollView::documentScrollPositionRelativeToScrollableAreaOrigin() const
@@ -709,7 +711,7 @@
         int clientWidth = visibleWidth();
         int pageStep = Scrollbar::pageStep(clientWidth);
         IntRect oldRect(m_horizontalScrollbar->frameRect());
-        IntRect hBarRect(ScrollableArea::systemLanguageIsRTL() && m_verticalScrollbar ? m_verticalScrollbar->occupiedWidth() : 0,
+        IntRect hBarRect(verticalScrollbarIsOnLeft() && m_verticalScrollbar ? m_verticalScrollbar->occupiedWidth() : 0,
             height() - m_horizontalScrollbar->height(),
             width() - (m_verticalScrollbar ? m_verticalScrollbar->occupiedWidth() : 0),
             m_horizontalScrollbar->height());
@@ -730,7 +732,7 @@
         int clientHeight = visibleHeight();
         int pageStep = Scrollbar::pageStep(clientHeight);
         IntRect oldRect(m_verticalScrollbar->frameRect());
-        IntRect vBarRect(ScrollableArea::systemLanguageIsRTL() ? 0 : width() - m_verticalScrollbar->width(),
+        IntRect vBarRect(verticalScrollbarIsOnLeft() ? 0 : width() - m_verticalScrollbar->width(),
             topContentInset(),
             m_verticalScrollbar->width(),
             height() - topContentInset() - (m_horizontalScrollbar ? m_horizontalScrollbar->occupiedHeight() : 0));
@@ -1124,14 +1126,14 @@
     int heightTrackedByScrollbar = height() - topContentInset();
 
     if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
-        cornerRect.unite(IntRect(ScrollableArea::systemLanguageIsRTL() ? 0 : m_horizontalScrollbar->width(),
+        cornerRect.unite(IntRect(verticalScrollbarIsOnLeft() ? 0 : m_horizontalScrollbar->width(),
             height() - m_horizontalScrollbar->height(),
             width() - m_horizontalScrollbar->width(),
             m_horizontalScrollbar->height()));
     }
 
     if (m_verticalScrollbar && heightTrackedByScrollbar - m_verticalScrollbar->height() > 0) {
-        cornerRect.unite(IntRect(ScrollableArea::systemLanguageIsRTL() ? 0 : width() - m_verticalScrollbar->width(),
+        cornerRect.unite(IntRect(verticalScrollbarIsOnLeft() ? 0 : width() - m_verticalScrollbar->width(),
             m_verticalScrollbar->height() + topContentInset(),
             m_verticalScrollbar->width(),
             heightTrackedByScrollbar - m_verticalScrollbar->height()));
diff --git a/Source/WebCore/platform/ScrollableArea.cpp b/Source/WebCore/platform/ScrollableArea.cpp
index 4e08f64..936553b 100644
--- a/Source/WebCore/platform/ScrollableArea.cpp
+++ b/Source/WebCore/platform/ScrollableArea.cpp
@@ -690,6 +690,11 @@
 }
 
 #if !PLATFORM(COCOA)
+bool ScrollableArea::verticalScrollbarIsOnLeft() const
+{
+    return false;
+}
+
 bool ScrollableArea::systemLanguageIsRTL()
 {
     return false;
diff --git a/Source/WebCore/platform/ScrollableArea.h b/Source/WebCore/platform/ScrollableArea.h
index f35cb8d..8f8e83c 100644
--- a/Source/WebCore/platform/ScrollableArea.h
+++ b/Source/WebCore/platform/ScrollableArea.h
@@ -312,6 +312,7 @@
     virtual bool usesMockScrollAnimator() const { return false; }
     virtual void logMockScrollAnimatorMessage(const String&) const { };
 
+    bool verticalScrollbarIsOnLeft() const;
     static bool systemLanguageIsRTL();
 
 protected:
diff --git a/Source/WebCore/platform/mac/ScrollableAreaMac.mm b/Source/WebCore/platform/mac/ScrollableAreaMac.mm
index 46df7ca..27e55ae 100644
--- a/Source/WebCore/platform/mac/ScrollableAreaMac.mm
+++ b/Source/WebCore/platform/mac/ScrollableAreaMac.mm
@@ -37,6 +37,13 @@
 
 namespace WebCore {
 
+// It's conceivable that in the future, we may want some scrollbars to be on the right while other scrollbars in the same document are on the left.
+// This non-static function on the ScrollableArea makes that possible.
+bool ScrollableArea::verticalScrollbarIsOnLeft() const
+{
+    return systemLanguageIsRTL();
+}
+
 bool ScrollableArea::systemLanguageIsRTL()
 {
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp
index dad6d9e..c3de3e6 100644
--- a/Source/WebCore/rendering/RenderLayerCompositor.cpp
+++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp
@@ -1759,9 +1759,11 @@
 
 FloatPoint RenderLayerCompositor::positionForClipLayer() const
 {
+    FrameView& frameView = m_renderView.frameView();
+
     return FloatPoint(
-        ScrollableArea::systemLanguageIsRTL() ? m_renderView.frameView().horizontalScrollbarIntrusion() : 0,
-        FrameView::yPositionForInsetClipLayer(m_renderView.frameView().scrollPosition(), m_renderView.frameView().topContentInset()));
+        frameView.verticalScrollbarIsOnLeft() ? frameView.horizontalScrollbarIntrusion() : 0,
+        FrameView::yPositionForInsetClipLayer(frameView.scrollPosition(), frameView.topContentInset()));
 }
 
 void RenderLayerCompositor::frameViewDidScroll()