Chromium Code Reviews| 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..86eece009ab276be45d9854baf0d564343b27590 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,43 @@ 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()) |
|
dcheng
2017/01/05 07:10:19
Can this be simplified to just checking if it has
kenrb
2017/01/09 19:31:20
Done. I had concern with lifetime issues here, sin
|
| + 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 +109,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 +119,8 @@ void RemoteFrameView::hide() { |
| Widget::hide(); |
| - m_remoteFrame->visibilityChanged(false); |
| + if (m_remoteFrame->client()) |
| + m_remoteFrame->client()->visibilityChanged(false); |
|
dcheng
2017/01/05 07:10:19
How come these need to null check while frameRects
kenrb
2017/01/09 19:31:20
The checks on RemoteFrame::visibilityChanged() wer
|
| } |
| void RemoteFrameView::show() { |
| @@ -84,7 +128,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 +140,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) { |