Title: [183967] trunk
Revision
183967
Author
wei...@apple.com
Date
2015-05-07 17:59:01 -0700 (Thu, 07 May 2015)

Log Message

Consider implementing Document.scrollingElement
<rdar://problem/20845213>
https://bugs.webkit.org/show_bug.cgi?id=143609

Reviewed by Simon Fraser.

Source/WebCore:

Add the non-compliant implementation of Document.scrollingElement that the spec,
found at http://dev.w3.org/csswg/cssom-view/#dom-document-scrollingelement, 
says we should have while we have non-compliant implementations of Element.scrollTop
and Element.scrollLeft (fixing that is tracked by https://bugs.webkit.org/show_bug.cgi?id=106133).

Tests: fast/dom/Document/scrollingElement-quirks-mode.html
       fast/dom/Document/scrollingElement-standards-mode.html

* dom/Document.cpp:
(WebCore::Document::scrollingElement):
* dom/Document.h:
* dom/Document.idl:

LayoutTests:

* fast/dom/Document/scrollingElement-quirks-mode-expected.txt: Added.
* fast/dom/Document/scrollingElement-quirks-mode.html: Added.
* fast/dom/Document/scrollingElement-standards-mode-expected.txt: Added.
* fast/dom/Document/scrollingElement-standards-mode.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (183966 => 183967)


--- trunk/LayoutTests/ChangeLog	2015-05-08 00:54:54 UTC (rev 183966)
+++ trunk/LayoutTests/ChangeLog	2015-05-08 00:59:01 UTC (rev 183967)
@@ -1,3 +1,16 @@
+2015-05-07  Sam Weinig  <s...@webkit.org>
+
+        Consider implementing Document.scrollingElement
+        <rdar://problem/20845213>
+        https://bugs.webkit.org/show_bug.cgi?id=143609
+
+        Reviewed by Simon Fraser.
+
+        * fast/dom/Document/scrollingElement-quirks-mode-expected.txt: Added.
+        * fast/dom/Document/scrollingElement-quirks-mode.html: Added.
+        * fast/dom/Document/scrollingElement-standards-mode-expected.txt: Added.
+        * fast/dom/Document/scrollingElement-standards-mode.html: Added.
+
 2015-05-07  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         Applying a filter on an SVG element, which is larger than 4096 pixels, causes this element to be rendered shifted to the left

Added: trunk/LayoutTests/fast/dom/Document/scrollingElement-quirks-mode-expected.txt (0 => 183967)


--- trunk/LayoutTests/fast/dom/Document/scrollingElement-quirks-mode-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/scrollingElement-quirks-mode-expected.txt	2015-05-08 00:59:01 UTC (rev 183967)
@@ -0,0 +1,18 @@
+Tests the behavior of document.scrollingElement in quirks mode.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+In quirks mode the scrolling element is `BODY`
+PASS document.scrollingElement is document.body
+PASS document.scrollingElement is document.body
+PASS document.scrollingElement is document.body
+In quirks mode, if the `BODY` is scrollable, the scrolling element is `null`
+INTENTIONAL FAILURE. This can be fixed once https://bugs.webkit.org/show_bug.cgi?id=106133 is fixed.
+FAIL document.scrollingElement.scrollingElement should be null (of type object). Was undefined (of type undefined).
+In quirks mode, if the `BODY` is `display: none`, the scrolling element is `BODY`
+PASS document.scrollingElement is document.body
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Document/scrollingElement-quirks-mode.html (0 => 183967)


--- trunk/LayoutTests/fast/dom/Document/scrollingElement-quirks-mode.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/scrollingElement-quirks-mode.html	2015-05-08 00:59:01 UTC (rev 183967)
@@ -0,0 +1,38 @@
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("Tests the behavior of document.scrollingElement in quirks mode.");
+
+debug("In quirks mode the scrolling element is `BODY`");
+shouldBe("document.scrollingElement", "document.body");
+
+document.documentElement.setAttribute('style', 'overflow: scroll');
+document.body.setAttribute('style', 'overflow: visible');
+shouldBe("document.scrollingElement", "document.body");
+
+document.documentElement.setAttribute('style', 'overflow: visible');
+document.body.setAttribute('style', 'overflow: scroll');
+shouldBe("document.scrollingElement", "document.body");
+
+debug("In quirks mode, if the `BODY` is scrollable, the scrolling element is `null`");
+debug("INTENTIONAL FAILURE. This can be fixed once https://bugs.webkit.org/show_bug.cgi?id=106133 is fixed.");
+document.documentElement.setAttribute('style', 'overflow: scroll');
+document.body.setAttribute('style', 'overflow: scroll');
+shouldBeNull("document.scrollingElement.scrollingElement");
+
+debug("In quirks mode, if the `BODY` is `display: none`, the scrolling element is `BODY`");
+document.documentElement.setAttribute('style', 'overflow: scroll');
+document.body.setAttribute('style', 'overflow: scroll; display: none');
+shouldBe("document.scrollingElement", "document.body");
+
+document.body.setAttribute('style', '');
+
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/dom/Document/scrollingElement-standards-mode-expected.txt (0 => 183967)


--- trunk/LayoutTests/fast/dom/Document/scrollingElement-standards-mode-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/scrollingElement-standards-mode-expected.txt	2015-05-08 00:59:01 UTC (rev 183967)
@@ -0,0 +1,12 @@
+Tests the behavior of document.scrollingElement in standards mode.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+In standards mode the scrolling element is supposed to be `HTML`
+INTENTIONAL FAILURE. This can be fixed once https://bugs.webkit.org/show_bug.cgi?id=106133 is fixed.
+FAIL document.scrollingElement should be [object HTMLHtmlElement]. Was [object HTMLBodyElement].
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Document/scrollingElement-standards-mode.html (0 => 183967)


--- trunk/LayoutTests/fast/dom/Document/scrollingElement-standards-mode.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/scrollingElement-standards-mode.html	2015-05-08 00:59:01 UTC (rev 183967)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("Tests the behavior of document.scrollingElement in standards mode.");
+
+debug("In standards mode the scrolling element is supposed to be `HTML`");
+debug("INTENTIONAL FAILURE. This can be fixed once https://bugs.webkit.org/show_bug.cgi?id=106133 is fixed.");
+shouldBe("document.scrollingElement", "document.documentElement");
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (183966 => 183967)


--- trunk/Source/WebCore/ChangeLog	2015-05-08 00:54:54 UTC (rev 183966)
+++ trunk/Source/WebCore/ChangeLog	2015-05-08 00:59:01 UTC (rev 183967)
@@ -1,3 +1,24 @@
+2015-05-07  Sam Weinig  <s...@webkit.org>
+
+        Consider implementing Document.scrollingElement
+        <rdar://problem/20845213>
+        https://bugs.webkit.org/show_bug.cgi?id=143609
+
+        Reviewed by Simon Fraser.
+
+        Add the non-compliant implementation of Document.scrollingElement that the spec,
+        found at http://dev.w3.org/csswg/cssom-view/#dom-document-scrollingelement, 
+        says we should have while we have non-compliant implementations of Element.scrollTop
+        and Element.scrollLeft (fixing that is tracked by https://bugs.webkit.org/show_bug.cgi?id=106133).
+
+        Tests: fast/dom/Document/scrollingElement-quirks-mode.html
+               fast/dom/Document/scrollingElement-standards-mode.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::scrollingElement):
+        * dom/Document.h:
+        * dom/Document.idl:
+
 2015-05-07  Dean Jackson  <d...@apple.com>
 
         [iOS] While scrubbing and holding down, video continues to play

Modified: trunk/Source/WebCore/dom/Document.cpp (183966 => 183967)


--- trunk/Source/WebCore/dom/Document.cpp	2015-05-08 00:54:54 UTC (rev 183966)
+++ trunk/Source/WebCore/dom/Document.cpp	2015-05-08 00:59:01 UTC (rev 183967)
@@ -1429,6 +1429,14 @@
     return Range::create(*this, rangeCompliantPosition, rangeCompliantPosition);
 }
 
