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 "platform/wtf/Functional.h" | 10 #include "platform/wtf/Functional.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 intersection_observer_->Deliver(); | 45 intersection_observer_->Deliver(); |
46 } | 46 } |
47 | 47 |
48 DEFINE_TRACE(ElementVisibilityObserver) { | 48 DEFINE_TRACE(ElementVisibilityObserver) { |
49 visitor->Trace(element_); | 49 visitor->Trace(element_); |
50 visitor->Trace(intersection_observer_); | 50 visitor->Trace(intersection_observer_); |
51 } | 51 } |
52 | 52 |
53 void ElementVisibilityObserver::OnVisibilityChanged( | 53 void ElementVisibilityObserver::OnVisibilityChanged( |
54 const HeapVector<Member<IntersectionObserverEntry>>& entries) { | 54 const HeapVector<Member<IntersectionObserverEntry>>& entries) { |
55 bool is_visible = entries.back()->intersectionRatio() > | 55 bool is_visible = entries.back()->intersectionRatio() >= |
56 intersection_observer_->thresholds()[0]; | 56 intersection_observer_->thresholds()[0]; |
57 (*callback_.get())(is_visible); | 57 (*callback_.get())(is_visible); |
58 } | 58 } |
59 | 59 |
60 } // namespace blink | 60 } // namespace blink |
OLD | NEW |