<https://webkit.org/b/106133> document.body.scrollTop & document.documentElement...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Aug 2013 17:48:49 +0000 (17:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Aug 2013 17:48:49 +0000 (17:48 +0000)
Patch by Gurpreet Kaur <gur.trio@gmail.com> on 2013-08-26
Reviewed by Darin Adler.

Source/WebCore:

Webkit always uses document.body.scrollTop whether quirks or
standard mode. Similiar behaviour is for document.body.scrollLeft.
As per the specification webkit should return document.body.scrollTop
for quirks mode and document.documentElement.scrollTop for standard mode.
Same for document.body.scrollLeft and document.documentElement.scrollLeft.

Tests: fast/dom/Element/scrollLeft-Quirks.html
       fast/dom/Element/scrollLeft.html
       fast/dom/Element/scrollTop-Quirks.html
       fast/dom/Element/scrollTop.html

* dom/Element.cpp:
(WebCore::Element::scrollLeft):
(WebCore::Element::scrollTop):
If the element does not have any associated CSS layout box or the element
is the root element and the Document is in quirks mode return zero.
Else If the element is the root element return the value of scrollY
for scrollTop and scrollX for scrollLeft.
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::scrollLeft):
(WebCore::HTMLBodyElement::scrollTop):
If the element is the HTML body element, the Document is in quirks mode,
return the value of scrollY for scrollTop and scrollX for scrollLeft.

LayoutTests:

* fast/dom/Element/scrollLeft-Quirks-expected.txt: Added.
* fast/dom/Element/scrollLeft-Quirks.html: Added.
* fast/dom/Element/scrollLeft-expected.txt: Added.
* fast/dom/Element/scrollLeft.html: Added.
* fast/dom/Element/scrollTop-Quirks-expected.txt: Added.
* fast/dom/Element/scrollTop-Quirks.html: Added.
* fast/dom/Element/scrollTop-expected.txt: Added.
* fast/dom/Element/scrollTop.html: Added.
Added new tests for verifying our behavior for document.body.scrollTop/scrollLeft and
document.documentElement.scrollTop/scrollLeft for both Quirks as well as Standard mode.

* fast/css/zoom-body-scroll-expected.txt:
* fast/css/zoom-body-scroll.html:
* fast/events/mouse-cursor.html:
* http/tests/navigation/anchor-frames-expected.txt:
* http/tests/navigation/anchor-frames-gbk-expected.txt:
* http/tests/navigation/resources/frame-with-anchor-gbk.html:
* http/tests/navigation/resources/frame-with-anchor-same-origin.html:
* http/tests/navigation/resources/frame-with-anchor.html:
* platform/mac-wk2/tiled-drawing/resources/scroll-and-load-page.html:
* platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html:
* platform/win/fast/css/zoom-body-scroll-expected.txt:
Rebaselining existing tests as per the new behavior. The test cases are changed to use
quirks mode because it uses document.body.scrollTop/scrollLeft and as per the new code
document.body.scrollTop/scrollLeft will return correct value if document is in quirk mode
Also test cases have been modified so that it tests what it used to.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154614 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/zoom-body-scroll-expected.txt
LayoutTests/fast/css/zoom-body-scroll.html
LayoutTests/fast/dom/Element/scrollLeft-Quirks-expected.txt [new file with mode: 0755]
LayoutTests/fast/dom/Element/scrollLeft-Quirks.html [new file with mode: 0755]
LayoutTests/fast/dom/Element/scrollLeft-expected.txt [new file with mode: 0755]
LayoutTests/fast/dom/Element/scrollLeft.html [new file with mode: 0755]
LayoutTests/fast/dom/Element/scrollTop-Quirks-expected.txt [new file with mode: 0755]
LayoutTests/fast/dom/Element/scrollTop-Quirks.html [new file with mode: 0755]
LayoutTests/fast/dom/Element/scrollTop-expected.txt [new file with mode: 0755]
LayoutTests/fast/dom/Element/scrollTop.html [new file with mode: 0755]
LayoutTests/fast/events/mouse-cursor.html
LayoutTests/http/tests/navigation/anchor-frames-expected.txt
LayoutTests/http/tests/navigation/anchor-frames-gbk-expected.txt
LayoutTests/http/tests/navigation/resources/frame-with-anchor-gbk.html
LayoutTests/http/tests/navigation/resources/frame-with-anchor-same-origin.html
LayoutTests/http/tests/navigation/resources/frame-with-anchor.html
LayoutTests/platform/mac-wk2/tiled-drawing/resources/scroll-and-load-page.html
LayoutTests/platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html
LayoutTests/platform/win/fast/css/zoom-body-scroll-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/html/HTMLBodyElement.cpp

index 6024de2..bfca3d0 100644 (file)
@@ -1,3 +1,36 @@
+2013-08-26  Gurpreet Kaur  <gur.trio@gmail.com>
+
+        <https://webkit.org/b/106133> document.body.scrollTop & document.documentElement.scrollTop differ cross-browser
+
+        Reviewed by Darin Adler.
+
+        * fast/dom/Element/scrollLeft-Quirks-expected.txt: Added.
+        * fast/dom/Element/scrollLeft-Quirks.html: Added.
+        * fast/dom/Element/scrollLeft-expected.txt: Added.
+        * fast/dom/Element/scrollLeft.html: Added.
+        * fast/dom/Element/scrollTop-Quirks-expected.txt: Added.
+        * fast/dom/Element/scrollTop-Quirks.html: Added.
+        * fast/dom/Element/scrollTop-expected.txt: Added.
+        * fast/dom/Element/scrollTop.html: Added.
+        Added new tests for verifying our behavior for document.body.scrollTop/scrollLeft and
+        document.documentElement.scrollTop/scrollLeft for both Quirks as well as Standard mode.
+
+        * fast/css/zoom-body-scroll-expected.txt:
+        * fast/css/zoom-body-scroll.html:
+        * fast/events/mouse-cursor.html:
+        * http/tests/navigation/anchor-frames-expected.txt:
+        * http/tests/navigation/anchor-frames-gbk-expected.txt:
+        * http/tests/navigation/resources/frame-with-anchor-gbk.html:
+        * http/tests/navigation/resources/frame-with-anchor-same-origin.html:
+        * http/tests/navigation/resources/frame-with-anchor.html:
+        * platform/mac-wk2/tiled-drawing/resources/scroll-and-load-page.html:
+        * platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html:
+        * platform/win/fast/css/zoom-body-scroll-expected.txt: 
+        Rebaselining existing tests as per the new behavior. The test cases are changed to use
+        quirks mode because it uses document.body.scrollTop/scrollLeft and as per the new code 
+        document.body.scrollTop/scrollLeft will return correct value if document is in quirk mode
+        Also test cases have been modified so that it tests what it used to.
+
 2013-08-26  Gavin Barraclough  <barraclough@apple.com>
 
         RegExpMatchesArray should not call [[put]]
index 7403b56..f960e57 100644 (file)
@@ -9,7 +9,7 @@ scrollLeft: 50
 Zooming in
 scrollHeight: 1000
 scrollWidth: 1000
-scrollTop: 0
+scrollTop: 100
 scrollLeft: 50
 
 Scrolling down to 100
index fce7b4c..1a180d2 100644 (file)
@@ -1,6 +1,5 @@
-<!DOCTYPE HTML>
 <html>
-<body>
+<body onload="bodyScroll()">
     <div style="width: 1000px; height: 1000px; position: absolute; top: 0; left: 0;"></div>
     <div style="width: 100px; height: 100px; position: absolute; top: 100px; left: 0; background: green"></div>
     <p>
             console.appendChild(document.createTextNode(message + "\n"));
         }
 
