Diff
Modified: trunk/LayoutTests/ChangeLog (234731 => 234732)
--- trunk/LayoutTests/ChangeLog 2018-08-09 19:02:21 UTC (rev 234731)
+++ trunk/LayoutTests/ChangeLog 2018-08-09 19:36:38 UTC (rev 234732)
@@ -1,3 +1,13 @@
+2018-08-09 Ali Juma <[email protected]>
+
+ 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 <[email protected]>
Array.prototype.sort should call @toLength instead of ">>> 0"
Modified: trunk/LayoutTests/intersection-observer/intersection-observer-entry-interface-expected.txt (234731 => 234732)
--- trunk/LayoutTests/intersection-observer/intersection-observer-entry-interface-expected.txt 2018-08-09 19:02:21 UTC (rev 234731)
+++ trunk/LayoutTests/intersection-observer/intersection-observer-entry-interface-expected.txt 2018-08-09 19:36:38 UTC (rev 234732)
@@ -2,7 +2,10 @@
PASS Constructor0
PASS ConstructorTime
PASS ConstructorRootBounds
+PASS ConstructorNullRootBounds
PASS ConstructorBoundingClientRect
PASS ConstructorIntersectionRect
-PASS ConstructorTime
+PASS ConstructorIsIntersecting
+PASS ConstructorIntersectionRatio
+PASS ConstructorTarget
Modified: trunk/LayoutTests/intersection-observer/intersection-observer-entry-interface.html (234731 => 234732)
--- trunk/LayoutTests/intersection-observer/intersection-observer-entry-interface.html 2018-08-09 19:02:21 UTC (rev 234731)
+++ trunk/LayoutTests/intersection-observer/intersection-observer-entry-interface.html 2018-08-09 19:36:38 UTC (rev 234732)
@@ -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
};
@@ -31,7 +33,12 @@
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}');
},'ConstructorBoundingClientRect');
@@ -42,8 +49,16 @@
},'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>
Modified: trunk/Source/WebCore/ChangeLog (234731 => 234732)
--- trunk/Source/WebCore/ChangeLog 2018-08-09 19:02:21 UTC (rev 234731)
+++ trunk/Source/WebCore/ChangeLog 2018-08-09 19:36:38 UTC (rev 234732)
@@ -1,3 +1,22 @@
+2018-08-09 Ali Juma <[email protected]>
+
+ 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 <[email protected]>
Fix copyright headers on new ISO parsing class
Modified: trunk/Source/WebCore/page/IntersectionObserverEntry.cpp (234731 => 234732)
--- trunk/Source/WebCore/page/IntersectionObserverEntry.cpp 2018-08-09 19:02:21 UTC (rev 234731)
+++ trunk/Source/WebCore/page/IntersectionObserverEntry.cpp 2018-08-09 19:36:38 UTC (rev 234732)
@@ -34,14 +34,16 @@
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)
Modified: trunk/Source/WebCore/page/IntersectionObserverEntry.h (234731 => 234732)
--- trunk/Source/WebCore/page/IntersectionObserverEntry.h 2018-08-09 19:02:21 UTC (rev 234731)
+++ trunk/Source/WebCore/page/IntersectionObserverEntry.h 2018-08-09 19:36:38 UTC (rev 234732)
@@ -43,10 +43,12 @@
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 @@
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 @@
RefPtr<DOMRectReadOnly> m_intersectionRect;
double m_intersectionRatio { 0 };
RefPtr<Element> m_target;
+ bool m_isIntersecting { false };
};
Modified: trunk/Source/WebCore/page/IntersectionObserverEntry.idl (234731 => 234732)
--- trunk/Source/WebCore/page/IntersectionObserverEntry.idl 2018-08-09 19:02:21 UTC (rev 234731)
+++ trunk/Source/WebCore/page/IntersectionObserverEntry.idl 2018-08-09 19:36:38 UTC (rev 234732)
@@ -34,9 +34,10 @@
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 @@
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;
};