| 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/IntersectionObservation.h" | 5 #include "core/dom/IntersectionObservation.h" |
| 6 | 6 |
| 7 #include "core/dom/ElementRareData.h" | 7 #include "core/dom/ElementRareData.h" |
| 8 #include "core/dom/IntersectionObserver.h" | 8 #include "core/dom/IntersectionObserver.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/layout/LayoutBox.h" | 10 #include "core/layout/LayoutBox.h" |
| 11 #include "core/layout/LayoutPart.h" | 11 #include "core/layout/LayoutPart.h" |
| 12 #include "core/layout/LayoutText.h" | 12 #include "core/layout/LayoutText.h" |
| 13 #include "core/layout/LayoutView.h" | 13 #include "core/layout/LayoutView.h" |
| 14 #include "core/paint/PaintLayer.h" | 14 #include "core/paint/PaintLayer.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 IntersectionObservation::IntersectionObservation(IntersectionObserver& observer,
Element& target, bool shouldReportRootBounds) | 18 IntersectionObservation::IntersectionObservation(IntersectionObserver& observer,
Element& target, bool shouldReportRootBounds) |
| 19 : m_observer(observer) | 19 : m_observer(observer) |
| 20 , m_target(target.ensureIntersectionObserverData().createWeakPtr(&target)) | 20 , m_target(&target) |
| 21 , m_shouldReportRootBounds(shouldReportRootBounds) | 21 , m_shouldReportRootBounds(shouldReportRootBounds) |
| 22 , m_lastThresholdIndex(0) | 22 , m_lastThresholdIndex(0) |
| 23 { | 23 { |
| 24 } | 24 } |
| 25 | 25 |
| 26 Element* IntersectionObservation::target() const | |
| 27 { | |
| 28 return toElement(m_target.get()); | |
| 29 } | |
| 30 | |
| 31 void IntersectionObservation::applyRootMargin(LayoutRect& rect) const | 26 void IntersectionObservation::applyRootMargin(LayoutRect& rect) const |
| 32 { | 27 { |
| 33 if (m_shouldReportRootBounds) | 28 if (m_shouldReportRootBounds) |
| 34 m_observer->applyRootMargin(rect); | 29 m_observer->applyRootMargin(rect); |
| 35 } | 30 } |
| 36 | 31 |
| 37 void IntersectionObservation::initializeGeometry(IntersectionGeometry& geometry)
const | 32 void IntersectionObservation::initializeGeometry(IntersectionGeometry& geometry)
const |
| 38 { | 33 { |
| 39 initializeTargetRect(geometry.targetRect); | 34 initializeTargetRect(geometry.targetRect); |
| 40 geometry.intersectionRect = geometry.targetRect; | 35 geometry.intersectionRect = geometry.targetRect; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 m_observer.clear(); | 236 m_observer.clear(); |
| 242 } | 237 } |
| 243 | 238 |
| 244 DEFINE_TRACE(IntersectionObservation) | 239 DEFINE_TRACE(IntersectionObservation) |
| 245 { | 240 { |
| 246 visitor->trace(m_observer); | 241 visitor->trace(m_observer); |
| 247 visitor->trace(m_target); | 242 visitor->trace(m_target); |
| 248 } | 243 } |
| 249 | 244 |
| 250 } // namespace blink | 245 } // namespace blink |
| OLD | NEW |