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..43212318c24dc6156292e81e263d9c741f407b53 100644 |
--- a/third_party/WebKit/Source/core/frame/RemoteFrameView.cpp |
+++ b/third_party/WebKit/Source/core/frame/RemoteFrameView.cpp |
@@ -5,9 +5,13 @@ |
#include "core/frame/RemoteFrameView.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" |
+#include "platform/geometry/IntPoint.h" |
namespace blink { |
@@ -29,6 +33,40 @@ RemoteFrameView* RemoteFrameView::create(RemoteFrame* remoteFrame) { |
return view; |
} |
+void RemoteFrameView::updateRemoteViewportIntersection() { |
+ if (!m_remoteFrame->tree().parent() || |
+ !m_remoteFrame->tree().parent()->isLocalFrame() || |
+ !m_remoteFrame->client() || !m_remoteFrame->ownerLayoutObject()) |
+ return; |
+ |
+ FrameView* parentView = toLocalFrame(m_remoteFrame->tree().parent())->view(); |
+ if (!parentView) |
+ return; |
+ |
+ // Start with rect in remote frame's coordinate space. Then |
+ // mapToVisualRectInAncestorSpace will move it to its parent's coordinate |
+ // space and account for any clip from containing elements such as a |
+ // scrollable div. |
+ LayoutRect rect(0, 0, frameRect().width(), frameRect().height()); |
+ if (!m_remoteFrame->ownerLayoutObject()->mapToVisualRectInAncestorSpace( |
+ parentView->layoutView(), rect)) |
+ return; |
+ IntRect viewportIntersection(rect); |
+ viewportIntersection.move(-parentView->scrollOffsetInt()); |
+ |
+ IntRect parentViewportIntersection = parentView->viewportIntersection(); |
+ |
+ viewportIntersection.intersect(parentViewportIntersection); |
+ // Translate the intersection rect from the parent frame's coordinate space |
+ // to the remote frame's coordinate space. |
+ viewportIntersection = convertFromContainingWidget(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 +106,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 +116,8 @@ void RemoteFrameView::hide() { |
Widget::hide(); |
- m_remoteFrame->visibilityChanged(false); |
+ if (m_remoteFrame->client()) |
+ m_remoteFrame->client()->visibilityChanged(false); |
} |
void RemoteFrameView::show() { |
@@ -84,7 +125,8 @@ void RemoteFrameView::show() { |
Widget::show(); |
- m_remoteFrame->visibilityChanged(true); |
+ if (m_remoteFrame->client()) |
+ m_remoteFrame->client()->visibilityChanged(true); |
} |
void RemoteFrameView::setParentVisible(bool visible) { |
@@ -95,7 +137,8 @@ void RemoteFrameView::setParentVisible(bool visible) { |
if (!isSelfVisible()) |
return; |
- m_remoteFrame->visibilityChanged(isVisible()); |
+ if (m_remoteFrame->client()) |
+ m_remoteFrame->client()->visibilityChanged(isVisible()); |
} |
DEFINE_TRACE(RemoteFrameView) { |