| Index: third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
|
| index c9c04457e5ea67c7f176de9f8542466870e0c392..04de0b1913767e8eeb2d146319f38c85d3fc3f34 100644
|
| --- a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
|
| @@ -22,6 +22,8 @@ IntersectionObservation::IntersectionObservation(IntersectionObserver& observer,
|
| m_shouldReportRootBounds(shouldReportRootBounds),
|
| m_lastThresholdIndex(0) {}
|
|
|
| +IntersectionObservation::~IntersectionObservation() {}
|
| +
|
| void IntersectionObservation::applyRootMargin(LayoutRect& rect) const {
|
| if (m_shouldReportRootBounds)
|
| m_observer->applyRootMargin(rect);
|
| @@ -255,4 +257,35 @@ DEFINE_TRACE(IntersectionObservation) {
|
| visitor->trace(m_target);
|
| }
|
|
|
| +ViewportIntersectionObservation::ViewportIntersectionObservation(
|
| + IntersectionObserver& observer,
|
| + Element& element)
|
| + : IntersectionObservation(observer, element, true),
|
| + m_lastIntersectRect(std::numeric_limits<float>::min(),
|
| + std::numeric_limits<float>::min(),
|
| + std::numeric_limits<float>::min(),
|
| + std::numeric_limits<float>::min()) {}
|
| +
|
| +ViewportIntersectionObservation::~ViewportIntersectionObservation() {}
|
| +
|
| +void ViewportIntersectionObservation::computeIntersectionObservations(
|
| + DOMHighResTimeStamp timestamp) {
|
| + IntersectionGeometry geometry;
|
| + if (!computeGeometry(geometry))
|
| + return;
|
| +
|
| + LayoutRect newIntersectRect;
|
| + if (!geometry.rootRect.isEmpty() && geometry.doesIntersect)
|
| + newIntersectRect = geometry.intersectionRect;
|
| + if (newIntersectRect != m_lastIntersectRect) {
|
| + IntRect snappedRootBounds = pixelSnappedIntRect(geometry.rootRect);
|
| + IntersectionObserverEntry* newEntry = new IntersectionObserverEntry(
|
| + timestamp, 0, pixelSnappedIntRect(geometry.targetRect),
|
| + &snappedRootBounds, pixelSnappedIntRect(geometry.intersectionRect),
|
| + target());
|
| + observer().enqueueIntersectionObserverEntry(*newEntry);
|
| + m_lastIntersectRect = newIntersectRect;
|
| + }
|
| +}
|
| +
|
| } // namespace blink
|
|
|