Index: Source/core/frame/FrameView.cpp |
diff --git a/Source/core/frame/FrameView.cpp b/Source/core/frame/FrameView.cpp |
index e4635d9f6241e3ebe2688d4f991e65c383eaba5e..b8b87101b64bf991b67319a1162f95b01e849685 100644 |
--- a/Source/core/frame/FrameView.cpp |
+++ b/Source/core/frame/FrameView.cpp |
@@ -34,6 +34,7 @@ |
#include "core/css/resolver/StyleResolver.h" |
#include "core/dom/AXObjectCache.h" |
#include "core/dom/Fullscreen.h" |
+#include "core/dom/IntersectionObserver.h" |
#include "core/editing/EditingUtilities.h" |
#include "core/editing/FrameSelection.h" |
#include "core/editing/RenderedPosition.h" |
@@ -1116,6 +1117,46 @@ void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation |
m_doFullPaintInvalidation = false; |
lifecycle().advanceTo(DocumentLifecycle::PaintInvalidationClean); |
+ |
+ if (RuntimeEnabledFeatures::intersectionObserverEnabled()) { |
+ computeIntersectionObservations(paintInvalidationState); |
+ } |
+} |
+ |
+void FrameView::computeIntersectionObservations(PaintInvalidationState& paintInvalidationState) |
+{ |
+ ASSERT(layoutView()); |
+ LayoutView& rootForPaintInvalidation = *layoutView(); |
+ |
+ if (FrameView* parent = parentFrameView()) { |
liberato (no reviews please)
2015/09/04 15:07:46
how will you handle different containing views ("v
MikeB
2015/09/04 17:59:33
I think viewportModifierLength is being dropped. I
|
+ m_clippedBounds = IntRect(frameRect().location(), paintInvalidationState.clipRect().pixelSnappedSize()); |
+ m_clippedBounds = parent->contentsToRootFrame(m_clippedBounds); |
+ m_clippedBounds.intersect(parent->contentsToRootFrame(parent->m_clippedBounds)); |
+ if (!m_clippedBounds.isEmpty()) { |
+ m_clippedBounds = rootFrameToContents(m_clippedBounds); |
+ } |
+ } else { |
+ m_clippedBounds = pixelSnappedIntRect(paintInvalidationState.clipRect()); |
liberato (no reviews please)
2015/09/04 15:07:46
is this correct if one zooms? i believe so.
MikeB
2015/09/04 17:59:34
Good question. I can test!
|
+ } |
+ |
+ FloatRect viewport(m_clippedBounds); |
+ for (auto& obj : rootForPaintInvalidation.intersectionObserverTargets()) { |
liberato (no reviews please)
2015/09/04 15:07:46
independently of the above comment about moving th
MikeB
2015/09/04 17:59:33
Fair point.
|
+ Node* node = obj.key->node(); |
liberato (no reviews please)
2015/09/04 15:07:46
for clarity, "LayoutObject* layoutObect = obj.key"
|
+ if (!node || !node->isElementNode()) |
+ continue; |
+ FloatRect bounds = obj.key->absoluteBoundingBoxFloatRect(); |
+ 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); |
liberato (no reviews please)
2015/09/04 15:07:46
this brings up a question i had about the doc. i'
MikeB
2015/09/04 17:59:33
According to the guys who drafted that particular
|
+ for (auto& observer : element->intersectionObservers()) { |
+ observer->enqueueIntersectionObserverEntry(IntersectionObserverEntry::create(0, quads, viewport, element)); |
+ } |
+ } |
} |
DocumentLifecycle& FrameView::lifecycle() const |