-        if (window.testRunner) {
-            testRunner.dumpAsText();
-            var body = document.body;
-            log("scrollHeight: " + body.scrollHeight);
-            log("scrollWidth: " + body.scrollWidth);
+        function bodyScroll() {
+            if (window.testRunner) {
+                testRunner.dumpAsText();
+                var body = document.body;
+                window.scrollTo(50,100);
+                log("scrollHeight: " + body.scrollHeight);
+                log("scrollWidth: " + body.scrollWidth);
 
-            log("\nScrolling right to 50");
-            body.scrollLeft = 50;
-            log("scrollLeft: " + body.scrollLeft);
+                log("\nScrolling right to 50");
+                body.scrollLeft = 50;
+                log("scrollLeft: " + body.scrollLeft);
 
-            log("\nZooming in");
-            eventSender.zoomPageIn();
-            log("scrollHeight: " + body.scrollHeight);
-            log("scrollWidth: " + body.scrollWidth);
-            log("scrollTop: " + body.scrollTop);
-            log("scrollLeft: " + body.scrollLeft);
+                log("\nZooming in");
+                eventSender.zoomPageIn();
+                log("scrollHeight: " + body.scrollHeight);
+                log("scrollWidth: " + body.scrollWidth);
+                log("scrollTop: " + body.scrollTop);
+                log("scrollLeft: " + body.scrollLeft);
 
-            log("\nScrolling down to 100");
-            body.scrollTop = 100;
-            log("scrollTop: " + body.scrollTop);
+                log("\nScrolling down to 100");
+                body.scrollTop = 100;
+                log("scrollTop: " + body.scrollTop);
 
-            log("\nZooming back out");
-            eventSender.zoomPageOut();
-            log("scrollTop: " + body.scrollTop);
-            log("scrollLeft: " + body.scrollLeft);
+                log("\nZooming back out");
+                eventSender.zoomPageOut();
+                log("scrollTop: " + body.scrollTop);
+                log("scrollLeft: " + body.scrollLeft);
+                       }
         }
     </script>
 </body>
diff --git a/LayoutTests/fast/dom/Element/scrollLeft-Quirks-expected.txt b/LayoutTests/fast/dom/Element/scrollLeft-Quirks-expected.txt
new file mode 100755 (executable)
index 0000000..ee1cdb3
--- /dev/null
@@ -0,0 +1,12 @@
+Tests that for quirks mode document.body.scrollLeft returns the scroll left value
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.pageXOffset is 500
+PASS document.body.scrollLeft is 500
+PASS document.documentElement.scrollLeft is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Element/scrollLeft-Quirks.html b/LayoutTests/fast/dom/Element/scrollLeft-Quirks.html
new file mode 100755 (executable)
index 0000000..e31bacf
--- /dev/null
@@ -0,0 +1,29 @@
+<html>\r
+    <head>\r
+        <style>\r
+            div {\r
+                height: 9999px;\r
+                width:9999px;\r
+            }\r
+        </style>\r
+        <script src="../../js/resources/js-test-pre.js"></script>\r
+        <script>\r
+            function runTest() {\r
+                description('Tests that for quirks mode document.body.scrollLeft returns the scroll left value');\r
+\r
+                setTimeout(function() {\r
+                    window.scrollTo(500,0);\r
+                    shouldBe("window.pageXOffset","500");\r
+                    shouldBe("document.body.scrollLeft","500");\r
+                    shouldBe("document.documentElement.scrollLeft","0");\r
+                    finishJSTest();\r
+                }, 0);\r
+            }\r
+            var jsTestIsAsync = true;\r
+        </script>\r
+    </head>\r
+    <body onload="runTest()">\r
+        <div></div>\r
+        <script src="../../js/resources/js-test-post.js"></script>\r
+    </body>\r
+</html>\r
diff --git a/LayoutTests/fast/dom/Element/scrollLeft-expected.txt b/LayoutTests/fast/dom/Element/scrollLeft-expected.txt
new file mode 100755 (executable)
index 0000000..0a23454
--- /dev/null
@@ -0,0 +1,12 @@
+Tests that for standard mode document.documentElement.scrollLeft returns the scroll left value
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.pageXOffset is 500
+PASS document.body.scrollLeft is 0
+PASS document.documentElement.scrollLeft is 500
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Element/scrollLeft.html b/LayoutTests/fast/dom/Element/scrollLeft.html
new file mode 100755 (executable)
index 0000000..9a6fa3f
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>\r
+<html>\r
+    <head>\r
+        <style>\r
+            div {\r
+                height: 9999px;\r
+                width:9999px;\r
+            }\r
+        </style>\r
+        <script src="../../js/resources/js-test-pre.js"></script>\r
+        <script>\r
+            function runTest() {\r
+                description('Tests that for standard mode document.documentElement.scrollLeft returns the scroll left value');\r
+\r
+                setTimeout(function() {\r
+                    window.scrollTo(500,0);\r
+                    shouldBe("window.pageXOffset","500");\r
+                    shouldBe("document.body.scrollLeft","0");\r
+                    shouldBe("document.documentElement.scrollLeft","500");\r
+                    finishJSTest();\r
+                }, 0);\r
+            }\r
+            var jsTestIsAsync = true;\r
+        </script>\r
+    </head>\r
+    <body onload="runTest()">\r
+        <div></div>\r
+        <script src="../../js/resources/js-test-post.js"></script>\r
+    </body>\r
+</html>\r
diff --git a/LayoutTests/fast/dom/Element/scrollTop-Quirks-expected.txt b/LayoutTests/fast/dom/Element/scrollTop-Quirks-expected.txt
new file mode 100755 (executable)
index 0000000..c233e40
--- /dev/null
@@ -0,0 +1,12 @@
+Tests that for quirks mode document.body.scrollTop returns the scroll top value
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.pageYOffset is 500
+PASS document.body.scrollTop is 500
+PASS document.documentElement.scrollTop is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Element/scrollTop-Quirks.html b/LayoutTests/fast/dom/Element/scrollTop-Quirks.html
new file mode 100755 (executable)
index 0000000..6016ad3
--- /dev/null
@@ -0,0 +1,29 @@
+<html>\r
+    <head>\r
+        <style>\r
+            div {\r
+                height: 9999px;\r
+                width:9999px;\r
+            }\r
+        </style>\r
+        <script src="../../js/resources/js-test-pre.js"></script>\r
+        <script>\r
+            function runTest() {\r
+                description('Tests that for quirks mode document.body.scrollTop returns the scroll top value');\r
+\r
+                setTimeout(function() {\r
+                    window.scrollTo(0,500);\r
+                    shouldBe("window.pageYOffset","500");\r
+                    shouldBe("document.body.scrollTop","500");\r
+                    shouldBe("document.documentElement.scrollTop","0");\r
+                    finishJSTest();\r
+                }, 0);\r
+            }\r
+            var jsTestIsAsync = true;\r
+        </script>\r
+    </head>\r
+    <body onload="runTest()">\r
+        <div></div>\r
+        <script src="../../js/resources/js-test-post.js"></script>\r
+    </body>\r
+</html>\r
diff --git a/LayoutTests/fast/dom/Element/scrollTop-expected.txt b/LayoutTests/fast/dom/Element/scrollTop-expected.txt
new file mode 100755 (executable)
index 0000000..405aed5
--- /dev/null
@@ -0,0 +1,12 @@
+Tests that for standard mode document.documentElement.scrollTop returns the scroll top value
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.pageYOffset is 500
+PASS document.body.scrollTop is 0
+PASS document.documentElement.scrollTop is 500
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Element/scrollTop.html b/LayoutTests/fast/dom/Element/scrollTop.html
new file mode 100755 (executable)
index 0000000..8323780
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>\r
+<html>\r
+    <head>\r
+        <style>\r
+            div {\r
+                height: 9999px;\r
+                width:9999px;\r
+            }\r
+        </style>\r
+        <script src="../../js/resources/js-test-pre.js"></script>\r
+        <script>\r
+            function runTest() {\r
+                description('Tests that for standard mode document.documentElement.scrollTop returns the scroll top value');\r
+\r
+                setTimeout(function() {\r
+                    window.scrollTo(0,500);\r
+                    shouldBe("window.pageYOffset","500");\r
+                    shouldBe("document.body.scrollTop","0");\r
+                    shouldBe("document.documentElement.scrollTop","500");\r
+                    finishJSTest();\r
+                }, 0);\r
+            }\r
+            var jsTestIsAsync = true;\r
+        </script>\r
+    </head>\r
+    <body onload="runTest()">\r
+        <div></div>\r
+        <script src="../../js/resources/js-test-post.js"></script>\r
+    </body>\r
+</html>\r
index 184bfea..fd99d5d 100644 (file)
@@ -1,4 +1,3 @@
-<!DOCTYPE html>
 <html>
 <head>
 <script src="../js/resources/js-test-pre.js"></script>
@@ -9,7 +8,7 @@
 <body>
 <p id="description"></p>
 <p><a href=https://bugs.webkit.org/show_bug.cgi?id=100550>Bug 100550</a></p>
-<svg xmlns="http://www.w3.org/2000/svg" 
+<svg xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0">
   <defs>
     <cursor id="greenbox" xlink:href="resources/greenbox.png" x="0" y="0"/>
@@ -45,7 +44,7 @@
 <script>
 
 var testContainer = document.getElementById('test-container');
-    
+
 function runTests() {
     // Can't do anything useful here without eventSender
     if (window.eventSender) {
@@ -68,7 +67,7 @@ function runTests() {
         // This text is redundant with the test output - hide it
         testContainer.style.display = 'none';
     }
-    
+
     finishJSTest();
 }
 
index fa04134..c6561d8 100644 (file)
@@ -8,7 +8,7 @@ Tests that loading a frame with a URL that contains a fragment pointed at a name
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.body.offsetHeight > document.documentElement.clientHeight is true
+PASS document.body.offsetHeight > window.innerHeight is true
 PASS document.body.scrollTop > 0 is true
 PASS document.body.scrollTop + document.documentElement.clientHeight > 2000 is true
 PASS successfullyParsed is true
index de5dd0c..42daf77 100644 (file)
@@ -8,7 +8,7 @@ Tests that loading a frame with a URL that contains a fragment pointed at a name
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.body.offsetHeight > document.documentElement.clientHeight is true
+PASS document.body.offsetHeight > window.innerHeight is true
 PASS document.body.scrollTop > 0 is true
 PASS document.body.scrollTop + document.documentElement.clientHeight > 2000 is true
 PASS successfullyParsed is true
index a4b9c5c..42d50e4 100644 (file)
@@ -1,4 +1,3 @@
-<!DOCTYPE html>
 <html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
       setTimeout(function() {
           // Make sure that the body is taller than the viewport (i.e. scrolling is
           // required).
-          shouldBeTrue('document.body.offsetHeight > document.documentElement.clientHeight');
+          shouldBeTrue('document.body.offsetHeight > window.innerHeight');
           
           // We should be scrolled at least a little bit
           shouldBeTrue('document.body.scrollTop > 0');
-          
+
           // And the bottom of the viewable area should be at least 2000 pixels from the top, due to the spacer element above.
           shouldBeTrue('document.body.scrollTop + document.documentElement.clientHeight > 2000');
 
-          finishJSTest();          
+          finishJSTest();
       }, 0);
     }
-    
+
     var jsTestIsAsync = true;
-  </script>  
+  </script>
 </head>
 <body onload="runTest()">
 <p id="description"></p>
index 2ece566..1db5ec5 100644 (file)
@@ -1,4 +1,3 @@
-<!DOCTYPE html>
 <html>
 <head>
   <script src="../../../js-test-resources/js-test-pre.js"></script>
       setTimeout(function() {
           shouldBeTrue('document.body.scrollTop > 0');
           shouldBeTrue('document.body.scrollLeft == 0');
-          finishJSTest();          
+          finishJSTest();
       }, 0);
     }
     var jsTestIsAsync = true;
