| 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/dom/IntersectionObserverEntry.h" | 7 #include "core/dom/IntersectionObserverEntry.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/frame/RemoteFrame.h" | 10 #include "core/frame/RemoteFrame.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return; | 43 return; |
| 44 | 44 |
| 45 // Start with rect in remote frame's coordinate space. Then | 45 // Start with rect in remote frame's coordinate space. Then |
| 46 // mapToVisualRectInAncestorSpace will move it to the local root's coordinate | 46 // mapToVisualRectInAncestorSpace will move it to the local root's coordinate |
| 47 // space and account for any clip from containing elements such as a | 47 // space and account for any clip from containing elements such as a |
| 48 // scrollable div. Passing nullptr as an argument to | 48 // scrollable div. Passing nullptr as an argument to |
| 49 // mapToVisualRectInAncestorSpace causes it to be clipped to the viewport, | 49 // mapToVisualRectInAncestorSpace causes it to be clipped to the viewport, |
| 50 // even if there are RemoteFrame ancestors in the frame tree. | 50 // even if there are RemoteFrame ancestors in the frame tree. |
| 51 LayoutRect rect(0, 0, FrameRect().Width(), FrameRect().Height()); | 51 LayoutRect rect(0, 0, FrameRect().Width(), FrameRect().Height()); |
| 52 rect.Move(remote_frame_->OwnerLayoutObject()->ContentBoxOffset()); | 52 rect.Move(remote_frame_->OwnerLayoutObject()->ContentBoxOffset()); |
| 53 if (!remote_frame_->OwnerLayoutObject()->MapToVisualRectInAncestorSpace( | 53 IntRect viewport_intersection; |
| 54 nullptr, rect)) | 54 if (remote_frame_->OwnerLayoutObject()->MapToVisualRectInAncestorSpace( |
| 55 return; | 55 nullptr, rect)) { |
| 56 IntRect root_visible_rect = local_root_view->VisibleContentRect(); | 56 IntRect root_visible_rect = local_root_view->VisibleContentRect(); |
| 57 IntRect viewport_intersection(rect); | 57 IntRect intersected_rect(rect); |
| 58 viewport_intersection.Intersect(root_visible_rect); | 58 intersected_rect.Intersect(root_visible_rect); |
| 59 viewport_intersection.Move(-local_root_view->ScrollOffsetInt()); | 59 intersected_rect.Move(-local_root_view->ScrollOffsetInt()); |
| 60 | 60 |
| 61 // Translate the intersection rect from the root frame's coordinate space | 61 // Translate the intersection rect from the root frame's coordinate space |
| 62 // to the remote frame's coordinate space. | 62 // to the remote frame's coordinate space. |
| 63 viewport_intersection = ConvertFromRootFrame(viewport_intersection); | 63 viewport_intersection = ConvertFromRootFrame(intersected_rect); |
| 64 } |
| 65 |
| 64 if (viewport_intersection != last_viewport_intersection_) { | 66 if (viewport_intersection != last_viewport_intersection_) { |
| 65 remote_frame_->Client()->UpdateRemoteViewportIntersection( | 67 remote_frame_->Client()->UpdateRemoteViewportIntersection( |
| 66 viewport_intersection); | 68 viewport_intersection); |
| 67 } | 69 } |
| 70 |
| 68 last_viewport_intersection_ = viewport_intersection; | 71 last_viewport_intersection_ = viewport_intersection; |
| 69 } | 72 } |
| 70 | 73 |
| 71 void RemoteFrameView::Dispose() { | 74 void RemoteFrameView::Dispose() { |
| 72 HTMLFrameOwnerElement* owner_element = remote_frame_->DeprecatedLocalOwner(); | 75 HTMLFrameOwnerElement* owner_element = remote_frame_->DeprecatedLocalOwner(); |
| 73 // ownerElement can be null during frame swaps, because the | 76 // ownerElement can be null during frame swaps, because the |
| 74 // RemoteFrameView is disconnected before detachment. | 77 // RemoteFrameView is disconnected before detachment. |
| 75 if (owner_element && owner_element->OwnedWidget() == this) | 78 if (owner_element && owner_element->OwnedWidget() == this) |
| 76 owner_element->SetWidget(nullptr); | 79 owner_element->SetWidget(nullptr); |
| 77 FrameViewBase::Dispose(); | 80 FrameViewBase::Dispose(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 101 | 104 |
| 102 void RemoteFrameView::FrameRectsChanged() { | 105 void RemoteFrameView::FrameRectsChanged() { |
| 103 // Update the rect to reflect the position of the frame relative to the | 106 // Update the rect to reflect the position of the frame relative to the |
| 104 // containing local frame root. The position of the local root within | 107 // containing local frame root. The position of the local root within |
| 105 // any remote frames, if any, is accounted for by the embedder. | 108 // any remote frames, if any, is accounted for by the embedder. |
| 106 IntRect new_rect = FrameRect(); | 109 IntRect new_rect = FrameRect(); |
| 107 if (Parent() && Parent()->IsFrameView()) | 110 if (Parent() && Parent()->IsFrameView()) |
| 108 new_rect = Parent()->ConvertToRootFrame( | 111 new_rect = Parent()->ConvertToRootFrame( |
| 109 ToFrameView(Parent())->ContentsToFrame(new_rect)); | 112 ToFrameView(Parent())->ContentsToFrame(new_rect)); |
| 110 remote_frame_->Client()->FrameRectsChanged(new_rect); | 113 remote_frame_->Client()->FrameRectsChanged(new_rect); |
| 111 | |
| 112 UpdateRemoteViewportIntersection(); | |
| 113 } | 114 } |
| 114 | 115 |
| 115 void RemoteFrameView::Hide() { | 116 void RemoteFrameView::Hide() { |
| 116 SetSelfVisible(false); | 117 SetSelfVisible(false); |
| 117 | 118 |
| 118 FrameViewBase::Hide(); | 119 FrameViewBase::Hide(); |
| 119 | 120 |
| 120 remote_frame_->Client()->VisibilityChanged(false); | 121 remote_frame_->Client()->VisibilityChanged(false); |
| 121 } | 122 } |
| 122 | 123 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 138 | 139 |
| 139 remote_frame_->Client()->VisibilityChanged(IsVisible()); | 140 remote_frame_->Client()->VisibilityChanged(IsVisible()); |
| 140 } | 141 } |
| 141 | 142 |
| 142 DEFINE_TRACE(RemoteFrameView) { | 143 DEFINE_TRACE(RemoteFrameView) { |
| 143 visitor->Trace(remote_frame_); | 144 visitor->Trace(remote_frame_); |
| 144 FrameViewBase::Trace(visitor); | 145 FrameViewBase::Trace(visitor); |
| 145 } | 146 } |
| 146 | 147 |
| 147 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |