| 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" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 &layoutObject, | 87 &layoutObject, |
| 88 FloatQuad(FloatRect(rect)), | 88 FloatQuad(FloatRect(rect)), |
| 89 UseTransforms | ApplyContainerFlip | TraverseDocumentBoundaries); | 89 UseTransforms | ApplyContainerFlip | TraverseDocumentBoundaries); |
| 90 rect = LayoutRect(mappedQuad.boundingBox()); | 90 rect = LayoutRect(mappedQuad.boundingBox()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void IntersectionObservation::mapTargetRectToTargetFrameCoordinates(LayoutRect&
rect) const | 93 void IntersectionObservation::mapTargetRectToTargetFrameCoordinates(LayoutRect&
rect) const |
| 94 { | 94 { |
| 95 LayoutObject& targetLayoutObject = *target()->layoutObject(); | 95 LayoutObject& targetLayoutObject = *target()->layoutObject(); |
| 96 Document& targetDocument = target()->document(); | 96 Document& targetDocument = target()->document(); |
| 97 LayoutSize scrollPosition = LayoutSize(toIntSize(targetDocument.view()->scro
llPosition())); | 97 LayoutSize scrollPosition = LayoutSize(targetDocument.view()->scrollOffset()
); |
| 98 mapRectUpToDocument(rect, targetLayoutObject, targetDocument); | 98 mapRectUpToDocument(rect, targetLayoutObject, targetDocument); |
| 99 rect.move(-scrollPosition); | 99 rect.move(-scrollPosition); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void IntersectionObservation::mapRootRectToRootFrameCoordinates(LayoutRect& rect
) const | 102 void IntersectionObservation::mapRootRectToRootFrameCoordinates(LayoutRect& rect
) const |
| 103 { | 103 { |
| 104 LayoutObject& rootLayoutObject = *m_observer->rootLayoutObject(); | 104 LayoutObject& rootLayoutObject = *m_observer->rootLayoutObject(); |
| 105 Document& rootDocument = rootLayoutObject.document(); | 105 Document& rootDocument = rootLayoutObject.document(); |
| 106 LayoutSize scrollPosition = LayoutSize(toIntSize(rootDocument.view()->scroll
Position())); | 106 LayoutSize scrollPosition = LayoutSize(rootDocument.view()->scrollOffset()); |
| 107 mapRectUpToDocument(rect, rootLayoutObject, rootLayoutObject.document()); | 107 mapRectUpToDocument(rect, rootLayoutObject, rootLayoutObject.document()); |
| 108 rect.move(-scrollPosition); | 108 rect.move(-scrollPosition); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void IntersectionObservation::mapRootRectToTargetFrameCoordinates(LayoutRect& re
ct) const | 111 void IntersectionObservation::mapRootRectToTargetFrameCoordinates(LayoutRect& re
ct) const |
| 112 { | 112 { |
| 113 LayoutObject& rootLayoutObject = *m_observer->rootLayoutObject(); | 113 LayoutObject& rootLayoutObject = *m_observer->rootLayoutObject(); |
| 114 Document& targetDocument = target()->document(); | 114 Document& targetDocument = target()->document(); |
| 115 LayoutSize scrollPosition = LayoutSize(toIntSize(targetDocument.view()->scro
llPosition())); | 115 LayoutSize scrollPosition = LayoutSize(targetDocument.view()->scrollOffset()
); |
| 116 | 116 |
| 117 if (&targetDocument == &rootLayoutObject.document()) | 117 if (&targetDocument == &rootLayoutObject.document()) |
| 118 mapRectUpToDocument(rect, rootLayoutObject, targetDocument); | 118 mapRectUpToDocument(rect, rootLayoutObject, targetDocument); |
| 119 else | 119 else |
| 120 mapRectDownToDocument(rect, toLayoutBoxModelObject(rootLayoutObject), ta
rgetDocument); | 120 mapRectDownToDocument(rect, toLayoutBoxModelObject(rootLayoutObject), ta
rgetDocument); |
| 121 | 121 |
| 122 rect.move(-scrollPosition); | 122 rect.move(-scrollPosition); |
| 123 } | 123 } |
| 124 | 124 |
| 125 static bool isContainingBlockChainDescendant(LayoutObject* descendant, LayoutObj
ect* ancestor) | 125 static bool isContainingBlockChainDescendant(LayoutObject* descendant, LayoutObj
ect* ancestor) |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 m_observer.clear(); | 244 m_observer.clear(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 DEFINE_TRACE(IntersectionObservation) | 247 DEFINE_TRACE(IntersectionObservation) |
| 248 { | 248 { |
| 249 visitor->trace(m_observer); | 249 visitor->trace(m_observer); |
| 250 visitor->trace(m_target); | 250 visitor->trace(m_target); |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace blink | 253 } // namespace blink |
| OLD | NEW |