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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 descendant = descendant->containingBlock(); | 136 descendant = descendant->containingBlock(); |
137 return descendant; | 137 return descendant; |
138 } | 138 } |
139 | 139 |
140 bool IntersectionObservation::computeGeometry(IntersectionGeometry& geometry) co
nst | 140 bool IntersectionObservation::computeGeometry(IntersectionGeometry& geometry) co
nst |
141 { | 141 { |
142 // In the first few lines here, before initializeGeometry is called, "return
true" | 142 // In the first few lines here, before initializeGeometry is called, "return
true" |
143 // effectively means "if the previous observed state was that root and targe
t were | 143 // effectively means "if the previous observed state was that root and targe
t were |
144 // intersecting, then generate a notification indicating that they are no lo
nger | 144 // intersecting, then generate a notification indicating that they are no lo
nger |
145 // intersecting." This happens, for example, when root or target is removed
from the | 145 // intersecting." This happens, for example, when root or target is removed
from the |
146 // DOM tree and not reinserted before the next frame is generated. | 146 // DOM tree and not reinserted before the next frame is generated, or displa
y:none |
| 147 // is set on the root or target. |
147 Element* targetElement = target(); | 148 Element* targetElement = target(); |
148 if (!targetElement) | 149 if (!targetElement) |
149 return false; | 150 return false; |
150 if (!targetElement->inShadowIncludingDocument()) | 151 if (!targetElement->inShadowIncludingDocument()) |
151 return true; | 152 return true; |
152 DCHECK(m_observer); | 153 DCHECK(m_observer); |
153 Element* rootElement = m_observer->root(); | 154 Element* rootElement = m_observer->root(); |
154 if (rootElement && !rootElement->inShadowIncludingDocument()) | 155 if (rootElement && !rootElement->inShadowIncludingDocument()) |
155 return true; | 156 return true; |
156 | 157 |
157 LayoutObject* rootLayoutObject = m_observer->rootLayoutObject(); | 158 LayoutObject* rootLayoutObject = m_observer->rootLayoutObject(); |
158 if (!rootLayoutObject || !rootLayoutObject->isBoxModelObject()) | 159 if (!rootLayoutObject || !rootLayoutObject->isBoxModelObject()) |
159 return false; | 160 return true; |
160 // TODO(szager): Support SVG | 161 // TODO(szager): Support SVG |
161 LayoutObject* targetLayoutObject = targetElement->layoutObject(); | 162 LayoutObject* targetLayoutObject = targetElement->layoutObject(); |
162 if (!targetLayoutObject) | 163 if (!targetLayoutObject) |
163 return false; | 164 return true; |
164 if (!targetLayoutObject->isBoxModelObject() && !targetLayoutObject->isText()
) | 165 if (!targetLayoutObject->isBoxModelObject() && !targetLayoutObject->isText()
) |
165 return false; | 166 return true; |
166 if (!isContainingBlockChainDescendant(targetLayoutObject, rootLayoutObject)) | 167 if (!isContainingBlockChainDescendant(targetLayoutObject, rootLayoutObject)) |
167 return true; | 168 return true; |
168 | 169 |
169 initializeGeometry(geometry); | 170 initializeGeometry(geometry); |
170 | 171 |
171 clipToRoot(geometry); | 172 clipToRoot(geometry); |
172 | 173 |
173 mapTargetRectToTargetFrameCoordinates(geometry.targetRect); | 174 mapTargetRectToTargetFrameCoordinates(geometry.targetRect); |
174 | 175 |
175 if (geometry.doesIntersect) | 176 if (geometry.doesIntersect) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 m_observer.clear(); | 244 m_observer.clear(); |
244 } | 245 } |
245 | 246 |
246 DEFINE_TRACE(IntersectionObservation) | 247 DEFINE_TRACE(IntersectionObservation) |
247 { | 248 { |
248 visitor->trace(m_observer); | 249 visitor->trace(m_observer); |
249 visitor->trace(m_target); | 250 visitor->trace(m_target); |
250 } | 251 } |
251 | 252 |
252 } // namespace blink | 253 } // namespace blink |
OLD | NEW |