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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 std::sort(m_thresholds.begin(), m_thresholds.end(), std::less<double>()); | 142 std::sort(m_thresholds.begin(), m_thresholds.end(), std::less<double>()); |
143 } | 143 } |
144 | 144 |
145 IntersectionObserver::~IntersectionObserver() | 145 IntersectionObserver::~IntersectionObserver() |
146 { | 146 { |
147 disconnect(); | 147 disconnect(); |
148 } | 148 } |
149 | 149 |
150 ExceptionOr<void> IntersectionObserver::observe(Element& element) | 150 ExceptionOr<void> IntersectionObserver::observe(Element& element) |
151 { | 151 { |
152 if (&element.document() != &m_document) { | 152 if (m_root && &element.document() != &m_document) { |
| 153 // FIXME: Should we be raising an exception or just silently doing nothi
ng (which is what the spec wants and what other browsers do). |
153 m_document.domWindow()->printErrorMessage("IntersectionObserver.observe(
) on an element from another document is not allowed."); | 154 m_document.domWindow()->printErrorMessage("IntersectionObserver.observe(
) on an element from another document is not allowed."); |
154 return Exception { WrongDocumentError }; | 155 return Exception { WrongDocumentError }; |
155 } | 156 } |
156 | 157 |
157 element.startObservingIntersections(*this); | 158 element.startObservingIntersections(*this); |
158 return { }; | 159 return { }; |
159 } | 160 } |
160 | 161 |
161 void IntersectionObserver::unobserve(Element& element) | 162 void IntersectionObserver::unobserve(Element& element) |
162 { | 163 { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return; | 207 return; |
207 | 208 |
208 LOG(IntersectionObserver, "IntersectionObserver %p callback(): %lu records",
this, m_queuedEntries.size()); | 209 LOG(IntersectionObserver, "IntersectionObserver %p callback(): %lu records",
this, m_queuedEntries.size()); |
209 | 210 |
210 m_callback->handleEvent(takeRecords(), *this); | 211 m_callback->handleEvent(takeRecords(), *this); |
211 } | 212 } |
212 | 213 |
213 } // namespace WebCore | 214 } // namespace WebCore |
214 | 215 |
215 #endif // ENABLE(INTERSECTION_OBSERVER) | 216 #endif // ENABLE(INTERSECTION_OBSERVER) |
LEFT | RIGHT |