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

Side by Side Diff: third_party/WebKit/Source/core/dom/IntersectionObservation.cpp

Issue 2727843003: Replace RELEASE_ASSERT with CHECK in core/{dom,editing,html} (Closed)
Patch Set: Add a comment Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/IntersectionObservation.h" 5 #include "core/dom/IntersectionObservation.h"
6 6
7 #include "core/dom/ElementRareData.h" 7 #include "core/dom/ElementRareData.h"
8 #include "core/dom/IntersectionObserver.h" 8 #include "core/dom/IntersectionObserver.h"
9 #include "core/layout/IntersectionGeometry.h" 9 #include "core/layout/IntersectionGeometry.h"
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 float targetArea = geometry.targetRect().size().width().toFloat() * 60 float targetArea = geometry.targetRect().size().width().toFloat() *
61 geometry.targetRect().size().height().toFloat(); 61 geometry.targetRect().size().height().toFloat();
62 newVisibleRatio = intersectionArea / targetArea; 62 newVisibleRatio = intersectionArea / targetArea;
63 } 63 }
64 newThresholdIndex = observer()->firstThresholdGreaterThan(newVisibleRatio); 64 newThresholdIndex = observer()->firstThresholdGreaterThan(newVisibleRatio);
65 } else { 65 } else {
66 newVisibleRatio = 0; 66 newVisibleRatio = 0;
67 newThresholdIndex = 0; 67 newThresholdIndex = 0;
68 } 68 }
69 69
70 RELEASE_ASSERT(newThresholdIndex < kMaxThresholdIndex); 70 // TODO(tkent): We can't use CHECK_LT due to a compile error.
71 CHECK(newThresholdIndex < kMaxThresholdIndex);
71 72
72 if (m_lastThresholdIndex != newThresholdIndex) { 73 if (m_lastThresholdIndex != newThresholdIndex) {
73 IntRect snappedRootBounds = geometry.rootIntRect(); 74 IntRect snappedRootBounds = geometry.rootIntRect();
74 IntRect* rootBoundsPointer = 75 IntRect* rootBoundsPointer =
75 m_shouldReportRootBounds ? &snappedRootBounds : nullptr; 76 m_shouldReportRootBounds ? &snappedRootBounds : nullptr;
76 IntersectionObserverEntry* newEntry = new IntersectionObserverEntry( 77 IntersectionObserverEntry* newEntry = new IntersectionObserverEntry(
77 timestamp, newVisibleRatio, geometry.targetIntRect(), rootBoundsPointer, 78 timestamp, newVisibleRatio, geometry.targetIntRect(), rootBoundsPointer,
78 geometry.intersectionIntRect(), geometry.doesIntersect(), target()); 79 geometry.intersectionIntRect(), geometry.doesIntersect(), target());
79 observer()->enqueueIntersectionObserverEntry(*newEntry); 80 observer()->enqueueIntersectionObserverEntry(*newEntry);
80 setLastThresholdIndex(newThresholdIndex); 81 setLastThresholdIndex(newThresholdIndex);
81 } 82 }
82 } 83 }
83 84
84 void IntersectionObservation::disconnect() { 85 void IntersectionObservation::disconnect() {
85 DCHECK(observer()); 86 DCHECK(observer());
86 if (m_target) 87 if (m_target)
87 target()->ensureIntersectionObserverData().removeObservation(*observer()); 88 target()->ensureIntersectionObserverData().removeObservation(*observer());
88 m_observer.clear(); 89 m_observer.clear();
89 } 90 }
90 91
91 DEFINE_TRACE(IntersectionObservation) { 92 DEFINE_TRACE(IntersectionObservation) {
92 visitor->trace(m_observer); 93 visitor->trace(m_observer);
93 visitor->trace(m_target); 94 visitor->trace(m_target);
94 } 95 }
95 96
96 } // namespace blink 97 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698