Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/frame/RemoteFrameView.h" | 5 #include "core/frame/RemoteFrameView.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/LocalFrame.h" | |
| 8 #include "core/frame/RemoteFrame.h" | 9 #include "core/frame/RemoteFrame.h" |
| 10 #include "core/frame/RemoteFrameClient.h" | |
| 9 #include "core/html/HTMLFrameOwnerElement.h" | 11 #include "core/html/HTMLFrameOwnerElement.h" |
| 10 #include "core/layout/api/LayoutPartItem.h" | 12 #include "core/layout/api/LayoutPartItem.h" |
| 13 #include "platform/geometry/IntPoint.h" | |
| 11 | 14 |
| 12 namespace blink { | 15 namespace blink { |
| 13 | 16 |
| 14 RemoteFrameView::RemoteFrameView(RemoteFrame* remoteFrame) | 17 RemoteFrameView::RemoteFrameView(RemoteFrame* remoteFrame) |
| 15 : m_remoteFrame(remoteFrame) { | 18 : m_remoteFrame(remoteFrame) { |
| 16 ASSERT(remoteFrame); | 19 ASSERT(remoteFrame); |
| 17 } | 20 } |
| 18 | 21 |
| 19 RemoteFrameView::~RemoteFrameView() {} | 22 RemoteFrameView::~RemoteFrameView() {} |
| 20 | 23 |
| 21 void RemoteFrameView::setParent(Widget* parent) { | 24 void RemoteFrameView::setParent(Widget* parent) { |
| 22 Widget::setParent(parent); | 25 Widget::setParent(parent); |
| 23 frameRectsChanged(); | 26 frameRectsChanged(); |
| 24 } | 27 } |
| 25 | 28 |
| 26 RemoteFrameView* RemoteFrameView::create(RemoteFrame* remoteFrame) { | 29 RemoteFrameView* RemoteFrameView::create(RemoteFrame* remoteFrame) { |
| 27 RemoteFrameView* view = new RemoteFrameView(remoteFrame); | 30 RemoteFrameView* view = new RemoteFrameView(remoteFrame); |
| 28 view->show(); | 31 view->show(); |
| 29 return view; | 32 return view; |
| 30 } | 33 } |
| 31 | 34 |
| 35 void RemoteFrameView::updateRemoteViewportIntersection() { | |
| 36 if (!m_remoteFrame->tree().parent() || | |
| 37 !m_remoteFrame->tree().parent()->isLocalFrame() || | |
| 38 !m_remoteFrame->client()) | |
| 39 return; | |
| 40 | |
| 41 FrameView* parent = toLocalFrame(m_remoteFrame->tree().parent())->view(); | |
| 42 if (!parent) | |
| 43 return; | |
| 44 | |
| 45 // TODO(kenrb): I don't think this works with nested OOPIFs. We need to take | |
| 46 // the local frame root's rootOffset into account to get actual viewport pos. | |
| 47 IntRect viewportIntersection = parent->contentsToRootFrame(frameRect()); | |
|
szager1
2016/10/24 16:54:52
I don't think this is right, because parentsToRoot
kenrb
2016/10/28 18:51:56
Done.
| |
| 48 IntPoint rootOffset(viewportIntersection.x(), viewportIntersection.y()); | |
| 49 | |
| 50 IntRect parentViewportIntersection = parent->viewportIntersection(); | |
| 51 if (parentViewportIntersection.isEmpty()) { | |
| 52 m_remoteFrame->client()->updateRemoteViewportIntersection( | |
| 53 parentViewportIntersection, rootOffset); | |
| 54 return; | |
| 55 } | |
| 56 | |
| 57 viewportIntersection.intersect(parentViewportIntersection); | |
| 58 if (viewportIntersection != m_lastViewportIntersection) { | |
| 59 m_remoteFrame->client()->updateRemoteViewportIntersection( | |
| 60 viewportIntersection, rootOffset); | |
| 61 } | |
| 62 m_lastViewportIntersection = viewportIntersection; | |
| 63 } | |
| 64 | |
| 32 void RemoteFrameView::dispose() { | 65 void RemoteFrameView::dispose() { |
| 33 HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner(); | 66 HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner(); |
| 34 // ownerElement can be null during frame swaps, because the | 67 // ownerElement can be null during frame swaps, because the |
| 35 // RemoteFrameView is disconnected before detachment. | 68 // RemoteFrameView is disconnected before detachment. |
| 36 if (ownerElement && ownerElement->ownedWidget() == this) | 69 if (ownerElement && ownerElement->ownedWidget() == this) |
| 37 ownerElement->setWidget(nullptr); | 70 ownerElement->setWidget(nullptr); |
| 38 Widget::dispose(); | 71 Widget::dispose(); |
| 39 } | 72 } |
| 40 | 73 |
| 41 void RemoteFrameView::invalidateRect(const IntRect& rect) { | 74 void RemoteFrameView::invalidateRect(const IntRect& rect) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 61 } | 94 } |
| 62 | 95 |
| 63 void RemoteFrameView::frameRectsChanged() { | 96 void RemoteFrameView::frameRectsChanged() { |
| 64 // Update the rect to reflect the position of the frame relative to the | 97 // Update the rect to reflect the position of the frame relative to the |
| 65 // containing local frame root. The position of the local root within | 98 // containing local frame root. The position of the local root within |
| 66 // any remote frames, if any, is accounted for by the embedder. | 99 // any remote frames, if any, is accounted for by the embedder. |
| 67 IntRect newRect = frameRect(); | 100 IntRect newRect = frameRect(); |
| 68 if (parent() && parent()->isFrameView()) | 101 if (parent() && parent()->isFrameView()) |
| 69 newRect = parent()->convertToRootFrame( | 102 newRect = parent()->convertToRootFrame( |
| 70 toFrameView(parent())->contentsToFrame(newRect)); | 103 toFrameView(parent())->contentsToFrame(newRect)); |
| 71 m_remoteFrame->frameRectsChanged(newRect); | 104 m_remoteFrame->client()->frameRectsChanged(newRect); |
| 105 | |
| 106 updateRemoteViewportIntersection(); | |
| 72 } | 107 } |
| 73 | 108 |
| 74 void RemoteFrameView::hide() { | 109 void RemoteFrameView::hide() { |
| 75 setSelfVisible(false); | 110 setSelfVisible(false); |
| 76 | 111 |
| 77 Widget::hide(); | 112 Widget::hide(); |
| 78 | 113 |
| 79 m_remoteFrame->visibilityChanged(false); | 114 if (m_remoteFrame->client()) |
| 115 m_remoteFrame->client()->visibilityChanged(false); | |
| 80 } | 116 } |
| 81 | 117 |
| 82 void RemoteFrameView::show() { | 118 void RemoteFrameView::show() { |
| 83 setSelfVisible(true); | 119 setSelfVisible(true); |
| 84 | 120 |
| 85 Widget::show(); | 121 Widget::show(); |
| 86 | 122 |
| 87 m_remoteFrame->visibilityChanged(true); | 123 if (m_remoteFrame->client()) |
| 124 m_remoteFrame->client()->visibilityChanged(true); | |
| 88 } | 125 } |
| 89 | 126 |
| 90 void RemoteFrameView::setParentVisible(bool visible) { | 127 void RemoteFrameView::setParentVisible(bool visible) { |
| 91 if (isParentVisible() == visible) | 128 if (isParentVisible() == visible) |
| 92 return; | 129 return; |
| 93 | 130 |
| 94 Widget::setParentVisible(visible); | 131 Widget::setParentVisible(visible); |
| 95 if (!isSelfVisible()) | 132 if (!isSelfVisible()) |
| 96 return; | 133 return; |
| 97 | 134 |
| 98 m_remoteFrame->visibilityChanged(isVisible()); | 135 if (m_remoteFrame->client()) |
| 136 m_remoteFrame->client()->visibilityChanged(isVisible()); | |
| 99 } | 137 } |
| 100 | 138 |
| 101 DEFINE_TRACE(RemoteFrameView) { | 139 DEFINE_TRACE(RemoteFrameView) { |
| 102 visitor->trace(m_remoteFrame); | 140 visitor->trace(m_remoteFrame); |
| 103 Widget::trace(visitor); | 141 Widget::trace(visitor); |
| 104 } | 142 } |
| 105 | 143 |
| 106 } // namespace blink | 144 } // namespace blink |
| OLD | NEW |