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 "web/RemoteFrameClientImpl.h" | 5 #include "web/RemoteFrameClientImpl.h" |
6 | 6 |
7 #include "core/events/KeyboardEvent.h" | 7 #include "core/events/KeyboardEvent.h" |
8 #include "core/events/MouseEvent.h" | 8 #include "core/events/MouseEvent.h" |
9 #include "core/events/WheelEvent.h" | 9 #include "core/events/WheelEvent.h" |
10 #include "core/frame/RemoteFrame.h" | 10 #include "core/frame/RemoteFrame.h" |
11 #include "core/frame/RemoteFrameView.h" | 11 #include "core/frame/RemoteFrameView.h" |
12 #include "core/layout/LayoutPart.h" | 12 #include "core/layout/LayoutPart.h" |
13 #include "core/layout/api/LayoutItem.h" | 13 #include "core/layout/api/LayoutItem.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 #include "wtf/PtrUtil.h" |
| 22 #include <memory> |
21 | 23 |
22 namespace blink { | 24 namespace blink { |
23 | 25 |
24 namespace { | 26 namespace { |
25 | 27 |
26 // Convenience helper for frame tree helpers in FrameClient to reduce the amount | 28 // 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 | 29 // 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: | 30 // 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(). | 31 // for example, a frame with no parent will return null for WebFrame::parent(). |
30 // TODO(dcheng): Remove duplication between FrameLoaderClientImpl and | 32 // TODO(dcheng): Remove duplication between FrameLoaderClientImpl and |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // We might need to revisit this after browser hit testing is fully | 167 // We might need to revisit this after browser hit testing is fully |
166 // implemented, since this code path will need to be removed or refactored | 168 // implemented, since this code path will need to be removed or refactored |
167 // anyway. | 169 // anyway. |
168 // See https://crbug.com/520705. | 170 // See https://crbug.com/520705. |
169 if (!m_webFrame->toImplBase()->frame()->ownerLayoutObject()) | 171 if (!m_webFrame->toImplBase()->frame()->ownerLayoutObject()) |
170 return; | 172 return; |
171 | 173 |
172 // This is only called when we have out-of-process iframes, which | 174 // This is only called when we have out-of-process iframes, which |
173 // need to forward input events across processes. | 175 // need to forward input events across processes. |
174 // FIXME: Add a check for out-of-process iframes enabled. | 176 // FIXME: Add a check for out-of-process iframes enabled. |
175 OwnPtr<WebInputEvent> webEvent; | 177 std::unique_ptr<WebInputEvent> webEvent; |
176 if (event->isKeyboardEvent()) | 178 if (event->isKeyboardEvent()) |
177 webEvent = adoptPtr(new WebKeyboardEventBuilder(*static_cast<KeyboardEve
nt*>(event))); | 179 webEvent = wrapUnique(new WebKeyboardEventBuilder(*static_cast<KeyboardE
vent*>(event))); |
178 else if (event->isMouseEvent()) | 180 else if (event->isMouseEvent()) |
179 webEvent = adoptPtr(new WebMouseEventBuilder(m_webFrame->frame()->view()
, LayoutItem(m_webFrame->toImplBase()->frame()->ownerLayoutObject()), *static_ca
st<MouseEvent*>(event))); | 181 webEvent = wrapUnique(new WebMouseEventBuilder(m_webFrame->frame()->view
(), LayoutItem(m_webFrame->toImplBase()->frame()->ownerLayoutObject()), *static_
cast<MouseEvent*>(event))); |
180 | 182 |
181 // Other or internal Blink events should not be forwarded. | 183 // Other or internal Blink events should not be forwarded. |
182 if (!webEvent || webEvent->type == WebInputEvent::Undefined) | 184 if (!webEvent || webEvent->type == WebInputEvent::Undefined) |
183 return; | 185 return; |
184 | 186 |
185 m_webFrame->client()->forwardInputEvent(webEvent.get()); | 187 m_webFrame->client()->forwardInputEvent(webEvent.get()); |
186 } | 188 } |
187 | 189 |
188 void RemoteFrameClientImpl::frameRectsChanged(const IntRect& frameRect) | 190 void RemoteFrameClientImpl::frameRectsChanged(const IntRect& frameRect) |
189 { | 191 { |
190 m_webFrame->client()->frameRectsChanged(frameRect); | 192 m_webFrame->client()->frameRectsChanged(frameRect); |
191 } | 193 } |
192 | 194 |
193 void RemoteFrameClientImpl::advanceFocus(WebFocusType type, LocalFrame* source) | 195 void RemoteFrameClientImpl::advanceFocus(WebFocusType type, LocalFrame* source) |
194 { | 196 { |
195 m_webFrame->client()->advanceFocus(type, WebLocalFrameImpl::fromFrame(source
)); | 197 m_webFrame->client()->advanceFocus(type, WebLocalFrameImpl::fromFrame(source
)); |
196 } | 198 } |
197 | 199 |
198 void RemoteFrameClientImpl::visibilityChanged(bool visible) | 200 void RemoteFrameClientImpl::visibilityChanged(bool visible) |
199 { | 201 { |
200 m_webFrame->client()->visibilityChanged(visible); | 202 m_webFrame->client()->visibilityChanged(visible); |
201 } | 203 } |
202 | 204 |
203 } // namespace blink | 205 } // namespace blink |
OLD | NEW |