<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)
commit8d7aa27190ac1c47fc9cc35a5292b42da99b9540
tree14d8e6aa3935ce73a945ba32d919e1c917482949
parent62f0d4994c87e17d8a4e2285c4a6e04aafd75e17
<https://webkit.org/b/106133> document.body.scrollTop & document.documentElement.scrollTop differ cross-browser

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