-  </script>  
+  </script>
 </head>
 <body>
 <!-- large same-origin grandchild frame -->
index f47190b..c494e7c 100644 (file)
@@ -1,4 +1,3 @@
-<!DOCTYPE html>
 <html>
 <head>
   <script src="../../../js-test-resources/js-test-pre.js"></script>
       setTimeout(function() {
           // Make sure that the body is taller than the viewport (i.e. scrolling is
           // required).
-          shouldBeTrue('document.body.offsetHeight > document.documentElement.clientHeight');
-          
+          shouldBeTrue('document.body.offsetHeight > window.innerHeight');
+
           // We should be scrolled at least a little bit
           shouldBeTrue('document.body.scrollTop > 0');
-          
+
           // And the bottom of the viewable area should be at least 2000 pixels from the top, due to the spacer element above.
           shouldBeTrue('document.body.scrollTop + document.documentElement.clientHeight > 2000');
-          
-          finishJSTest();          
+
+          finishJSTest();
       }, 0);
     }
-    
+
     var jsTestIsAsync = true;
-  </script>  
+  </script>
 </head>
 <body onload="runTest()">
 <p id="description"></p>
index ecb90ea..c7155a2 100644 (file)
@@ -1,4 +1,3 @@
-<!DOCTYPE html>
 <html>
 <head>
     <script>
