| OLD | NEW |
| 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/IntersectionObserverController.h" | 5 #include "core/dom/IntersectionObserverController.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 : ActiveDOMObject(document) | 21 : ActiveDOMObject(document) |
| 22 , m_timer(this, &IntersectionObserverController::deliverIntersectionObservat
ions) | 22 , m_timer(this, &IntersectionObserverController::deliverIntersectionObservat
ions) |
| 23 , m_timerFiredWhileSuspended(false) | 23 , m_timerFiredWhileSuspended(false) |
| 24 { | 24 { |
| 25 } | 25 } |
| 26 | 26 |
| 27 IntersectionObserverController::~IntersectionObserverController() { } | 27 IntersectionObserverController::~IntersectionObserverController() { } |
| 28 | 28 |
| 29 void IntersectionObserverController::scheduleIntersectionObserverForDelivery(Int
ersectionObserver& observer) | 29 void IntersectionObserverController::scheduleIntersectionObserverForDelivery(Int
ersectionObserver& observer) |
| 30 { | 30 { |
| 31 // TODO(szager): use idle callback with a timeout | 31 // TODO(szager): use idle callback with a timeout. Until we do that, there
is no |
| 32 // reliable way to write a test for takeRecords, because it's impossible to
guarantee |
| 33 // that javascript will get a chance to run before the timer fires. |
| 32 if (!m_timer.isActive()) | 34 if (!m_timer.isActive()) |
| 33 m_timer.startOneShot(0, BLINK_FROM_HERE); | 35 m_timer.startOneShot(0, BLINK_FROM_HERE); |
| 34 m_pendingIntersectionObservers.add(&observer); | 36 m_pendingIntersectionObservers.add(&observer); |
| 35 } | 37 } |
| 36 | 38 |
| 37 void IntersectionObserverController::resume() | 39 void IntersectionObserverController::resume() |
| 38 { | 40 { |
| 39 // If the timer fired while DOM objects were suspended, notifications might
be late, so deliver | 41 // If the timer fired while DOM objects were suspended, notifications might
be late, so deliver |
| 40 // them right away (rather than waiting for m_timer to fire again). | 42 // them right away (rather than waiting for m_timer to fire again). |
| 41 if (m_timerFiredWhileSuspended) { | 43 if (m_timerFiredWhileSuspended) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 86 } |
| 85 | 87 |
| 86 DEFINE_TRACE(IntersectionObserverController) | 88 DEFINE_TRACE(IntersectionObserverController) |
| 87 { | 89 { |
| 88 visitor->trace(m_trackedIntersectionObservers); | 90 visitor->trace(m_trackedIntersectionObservers); |
| 89 visitor->trace(m_pendingIntersectionObservers); | 91 visitor->trace(m_pendingIntersectionObservers); |
| 90 ActiveDOMObject::trace(visitor); | 92 ActiveDOMObject::trace(visitor); |
| 91 } | 93 } |
| 92 | 94 |
| 93 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |