OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/glue/plugins/webplugin_delegate_impl.h" | 5 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 WebPluginDelegateImpl::WebPluginDelegateImpl( | 138 WebPluginDelegateImpl::WebPluginDelegateImpl( |
139 gfx::NativeView containing_view, | 139 gfx::NativeView containing_view, |
140 NPAPI::PluginInstance *instance) | 140 NPAPI::PluginInstance *instance) |
141 : parent_(containing_view), | 141 : parent_(containing_view), |
142 instance_(instance), | 142 instance_(instance), |
143 quirks_(0), | 143 quirks_(0), |
144 plugin_(NULL), | 144 plugin_(NULL), |
145 windowless_(false), | 145 windowless_(false), |
146 windowed_handle_(NULL), | 146 windowed_handle_(NULL), |
147 windowed_did_set_window_(false), | 147 windowed_did_set_window_(false), |
| 148 windowed_manage_position_(false), |
148 windowless_needs_set_window_(true), | 149 windowless_needs_set_window_(true), |
149 plugin_wnd_proc_(NULL), | 150 plugin_wnd_proc_(NULL), |
150 last_message_(0), | 151 last_message_(0), |
151 is_calling_wndproc(false), | 152 is_calling_wndproc(false), |
152 dummy_window_for_activation_(NULL), | 153 dummy_window_for_activation_(NULL), |
153 handle_event_message_filter_hook_(NULL), | 154 handle_event_message_filter_hook_(NULL), |
154 handle_event_pump_messages_event_(NULL), | 155 handle_event_pump_messages_event_(NULL), |
155 handle_event_depth_(0), | 156 handle_event_depth_(0), |
156 user_gesture_message_posted_(false), | 157 user_gesture_message_posted_(false), |
157 #pragma warning(suppress: 4355) // can use this | 158 #pragma warning(suppress: 4355) // can use this |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // the window handle and validate the same. The window handle can be | 260 // the window handle and validate the same. The window handle can be |
260 // retreived via NPN_GetValue of NPNVnetscapeWindow. | 261 // retreived via NPN_GetValue of NPNVnetscapeWindow. |
261 instance_->set_window_handle(parent_); | 262 instance_->set_window_handle(parent_); |
262 CreateDummyWindowForActivation(); | 263 CreateDummyWindowForActivation(); |
263 handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); | 264 handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); |
264 } else { | 265 } else { |
265 if (!WindowedCreatePlugin()) | 266 if (!WindowedCreatePlugin()) |
266 return false; | 267 return false; |
267 } | 268 } |
268 | 269 |
269 plugin->SetWindow(windowed_handle_, handle_event_pump_messages_event_); | 270 windowed_manage_position_ = |
| 271 plugin->SetWindow(windowed_handle_, handle_event_pump_messages_event_); |
270 plugin_url_ = url.spec(); | 272 plugin_url_ = url.spec(); |
271 | 273 |
272 // The windowless version of the Silverlight plugin calls the | 274 // The windowless version of the Silverlight plugin calls the |
273 // WindowFromPoint API and passes the result of that to the | 275 // WindowFromPoint API and passes the result of that to the |
274 // TrackPopupMenu API call as the owner window. This causes the API | 276 // TrackPopupMenu API call as the owner window. This causes the API |
275 // to fail as the API expects the window handle to live on the same | 277 // to fail as the API expects the window handle to live on the same |
276 // thread as the caller. It works in the other browsers as the plugin | 278 // thread as the caller. It works in the other browsers as the plugin |
277 // lives on the browser thread. Our workaround is to intercept the | 279 // lives on the browser thread. Our workaround is to intercept the |
278 // TrackPopupMenu API for Silverlight and replace the window handle | 280 // TrackPopupMenu API for Silverlight and replace the window handle |
279 // with the dummy activation window. | 281 // with the dummy activation window. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 // all active plugins with each pass through the throttle, otherwise | 545 // all active plugins with each pass through the throttle, otherwise |
544 // we see video jankiness. | 546 // we see video jankiness. |
545 std::list<MSG>* throttle_queue = g_throttle_queue.Pointer(); | 547 std::list<MSG>* throttle_queue = g_throttle_queue.Pointer(); |
546 std::map<HWND, int> processed; | 548 std::map<HWND, int> processed; |
547 | 549 |
548 std::list<MSG>::iterator it = throttle_queue->begin(); | 550 std::list<MSG>::iterator it = throttle_queue->begin(); |
549 while (it != throttle_queue->end()) { | 551 while (it != throttle_queue->end()) { |
550 const MSG& msg = *it; | 552 const MSG& msg = *it; |
551 if (processed.find(msg.hwnd) == processed.end()) { | 553 if (processed.find(msg.hwnd) == processed.end()) { |
552 WNDPROC proc = reinterpret_cast<WNDPROC>(msg.time); | 554 WNDPROC proc = reinterpret_cast<WNDPROC>(msg.time); |
553 » // It is possible that the window was closed after we queued | 555 // It is possible that the window was closed after we queued |
554 » // this message. This is a rare event; just verify the window | 556 // this message. This is a rare event; just verify the window |
555 » // is alive. (see also bug 1259488) | 557 // is alive. (see also bug 1259488) |
556 » if (IsWindow(msg.hwnd)) | 558 if (IsWindow(msg.hwnd)) |
557 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); | 559 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); |
558 processed[msg.hwnd] = 1; | 560 processed[msg.hwnd] = 1; |
559 it = throttle_queue->erase(it); | 561 it = throttle_queue->erase(it); |
560 } else { | 562 } else { |
561 it++; | 563 it++; |
562 } | 564 } |
563 } | 565 } |
564 | 566 |
565 if (throttle_queue->size() > 0) | 567 if (throttle_queue->size() > 0) |
566 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 568 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 const gfx::Rect& window_rect, | 690 const gfx::Rect& window_rect, |
689 const gfx::Rect& clip_rect) { | 691 const gfx::Rect& clip_rect) { |
690 if (!windowed_handle_) { | 692 if (!windowed_handle_) { |
691 NOTREACHED(); | 693 NOTREACHED(); |
692 return false; | 694 return false; |
693 } | 695 } |
694 | 696 |
695 if (window_rect_ == window_rect && clip_rect_ == clip_rect) | 697 if (window_rect_ == window_rect && clip_rect_ == clip_rect) |
696 return false; | 698 return false; |
697 | 699 |
698 // There are a few parts to managing the plugin windows: | 700 // If windowed_manage_position_ is false, then the plugin will be moved |
699 // - Initial geometry, show / resize / position the window. | 701 // elsewhere. This allows the window moves/scrolling/clipping to be |
700 // - Geometry updates, resize the window. | 702 // synchronized with the page and other windows. |
701 // - Geometry updates, move the window or update the clipping region. | |
702 // This code should handle the first two, positioning and sizing the window | |
703 // initially, and resizing it when the size changes. Clipping and moving are | |
704 // handled separately by WebPlugin, after it has called this code. This | |
705 // allows window moves, like scrolling, to be synchronized with painting. | |
706 // See WebPluginImpl::setFrameRect(). | |
707 if (window_rect.size() != window_rect_.size()) { | 703 if (window_rect.size() != window_rect_.size()) { |
708 ::SetWindowPos(windowed_handle_, | 704 ::SetWindowPos(windowed_handle_, |
709 NULL, | 705 NULL, |
710 0, | 706 windowed_manage_position_ ? window_rect.x() : 0, |
711 0, | 707 windowed_manage_position_ ? window_rect.y() : 0, |
712 window_rect.width(), | 708 window_rect.width(), |
713 window_rect.height(), | 709 window_rect.height(), |
714 SWP_SHOWWINDOW); | 710 SWP_SHOWWINDOW); |
715 } | 711 } |
716 | 712 |
717 window_rect_ = window_rect; | 713 window_rect_ = window_rect; |
718 clip_rect_ = clip_rect; | 714 clip_rect_ = clip_rect; |
719 | 715 |
720 // Ensure that the entire window gets repainted. | 716 // Ensure that the entire window gets repainted. |
721 ::InvalidateRect(windowed_handle_, NULL, FALSE); | 717 ::InvalidateRect(windowed_handle_, NULL, FALSE); |
(...skipping 13 matching lines...) Expand all Loading... |
735 instance()->set_window_handle(windowed_handle_); | 731 instance()->set_window_handle(windowed_handle_); |
736 | 732 |
737 DCHECK(!instance()->windowless()); | 733 DCHECK(!instance()->windowless()); |
738 | 734 |
739 window_.clipRect.top = clip_rect_.y(); | 735 window_.clipRect.top = clip_rect_.y(); |
740 window_.clipRect.left = clip_rect_.x(); | 736 window_.clipRect.left = clip_rect_.x(); |
741 window_.clipRect.bottom = clip_rect_.y() + clip_rect_.height(); | 737 window_.clipRect.bottom = clip_rect_.y() + clip_rect_.height(); |
742 window_.clipRect.right = clip_rect_.x() + clip_rect_.width(); | 738 window_.clipRect.right = clip_rect_.x() + clip_rect_.width(); |
743 window_.height = window_rect_.height(); | 739 window_.height = window_rect_.height(); |
744 window_.width = window_rect_.width(); | 740 window_.width = window_rect_.width(); |
745 window_.x = window_rect_.x(); | 741 window_.x = windowed_manage_position_ ? window_rect_.x() : 0; |
746 window_.y = window_rect_.y(); | 742 window_.y = windowed_manage_position_ ? window_rect_.y() : 0; |
747 | 743 |
748 window_.window = windowed_handle_; | 744 window_.window = windowed_handle_; |
749 window_.type = NPWindowTypeWindow; | 745 window_.type = NPWindowTypeWindow; |
750 | 746 |
751 // Reset this flag before entering the instance in case of side-effects. | 747 // Reset this flag before entering the instance in case of side-effects. |
752 windowed_did_set_window_ = true; | 748 windowed_did_set_window_ = true; |
753 | 749 |
754 NPError err = instance()->NPP_SetWindow(&window_); | 750 NPError err = instance()->NPP_SetWindow(&window_); |
755 if (quirks_ & PLUGIN_QUIRK_SETWINDOW_TWICE) | 751 if (quirks_ & PLUGIN_QUIRK_SETWINDOW_TWICE) |
756 instance()->NPP_SetWindow(&window_); | 752 instance()->NPP_SetWindow(&window_); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 | 1188 |
1193 // It is ok to pass NULL here to GetCursor as we are not looking for cursor | 1189 // It is ok to pass NULL here to GetCursor as we are not looking for cursor |
1194 // types defined by Webkit. | 1190 // types defined by Webkit. |
1195 HCURSOR previous_cursor = | 1191 HCURSOR previous_cursor = |
1196 g_current_plugin_instance->current_windowless_cursor_.GetCursor(NULL); | 1192 g_current_plugin_instance->current_windowless_cursor_.GetCursor(NULL); |
1197 | 1193 |
1198 g_current_plugin_instance->current_windowless_cursor_.InitFromExternalCursor( | 1194 g_current_plugin_instance->current_windowless_cursor_.InitFromExternalCursor( |
1199 cursor); | 1195 cursor); |
1200 return previous_cursor; | 1196 return previous_cursor; |
1201 } | 1197 } |
OLD | NEW |