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

Side by Side Diff: third_party/WebKit/Source/core/frame/RemoteFrameView.cpp

Issue 2431473003: Intersection Observer support for OOPIF (Closed)
Patch Set: Rebase only 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 unified diff | Download patch
OLDNEW
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/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h"
8 #include "core/frame/RemoteFrame.h" 10 #include "core/frame/RemoteFrame.h"
11 #include "core/frame/RemoteFrameClient.h"
9 #include "core/html/HTMLFrameOwnerElement.h" 12 #include "core/html/HTMLFrameOwnerElement.h"
13 #include "core/layout/LayoutView.h"
10 #include "core/layout/api/LayoutPartItem.h" 14 #include "core/layout/api/LayoutPartItem.h"
11 15
12 namespace blink { 16 namespace blink {
13 17
14 RemoteFrameView::RemoteFrameView(RemoteFrame* remoteFrame) 18 RemoteFrameView::RemoteFrameView(RemoteFrame* remoteFrame)
15 : m_remoteFrame(remoteFrame) { 19 : m_remoteFrame(remoteFrame) {
16 ASSERT(remoteFrame); 20 ASSERT(remoteFrame);
17 } 21 }
18 22
19 RemoteFrameView::~RemoteFrameView() {} 23 RemoteFrameView::~RemoteFrameView() {}
20 24
21 void RemoteFrameView::setParent(Widget* parent) { 25 void RemoteFrameView::setParent(Widget* parent) {
22 Widget::setParent(parent); 26 Widget::setParent(parent);
23 frameRectsChanged(); 27 frameRectsChanged();
24 } 28 }
25 29
26 RemoteFrameView* RemoteFrameView::create(RemoteFrame* remoteFrame) { 30 RemoteFrameView* RemoteFrameView::create(RemoteFrame* remoteFrame) {
27 RemoteFrameView* view = new RemoteFrameView(remoteFrame); 31 RemoteFrameView* view = new RemoteFrameView(remoteFrame);
28 view->show(); 32 view->show();
29 return view; 33 return view;
30 } 34 }
31 35
36 void RemoteFrameView::updateRemoteViewportIntersection() {
37 if (!m_remoteFrame->tree().parent() ||
38 !m_remoteFrame->tree().parent()->isLocalFrame() ||
39 !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
40 return;
41
42 FrameView* localRootView =
43 toLocalFrame(m_remoteFrame->tree().parent())->localFrameRoot()->view();
44 if (!localRootView)
45 return;
46
47 // Start with rect in remote frame's coordinate space. Then
48 // mapToVisualRectInAncestorSpace will move it to the local root's coordinate
49 // space and account for any clip from containing elements such as a
50 // scrollable div. Passing nullptr as an argument to
51 // mapToVisualRectInAncestorSpace causes it to be clipped to the viewport,
52 // even if there are RemoteFrame ancestors in the frame tree.
53 LayoutRect rect(0, 0, frameRect().width(), frameRect().height());
54 rect.move(m_remoteFrame->ownerLayoutObject()->contentBoxOffset());
55 if (!m_remoteFrame->ownerLayoutObject()->mapToVisualRectInAncestorSpace(
56 nullptr, rect))
57 return;
58 IntRect rootVisibleRect = localRootView->visibleContentRect();
59 IntRect viewportIntersection(rect);
60 viewportIntersection.intersect(rootVisibleRect);
61 viewportIntersection.move(-localRootView->scrollOffsetInt());
62
63 // Translate the intersection rect from the root frame's coordinate space
64 // to the remote frame's coordinate space.
65 viewportIntersection = convertFromRootFrame(viewportIntersection);
66 if (viewportIntersection != m_lastViewportIntersection) {
67 m_remoteFrame->client()->updateRemoteViewportIntersection(
68 viewportIntersection);
69 }
70 m_lastViewportIntersection = viewportIntersection;
71 }
72
32 void RemoteFrameView::dispose() { 73 void RemoteFrameView::dispose() {
33 HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner(); 74 HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner();
34 // ownerElement can be null during frame swaps, because the 75 // ownerElement can be null during frame swaps, because the
35 // RemoteFrameView is disconnected before detachment. 76 // RemoteFrameView is disconnected before detachment.
36 if (ownerElement && ownerElement->ownedWidget() == this) 77 if (ownerElement && ownerElement->ownedWidget() == this)
37 ownerElement->setWidget(nullptr); 78 ownerElement->setWidget(nullptr);
38 Widget::dispose(); 79 Widget::dispose();
39 } 80 }
40 81
41 void RemoteFrameView::invalidateRect(const IntRect& rect) { 82 void RemoteFrameView::invalidateRect(const IntRect& rect) {
(...skipping 19 matching lines...) Expand all
61 } 102 }
62 103
63 void RemoteFrameView::frameRectsChanged() { 104 void RemoteFrameView::frameRectsChanged() {
64 // Update the rect to reflect the position of the frame relative to the 105 // 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 106 // containing local frame root. The position of the local root within
66 // any remote frames, if any, is accounted for by the embedder. 107 // any remote frames, if any, is accounted for by the embedder.
67 IntRect newRect = frameRect(); 108 IntRect newRect = frameRect();
68 if (parent() && parent()->isFrameView()) 109 if (parent() && parent()->isFrameView())
69 newRect = parent()->convertToRootFrame( 110 newRect = parent()->convertToRootFrame(
70 toFrameView(parent())->contentsToFrame(newRect)); 111 toFrameView(parent())->contentsToFrame(newRect));
71 m_remoteFrame->frameRectsChanged(newRect); 112 m_remoteFrame->client()->frameRectsChanged(newRect);
113
114 updateRemoteViewportIntersection();
72 } 115 }
73 116
74 void RemoteFrameView::hide() { 117 void RemoteFrameView::hide() {
75 setSelfVisible(false); 118 setSelfVisible(false);
76 119
77 Widget::hide(); 120 Widget::hide();
78 121
79 m_remoteFrame->visibilityChanged(false); 122 if (m_remoteFrame->client())
123 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
80 } 124 }
81 125
82 void RemoteFrameView::show() { 126 void RemoteFrameView::show() {
83 setSelfVisible(true); 127 setSelfVisible(true);
84 128
85 Widget::show(); 129 Widget::show();
86 130
87 m_remoteFrame->visibilityChanged(true); 131 if (m_remoteFrame->client())
132 m_remoteFrame->client()->visibilityChanged(true);
88 } 133 }
89 134
90 void RemoteFrameView::setParentVisible(bool visible) { 135 void RemoteFrameView::setParentVisible(bool visible) {
91 if (isParentVisible() == visible) 136 if (isParentVisible() == visible)
92 return; 137 return;
93 138
94 Widget::setParentVisible(visible); 139 Widget::setParentVisible(visible);
95 if (!isSelfVisible()) 140 if (!isSelfVisible())
96 return; 141 return;
97 142
98 m_remoteFrame->visibilityChanged(isVisible()); 143 if (m_remoteFrame->client())
144 m_remoteFrame->client()->visibilityChanged(isVisible());
99 } 145 }
100 146
101 DEFINE_TRACE(RemoteFrameView) { 147 DEFINE_TRACE(RemoteFrameView) {
102 visitor->trace(m_remoteFrame); 148 visitor->trace(m_remoteFrame);
103 Widget::trace(visitor); 149 Widget::trace(visitor);
104 } 150 }
105 151
106 } // namespace blink 152 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698