Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(971)

Unified Diff: third_party/WebKit/Source/core/dom/IntersectionObservation.cpp

Issue 2645283008: IntersectionObserver: Always send an initial notification. (Closed)
Patch Set: Fix unit test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 =

Powered by Google App Engine
This is Rietveld 408576698