Chromium Code Reviews| 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 #ifndef IntersectionObservation_h | 5 #ifndef IntersectionObservation_h |
| 6 #define IntersectionObservation_h | 6 #define IntersectionObservation_h |
| 7 | 7 |
| 8 #include "core/dom/DOMHighResTimeStamp.h" | 8 #include "core/dom/DOMHighResTimeStamp.h" |
| 9 #include "platform/geometry/LayoutRect.h" | 9 #include "core/dom/IntersectionGeometry.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class Element; | 14 class Element; |
| 15 class IntersectionObserver; | 15 class IntersectionObserver; |
| 16 | 16 |
| 17 class IntersectionObservation final | 17 class IntersectionObservation final |
| 18 : public GarbageCollected<IntersectionObservation> { | 18 : public GarbageCollected<IntersectionObservation> { |
| 19 public: | 19 public: |
| 20 IntersectionObservation(IntersectionObserver&, | 20 IntersectionObservation( |
| 21 Element&, | 21 IntersectionObserver&, |
| 22 bool shouldReportRootBounds); | 22 Element&, |
| 23 | 23 IntersectionGeometry::ReportRootBounds shouldReportRootBounds); |
| 24 struct IntersectionGeometry { | |
| 25 LayoutRect targetRect; | |
| 26 LayoutRect intersectionRect; | |
| 27 LayoutRect rootRect; | |
| 28 bool doesIntersect; | |
| 29 | |
| 30 IntersectionGeometry() : doesIntersect(false) {} | |
| 31 }; | |
| 32 | 24 |
| 33 IntersectionObserver& observer() const { return *m_observer; } | 25 IntersectionObserver& observer() const { return *m_observer; } |
| 34 Element* target() const { return m_target; } | 26 Element* target() const { return m_target; } |
| 35 unsigned lastThresholdIndex() const { return m_lastThresholdIndex; } | 27 unsigned lastThresholdIndex() const { return m_lastThresholdIndex; } |
| 36 void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; } | 28 void setLastThresholdIndex(unsigned index) { m_lastThresholdIndex = index; } |
| 37 bool shouldReportRootBounds() const { return m_shouldReportRootBounds; } | |
| 38 void computeIntersectionObservations(DOMHighResTimeStamp); | 29 void computeIntersectionObservations(DOMHighResTimeStamp); |
| 39 void disconnect(); | 30 void disconnect(); |
| 40 void clearRootAndRemoveFromTarget(); | 31 void clearRootAndRemoveFromTarget(); |
| 41 | 32 |
| 42 DECLARE_TRACE(); | 33 DECLARE_TRACE(); |
| 43 | 34 |
| 44 private: | 35 private: |
| 45 void applyRootMargin(LayoutRect&) const; | |
| 46 void initializeGeometry(IntersectionGeometry&) const; | |
| 47 void initializeTargetRect(LayoutRect&) const; | |
| 48 void initializeRootRect(LayoutRect&) const; | |
| 49 void clipToRoot(IntersectionGeometry&) const; | |
| 50 void mapTargetRectToTargetFrameCoordinates(LayoutRect&) const; | |
| 51 void mapRootRectToRootFrameCoordinates(LayoutRect&) const; | |
| 52 void mapRootRectToTargetFrameCoordinates(LayoutRect&) const; | |
| 53 bool computeGeometry(IntersectionGeometry&) const; | |
| 54 | |
| 55 Member<IntersectionObserver> m_observer; | 36 Member<IntersectionObserver> m_observer; |
| 56 | |
| 57 WeakMember<Element> m_target; | 37 WeakMember<Element> m_target; |
| 58 | 38 |
| 59 unsigned m_shouldReportRootBounds : 1; | 39 IntersectionGeometry::ReportRootBounds m_shouldReportRootBounds; |
| 60 unsigned m_lastThresholdIndex : 30; | 40 unsigned m_lastThresholdIndex; |
|
ojan
2016/11/24 03:06:06
Please keep the : 1 and the : 30. That should work
xjz
2016/11/30 01:58:44
Yes, it still only takes 1 bit. The only reason I
miu
2016/11/30 03:40:36
You can make it unsigned. Just initialize it in th
xjz
2016/11/30 07:05:54
Yes, that is what toShouldReportRootBounds() does.
| |
| 61 }; | 41 }; |
| 62 | 42 |
| 63 } // namespace blink | 43 } // namespace blink |
| 64 | 44 |
| 65 #endif // IntersectionObservation_h | 45 #endif // IntersectionObservation_h |
| OLD | NEW |