+Element* Document::scrollingElement()
+{
+    // FIXME: When we fix https://bugs.webkit.org/show_bug.cgi?id=106133, this should be replaced with the full implementation
+    // of Document.scrollingElement() as specified at http://dev.w3.org/csswg/cssom-view/#dom-document-scrollingelement.
+
+    return body();
+}
+
 /*
  * Performs three operations:
  *  1. Convert control characters to spaces

Modified: trunk/Source/WebCore/dom/Document.h (183966 => 183967)


--- trunk/Source/WebCore/dom/Document.h	2015-05-08 00:54:54 UTC (rev 183966)
+++ trunk/Source/WebCore/dom/Document.h	2015-05-08 00:59:01 UTC (rev 183967)
@@ -381,6 +381,8 @@
     RefPtr<Range> caretRangeFromPoint(int x, int y);
     RefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint);
 
+    Element* scrollingElement();
+
     String readyState() const;
 
     String defaultCharset() const;

Modified: trunk/Source/WebCore/dom/Document.idl (183966 => 183967)


--- trunk/Source/WebCore/dom/Document.idl	2015-05-08 00:54:54 UTC (rev 183966)
+++ trunk/Source/WebCore/dom/Document.idl	2015-05-08 00:59:01 UTC (rev 183967)
@@ -341,5 +341,7 @@
 
     // http://www.w3.org/TR/2014/WD-dom-20140204/#dom-document-origin
     readonly attribute DOMString origin;
+
+    readonly attribute Element scrollingElement;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to