Index: Source/core/layout/LayoutView.cpp |
diff --git a/Source/core/layout/LayoutView.cpp b/Source/core/layout/LayoutView.cpp |
index 6d382e74a7b20b63b47724a53c4b8287df0b300c..fd4835706135395a6ef99b3e9817c5f903b67289 100644 |
--- a/Source/core/layout/LayoutView.cpp |
+++ b/Source/core/layout/LayoutView.cpp |
@@ -23,6 +23,7 @@ |
#include "core/dom/Document.h" |
#include "core/dom/Element.h" |
+#include "core/dom/IntersectionObserver.h" |
#include "core/editing/FrameSelection.h" |
#include "core/frame/LocalFrame.h" |
#include "core/frame/Settings.h" |
@@ -1012,4 +1013,36 @@ void LayoutView::willBeDestroyed() |
m_compositor.clear(); |
} |
+void LayoutView::addIntersectionObserverTarget(LayoutObject* obj) |
+{ |
+ m_intersectionObserverTargets.add(obj, IntRect()); |
+} |
+ |
+void LayoutView::removeIntersectionObserverTarget(LayoutObject* obj) |
+{ |
+ m_intersectionObserverTargets.remove(obj); |
+} |
+ |
+void LayoutView::computeIntersectionObservations(const FloatRect& viewport) |
+{ |
+ for (auto& obj : m_intersectionObserverTargets) { |
+ LayoutObject* layoutObect = obj.key; |
ojan
2015/09/21 03:49:09
Typo: layoutObect
MikeB
2015/09/24 19:04:04
Done.
|
+ Node* node = layoutObect->node(); |
+ if (!node || !node->isElementNode()) |
+ continue; |
+ FloatRect bounds = layoutObect->absoluteBoundingBoxFloatRect(); |
ojan
2015/09/21 03:49:09
I don't think this handles clipping from ancestor
|
+ bounds.intersect(viewport); |
+ const FloatRect& oldBounds = obj.value; |
+ if (oldBounds == bounds) |
+ continue; |
+ obj.value = bounds; |
+ Element* element = toElement(node); |
+ Vector<FloatRect> quads; |
+ quads.append(bounds); |
+ for (auto& observer : element->intersectionObservers()) { |
+ observer->enqueueIntersectionObserverEntry(IntersectionObserverEntry::create(0, quads, viewport, element)); |
+ } |
+ } |
+} |
+ |
} // namespace blink |