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

Unified Diff: third_party/WebKit/Source/core/frame/RemoteFrameView.cpp

Issue 2431473003: Intersection Observer support for OOPIF (Closed)
Patch Set: dcheng comments addressed Created 3 years, 11 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/frame/RemoteFrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/RemoteFrameView.cpp b/third_party/WebKit/Source/core/frame/RemoteFrameView.cpp
index d73ac0a12b1be30a510ebefa50124bbe42f465bd..fb2ad9dfca532834c155c4a89822bf45bf60e5ae 100644
--- a/third_party/WebKit/Source/core/frame/RemoteFrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/RemoteFrameView.cpp
@@ -4,9 +4,13 @@
#include "core/frame/RemoteFrameView.h"
+#include "core/dom/IntersectionObserverEntry.h"
#include "core/frame/FrameView.h"
+#include "core/frame/LocalFrame.h"
#include "core/frame/RemoteFrame.h"
+#include "core/frame/RemoteFrameClient.h"
#include "core/html/HTMLFrameOwnerElement.h"
+#include "core/layout/LayoutView.h"
#include "core/layout/api/LayoutPartItem.h"
namespace blink {
@@ -29,6 +33,41 @@ RemoteFrameView* RemoteFrameView::create(RemoteFrame* remoteFrame) {
return view;
}
+void RemoteFrameView::updateRemoteViewportIntersection() {
+ if (!m_remoteFrame->ownerLayoutObject())
+ return;
+
+ FrameView* localRootView =
+ toLocalFrame(m_remoteFrame->tree().parent())->localFrameRoot()->view();
+ if (!localRootView)
+ return;
+
+ // Start with rect in remote frame's coordinate space. Then
+ // mapToVisualRectInAncestorSpace will move it to the local root's coordinate
+ // space and account for any clip from containing elements such as a
+ // scrollable div. Passing nullptr as an argument to
+ // mapToVisualRectInAncestorSpace causes it to be clipped to the viewport,
+ // even if there are RemoteFrame ancestors in the frame tree.
+ LayoutRect rect(0, 0, frameRect().width(), frameRect().height());
+ rect.move(m_remoteFrame->ownerLayoutObject()->contentBoxOffset());
+ if (!m_remoteFrame->ownerLayoutObject()->mapToVisualRectInAncestorSpace(
+ nullptr, rect))
+ return;
+ IntRect rootVisibleRect = localRootView->visibleContentRect();
+ IntRect viewportIntersection(rect);
+ viewportIntersection.intersect(rootVisibleRect);
+ viewportIntersection.move(-localRootView->scrollOffsetInt());
+
+ // Translate the intersection rect from the root frame's coordinate space
+ // to the remote frame's coordinate space.
+ viewportIntersection = convertFromRootFrame(viewportIntersection);
+ if (viewportIntersection != m_lastViewportIntersection) {
+ m_remoteFrame->client()->updateRemoteViewportIntersection(
+ viewportIntersection);
+ }
+ m_lastViewportIntersection = viewportIntersection;
+}
+
void RemoteFrameView::dispose() {
HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner();
// ownerElement can be null during frame swaps, because the
@@ -68,7 +107,9 @@ void RemoteFrameView::frameRectsChanged() {
if (parent() && parent()->isFrameView())
newRect = parent()->convertToRootFrame(
toFrameView(parent())->contentsToFrame(newRect));
- m_remoteFrame->frameRectsChanged(newRect);
+ m_remoteFrame->client()->frameRectsChanged(newRect);
+
+ updateRemoteViewportIntersection();
}
void RemoteFrameView::hide() {
@@ -76,7 +117,7 @@ void RemoteFrameView::hide() {
Widget::hide();
- m_remoteFrame->visibilityChanged(false);
+ m_remoteFrame->client()->visibilityChanged(false);
}
void RemoteFrameView::show() {
@@ -84,7 +125,7 @@ void RemoteFrameView::show() {
Widget::show();
- m_remoteFrame->visibilityChanged(true);
+ m_remoteFrame->client()->visibilityChanged(true);
}
void RemoteFrameView::setParentVisible(bool visible) {
@@ -95,7 +136,7 @@ void RemoteFrameView::setParentVisible(bool visible) {
if (!isSelfVisible())
return;
- m_remoteFrame->visibilityChanged(isVisible());
+ m_remoteFrame->client()->visibilityChanged(isVisible());
}
DEFINE_TRACE(RemoteFrameView) {
« no previous file with comments | « third_party/WebKit/Source/core/frame/RemoteFrameView.h ('k') | third_party/WebKit/Source/core/layout/IntersectionGeometry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698