@@ -10,7 +9,7 @@
         }
 
         window.finishedTest = function (layerTree)
-        {   
+        {
             document.getElementById('layers').innerText = layerTree;
             testRunner.notifyDone();
         }
index 7ac0fe9..f960e57 100644 (file)
@@ -9,13 +9,13 @@ scrollLeft: 50
 Zooming in
 scrollHeight: 1000
 scrollWidth: 1000
-scrollTop: 0
+scrollTop: 100
 scrollLeft: 50
 
 Scrolling down to 100
 scrollTop: 100
 
 Zooming back out
-scrollTop: 99
-scrollLeft: 49
+scrollTop: 100
+scrollLeft: 50
 
index f14a3a6..0214274 100644 (file)
@@ -1,3 +1,33 @@
+2013-08-26  Gurpreet Kaur  <gur.trio@gmail.com>
+
+        <https://webkit.org/b/106133> document.body.scrollTop & document.documentElement.scrollTop differ cross-browser
+
+        Reviewed by Darin Adler.
+
+        Webkit always uses document.body.scrollTop whether quirks or
+        standard mode. Similiar behaviour is for document.body.scrollLeft.
+        As per the specification webkit should return document.body.scrollTop
+        for quirks mode and document.documentElement.scrollTop for standard mode.
+        Same for document.body.scrollLeft and document.documentElement.scrollLeft.
+
+        Tests: fast/dom/Element/scrollLeft-Quirks.html
+               fast/dom/Element/scrollLeft.html
+               fast/dom/Element/scrollTop-Quirks.html
+               fast/dom/Element/scrollTop.html
+
+        * dom/Element.cpp:
+        (WebCore::Element::scrollLeft):
+        (WebCore::Element::scrollTop): 
+        If the element does not have any associated CSS layout box or the element
+        is the root element and the Document is in quirks mode return zero.
+        Else If the element is the root element return the value of scrollY
+        for scrollTop and scrollX for scrollLeft.
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::scrollLeft):
+        (WebCore::HTMLBodyElement::scrollTop):
+        If the element is the HTML body element, the Document is in quirks mode,
+        return the value of scrollY for scrollTop and scrollX for scrollLeft.
+
 2013-08-26  Antti Koivisto  <antti@apple.com>
 
         REGRESSION (r154581): Some plugin tests failing in debug bots
