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

Side by Side Diff: components/plugins/renderer/webview_plugin.cc

Issue 2479123003: WIP Add getCoalescedEvents API using vector of WebInputEvents (Closed)
Patch Set: Creating CoalescedWebInputEvent Created 4 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/plugins/renderer/webview_plugin.h" 5 #include "components/plugins/renderer/webview_plugin.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/numerics/safe_conversions.h" 13 #include "base/numerics/safe_conversions.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "content/public/common/web_preferences.h" 16 #include "content/public/common/web_preferences.h"
17 #include "content/public/renderer/render_view.h" 17 #include "content/public/renderer/render_view.h"
18 #include "gin/converter.h" 18 #include "gin/converter.h"
19 #include "skia/ext/platform_canvas.h" 19 #include "skia/ext/platform_canvas.h"
20 #include "third_party/WebKit/public/platform/WebInputEvent.h" 20 #include "third_party/WebKit/public/platform/CoalescedWebInputEvent.h"
21 #include "third_party/WebKit/public/platform/WebURL.h" 21 #include "third_party/WebKit/public/platform/WebURL.h"
22 #include "third_party/WebKit/public/platform/WebURLResponse.h" 22 #include "third_party/WebKit/public/platform/WebURLResponse.h"
23 #include "third_party/WebKit/public/web/WebDocument.h" 23 #include "third_party/WebKit/public/web/WebDocument.h"
24 #include "third_party/WebKit/public/web/WebElement.h" 24 #include "third_party/WebKit/public/web/WebElement.h"
25 #include "third_party/WebKit/public/web/WebFrameWidget.h" 25 #include "third_party/WebKit/public/web/WebFrameWidget.h"
26 #include "third_party/WebKit/public/web/WebLocalFrame.h" 26 #include "third_party/WebKit/public/web/WebLocalFrame.h"
27 #include "third_party/WebKit/public/web/WebPluginContainer.h" 27 #include "third_party/WebKit/public/web/WebPluginContainer.h"
28 #include "third_party/WebKit/public/web/WebView.h" 28 #include "third_party/WebKit/public/web/WebView.h"
29 29
30 using blink::WebCanvas; 30 using blink::WebCanvas;
31 using blink::WebCursorInfo; 31 using blink::WebCursorInfo;
32 using blink::WebDragData; 32 using blink::WebDragData;
33 using blink::WebDragOperationsMask; 33 using blink::WebDragOperationsMask;
34 using blink::WebFrameWidget; 34 using blink::WebFrameWidget;
35 using blink::WebImage; 35 using blink::WebImage;
36 using blink::WebInputEvent; 36 using blink::CoalescedWebInputEvent;
37 using blink::WebLocalFrame; 37 using blink::WebLocalFrame;
38 using blink::WebMouseEvent; 38 using blink::WebMouseEvent;
39 using blink::WebPlugin; 39 using blink::WebPlugin;
40 using blink::WebPluginContainer; 40 using blink::WebPluginContainer;
41 using blink::WebPoint; 41 using blink::WebPoint;
42 using blink::WebRect; 42 using blink::WebRect;
43 using blink::WebString; 43 using blink::WebString;
44 using blink::WebURLError; 44 using blink::WebURLError;
45 using blink::WebURLResponse; 45 using blink::WebURLResponse;
46 using blink::WebVector; 46 using blink::WebVector;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 FROM_HERE, 181 FROM_HERE,
182 base::Bind(&WebViewPlugin::UpdatePluginForNewGeometry, 182 base::Bind(&WebViewPlugin::UpdatePluginForNewGeometry,
183 weak_factory_.GetWeakPtr(), window_rect, unobscured_rect)); 183 weak_factory_.GetWeakPtr(), window_rect, unobscured_rect));
184 } 184 }
185 185
186 void WebViewPlugin::updateFocus(bool focused, blink::WebFocusType focus_type) { 186 void WebViewPlugin::updateFocus(bool focused, blink::WebFocusType focus_type) {
187 focused_ = focused; 187 focused_ = focused;
188 } 188 }
189 189
190 blink::WebInputEventResult WebViewPlugin::handleInputEvent( 190 blink::WebInputEventResult WebViewPlugin::handleInputEvent(
191 const WebInputEvent& event, 191 const CoalescedWebInputEvent& coalescedEvent,
192 WebCursorInfo& cursor) { 192 WebCursorInfo& cursor) {
193 // For tap events, don't handle them. They will be converted to 193 // For tap events, don't handle them. They will be converted to
194 // mouse events later and passed to here. 194 // mouse events later and passed to here.
195 if (event.type == WebInputEvent::GestureTap) 195 if (coalescedEvent.event().type == blink::WebInputEvent::GestureTap)
196 return blink::WebInputEventResult::NotHandled; 196 return blink::WebInputEventResult::NotHandled;
197 197
198 // For LongPress events we return false, since otherwise the context menu will 198 // For LongPress events we return false, since otherwise the context menu will
199 // be suppressed. https://crbug.com/482842 199 // be suppressed. https://crbug.com/482842
200 if (event.type == WebInputEvent::GestureLongPress) 200 if (coalescedEvent.event().type == blink::WebInputEvent::GestureLongPress)
201 return blink::WebInputEventResult::NotHandled; 201 return blink::WebInputEventResult::NotHandled;
202 202
203 if (event.type == WebInputEvent::ContextMenu) { 203 if (coalescedEvent.event().type == blink::WebInputEvent::ContextMenu) {
204 if (delegate_) { 204 if (delegate_) {
205 const WebMouseEvent& mouse_event = 205 const WebMouseEvent& mouse_event =
206 reinterpret_cast<const WebMouseEvent&>(event); 206 reinterpret_cast<const WebMouseEvent&>(coalescedEvent.event());
207 delegate_->ShowContextMenu(mouse_event); 207 delegate_->ShowContextMenu(mouse_event);
208 } 208 }
209 return blink::WebInputEventResult::HandledSuppressed; 209 return blink::WebInputEventResult::HandledSuppressed;
210 } 210 }
211 current_cursor_ = cursor; 211 current_cursor_ = cursor;
212 blink::WebInputEventResult handled = web_view_->handleInputEvent(event); 212 blink::WebInputEventResult handled =
213 web_view_->handleInputEvent(coalescedEvent);
213 cursor = current_cursor_; 214 cursor = current_cursor_;
214 215
215 return handled; 216 return handled;
216 } 217 }
217 218
218 void WebViewPlugin::didReceiveResponse(const WebURLResponse& response) { 219 void WebViewPlugin::didReceiveResponse(const WebURLResponse& response) {
219 NOTREACHED(); 220 NOTREACHED();
220 } 221 }
221 222
222 void WebViewPlugin::didReceiveData(const char* data, int data_length) { 223 void WebViewPlugin::didReceiveData(const char* data, int data_length) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (!delegate_) 313 if (!delegate_)
313 return; 314 return;
314 315
315 // The delegate may instantiate a new plugin. 316 // The delegate may instantiate a new plugin.
316 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect)); 317 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect));
317 // The delegate may have dirtied style and layout of the WebView. 318 // The delegate may have dirtied style and layout of the WebView.
318 // See for example the resizePoster function in plugin_poster.html. 319 // See for example the resizePoster function in plugin_poster.html.
319 // Run the lifecycle now so that it is clean. 320 // Run the lifecycle now so that it is clean.
320 web_view_->updateAllLifecyclePhases(); 321 web_view_->updateAllLifecyclePhases();
321 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698