| 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/ElementVisibilityObserver.h" | 5 #include "core/dom/ElementVisibilityObserver.h" |
| 6 | 6 |
| 7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.h" |
| 8 #include "core/dom/IntersectionObserverEntry.h" | 8 #include "core/dom/IntersectionObserverEntry.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "wtf/Functional.h" | 10 #include "wtf/Functional.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 m_intersectionObserver->deliver(); | 67 m_intersectionObserver->deliver(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 DEFINE_TRACE(ElementVisibilityObserver) { | 70 DEFINE_TRACE(ElementVisibilityObserver) { |
| 71 visitor->trace(m_element); | 71 visitor->trace(m_element); |
| 72 visitor->trace(m_intersectionObserver); | 72 visitor->trace(m_intersectionObserver); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ElementVisibilityObserver::onVisibilityChanged( | 75 void ElementVisibilityObserver::onVisibilityChanged( |
| 76 const HeapVector<Member<IntersectionObserverEntry>>& entries) { | 76 const HeapVector<Member<IntersectionObserverEntry>>& entries) { |
| 77 bool isVisible = entries.last()->intersectionRatio() > 0.f; | 77 bool isVisible = entries.back()->intersectionRatio() > 0.f; |
| 78 (*m_callback.get())(isVisible); | 78 (*m_callback.get())(isVisible); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |