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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 8951014: Change the DidChangeView update to take a new ViewChanged resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New patch Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/utf_offset_string_conversions.h" 13 #include "base/utf_offset_string_conversions.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "ppapi/c/dev/ppb_console_dev.h" 15 #include "ppapi/c/dev/ppb_console_dev.h"
16 #include "ppapi/c/dev/ppb_find_dev.h" 16 #include "ppapi/c/dev/ppb_find_dev.h"
17 #include "ppapi/c/dev/ppb_zoom_dev.h" 17 #include "ppapi/c/dev/ppb_zoom_dev.h"
18 #include "ppapi/c/dev/ppp_find_dev.h" 18 #include "ppapi/c/dev/ppp_find_dev.h"
19 #include "ppapi/c/dev/ppp_selection_dev.h" 19 #include "ppapi/c/dev/ppp_selection_dev.h"
20 #include "ppapi/c/dev/ppp_zoom_dev.h" 20 #include "ppapi/c/dev/ppp_zoom_dev.h"
21 #include "ppapi/c/pp_rect.h" 21 #include "ppapi/c/pp_rect.h"
22 #include "ppapi/c/ppb_core.h" 22 #include "ppapi/c/ppb_core.h"
23 #include "ppapi/c/ppp_input_event.h" 23 #include "ppapi/c/ppp_input_event.h"
24 #include "ppapi/c/ppp_instance.h" 24 #include "ppapi/c/ppp_instance.h"
25 #include "ppapi/c/ppp_messaging.h" 25 #include "ppapi/c/ppp_messaging.h"
26 #include "ppapi/c/ppp_mouse_lock.h" 26 #include "ppapi/c/ppp_mouse_lock.h"
27 #include "ppapi/c/private/ppp_instance_private.h" 27 #include "ppapi/c/private/ppp_instance_private.h"
28 #include "ppapi/shared_impl/ppb_input_event_shared.h" 28 #include "ppapi/shared_impl/ppb_input_event_shared.h"
29 #include "ppapi/shared_impl/ppb_url_util_shared.h" 29 #include "ppapi/shared_impl/ppb_url_util_shared.h"
30 #include "ppapi/shared_impl/ppb_view_shared.h"
30 #include "ppapi/shared_impl/ppp_instance_combined.h" 31 #include "ppapi/shared_impl/ppp_instance_combined.h"
32 #include "ppapi/shared_impl/resource.h"
33 #include "ppapi/shared_impl/scoped_pp_resource.h"
31 #include "ppapi/shared_impl/time_conversion.h" 34 #include "ppapi/shared_impl/time_conversion.h"
32 #include "ppapi/shared_impl/var.h" 35 #include "ppapi/shared_impl/var.h"
33 #include "ppapi/thunk/enter.h" 36 #include "ppapi/thunk/enter.h"
34 #include "ppapi/thunk/ppb_buffer_api.h" 37 #include "ppapi/thunk/ppb_buffer_api.h"
35 #include "printing/units.h" 38 #include "printing/units.h"
36 #include "third_party/skia/include/core/SkCanvas.h" 39 #include "third_party/skia/include/core/SkCanvas.h"
37 #include "third_party/skia/include/core/SkRect.h" 40 #include "third_party/skia/include/core/SkRect.h"
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h"
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
48 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 51 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
49 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 52 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
50 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" 53 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h"
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
52 #include "webkit/plugins/ppapi/common.h" 55 #include "webkit/plugins/ppapi/common.h"
53 #include "webkit/plugins/ppapi/event_conversion.h" 56 #include "webkit/plugins/ppapi/event_conversion.h"
54 #include "webkit/plugins/ppapi/fullscreen_container.h" 57 #include "webkit/plugins/ppapi/fullscreen_container.h"
58 #include "webkit/plugins/ppapi/gfx_conversion.h"
55 #include "webkit/plugins/ppapi/host_globals.h" 59 #include "webkit/plugins/ppapi/host_globals.h"
56 #include "webkit/plugins/ppapi/message_channel.h" 60 #include "webkit/plugins/ppapi/message_channel.h"
57 #include "webkit/plugins/ppapi/npapi_glue.h" 61 #include "webkit/plugins/ppapi/npapi_glue.h"
58 #include "webkit/plugins/ppapi/plugin_module.h" 62 #include "webkit/plugins/ppapi/plugin_module.h"
59 #include "webkit/plugins/ppapi/plugin_object.h" 63 #include "webkit/plugins/ppapi/plugin_object.h"
60 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 64 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
61 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 65 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
62 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" 66 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
63 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 67 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
64 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" 68 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
(...skipping 19 matching lines...) Expand all
84 #include "base/metrics/histogram.h" 88 #include "base/metrics/histogram.h"
85 #include "skia/ext/platform_canvas.h" 89 #include "skia/ext/platform_canvas.h"
86 #include "ui/gfx/codec/jpeg_codec.h" 90 #include "ui/gfx/codec/jpeg_codec.h"
87 #include "ui/gfx/gdi_util.h" 91 #include "ui/gfx/gdi_util.h"
88 #endif 92 #endif
89 93
90 using base::StringPrintf; 94 using base::StringPrintf;
91 using ppapi::InputEventData; 95 using ppapi::InputEventData;
92 using ppapi::PPB_InputEvent_Shared; 96 using ppapi::PPB_InputEvent_Shared;
93 using ppapi::PpapiGlobals; 97 using ppapi::PpapiGlobals;
98 using ppapi::PPB_View_Shared;
99 using ppapi::ScopedPPResource;
94 using ppapi::StringVar; 100 using ppapi::StringVar;
95 using ppapi::thunk::EnterResourceNoLock; 101 using ppapi::thunk::EnterResourceNoLock;
96 using ppapi::thunk::PPB_Buffer_API; 102 using ppapi::thunk::PPB_Buffer_API;
97 using ppapi::thunk::PPB_Graphics2D_API; 103 using ppapi::thunk::PPB_Graphics2D_API;
98 using ppapi::thunk::PPB_Graphics3D_API; 104 using ppapi::thunk::PPB_Graphics3D_API;
99 using ppapi::thunk::PPB_ImageData_API; 105 using ppapi::thunk::PPB_ImageData_API;
100 using ppapi::thunk::PPB_Instance_FunctionAPI; 106 using ppapi::thunk::PPB_Instance_FunctionAPI;
101 using ppapi::Var; 107 using ppapi::Var;
108 using ppapi::ViewData;
102 using WebKit::WebBindings; 109 using WebKit::WebBindings;
103 using WebKit::WebCanvas; 110 using WebKit::WebCanvas;
104 using WebKit::WebConsoleMessage; 111 using WebKit::WebConsoleMessage;
105 using WebKit::WebCursorInfo; 112 using WebKit::WebCursorInfo;
106 using WebKit::WebDocument; 113 using WebKit::WebDocument;
107 using WebKit::WebElement; 114 using WebKit::WebElement;
108 using WebKit::WebFrame; 115 using WebKit::WebFrame;
109 using WebKit::WebInputEvent; 116 using WebKit::WebInputEvent;
110 using WebKit::WebPluginContainer; 117 using WebKit::WebPluginContainer;
111 using WebKit::WebString; 118 using WebKit::WebString;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_CURSORTYPE_COPY); 219 COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_CURSORTYPE_COPY);
213 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_CURSORTYPE_NONE); 220 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_CURSORTYPE_NONE);
214 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_CURSORTYPE_NOTALLOWED); 221 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_CURSORTYPE_NOTALLOWED);
215 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_CURSORTYPE_ZOOMIN); 222 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_CURSORTYPE_ZOOMIN);
216 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_CURSORTYPE_ZOOMOUT); 223 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_CURSORTYPE_ZOOMOUT);
217 COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_CURSORTYPE_GRAB); 224 COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_CURSORTYPE_GRAB);
218 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_CURSORTYPE_GRABBING); 225 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_CURSORTYPE_GRABBING);
219 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; 226 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM;
220 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. 227 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types.
221 228
222 void RectToPPRect(const gfx::Rect& input, PP_Rect* output) {
223 *output = PP_MakeRectFromXYWH(input.x(), input.y(),
224 input.width(), input.height());
225 }
226
227 // Sets |*security_origin| to be the WebKit security origin associated with the 229 // Sets |*security_origin| to be the WebKit security origin associated with the
228 // document containing the given plugin instance. On success, returns true. If 230 // document containing the given plugin instance. On success, returns true. If
229 // the instance is invalid, returns false and |*security_origin| will be 231 // the instance is invalid, returns false and |*security_origin| will be
230 // unchanged. 232 // unchanged.
231 bool SecurityOriginForInstance(PP_Instance instance_id, 233 bool SecurityOriginForInstance(PP_Instance instance_id,
232 WebKit::WebSecurityOrigin* security_origin) { 234 WebKit::WebSecurityOrigin* security_origin) {
233 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); 235 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
234 if (!instance) 236 if (!instance)
235 return false; 237 return false;
236 238
237 WebElement plugin_element = instance->container()->element(); 239 WebElement plugin_element = instance->container()->element();
238 *security_origin = plugin_element.document().securityOrigin(); 240 *security_origin = plugin_element.document().securityOrigin();
239 return true; 241 return true;
240 } 242 }
241 243
242 } // namespace 244 } // namespace
243 245
244 // static 246 // static
245 PluginInstance* PluginInstance::Create1_0(PluginDelegate* delegate, 247 PluginInstance* PluginInstance::Create1_0(PluginDelegate* delegate,
246 PluginModule* module, 248 PluginModule* module,
247 const void* ppp_instance_if_1_0) { 249 const void* ppp_instance_if_1_0) {
248 const PPP_Instance_1_0* instance = 250 const PPP_Instance_1_0* instance =
249 static_cast<const PPP_Instance_1_0*>(ppp_instance_if_1_0); 251 static_cast<const PPP_Instance_1_0*>(ppp_instance_if_1_0);
250 return new PluginInstance( 252 return new PluginInstance(
251 delegate, 253 delegate,
252 module, 254 module,
253 new ::ppapi::PPP_Instance_Combined(*instance)); 255 new ::ppapi::PPP_Instance_Combined(*instance));
254 } 256 }
255 257
258 // static
259 PluginInstance* PluginInstance::Create1_1(PluginDelegate* delegate,
260 PluginModule* module,
261 const void* ppp_instance_if_1_1) {
262 const PPP_Instance_1_1* instance =
263 static_cast<const PPP_Instance_1_1*>(ppp_instance_if_1_1);
264 return new PluginInstance(
265 delegate,
266 module,
267 new ::ppapi::PPP_Instance_Combined(*instance));
268 }
269
256 PluginInstance::PluginInstance( 270 PluginInstance::PluginInstance(
257 PluginDelegate* delegate, 271 PluginDelegate* delegate,
258 PluginModule* module, 272 PluginModule* module,
259 ::ppapi::PPP_Instance_Combined* instance_interface) 273 ::ppapi::PPP_Instance_Combined* instance_interface)
260 : delegate_(delegate), 274 : delegate_(delegate),
261 module_(module), 275 module_(module),
262 instance_interface_(instance_interface), 276 instance_interface_(instance_interface),
263 pp_instance_(0), 277 pp_instance_(0),
264 container_(NULL), 278 container_(NULL),
265 full_frame_(false), 279 full_frame_(false),
266 sent_did_change_view_(false), 280 sent_did_change_view_(false),
281 suppress_did_change_view_(false),
267 has_webkit_focus_(false), 282 has_webkit_focus_(false),
268 has_content_area_focus_(false), 283 has_content_area_focus_(false),
269 find_identifier_(-1), 284 find_identifier_(-1),
270 plugin_find_interface_(NULL), 285 plugin_find_interface_(NULL),
271 plugin_messaging_interface_(NULL), 286 plugin_messaging_interface_(NULL),
272 plugin_mouse_lock_interface_(NULL), 287 plugin_mouse_lock_interface_(NULL),
273 plugin_input_event_interface_(NULL), 288 plugin_input_event_interface_(NULL),
274 plugin_private_interface_(NULL), 289 plugin_private_interface_(NULL),
275 plugin_pdf_interface_(NULL), 290 plugin_pdf_interface_(NULL),
276 plugin_selection_interface_(NULL), 291 plugin_selection_interface_(NULL),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect); 376 bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect);
362 } 377 }
363 378
364 void PluginInstance::InvalidateRect(const gfx::Rect& rect) { 379 void PluginInstance::InvalidateRect(const gfx::Rect& rect) {
365 if (fullscreen_container_) { 380 if (fullscreen_container_) {
366 if (rect.IsEmpty()) 381 if (rect.IsEmpty())
367 fullscreen_container_->Invalidate(); 382 fullscreen_container_->Invalidate();
368 else 383 else
369 fullscreen_container_->InvalidateRect(rect); 384 fullscreen_container_->InvalidateRect(rect);
370 } else { 385 } else {
371 if (!container_ || position_.IsEmpty()) 386 if (!container_ ||
387 view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0)
372 return; // Nothing to do. 388 return; // Nothing to do.
373 if (rect.IsEmpty()) 389 if (rect.IsEmpty())
374 container_->invalidate(); 390 container_->invalidate();
375 else 391 else
376 container_->invalidateRect(rect); 392 container_->invalidateRect(rect);
377 } 393 }
378 } 394 }
379 395
380 void PluginInstance::ScrollRect(int dx, int dy, const gfx::Rect& rect) { 396 void PluginInstance::ScrollRect(int dx, int dy, const gfx::Rect& rect) {
381 if (fullscreen_container_) { 397 if (fullscreen_container_) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 639 }
624 640
625 bool PluginInstance::IsPluginAcceptingCompositionEvents() const { 641 bool PluginInstance::IsPluginAcceptingCompositionEvents() const {
626 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) || 642 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) ||
627 (input_event_mask_ & PP_INPUTEVENT_CLASS_IME); 643 (input_event_mask_ & PP_INPUTEVENT_CLASS_IME);
628 } 644 }
629 645
630 gfx::Rect PluginInstance::GetCaretBounds() const { 646 gfx::Rect PluginInstance::GetCaretBounds() const {
631 if (!text_input_caret_set_) { 647 if (!text_input_caret_set_) {
632 // If it is never set by the plugin, use the bottom left corner. 648 // If it is never set by the plugin, use the bottom left corner.
633 return gfx::Rect(position().x(), position().y()+position().height(), 0, 0); 649 return gfx::Rect(view_data_.rect.point.x,
650 view_data_.rect.point.y + view_data_.rect.size.height,
651 0, 0);
634 } 652 }
635 653
636 // TODO(kinaba) Take CSS transformation into accont. 654 // TODO(kinaba) Take CSS transformation into accont.
637 // TODO(kinaba) Take bounding_box into account. On some platforms, an 655 // TODO(kinaba) Take bounding_box into account. On some platforms, an
638 // "exclude rectangle" where candidate window must avoid the region can be 656 // "exclude rectangle" where candidate window must avoid the region can be
639 // passed to IME. Currently, we pass only the caret rectangle because 657 // passed to IME. Currently, we pass only the caret rectangle because
640 // it is the only information supported uniformly in Chromium. 658 // it is the only information supported uniformly in Chromium.
641 gfx::Rect caret(text_input_caret_); 659 gfx::Rect caret(text_input_caret_);
642 caret.Offset(position().origin()); 660 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y);
643 return caret; 661 return caret;
644 } 662 }
645 663
646 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, 664 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event,
647 WebCursorInfo* cursor_info) { 665 WebCursorInfo* cursor_info) {
648 TRACE_EVENT0("ppapi", "PluginInstance::HandleInputEvent"); 666 TRACE_EVENT0("ppapi", "PluginInstance::HandleInputEvent");
649 667
650 if (WebInputEvent::isMouseEventType(event.type)) 668 if (WebInputEvent::isMouseEventType(event.type))
651 delegate()->DidReceiveMouseEvent(this); 669 delegate()->DidReceiveMouseEvent(this);
652 670
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 void PluginInstance::ViewChanged(const gfx::Rect& position, 731 void PluginInstance::ViewChanged(const gfx::Rect& position,
714 const gfx::Rect& clip) { 732 const gfx::Rect& clip) {
715 // WebKit can give weird (x,y) positions for empty clip rects (since the 733 // WebKit can give weird (x,y) positions for empty clip rects (since the
716 // position technically doesn't matter). But we want to make these 734 // position technically doesn't matter). But we want to make these
717 // consistent since this is given to the plugin, so force everything to 0 735 // consistent since this is given to the plugin, so force everything to 0
718 // in the "everything is clipped" case. 736 // in the "everything is clipped" case.
719 gfx::Rect new_clip; 737 gfx::Rect new_clip;
720 if (!clip.IsEmpty()) 738 if (!clip.IsEmpty())
721 new_clip = clip; 739 new_clip = clip;
722 740
723 // Don't notify the plugin if we've already sent these same params before. 741 ViewData previous_view = view_data_;
724 if (sent_did_change_view_ && position == position_ && new_clip == clip_)
725 return;
726 742
727 if (desired_fullscreen_state_ || fullscreen_) { 743 view_data_.rect = PP_FromGfxRect(position);
744 view_data_.clip_rect = PP_FromGfxRect(clip);
745
746 if (desired_fullscreen_state_ || view_data_.is_fullscreen) {
728 WebElement element = container_->element(); 747 WebElement element = container_->element();
729 WebDocument document = element.document(); 748 WebDocument document = element.document();
730 bool is_fullscreen_element = (element == document.fullScreenElement()); 749 bool is_fullscreen_element = (element == document.fullScreenElement());
731 if (!fullscreen_ && desired_fullscreen_state_ && 750 if (!view_data_.is_fullscreen && desired_fullscreen_state_ &&
732 delegate()->IsInFullscreenMode() && is_fullscreen_element) { 751 delegate()->IsInFullscreenMode() && is_fullscreen_element) {
733 // Entered fullscreen. Only possible via SetFullscreen(). 752 // Entered fullscreen. Only possible via SetFullscreen().
734 fullscreen_ = true; 753 view_data_.is_fullscreen = true;
735 } else if (fullscreen_ && !is_fullscreen_element) { 754 } else if (view_data_.is_fullscreen && !is_fullscreen_element) {
736 // Exited fullscreen. Possible via SetFullscreen() or F11/link, 755 // Exited fullscreen. Possible via SetFullscreen() or F11/link,
737 // so desired_fullscreen_state might be out-of-date. 756 // so desired_fullscreen_state might be out-of-date.
738 desired_fullscreen_state_ = false; 757 desired_fullscreen_state_ = false;
739 fullscreen_ = false; 758 view_data_.is_fullscreen = false;
759
760 // This operation will cause the plugin to re-layout which will send more
761 // DidChangeView updates. Schedule an asynchronous update and suppress
762 // notifications until that completes to avoid sending intermediate sizes
763 // to the plugins.
764 ScheduleAsyncDidChangeView(previous_view);
765
740 // Reset the size attributes that we hacked to fill in the screen and 766 // Reset the size attributes that we hacked to fill in the screen and
741 // retrigger ViewChanged. Make sure we don't forward duplicates of 767 // retrigger ViewChanged. Make sure we don't forward duplicates of
742 // this view to the plugin. 768 // this view to the plugin.
743 ResetSizeAttributesAfterFullscreen(); 769 ResetSizeAttributesAfterFullscreen();
744 SetSentDidChangeView(position, new_clip);
745 MessageLoop::current()->PostTask(
746 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this));
747 return; 770 return;
748 } 771 }
749 } 772 }
750 773
751 SetSentDidChangeView(position, new_clip);
752 flash_fullscreen_ = (fullscreen_container_ != NULL); 774 flash_fullscreen_ = (fullscreen_container_ != NULL);
753 775 SendDidChangeView(previous_view);
754 PP_Rect pp_position, pp_clip;
755 RectToPPRect(position_, &pp_position);
756 RectToPPRect(clip_, &pp_clip);
757 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip);
758 } 776 }
759 777
760 void PluginInstance::SetWebKitFocus(bool has_focus) { 778 void PluginInstance::SetWebKitFocus(bool has_focus) {
761 if (has_webkit_focus_ == has_focus) 779 if (has_webkit_focus_ == has_focus)
762 return; 780 return;
763 781
764 bool old_plugin_focus = PluginHasFocus(); 782 bool old_plugin_focus = PluginHasFocus();
765 has_webkit_focus_ = has_focus; 783 has_webkit_focus_ = has_focus;
766 if (PluginHasFocus() != old_plugin_focus) { 784 if (PluginHasFocus() != old_plugin_focus) {
767 delegate()->PluginFocusChanged(this, PluginHasFocus()); 785 delegate()->PluginFocusChanged(this, PluginHasFocus());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 gfx::Rect* clip) { 823 gfx::Rect* clip) {
806 if (!always_on_top_) 824 if (!always_on_top_)
807 return false; 825 return false;
808 if (!GetBoundGraphics2D() || !GetBoundGraphics2D()->is_always_opaque()) 826 if (!GetBoundGraphics2D() || !GetBoundGraphics2D()->is_always_opaque())
809 return false; 827 return false;
810 828
811 // We specifically want to compare against the area covered by the backing 829 // We specifically want to compare against the area covered by the backing
812 // store when seeing if we cover the given paint bounds, since the backing 830 // store when seeing if we cover the given paint bounds, since the backing
813 // store could be smaller than the declared plugin area. 831 // store could be smaller than the declared plugin area.
814 PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->image_data(); 832 PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->image_data();
815 gfx::Rect plugin_backing_store_rect(position_.origin(), 833 gfx::Rect plugin_backing_store_rect(
816 gfx::Size(image_data->width(), 834 PP_ToGfxPoint(view_data_.rect.point),
817 image_data->height())); 835 gfx::Size(image_data->width(), image_data->height()));
818 gfx::Rect clip_page(clip_); 836
819 clip_page.Offset(position_.origin()); 837 gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect);
838 clip_page.Offset(PP_ToGfxPoint(view_data_.rect.point));
820 gfx::Rect plugin_paint_rect = plugin_backing_store_rect.Intersect(clip_page); 839 gfx::Rect plugin_paint_rect = plugin_backing_store_rect.Intersect(clip_page);
821 if (!plugin_paint_rect.Contains(paint_bounds)) 840 if (!plugin_paint_rect.Contains(paint_bounds))
822 return false; 841 return false;
823 842
824 *dib = image_data->platform_image()->GetTransportDIB(); 843 *dib = image_data->platform_image()->GetTransportDIB();
825 *location = plugin_backing_store_rect; 844 *location = plugin_backing_store_rect;
826 *clip = clip_page; 845 *clip = clip_page;
827 return true; 846 return true;
828 } 847 }
829 848
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 PPP_ZOOM_DEV_INTERFACE)); 1005 PPP_ZOOM_DEV_INTERFACE));
987 } 1006 }
988 1007
989 return !!plugin_zoom_interface_; 1008 return !!plugin_zoom_interface_;
990 } 1009 }
991 1010
992 bool PluginInstance::PluginHasFocus() const { 1011 bool PluginInstance::PluginHasFocus() const {
993 return has_webkit_focus_ && has_content_area_focus_; 1012 return has_webkit_focus_ && has_content_area_focus_;
994 } 1013 }
995 1014
1015 void PluginInstance::ScheduleAsyncDidChangeView(
1016 const ::ppapi::ViewData& previous_view) {
1017 if (suppress_did_change_view_)
1018 return; // Already scheduled.
1019 suppress_did_change_view_ = true;
1020 MessageLoop::current()->PostTask(
1021 FROM_HERE, base::Bind(&PluginInstance::SendAsyncDidChangeView,
1022 this, previous_view));
1023 }
1024
1025 void PluginInstance::SendAsyncDidChangeView(const ViewData& previous_view) {
1026 DCHECK(suppress_did_change_view_);
1027 suppress_did_change_view_ = false;
1028 SendDidChangeView(previous_view);
1029 }
1030
1031 void PluginInstance::SendDidChangeView(const ViewData& previous_view) {
1032 if (suppress_did_change_view_ ||
1033 (sent_did_change_view_ && previous_view.Equals(view_data_)))
1034 return; // Nothing to update.
1035
1036 sent_did_change_view_ = true;
dmichael (off chromium) 2011/12/20 19:01:34 Maybe sent_initial_did_change_view_ would be a bet
1037 ScopedPPResource resource(
1038 ScopedPPResource::PassRef(),
1039 (new PPB_View_Shared(PPB_View_Shared::InitAsImpl(),
1040 pp_instance(), view_data_))->GetReference());
1041
1042 instance_interface_->DidChangeView(pp_instance(), resource,
1043 &view_data_.rect,
1044 &view_data_.clip_rect);
1045 }
1046
996 void PluginInstance::ReportGeometry() { 1047 void PluginInstance::ReportGeometry() {
997 // If this call was delayed, we may have transitioned back to fullscreen in 1048 // If this call was delayed, we may have transitioned back to fullscreen in
998 // the mean time, so only report the geometry if we are actually in normal 1049 // the mean time, so only report the geometry if we are actually in normal
999 // mode. 1050 // mode.
1000 if (container_ && !fullscreen_container_ && !flash_fullscreen_) 1051 if (container_ && !fullscreen_container_ && !flash_fullscreen_)
1001 container_->reportGeometry(); 1052 container_->reportGeometry();
1002 } 1053 }
1003 1054
1004 bool PluginInstance::GetPreferredPrintOutputFormat( 1055 bool PluginInstance::GetPreferredPrintOutputFormat(
1005 PP_PrintOutputFormat_Dev* format) { 1056 PP_PrintOutputFormat_Dev* format) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 PP_PrintOutputFormat_Dev format; 1089 PP_PrintOutputFormat_Dev format;
1039 if (!GetPreferredPrintOutputFormat(&format)) { 1090 if (!GetPreferredPrintOutputFormat(&format)) {
1040 // PrintBegin should not have been called since SupportsPrintInterface 1091 // PrintBegin should not have been called since SupportsPrintInterface
1041 // would have returned false; 1092 // would have returned false;
1042 NOTREACHED(); 1093 NOTREACHED();
1043 return 0; 1094 return 0;
1044 } 1095 }
1045 1096
1046 int num_pages = 0; 1097 int num_pages = 0;
1047 PP_PrintSettings_Dev print_settings; 1098 PP_PrintSettings_Dev print_settings;
1048 RectToPPRect(printable_area, &print_settings.printable_area); 1099 print_settings.printable_area = PP_FromGfxRect(printable_area);
1049 print_settings.dpi = printer_dpi; 1100 print_settings.dpi = printer_dpi;
1050 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; 1101 print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
1051 print_settings.grayscale = PP_FALSE; 1102 print_settings.grayscale = PP_FALSE;
1052 print_settings.format = format; 1103 print_settings.format = format;
1053 num_pages = plugin_print_interface_->Begin(pp_instance(), 1104 num_pages = plugin_print_interface_->Begin(pp_instance(),
1054 &print_settings); 1105 &print_settings);
1055 if (!num_pages) 1106 if (!num_pages)
1056 return 0; 1107 return 0;
1057 current_print_settings_ = print_settings; 1108 current_print_settings_ = print_settings;
1058 #if defined(USE_SKIA) 1109 #if defined(USE_SKIA)
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 void PluginInstance::SimulateInputEvent(const InputEventData& input_event) { 1626 void PluginInstance::SimulateInputEvent(const InputEventData& input_event) {
1576 WebView* web_view = container()->element().document().frame()->view(); 1627 WebView* web_view = container()->element().document().frame()->view();
1577 if (!web_view) { 1628 if (!web_view) {
1578 NOTREACHED(); 1629 NOTREACHED();
1579 return; 1630 return;
1580 } 1631 }
1581 1632
1582 std::vector<linked_ptr<WebInputEvent> > events = 1633 std::vector<linked_ptr<WebInputEvent> > events =
1583 CreateSimulatedWebInputEvents( 1634 CreateSimulatedWebInputEvents(
1584 input_event, 1635 input_event,
1585 position().x() + position().width() / 2, 1636 view_data_.rect.point.x + view_data_.rect.size.width / 2,
1586 position().y() + position().height() / 2); 1637 view_data_.rect.point.y + view_data_.rect.size.height / 2);
1587 for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin(); 1638 for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin();
1588 it != events.end(); ++it) { 1639 it != events.end(); ++it) {
1589 web_view->handleInputEvent(*it->get()); 1640 web_view->handleInputEvent(*it->get());
1590 } 1641 }
1591 } 1642 }
1592 1643
1593 PPB_Instance_FunctionAPI* PluginInstance::AsPPB_Instance_FunctionAPI() { 1644 PPB_Instance_FunctionAPI* PluginInstance::AsPPB_Instance_FunctionAPI() {
1594 return this; 1645 return this;
1595 } 1646 }
1596 1647
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 return PP_FALSE; 1700 return PP_FALSE;
1650 } 1701 }
1651 1702
1652 return PP_TRUE; 1703 return PP_TRUE;
1653 } 1704 }
1654 1705
1655 PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) { 1706 PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) {
1656 return PP_FromBool(full_frame()); 1707 return PP_FromBool(full_frame());
1657 } 1708 }
1658 1709
1710 PP_Resource PluginInstance::GetView(PP_Instance instance) {
1711 return (new PPB_View_Shared(PPB_View_Shared::InitAsImpl(), instance,
1712 view_data_))->GetReference();
dmichael (off chromium) 2011/12/20 19:01:34 Don't think you need this one anymore
1713 }
1714
1715 const ViewData* PluginInstance::GetViewData(PP_Instance instance) {
1716 return &view_data_;
1717 }
1718
1659 PP_Var PluginInstance::GetWindowObject(PP_Instance instance) { 1719 PP_Var PluginInstance::GetWindowObject(PP_Instance instance) {
1660 if (!container_) 1720 if (!container_)
1661 return PP_MakeUndefined(); 1721 return PP_MakeUndefined();
1662 1722
1663 WebFrame* frame = container_->element().document().frame(); 1723 WebFrame* frame = container_->element().document().frame();
1664 if (!frame) 1724 if (!frame)
1665 return PP_MakeUndefined(); 1725 return PP_MakeUndefined();
1666 1726
1667 return NPObjectToPPVar(this, frame->windowObject()); 1727 return NPObjectToPPVar(this, frame->windowObject());
1668 } 1728 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 delegate_->NumberOfFindResultsChanged(find_identifier_, total, 1832 delegate_->NumberOfFindResultsChanged(find_identifier_, total,
1773 PP_ToBool(final_result)); 1833 PP_ToBool(final_result));
1774 } 1834 }
1775 1835
1776 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, 1836 void PluginInstance::SelectedFindResultChanged(PP_Instance instance,
1777 int32_t index) { 1837 int32_t index) {
1778 DCHECK_NE(find_identifier_, -1); 1838 DCHECK_NE(find_identifier_, -1);
1779 delegate_->SelectedFindResultChanged(find_identifier_, index); 1839 delegate_->SelectedFindResultChanged(find_identifier_, index);
1780 } 1840 }
1781 1841
1782 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) {
1783 return PP_FromBool(fullscreen_);
1784 }
1785
1786 PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) { 1842 PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) {
1787 return PP_FromBool(flash_fullscreen_); 1843 return PP_FromBool(flash_fullscreen_);
1788 } 1844 }
1789 1845
1790 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance, 1846 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance,
1791 PP_Bool fullscreen) { 1847 PP_Bool fullscreen) {
1792 return PP_FromBool(SetFullscreen(PP_ToBool(fullscreen))); 1848 return PP_FromBool(SetFullscreen(PP_ToBool(fullscreen)));
1793 } 1849 }
1794 1850
1795 PP_Bool PluginInstance::FlashSetFullscreen(PP_Instance instance, 1851 PP_Bool PluginInstance::FlashSetFullscreen(PP_Instance instance,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 !containing_document.frame()->view()->mainFrame()) { 2006 !containing_document.frame()->view()->mainFrame()) {
1951 return false; 2007 return false;
1952 } 2008 }
1953 WebKit::WebDocument main_document = 2009 WebKit::WebDocument main_document =
1954 containing_document.frame()->view()->mainFrame()->document(); 2010 containing_document.frame()->view()->mainFrame()->document();
1955 2011
1956 return containing_document.securityOrigin().canAccess( 2012 return containing_document.securityOrigin().canAccess(
1957 main_document.securityOrigin()); 2013 main_document.securityOrigin());
1958 } 2014 }
1959 2015
1960 void PluginInstance::SetSentDidChangeView(const gfx::Rect& position,
1961 const gfx::Rect& clip) {
1962 sent_did_change_view_ = true;
1963 position_ = position;
1964 clip_ = clip;
1965 }
1966
1967 void PluginInstance::KeepSizeAttributesBeforeFullscreen() { 2016 void PluginInstance::KeepSizeAttributesBeforeFullscreen() {
1968 WebElement element = container_->element(); 2017 WebElement element = container_->element();
1969 width_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kWidth)); 2018 width_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kWidth));
1970 height_before_fullscreen_ = 2019 height_before_fullscreen_ =
1971 element.getAttribute(WebString::fromUTF8(kHeight)); 2020 element.getAttribute(WebString::fromUTF8(kHeight));
1972 border_before_fullscreen_ = 2021 border_before_fullscreen_ =
1973 element.getAttribute(WebString::fromUTF8(kBorder)); 2022 element.getAttribute(WebString::fromUTF8(kBorder));
1974 style_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kStyle)); 2023 style_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kStyle));
1975 } 2024 }
1976 2025
(...skipping 24 matching lines...) Expand all
2001 screen_size_for_fullscreen_ = gfx::Size(); 2050 screen_size_for_fullscreen_ = gfx::Size();
2002 WebElement element = container_->element(); 2051 WebElement element = container_->element();
2003 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2052 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2004 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2053 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2005 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2054 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2006 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2055 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2007 } 2056 }
2008 2057
2009 } // namespace ppapi 2058 } // namespace ppapi
2010 } // namespace webkit 2059 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698