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 2d55282406f2ccc17586036c1e09d555105236ff..e8e803085618f7114f6a5e09ca261f70ef950e75 100644 |
--- a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp |
+++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp |
@@ -16,7 +16,10 @@ IntersectionObservation::IntersectionObservation(IntersectionObserver& observer, |
: m_observer(observer), |
m_target(&target), |
m_shouldReportRootBounds(shouldReportRootBounds), |
- m_lastThresholdIndex(0) {} |
+ // Note that the spec says the initial value of m_lastThresholdIndex |
+ // should be -1, but since m_lastThresholdIndex is unsigned, we use a |
+ // different sentinel value. |
+ m_lastThresholdIndex(kMaxThresholdIndex - 1) {} |
void IntersectionObservation::computeIntersectionObservations( |
DOMHighResTimeStamp timestamp) { |
@@ -63,6 +66,9 @@ void IntersectionObservation::computeIntersectionObservations( |
newVisibleRatio = 0; |
newThresholdIndex = 0; |
} |
+ |
+ RELEASE_ASSERT(newThresholdIndex < kMaxThresholdIndex); |
+ |
if (m_lastThresholdIndex != newThresholdIndex) { |
IntRect snappedRootBounds = geometry.rootIntRect(); |
IntRect* rootBoundsPointer = |