index 84a236a..7c60400 100644 (file)
@@ -760,7 +760,16 @@ int Element::clientHeight()
 
 int Element::scrollLeft()
 {
+    if (document()->documentElement() == this && document()->inQuirksMode())
+        return 0;
+
     document()->updateLayoutIgnorePendingStylesheets();
+    if (document()->documentElement() == this) {
+        if (RenderView* renderView = document()->renderView()) {
+            if (FrameView* view = &renderView->frameView())
+                return adjustForAbsoluteZoom(view->scrollX(), renderView);
+        }
+    }
     if (RenderBox* rend = renderBox())
         return adjustForAbsoluteZoom(rend->scrollLeft(), rend);
     return 0;
@@ -768,7 +777,16 @@ int Element::scrollLeft()
 
 int Element::scrollTop()
 {
+    if (document()->documentElement() == this && document()->inQuirksMode())
+        return 0;
+
     document()->updateLayoutIgnorePendingStylesheets();
+    if (document()->documentElement() == this) {
+        if (RenderView* renderView = document()->renderView()) {
+            if (FrameView* view = &renderView->frameView())
+                return adjustForAbsoluteZoom(view->scrollY(), renderView);
+        }
+    }
     if (RenderBox* rend = renderBox())
         return adjustForAbsoluteZoom(rend->scrollTop(), rend);
     return 0;
index fbe6484..5c364a3 100644 (file)
@@ -261,8 +261,9 @@ static int adjustForZoom(int value, Document* document)
 
 int HTMLBodyElement::scrollLeft()
 {
-    // Update the document's layout.
     Document* document = this->document();
+    if (!document->inQuirksMode())
+        return 0;
     document->updateLayoutIgnorePendingStylesheets();
     FrameView* view = document->view();
     return view ? adjustForZoom(view->scrollX(), document) : 0;
@@ -283,8 +284,9 @@ void HTMLBodyElement::setScrollLeft(int scrollLeft)
 
 int HTMLBodyElement::scrollTop()
 {
-    // Update the document's layout.
     Document* document = this->document();
+    if (!document->inQuirksMode())
+        return 0;
     document->updateLayoutIgnorePendingStylesheets();
     FrameView* view = document->view();
     return view ? adjustForZoom(view->scrollY(), document) : 0;