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" |
11 #include "core/frame/RemoteFrameClient.h" | 11 #include "core/frame/RemoteFrameClient.h" |
12 #include "core/html/HTMLFrameOwnerElement.h" | 12 #include "core/html/HTMLFrameOwnerElement.h" |
13 #include "core/layout/LayoutView.h" | 13 #include "core/layout/LayoutView.h" |
14 #include "core/layout/api/LayoutPartItem.h" | 14 #include "core/layout/api/LayoutPartItem.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 RemoteFrameView::RemoteFrameView(RemoteFrame* remoteFrame) | 18 RemoteFrameView::RemoteFrameView(RemoteFrame* remoteFrame) |
19 : m_remoteFrame(remoteFrame) { | 19 : m_remoteFrame(remoteFrame) { |
20 ASSERT(remoteFrame); | 20 ASSERT(remoteFrame); |
21 } | 21 } |
22 | 22 |
23 RemoteFrameView::~RemoteFrameView() {} | 23 RemoteFrameView::~RemoteFrameView() {} |
24 | 24 |
25 void RemoteFrameView::setParent(Widget* parent) { | 25 void RemoteFrameView::setParent(FrameViewBase* parent) { |
26 Widget::setParent(parent); | 26 FrameViewBase::setParent(parent); |
27 frameRectsChanged(); | 27 frameRectsChanged(); |
28 } | 28 } |
29 | 29 |
30 RemoteFrameView* RemoteFrameView::create(RemoteFrame* remoteFrame) { | 30 RemoteFrameView* RemoteFrameView::create(RemoteFrame* remoteFrame) { |
31 RemoteFrameView* view = new RemoteFrameView(remoteFrame); | 31 RemoteFrameView* view = new RemoteFrameView(remoteFrame); |
32 view->show(); | 32 view->show(); |
33 return view; | 33 return view; |
34 } | 34 } |
35 | 35 |
36 void RemoteFrameView::updateRemoteViewportIntersection() { | 36 void RemoteFrameView::updateRemoteViewportIntersection() { |
(...skipping 30 matching lines...) Expand all Loading... |
67 } | 67 } |
68 m_lastViewportIntersection = viewportIntersection; | 68 m_lastViewportIntersection = viewportIntersection; |
69 } | 69 } |
70 | 70 |
71 void RemoteFrameView::dispose() { | 71 void RemoteFrameView::dispose() { |
72 HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner(); | 72 HTMLFrameOwnerElement* ownerElement = m_remoteFrame->deprecatedLocalOwner(); |
73 // ownerElement can be null during frame swaps, because the | 73 // ownerElement can be null during frame swaps, because the |
74 // RemoteFrameView is disconnected before detachment. | 74 // RemoteFrameView is disconnected before detachment. |
75 if (ownerElement && ownerElement->ownedWidget() == this) | 75 if (ownerElement && ownerElement->ownedWidget() == this) |
76 ownerElement->setWidget(nullptr); | 76 ownerElement->setWidget(nullptr); |
77 Widget::dispose(); | 77 FrameViewBase::dispose(); |
78 } | 78 } |
79 | 79 |
80 void RemoteFrameView::invalidateRect(const IntRect& rect) { | 80 void RemoteFrameView::invalidateRect(const IntRect& rect) { |
81 LayoutPartItem layoutItem = m_remoteFrame->ownerLayoutItem(); | 81 LayoutPartItem layoutItem = m_remoteFrame->ownerLayoutItem(); |
82 if (layoutItem.isNull()) | 82 if (layoutItem.isNull()) |
83 return; | 83 return; |
84 | 84 |
85 LayoutRect repaintRect(rect); | 85 LayoutRect repaintRect(rect); |
86 repaintRect.move(layoutItem.borderLeft() + layoutItem.paddingLeft(), | 86 repaintRect.move(layoutItem.borderLeft() + layoutItem.paddingLeft(), |
87 layoutItem.borderTop() + layoutItem.paddingTop()); | 87 layoutItem.borderTop() + layoutItem.paddingTop()); |
88 layoutItem.invalidatePaintRectangle(repaintRect); | 88 layoutItem.invalidatePaintRectangle(repaintRect); |
89 } | 89 } |
90 | 90 |
91 void RemoteFrameView::setFrameRect(const IntRect& newRect) { | 91 void RemoteFrameView::setFrameRect(const IntRect& newRect) { |
92 IntRect oldRect = frameRect(); | 92 IntRect oldRect = frameRect(); |
93 | 93 |
94 if (newRect == oldRect) | 94 if (newRect == oldRect) |
95 return; | 95 return; |
96 | 96 |
97 Widget::setFrameRect(newRect); | 97 FrameViewBase::setFrameRect(newRect); |
98 | 98 |
99 frameRectsChanged(); | 99 frameRectsChanged(); |
100 } | 100 } |
101 | 101 |
102 void RemoteFrameView::frameRectsChanged() { | 102 void RemoteFrameView::frameRectsChanged() { |
103 // Update the rect to reflect the position of the frame relative to the | 103 // 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 | 104 // containing local frame root. The position of the local root within |
105 // any remote frames, if any, is accounted for by the embedder. | 105 // any remote frames, if any, is accounted for by the embedder. |
106 IntRect newRect = frameRect(); | 106 IntRect newRect = frameRect(); |
107 if (parent() && parent()->isFrameView()) | 107 if (parent() && parent()->isFrameView()) |
108 newRect = parent()->convertToRootFrame( | 108 newRect = parent()->convertToRootFrame( |
109 toFrameView(parent())->contentsToFrame(newRect)); | 109 toFrameView(parent())->contentsToFrame(newRect)); |
110 m_remoteFrame->client()->frameRectsChanged(newRect); | 110 m_remoteFrame->client()->frameRectsChanged(newRect); |
111 | 111 |
112 updateRemoteViewportIntersection(); | 112 updateRemoteViewportIntersection(); |
113 } | 113 } |
114 | 114 |
115 void RemoteFrameView::hide() { | 115 void RemoteFrameView::hide() { |
116 setSelfVisible(false); | 116 setSelfVisible(false); |
117 | 117 |
118 Widget::hide(); | 118 FrameViewBase::hide(); |
119 | 119 |
120 m_remoteFrame->client()->visibilityChanged(false); | 120 m_remoteFrame->client()->visibilityChanged(false); |
121 } | 121 } |
122 | 122 |
123 void RemoteFrameView::show() { | 123 void RemoteFrameView::show() { |
124 setSelfVisible(true); | 124 setSelfVisible(true); |
125 | 125 |
126 Widget::show(); | 126 FrameViewBase::show(); |
127 | 127 |
128 m_remoteFrame->client()->visibilityChanged(true); | 128 m_remoteFrame->client()->visibilityChanged(true); |
129 } | 129 } |
130 | 130 |
131 void RemoteFrameView::setParentVisible(bool visible) { | 131 void RemoteFrameView::setParentVisible(bool visible) { |
132 if (isParentVisible() == visible) | 132 if (isParentVisible() == visible) |
133 return; | 133 return; |
134 | 134 |
135 Widget::setParentVisible(visible); | 135 FrameViewBase::setParentVisible(visible); |
136 if (!isSelfVisible()) | 136 if (!isSelfVisible()) |
137 return; | 137 return; |
138 | 138 |
139 m_remoteFrame->client()->visibilityChanged(isVisible()); | 139 m_remoteFrame->client()->visibilityChanged(isVisible()); |
140 } | 140 } |
141 | 141 |
142 DEFINE_TRACE(RemoteFrameView) { | 142 DEFINE_TRACE(RemoteFrameView) { |
143 visitor->trace(m_remoteFrame); | 143 visitor->trace(m_remoteFrame); |
144 Widget::trace(visitor); | 144 FrameViewBase::trace(visitor); |
145 } | 145 } |
146 | 146 |
147 } // namespace blink | 147 } // namespace blink |
OLD | NEW |