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

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

Issue 1330633003: Intersection Observer first draft Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Lost newline in merge 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: third_party/WebKit/Source/core/layout/LayoutView.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutView.cpp b/third_party/WebKit/Source/core/layout/LayoutView.cpp
index aa3ccf3f2599d681445a8a682a191d7b98273321..858c8d2d2bab94658c3d7a283e1c24d83c7d545c 100644
--- a/third_party/WebKit/Source/core/layout/LayoutView.cpp
+++ b/third_party/WebKit/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"
@@ -954,4 +955,35 @@ 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& rootBounds)
+{
+ for (auto& obj : m_intersectionObserverTargets) {
+ LayoutObject* layoutObject = obj.key;
+ Node* node = layoutObject->node();
+ if (!node || !node->isElementNode())
+ continue;
+ FloatRect bounds = layoutObject->absoluteBoundingBoxFloatRect();
+ FloatRect intersection(bounds);
+ intersection.intersect(rootBounds);
+ const FloatRect& oldIntersection = obj.value;
+ if (oldIntersection == intersection)
+ continue;
+ obj.value = intersection;
+ Element* element = toElement(node);
+ for (auto& observer : element->intersectionObservers()) {
+ observer->enqueueIntersectionObserverEntry(IntersectionObserverEntry::create(0, bounds, rootBounds, intersection, element));
+ }
+ }
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.h ('k') | third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698