| 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/IntersectionObserver.h" | 5 #include "core/dom/IntersectionObserver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/css/parser/CSSParserTokenRange.h" | 8 #include "core/css/parser/CSSParserTokenRange.h" |
| 9 #include "core/css/parser/CSSTokenizer.h" | 9 #include "core/css/parser/CSSTokenizer.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 rect.setX(rect.x() - leftMargin); | 284 rect.setX(rect.x() - leftMargin); |
| 285 rect.setWidth(rect.width() + leftMargin + rightMargin); | 285 rect.setWidth(rect.width() + leftMargin + rightMargin); |
| 286 rect.setY(rect.y() - topMargin); | 286 rect.setY(rect.y() - topMargin); |
| 287 rect.setHeight(rect.height() + topMargin + bottomMargin); | 287 rect.setHeight(rect.height() + topMargin + bottomMargin); |
| 288 } | 288 } |
| 289 | 289 |
| 290 unsigned IntersectionObserver::firstThresholdGreaterThan(float ratio) const | 290 unsigned IntersectionObserver::firstThresholdGreaterThan(float ratio) const |
| 291 { | 291 { |
| 292 unsigned result = 0; | 292 unsigned result = 0; |
| 293 | |
| 294 // Special handling for zero threshold, which means "any non-zero number of
pixels." | |
| 295 // If the ratio is zero, then it should be treated as smaller than any thres
hold, | |
| 296 // even a zero threshold. | |
| 297 if (!ratio) | |
| 298 return 0; | |
| 299 | |
| 300 while (result < m_thresholds.size() && m_thresholds[result] <= ratio) | 293 while (result < m_thresholds.size() && m_thresholds[result] <= ratio) |
| 301 ++result; | 294 ++result; |
| 302 return result; | 295 return result; |
| 303 } | 296 } |
| 304 | 297 |
| 305 void IntersectionObserver::deliver() | 298 void IntersectionObserver::deliver() |
| 306 { | 299 { |
| 307 | 300 |
| 308 if (m_entries.isEmpty()) | 301 if (m_entries.isEmpty()) |
| 309 return; | 302 return; |
| 310 | 303 |
| 311 HeapVector<Member<IntersectionObserverEntry>> entries; | 304 HeapVector<Member<IntersectionObserverEntry>> entries; |
| 312 entries.swap(m_entries); | 305 entries.swap(m_entries); |
| 313 m_callback->handleEvent(entries, *this); | 306 m_callback->handleEvent(entries, *this); |
| 314 } | 307 } |
| 315 | 308 |
| 316 DEFINE_TRACE(IntersectionObserver) | 309 DEFINE_TRACE(IntersectionObserver) |
| 317 { | 310 { |
| 318 #if ENABLE(OILPAN) | 311 #if ENABLE(OILPAN) |
| 319 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs
erver::clearWeakMembers>(this); | 312 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs
erver::clearWeakMembers>(this); |
| 320 #endif | 313 #endif |
| 321 visitor->trace(m_callback); | 314 visitor->trace(m_callback); |
| 322 visitor->trace(m_observations); | 315 visitor->trace(m_observations); |
| 323 visitor->trace(m_entries); | 316 visitor->trace(m_entries); |
| 324 } | 317 } |
| 325 | 318 |
| 326 } // namespace blink | 319 } // namespace blink |
| OLD | NEW |