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

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

Issue 2646633002: IntersectionObserver: remove gc-timing-revealing execeptions. (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/IntersectionObserver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
diff --git a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
index 9cf2e7ded17bcf02d39004910123108e35aabd6b..408fc2c21c8c4fa315a352cb12f394a5fbf0b496 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
@@ -230,12 +230,8 @@ Document& IntersectionObserver::trackingDocument() const {
void IntersectionObserver::observe(Element* target,
ExceptionState& exceptionState) {
- if (!rootIsValid()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "observe() called on an IntersectionObserver with an invalid root.");
+ if (!rootIsValid())
return;
- }
if (!target || root() == target)
return;
@@ -287,19 +283,14 @@ void IntersectionObserver::observe(Element* target,
void IntersectionObserver::unobserve(Element* target,
ExceptionState& exceptionState) {
- if (!rootIsValid()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "unobserve() called on an IntersectionObserver with an invalid root.");
- return;
- }
-
if (!target || !target->intersectionObserverData())
return;
if (IntersectionObservation* observation =
- target->intersectionObserverData()->getObservationFor(*this))
+ target->intersectionObserverData()->getObservationFor(*this)) {
observation->disconnect();
+ m_observations.remove(observation);
+ }
}
void IntersectionObserver::computeIntersectionObservations() {
@@ -318,23 +309,11 @@ void IntersectionObserver::computeIntersectionObservations() {
}
void IntersectionObserver::disconnect(ExceptionState& exceptionState) {
- if (!rootIsValid()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "disconnect() called on an IntersectionObserver with an invalid root.");
- return;
- }
-
for (auto& observation : m_observations)
- observation->clearRootAndRemoveFromTarget();
+ observation->disconnect();
m_observations.clear();
}
-void IntersectionObserver::removeObservation(
- IntersectionObservation& observation) {
- m_observations.remove(&observation);
-}
-
void IntersectionObserver::setInitialState(InitialState initialState) {
DCHECK(m_observations.isEmpty());
m_initialState = initialState;
@@ -343,16 +322,7 @@ void IntersectionObserver::setInitialState(InitialState initialState) {
HeapVector<Member<IntersectionObserverEntry>> IntersectionObserver::takeRecords(
ExceptionState& exceptionState) {
HeapVector<Member<IntersectionObserverEntry>> entries;
-
- if (!rootIsValid()) {
- exceptionState.throwDOMException(InvalidStateError,
- "takeRecords() called on an "
- "IntersectionObserver with an invalid "
- "root.");
- } else {
- entries.swap(m_entries);
- }
-
+ entries.swap(m_entries);
return entries;
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/IntersectionObserver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698