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

Unified Diff: Source/core/frame/FrameView.cpp

Issue 1330633003: Intersection Observer first draft Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Include new files as well. 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
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/layout/LayoutObject.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/layout/LayoutObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698