Title: [238610] trunk
Revision
238610
Author
[email protected]
Date
2018-11-28 07:06:19 -0800 (Wed, 28 Nov 2018)

Log Message

Intersection Observer: rootMargin: '' gives weird results
https://bugs.webkit.org/show_bug.cgi?id=191975

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Add test coverage.

* web-platform-tests/intersection-observer/empty-root-margin-expected.txt: Added.
* web-platform-tests/intersection-observer/empty-root-margin.html: Added.

Source/WebCore:

When converting the rootMargin string into a LengthBox, explicitly construct a Length
of size 0px for each dimension, instead of using Length's default constructor. The
default constructor creates a Length with value Auto, which causes us to incorrectly
apply a non-zero rootMargin.

Test: imported/w3c/web-platform-tests/intersection-observer/empty-root-margin.html

* page/IntersectionObserver.cpp:
(WebCore::parseRootMargin):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (238609 => 238610)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-11-28 14:56:11 UTC (rev 238609)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-11-28 15:06:19 UTC (rev 238610)
@@ -1,3 +1,15 @@
+2018-11-28  Ali Juma  <[email protected]>
+
+        Intersection Observer: rootMargin: '' gives weird results
+        https://bugs.webkit.org/show_bug.cgi?id=191975
+
+        Reviewed by Simon Fraser.
+
+        Add test coverage.
+
+        * web-platform-tests/intersection-observer/empty-root-margin-expected.txt: Added.
+        * web-platform-tests/intersection-observer/empty-root-margin.html: Added.
+
 2018-11-27  Rob Buis  <[email protected]>
 
         Block more ports (427, 548, 6697)

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/empty-root-margin-expected.txt (0 => 238610)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/empty-root-margin-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/empty-root-margin-expected.txt	2018-11-28 15:06:19 UTC (rev 238610)
@@ -0,0 +1,3 @@
+
+PASS An empty rootMargin string is interpreted as a margin of size zero 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/empty-root-margin.html (0 => 238610)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/empty-root-margin.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/empty-root-margin.html	2018-11-28 15:06:19 UTC (rev 238610)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script src=""
+<script src=""
+
+<style>
+#target {
+  width: 100px;
+  height: 100px;
+  background-color: green;
+}
+</style>
+
+<div id="target"></div>
+
+<script>
+var target = document.getElementById("target");
+async_test((t) => {
+    var observer = new IntersectionObserver(t.step_func_done((entries) => {
+        var rootBounds = entries[0].rootBounds;
+        assert_equals(rootBounds.left, 0);
+        assert_equals(rootBounds.right, document.documentElement.clientWidth);
+        assert_equals(rootBounds.top, 0);
+        assert_equals(rootBounds.bottom, document.documentElement.clientHeight);
+        observer.disconnect();
+    }), { rootMargin: "" });
+    observer.observe(document.getElementById("target"));
+}, "An empty rootMargin string is interpreted as a margin of size zero");
+</script>

Modified: trunk/Source/WebCore/ChangeLog (238609 => 238610)


--- trunk/Source/WebCore/ChangeLog	2018-11-28 14:56:11 UTC (rev 238609)
+++ trunk/Source/WebCore/ChangeLog	2018-11-28 15:06:19 UTC (rev 238610)
@@ -1,3 +1,20 @@
+2018-11-28  Ali Juma  <[email protected]>
+
+        Intersection Observer: rootMargin: '' gives weird results
+        https://bugs.webkit.org/show_bug.cgi?id=191975
+
+        Reviewed by Simon Fraser.
+
+        When converting the rootMargin string into a LengthBox, explicitly construct a Length
+        of size 0px for each dimension, instead of using Length's default constructor. The
+        default constructor creates a Length with value Auto, which causes us to incorrectly
+        apply a non-zero rootMargin.
+
+        Test: imported/w3c/web-platform-tests/intersection-observer/empty-root-margin.html
+
+        * page/IntersectionObserver.cpp:
+        (WebCore::parseRootMargin):
+
 2018-11-28  Thibault Saunier  <[email protected]>
 
         [WebRTC][GStreamer] Make sure to have the default microphone on the top of the list

Modified: trunk/Source/WebCore/page/IntersectionObserver.cpp (238609 => 238610)


--- trunk/Source/WebCore/page/IntersectionObserver.cpp	2018-11-28 14:56:11 UTC (rev 238609)
+++ trunk/Source/WebCore/page/IntersectionObserver.cpp	2018-11-28 15:06:19 UTC (rev 238610)
@@ -60,7 +60,7 @@
     switch (margins.size()) {
     case 0:
         for (unsigned i = 0; i < 4; ++i)
-            margins.append(Length());
+            margins.append(Length(0, Fixed));
         break;
     case 1:
         for (unsigned i = 0; i < 3; ++i)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to