Update IDL for IntersectionObserverEntry and IntersectionObserverEntryInit
authorajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2018 19:36:38 +0000 (19:36 +0000)
committerajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2018 19:36:38 +0000 (19:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188445

Reviewed by Simon Fraser.

Source/WebCore:

Update IntersectionObserverEntry by making rootBounds nullable, and adding an
isIntersecting attribute. Make the same changes to IntersectionObserverEntryInit,
and also add an intersectionRatio attribute.

Tested by intersection-observer/intersection-observer-entry-interface.html

* page/IntersectionObserverEntry.cpp:
(WebCore::IntersectionObserverEntry::IntersectionObserverEntry):
* page/IntersectionObserverEntry.h:
(WebCore::IntersectionObserverEntry::isIntersecting const):
* page/IntersectionObserverEntry.idl:

LayoutTests:

* intersection-observer/intersection-observer-entry-interface-expected.txt:
* intersection-observer/intersection-observer-entry-interface.html:

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

LayoutTests/ChangeLog
LayoutTests/intersection-observer/intersection-observer-entry-interface-expected.txt
LayoutTests/intersection-observer/intersection-observer-entry-interface.html
Source/WebCore/ChangeLog
Source/WebCore/page/IntersectionObserverEntry.cpp
Source/WebCore/page/IntersectionObserverEntry.h
Source/WebCore/page/IntersectionObserverEntry.idl

index 0b73be4..d9a2077 100644 (file)
@@ -1,3 +1,13 @@
+2018-08-09  Ali Juma  <ajuma@chromium.org>
+
+        Update IDL for IntersectionObserverEntry and IntersectionObserverEntryInit
+        https://bugs.webkit.org/show_bug.cgi?id=188445
+
+        Reviewed by Simon Fraser.
+
+        * intersection-observer/intersection-observer-entry-interface-expected.txt:
+        * intersection-observer/intersection-observer-entry-interface.html:
+
 2018-08-08  Keith Miller  <keith_miller@apple.com>
 
         Array.prototype.sort should call @toLength instead of ">>> 0"
index 25d93e2..89c2bf7 100644 (file)
@@ -2,7 +2,10 @@
 PASS Constructor0 
 PASS ConstructorTime 
 PASS ConstructorRootBounds 
+PASS ConstructorNullRootBounds 
 PASS ConstructorBoundingClientRect 
 PASS ConstructorIntersectionRect 
-PASS ConstructorTime 
+PASS ConstructorIsIntersecting 
+PASS ConstructorIntersectionRatio 
+PASS ConstructorTarget 
 
index ac815a5..2ddc65c 100644 (file)
@@ -15,6 +15,8 @@
         rootBounds: { x: 10, y: 12.5, width: 130, height: 140 },
         boundingClientRect: { x: 110, y: 112.7, width: 1130, height: 1140 },
         intersectionRect: { x: 210, y: 212, width: 2130, height: 2140 },
+        isIntersecting: true,
+        intersectionRatio: 0.35,
         target: document.body
     };
 
         assert_class_string(entry.rootBounds, 'DOMRectReadOnly');
     },'ConstructorRootBounds');
     test(function() {
+        entryInit.rootBounds = null;
+        var entry = new IntersectionObserverEntry(entryInit);
+        assert_equals(entry.rootBounds, null);
+    },'ConstructorNullRootBounds');
+    test(function() {
         var entry = new IntersectionObserverEntry(entryInit);
         assert_class_string(entry.boundingClientRect, 'DOMRectReadOnly');
         assert_equals(JSON.stringify(entry.boundingClientRect), '{"x":110,"y":112.7,"width":1130,"height":1140,"top":112.7,"right":1240,"bottom":1252.7,"left":110}');
     },'ConstructorIntersectionRect');
     test(function() {
         var entry = new IntersectionObserverEntry(entryInit);
+        assert_true(entry.isIntersecting);
+    },'ConstructorIsIntersecting');
+    test(function() {
+        var entry = new IntersectionObserverEntry(entryInit);
+        assert_equals(entry.intersectionRatio, 0.35);
+    },'ConstructorIntersectionRatio');
+    test(function() {
+        var entry = new IntersectionObserverEntry(entryInit);
         assert_equals(entry.target, document.body);
-    },'ConstructorTime');
+    },'ConstructorTarget');
 
 </script>
 </body>
index 2b74647..0ef337b 100644 (file)
@@ -1,3 +1,22 @@
+2018-08-09  Ali Juma  <ajuma@chromium.org>
+
+        Update IDL for IntersectionObserverEntry and IntersectionObserverEntryInit
+        https://bugs.webkit.org/show_bug.cgi?id=188445
+
+        Reviewed by Simon Fraser.
+
+        Update IntersectionObserverEntry by making rootBounds nullable, and adding an
+        isIntersecting attribute. Make the same changes to IntersectionObserverEntryInit,
+        and also add an intersectionRatio attribute.
+
+        Tested by intersection-observer/intersection-observer-entry-interface.html
+
+        * page/IntersectionObserverEntry.cpp:
+        (WebCore::IntersectionObserverEntry::IntersectionObserverEntry):
+        * page/IntersectionObserverEntry.h:
+        (WebCore::IntersectionObserverEntry::isIntersecting const):
+        * page/IntersectionObserverEntry.idl:
+
 2018-08-09  Charlie Turner  <cturner@igalia.com>
 
         Fix copyright headers on new ISO parsing class
index e3f9c3c..a2244fe 100644 (file)
@@ -34,14 +34,16 @@ namespace WebCore {
 
 IntersectionObserverEntry::IntersectionObserverEntry(const Init& init)
     : m_time(init.time)
-    , m_rootBounds(DOMRectReadOnly::fromRect(init.rootBounds))
     , m_boundingClientRect(DOMRectReadOnly::fromRect(init.boundingClientRect))
     , m_intersectionRect(DOMRectReadOnly::fromRect(init.intersectionRect))
+    , m_intersectionRatio(init.intersectionRatio)
     , m_target(init.target)
+    , m_isIntersecting(init.isIntersecting)
 {
+    if (init.rootBounds)
+        m_rootBounds = DOMRectReadOnly::fromRect(*init.rootBounds);
 }
 
-
 } // namespace WebCore
 
 #endif // ENABLE(INTERSECTION_OBSERVER)
index 638d4b8..7c4c0b6 100644 (file)
@@ -43,10 +43,12 @@ public:
 
     struct Init {
         double time;
-        DOMRectInit rootBounds;
+        std::optional<DOMRectInit> rootBounds;
         DOMRectInit boundingClientRect;
         DOMRectInit intersectionRect;
+        double intersectionRatio;
         RefPtr<Element> target;
+        bool isIntersecting;
     };
 
     static Ref<IntersectionObserverEntry> create(const Init& init)
@@ -60,6 +62,7 @@ public:
     RefPtr<DOMRectReadOnly> intersectionRect() const { return m_intersectionRect; }
     RefPtr<Element> target() const { return m_target; }
 
+    bool isIntersecting() const { return m_isIntersecting; }
     double intersectionRatio() const { return m_intersectionRatio; }
 
 private:
@@ -71,6 +74,7 @@ private:
     RefPtr<DOMRectReadOnly> m_intersectionRect;
     double m_intersectionRatio { 0 };
     RefPtr<Element> m_target;
+    bool m_isIntersecting { false };
 };
 
 
index 1b4338b..47612d0 100644 (file)
@@ -34,9 +34,10 @@ typedef double DOMHighResTimeStamp;
     EnabledAtRuntime=IntersectionObserver
 ] interface IntersectionObserverEntry {
     readonly attribute DOMHighResTimeStamp time;
-    readonly attribute DOMRectReadOnly rootBounds;
+    readonly attribute DOMRectReadOnly? rootBounds;
     readonly attribute DOMRectReadOnly boundingClientRect;
     readonly attribute DOMRectReadOnly intersectionRect;
+    readonly attribute boolean isIntersecting;
     readonly attribute double intersectionRatio;
     readonly attribute Element target;
 };
@@ -45,8 +46,10 @@ typedef double DOMHighResTimeStamp;
     Conditional=INTERSECTION_OBSERVER,
 ] dictionary IntersectionObserverEntryInit {
     required DOMHighResTimeStamp time;
-    required DOMRectInit rootBounds;
+    required DOMRectInit? rootBounds;
     required DOMRectInit boundingClientRect;
     required DOMRectInit intersectionRect;
+    required boolean isIntersecting;
+    required double intersectionRatio;
     required Element target;
 };