Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1045)

Unified Diff: Source/core/layout/LayoutView.cpp

Issue 1330633003: Intersection Observer first draft Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix segfault on null input. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698