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 "config.h" | 5 #include "config.h" |
6 #include "web/RemoteFrameClientImpl.h" | 6 #include "web/RemoteFrameClientImpl.h" |
7 | 7 |
8 #include "core/events/KeyboardEvent.h" | 8 #include "core/events/KeyboardEvent.h" |
9 #include "core/events/MouseEvent.h" | 9 #include "core/events/MouseEvent.h" |
10 #include "core/events/WheelEvent.h" | 10 #include "core/events/WheelEvent.h" |
11 #include "core/frame/RemoteFrame.h" | 11 #include "core/frame/RemoteFrame.h" |
12 #include "core/frame/RemoteFrameView.h" | 12 #include "core/frame/RemoteFrameView.h" |
13 #include "core/layout/LayoutPart.h" | 13 #include "core/layout/LayoutPart.h" |
14 #include "platform/exported/WrappedResourceRequest.h" | 14 #include "platform/exported/WrappedResourceRequest.h" |
15 #include "platform/weborigin/SecurityOrigin.h" | 15 #include "platform/weborigin/SecurityOrigin.h" |
16 #include "platform/weborigin/SecurityPolicy.h" | 16 #include "platform/weborigin/SecurityPolicy.h" |
17 #include "public/web/WebRemoteFrameClient.h" | 17 #include "public/web/WebRemoteFrameClient.h" |
18 #include "web/WebInputEventConversion.h" | 18 #include "web/WebInputEventConversion.h" |
19 #include "web/WebLocalFrameImpl.h" | 19 #include "web/WebLocalFrameImpl.h" |
20 #include "web/WebRemoteFrameImpl.h" | 20 #include "web/WebRemoteFrameImpl.h" |
21 | 21 |
22 namespace blink { | 22 namespace blink { |
23 | 23 |
| 24 namespace { |
| 25 |
| 26 // Convenience helper for frame tree helpers in FrameClient to reduce the amount |
| 27 // of null-checking boilerplate code. Since the frame tree is maintained in the |
| 28 // web/ layer, the frame tree helpers often have to deal with null WebFrames: |
| 29 // for example, a frame with no parent will return null for WebFrame::parent(). |
| 30 // TODO(dcheng): Remove duplication between FrameLoaderClientImpl and |
| 31 // RemoteFrameClientImpl somehow... |
| 32 Frame* toCoreFrame(WebFrame* frame) |
| 33 { |
| 34 return frame ? frame->toImplBase()->frame() : nullptr; |
| 35 } |
| 36 |
| 37 } // namespace |
| 38 |
24 RemoteFrameClientImpl::RemoteFrameClientImpl(WebRemoteFrameImpl* webFrame) | 39 RemoteFrameClientImpl::RemoteFrameClientImpl(WebRemoteFrameImpl* webFrame) |
25 : m_webFrame(webFrame) | 40 : m_webFrame(webFrame) |
26 { | 41 { |
27 } | 42 } |
28 | 43 |
29 PassOwnPtrWillBeRawPtr<RemoteFrameClientImpl> RemoteFrameClientImpl::create(WebR
emoteFrameImpl* webFrame) | 44 PassOwnPtrWillBeRawPtr<RemoteFrameClientImpl> RemoteFrameClientImpl::create(WebR
emoteFrameImpl* webFrame) |
30 { | 45 { |
31 return adoptPtrWillBeNoop(new RemoteFrameClientImpl(webFrame)); | 46 return adoptPtrWillBeNoop(new RemoteFrameClientImpl(webFrame)); |
32 } | 47 } |
33 | 48 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // It is possible for a platform event to cause the remote iframe element | 155 // It is possible for a platform event to cause the remote iframe element |
141 // to be hidden, which destroys the layout object (for instance, a mouse | 156 // to be hidden, which destroys the layout object (for instance, a mouse |
142 // event that moves between elements will trigger a mouseout on the old | 157 // event that moves between elements will trigger a mouseout on the old |
143 // element, which might hide the new element). In that case we do not | 158 // element, which might hide the new element). In that case we do not |
144 // forward. This is divergent behavior from local frames, where the | 159 // forward. This is divergent behavior from local frames, where the |
145 // content of the frame can receive events even after the frame is hidden. | 160 // content of the frame can receive events even after the frame is hidden. |
146 // We might need to revisit this after browser hit testing is fully | 161 // We might need to revisit this after browser hit testing is fully |
147 // implemented, since this code path will need to be removed or refactored | 162 // implemented, since this code path will need to be removed or refactored |
148 // anyway. | 163 // anyway. |
149 // See https://crbug.com/520705. | 164 // See https://crbug.com/520705. |
150 if (!toCoreFrame(m_webFrame)->ownerLayoutObject()) | 165 if (!m_webFrame->toImplBase()->frame()->ownerLayoutObject()) |
151 return; | 166 return; |
152 | 167 |
153 // This is only called when we have out-of-process iframes, which | 168 // This is only called when we have out-of-process iframes, which |
154 // need to forward input events across processes. | 169 // need to forward input events across processes. |
155 // FIXME: Add a check for out-of-process iframes enabled. | 170 // FIXME: Add a check for out-of-process iframes enabled. |
156 OwnPtr<WebInputEvent> webEvent; | 171 OwnPtr<WebInputEvent> webEvent; |
157 if (event->isKeyboardEvent()) | 172 if (event->isKeyboardEvent()) |
158 webEvent = adoptPtr(new WebKeyboardEventBuilder(*static_cast<KeyboardEve
nt*>(event))); | 173 webEvent = adoptPtr(new WebKeyboardEventBuilder(*static_cast<KeyboardEve
nt*>(event))); |
159 else if (event->isMouseEvent()) | 174 else if (event->isMouseEvent()) |
160 webEvent = adoptPtr(new WebMouseEventBuilder(m_webFrame->frame()->view()
, toCoreFrame(m_webFrame)->ownerLayoutObject(), *static_cast<MouseEvent*>(event)
)); | 175 webEvent = adoptPtr(new WebMouseEventBuilder(m_webFrame->frame()->view()
, m_webFrame->toImplBase()->frame()->ownerLayoutObject(), *static_cast<MouseEven
t*>(event))); |
161 else if (event->isWheelEvent()) | 176 else if (event->isWheelEvent()) |
162 webEvent = adoptPtr(new WebMouseWheelEventBuilder(m_webFrame->frame()->v
iew(), toCoreFrame(m_webFrame)->ownerLayoutObject(), *static_cast<WheelEvent*>(e
vent))); | 177 webEvent = adoptPtr(new WebMouseWheelEventBuilder(m_webFrame->frame()->v
iew(), m_webFrame->toImplBase()->frame()->ownerLayoutObject(), *static_cast<Whee
lEvent*>(event))); |
163 | 178 |
164 // Other or internal Blink events should not be forwarded. | 179 // Other or internal Blink events should not be forwarded. |
165 if (!webEvent || webEvent->type == WebInputEvent::Undefined) | 180 if (!webEvent || webEvent->type == WebInputEvent::Undefined) |
166 return; | 181 return; |
167 | 182 |
168 m_webFrame->client()->forwardInputEvent(webEvent.get()); | 183 m_webFrame->client()->forwardInputEvent(webEvent.get()); |
169 } | 184 } |
170 | 185 |
171 void RemoteFrameClientImpl::frameRectsChanged(const IntRect& frameRect) | 186 void RemoteFrameClientImpl::frameRectsChanged(const IntRect& frameRect) |
172 { | 187 { |
173 m_webFrame->client()->frameRectsChanged(frameRect); | 188 m_webFrame->client()->frameRectsChanged(frameRect); |
174 } | 189 } |
175 | 190 |
176 } // namespace blink | 191 } // namespace blink |
OLD | NEW |