LEFT | RIGHT |
1 /* | 1 /* |
2 * Copyright (C) 2016 Apple Inc. All rights reserved. | 2 * Copyright (C) 2016 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // IntersectionObservers for which the element that owns this IntersectionOb
serverData is the root. | 49 // IntersectionObservers for which the element that owns this IntersectionOb
serverData is the root. |
50 Vector<IntersectionObserver*> observers; | 50 Vector<IntersectionObserver*> observers; |
51 | 51 |
52 // Intersection observations for which the element that owns this Intersecti
onObserverData is the target. | 52 // Intersection observations for which the element that owns this Intersecti
onObserverData is the target. |
53 Vector<IntersectionObserverRegistration> registrations; | 53 Vector<IntersectionObserverRegistration> registrations; |
54 }; | 54 }; |
55 | 55 |
56 class IntersectionObserver : public RefCounted<IntersectionObserver> { | 56 class IntersectionObserver : public RefCounted<IntersectionObserver> { |
57 public: | 57 public: |
58 struct Init { | 58 struct Init { |
59 RefPtr<Element> root; | 59 Element* root; |
60 String rootMargin; | 60 String rootMargin; |
61 Variant<double, Vector<double>> threshold; | 61 Variant<double, Vector<double>> threshold; |
62 }; | 62 }; |
63 | 63 |
64 static ExceptionOr<Ref<IntersectionObserver>> create(Document&, Ref<Intersec
tionObserverCallback>&&, Init&&); | 64 static ExceptionOr<Ref<IntersectionObserver>> create(Document&, Ref<Intersec
tionObserverCallback>&&, Init&&); |
65 | 65 |
| 66 Element* root() const { return m_root; } |
| 67 String rootMargin() const; |
| 68 |
66 ~IntersectionObserver(); | 69 ~IntersectionObserver(); |
67 | 70 |
68 Document* trackingDocument() { return m_root ? &m_root->document() : m_impli
citRootDocument; } | 71 Document* trackingDocument() { return m_root ? &m_root->document() : m_impli
citRootDocument; } |
69 | 72 |
70 Element* root() const { return m_root.get(); } | 73 const LengthBox& marginBox() const { return m_rootMargin; } |
71 String rootMargin() const { return m_rootMargin; } | |
72 const LengthBox& marginBox() const { return m_marginBox; } | |
73 const Vector<double>& thresholds() const { return m_thresholds; } | 74 const Vector<double>& thresholds() const { return m_thresholds; } |
74 const Vector<Element*> observationTargets() const { return m_observationTarg
ets; } | 75 const Vector<Element*> observationTargets() const { return m_observationTarg
ets; } |
75 | 76 |
76 // Called from JavaScript API | 77 // Called from JavaScript API |
77 void observe(Element&); | 78 void observe(Element&); |
78 void unobserve(Element&); | 79 void unobserve(Element&); |
79 void disconnect(); | 80 void disconnect(); |
80 | 81 |
81 Vector<Ref<IntersectionObserverEntry>> takeRecords(); | 82 Vector<Ref<IntersectionObserverEntry>> takeRecords(); |
82 | 83 |
83 // Called internally. | 84 // Called internally. |
84 void addObservationTarget(Element&); | 85 void addObservationTarget(Element&); |
85 void removeObservationTarget(Element&); | 86 void removeObservationTarget(Element&); |
86 bool hasObservationTarget(Element&) const; | 87 bool hasObservationTarget(Element&) const; |
87 bool hasObservationTargets() const { return m_observationTargets.size(); } | 88 bool hasObservationTargets() const { return m_observationTargets.size(); } |
88 bool createTimestamp(DOMHighResTimeStamp&) const; | 89 bool createTimestamp(DOMHighResTimeStamp&) const; |
| 90 void rootDestroyed(); |
89 void implicitRootDocumentDestroyed(); | 91 void implicitRootDocumentDestroyed(); |
90 | 92 |
91 void appendQueuedEntry(Ref<IntersectionObserverEntry>&&); | 93 void appendQueuedEntry(Ref<IntersectionObserverEntry>&&); |
92 void notify(); | 94 void notify(); |
93 | 95 |
94 private: | 96 private: |
95 IntersectionObserver(Document&, Ref<IntersectionObserverCallback>&&, Init&&,
LengthBox&& marginBox); | 97 IntersectionObserver(Document&, Ref<IntersectionObserverCallback>&&, Init&&,
LengthBox&& marginBox); |
96 | 98 |
97 Document* m_implicitRootDocument; | 99 Document* m_implicitRootDocument; |
98 RefPtr<Element> m_root; | 100 Element* m_root; |
99 String m_rootMargin; | 101 LengthBox m_rootMargin; |
100 Vector<double> m_thresholds; | 102 Vector<double> m_thresholds; |
101 Ref<IntersectionObserverCallback> m_callback; | 103 Ref<IntersectionObserverCallback> m_callback; |
102 LengthBox m_marginBox; | 104 LengthBox m_marginBox; |
103 Vector<Element*> m_observationTargets; | 105 Vector<Element*> m_observationTargets; |
104 Vector<Ref<IntersectionObserverEntry>> m_queuedEntries; | 106 Vector<Ref<IntersectionObserverEntry>> m_queuedEntries; |
105 }; | 107 }; |
106 | 108 |
107 } // namespace WebCore | 109 } // namespace WebCore |
108 | 110 |
109 #endif // ENABLE(INTERSECTION_OBSERVER) | 111 #endif // ENABLE(INTERSECTION_OBSERVER) |
LEFT | RIGHT |