| 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/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 else | 54 else |
| 55 rect = LayoutRect(toLayoutBoxModelObject(rootLayoutObject)->borderBoundi
ngBox()); | 55 rect = LayoutRect(toLayoutBoxModelObject(rootLayoutObject)->borderBoundi
ngBox()); |
| 56 applyRootMargin(rect); | 56 applyRootMargin(rect); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void IntersectionObservation::clipToRoot(IntersectionGeometry& geometry) const | 59 void IntersectionObservation::clipToRoot(IntersectionGeometry& geometry) const |
| 60 { | 60 { |
| 61 // Map and clip rect into root element coordinates. | 61 // Map and clip rect into root element coordinates. |
| 62 // TODO(szager): the writing mode flipping needs a test. | 62 // TODO(szager): the writing mode flipping needs a test. |
| 63 DCHECK(m_target); | 63 DCHECK(m_target); |
| 64 LayoutObject* rootLayoutObject = m_observer->rootLayoutObject(); | 64 LayoutBox* rootLayoutObject = toLayoutBox(m_observer->rootLayoutObject()); |
| 65 LayoutObject* targetLayoutObject = target()->layoutObject(); | 65 LayoutObject* targetLayoutObject = target()->layoutObject(); |
| 66 | 66 |
| 67 geometry.doesIntersect = targetLayoutObject->mapToVisualRectInAncestorSpace(
toLayoutBoxModelObject(rootLayoutObject), geometry.intersectionRect, EdgeInclusi
ve); | 67 geometry.doesIntersect = targetLayoutObject->mapToVisualRectInAncestorSpace(
rootLayoutObject, geometry.intersectionRect, EdgeInclusive); |
| 68 if (rootLayoutObject->hasOverflowClip()) |
| 69 geometry.intersectionRect.move(-rootLayoutObject->scrolledContentOffset(
)); |
| 70 |
| 68 if (!geometry.doesIntersect) | 71 if (!geometry.doesIntersect) |
| 69 return; | 72 return; |
| 70 LayoutRect rootClipRect(geometry.rootRect); | 73 LayoutRect rootClipRect(geometry.rootRect); |
| 71 toLayoutBox(rootLayoutObject)->flipForWritingMode(rootClipRect); | 74 rootLayoutObject->flipForWritingMode(rootClipRect); |
| 72 geometry.doesIntersect &= geometry.intersectionRect.inclusiveIntersect(rootC
lipRect); | 75 geometry.doesIntersect &= geometry.intersectionRect.inclusiveIntersect(rootC
lipRect); |
| 73 } | 76 } |
| 74 | 77 |
| 75 static void mapRectUpToDocument(LayoutRect& rect, const LayoutObject& layoutObje
ct, const Document& document) | 78 static void mapRectUpToDocument(LayoutRect& rect, const LayoutObject& layoutObje
ct, const Document& document) |
| 76 { | 79 { |
| 77 FloatQuad mappedQuad = layoutObject.localToAbsoluteQuad( | 80 FloatQuad mappedQuad = layoutObject.localToAbsoluteQuad( |
| 78 FloatQuad(FloatRect(rect)), | 81 FloatQuad(FloatRect(rect)), |
| 79 UseTransforms | ApplyContainerFlip); | 82 UseTransforms | ApplyContainerFlip); |
| 80 rect = LayoutRect(mappedQuad.boundingBox()); | 83 rect = LayoutRect(mappedQuad.boundingBox()); |
| 81 } | 84 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 m_observer.clear(); | 247 m_observer.clear(); |
| 245 } | 248 } |
| 246 | 249 |
| 247 DEFINE_TRACE(IntersectionObservation) | 250 DEFINE_TRACE(IntersectionObservation) |
| 248 { | 251 { |
| 249 visitor->trace(m_observer); | 252 visitor->trace(m_observer); |
| 250 visitor->trace(m_target); | 253 visitor->trace(m_target); |
| 251 } | 254 } |
| 252 | 255 |
| 253 } // namespace blink | 256 } // namespace blink |
| OLD | NEW |