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

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

Issue 2431473003: Intersection Observer support for OOPIF (Closed)
Patch Set: Fixed test issue Created 4 years 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())
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 if (!m_remoteFrame->ownerLayoutObject()->mapToVisualRectInAncestorSpace(
55 nullptr, rect))
56 return;
57 IntRect rootVisibleRect = localRootView->visibleContentRect();
58 IntRect viewportIntersection(rect);
59 viewportIntersection.intersect(rootVisibleRect);
60 viewportIntersection.move(-localRootView->scrollOffsetInt());
61
62 // Translate the intersection rect from the root frame's coordinate space
63 // to the remote frame's coordinate space.
64 viewportIntersection = convertFromRootFrame(viewportIntersection);
65 if (viewportIntersection != m_lastViewportIntersection) {
66 m_remoteFrame->client()->updateRemoteViewportIntersection(
67 viewportIntersection);
68 }
69 m_lastViewportIntersection = viewportIntersection;
70 }
71
32 void RemoteFrameView::dispose() { 72 void RemoteFrameView::dispose() {
33 HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner(); 73 HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner();
34 // ownerElement can be null during frame swaps, because the 74 // ownerElement can be null during frame swaps, because the
35 // RemoteFrameView is disconnected before detachment. 75 // RemoteFrameView is disconnected before detachment.
36 if (ownerElement && ownerElement->ownedWidget() == this) 76 if (ownerElement && ownerElement->ownedWidget() == this)
37 ownerElement->setWidget(nullptr); 77 ownerElement->setWidget(nullptr);
38 Widget::dispose(); 78 Widget::dispose();
39 } 79 }
40 80
41 void RemoteFrameView::invalidateRect(const IntRect& rect) { 81 void RemoteFrameView::invalidateRect(const IntRect& rect) {
(...skipping 19 matching lines...) Expand all
61 } 101 }
62 102
63 void RemoteFrameView::frameRectsChanged() { 103 void RemoteFrameView::frameRectsChanged() {
64 // Update the rect to reflect the position of the frame relative to the 104 // 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 105 // containing local frame root. The position of the local root within
66 // any remote frames, if any, is accounted for by the embedder. 106 // any remote frames, if any, is accounted for by the embedder.
67 IntRect newRect = frameRect(); 107 IntRect newRect = frameRect();
68 if (parent() && parent()->isFrameView()) 108 if (parent() && parent()->isFrameView())
69 newRect = parent()->convertToRootFrame( 109 newRect = parent()->convertToRootFrame(
70 toFrameView(parent())->contentsToFrame(newRect)); 110 toFrameView(parent())->contentsToFrame(newRect));
71 m_remoteFrame->frameRectsChanged(newRect); 111 m_remoteFrame->client()->frameRectsChanged(newRect);
112
113 updateRemoteViewportIntersection();
72 } 114 }
73 115
74 void RemoteFrameView::hide() { 116 void RemoteFrameView::hide() {
75 setSelfVisible(false); 117 setSelfVisible(false);
76 118
77 Widget::hide(); 119 Widget::hide();
78 120
79 m_remoteFrame->visibilityChanged(false); 121 if (m_remoteFrame->client())
122 m_remoteFrame->client()->visibilityChanged(false);
80 } 123 }
81 124
82 void RemoteFrameView::show() { 125 void RemoteFrameView::show() {
83 setSelfVisible(true); 126 setSelfVisible(true);
84 127
85 Widget::show(); 128 Widget::show();
86 129
87 m_remoteFrame->visibilityChanged(true); 130 if (m_remoteFrame->client())
131 m_remoteFrame->client()->visibilityChanged(true);
88 } 132 }
89 133
90 void RemoteFrameView::setParentVisible(bool visible) { 134 void RemoteFrameView::setParentVisible(bool visible) {
91 if (isParentVisible() == visible) 135 if (isParentVisible() == visible)
92 return; 136 return;
93 137
94 Widget::setParentVisible(visible); 138 Widget::setParentVisible(visible);
95 if (!isSelfVisible()) 139 if (!isSelfVisible())
96 return; 140 return;
97 141
98 m_remoteFrame->visibilityChanged(isVisible()); 142 if (m_remoteFrame->client())
143 m_remoteFrame->client()->visibilityChanged(isVisible());
99 } 144 }
100 145
101 DEFINE_TRACE(RemoteFrameView) { 146 DEFINE_TRACE(RemoteFrameView) {
102 visitor->trace(m_remoteFrame); 147 visitor->trace(m_remoteFrame);
103 Widget::trace(visitor); 148 Widget::trace(visitor);
104 } 149 }
105 150
106 } // namespace blink 151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698