…lines 1–80 unchanged (80 lines)
81 // 12. Set this’s internal [[delay]] slot to options.delay to delay.
82 // 13. Set this’s internal [[trackVisibility]] slot to options.trackVisibility.
83 // 14. Return this.
84 return realm.create<IntersectionObserver>(realm, callback, options.root, move(root_margin.value()), move(scroll_margin.value()), move(thresholds), move(delay), move(options.track_visibility));
85}
86
87IntersectionObserver::IntersectionObserver(JS::Realm& realm, GC::Ptr<WebIDL::CallbackType> callback, NullableIntersectionObserverRoot const& root, Vector<CSS::LengthPercentage> root_margin, Vector<CSS::LengthPercentage> scroll_margin, Vector<double>&& thresholds, double delay, bool track_visibility)
88 : PlatformObject(realm)
89 , m_callback(callback)
90 , m_root_margin(root_margin)
91 , m_scroll_margin(scroll_margin)
92 , m_thresholds(move(thresholds))
93 , m_delay(delay)
94 , m_track_visibility(track_visibility)
95{
96 m_root = root.has<Empty>() ? nullptr : root.visit([](GC::Root<DOM::Element> const& value) -> GC::Ptr<DOM::Node> { return *value; }, [](GC::Root<DOM::Document> const& value) -> GC::Ptr<DOM::Node> { return *value; }, [](Empty) -> GC::Ptr<DOM::Node> { return nullptr; });
97 intersection_root().visit([this](auto& node) {
98 m_document = node->document();
99 });
100 m_document->register_intersection_observer({}, *this);
101}
102
…lines 103–186 unchanged (84 lines)
187 // 2. Clear this’s internal [[QueuedEntries]] slot.
188 m_queued_entries.clear();
189
190 // 3. Return queue.
191 return queue;
192}
193
194NullableIntersectionObserverRoot IntersectionObserver::root() const
195{
196 if (!m_root)
197 return Empty {};
198 if (m_root->is_element())
199 return GC::make_root(static_cast<DOM::Element&>(*m_root));
200 if (m_root->is_document())
…lines 201–388 unchanged (188 lines)