OLD | NEW |
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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #import <QuartzCore/QuartzCore.h> | 6 #import <QuartzCore/QuartzCore.h> |
7 | 7 |
8 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 8 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 private: | 116 private: |
117 class VisibilityGroup { | 117 class VisibilityGroup { |
118 public: | 118 public: |
119 explicit VisibilityGroup(int timer_period) | 119 explicit VisibilityGroup(int timer_period) |
120 : timer_period_(timer_period), iterator_(delegates_.end()) {} | 120 : timer_period_(timer_period), iterator_(delegates_.end()) {} |
121 | 121 |
122 // Adds |delegate| to this visibility group. | 122 // Adds |delegate| to this visibility group. |
123 void RegisterDelegate(WebPluginDelegateImpl* delegate) { | 123 void RegisterDelegate(WebPluginDelegateImpl* delegate) { |
124 if (delegates_.empty()) { | 124 if (delegates_.empty()) { |
125 timer_.Start(base::TimeDelta::FromMilliseconds(timer_period_), | 125 timer_.Start(FROM_HERE, |
| 126 base::TimeDelta::FromMilliseconds(timer_period_), |
126 this, &VisibilityGroup::SendIdleEvents); | 127 this, &VisibilityGroup::SendIdleEvents); |
127 } | 128 } |
128 delegates_.insert(delegate); | 129 delegates_.insert(delegate); |
129 } | 130 } |
130 | 131 |
131 // Removes |delegate| from this visibility group. | 132 // Removes |delegate| from this visibility group. |
132 void UnregisterDelegate(WebPluginDelegateImpl* delegate) { | 133 void UnregisterDelegate(WebPluginDelegateImpl* delegate) { |
133 // If a plugin changes visibility during idle event handling, it | 134 // If a plugin changes visibility during idle event handling, it |
134 // may be removed from this set while SendIdleEvents is still iterating; | 135 // may be removed from this set while SendIdleEvents is still iterating; |
135 // if that happens and it's next on the list, increment the iterator | 136 // if that happens and it's next on the list, increment the iterator |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 } | 1017 } |
1017 | 1018 |
1018 void WebPluginDelegateImpl::PluginVisibilityChanged() { | 1019 void WebPluginDelegateImpl::PluginVisibilityChanged() { |
1019 #ifndef NP_NO_CARBON | 1020 #ifndef NP_NO_CARBON |
1020 if (instance()->event_model() == NPEventModelCarbon) | 1021 if (instance()->event_model() == NPEventModelCarbon) |
1021 UpdateIdleEventRate(); | 1022 UpdateIdleEventRate(); |
1022 #endif | 1023 #endif |
1023 if (instance()->drawing_model() == NPDrawingModelCoreAnimation) { | 1024 if (instance()->drawing_model() == NPDrawingModelCoreAnimation) { |
1024 bool plugin_visible = container_is_visible_ && !clip_rect_.IsEmpty(); | 1025 bool plugin_visible = container_is_visible_ && !clip_rect_.IsEmpty(); |
1025 if (plugin_visible && !redraw_timer_->IsRunning() && windowed_handle()) { | 1026 if (plugin_visible && !redraw_timer_->IsRunning() && windowed_handle()) { |
1026 redraw_timer_->Start( | 1027 redraw_timer_->Start(FROM_HERE, |
1027 base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs), | 1028 base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs), |
1028 this, &WebPluginDelegateImpl::DrawLayerInSurface); | 1029 this, &WebPluginDelegateImpl::DrawLayerInSurface); |
1029 } else if (!plugin_visible) { | 1030 } else if (!plugin_visible) { |
1030 redraw_timer_->Stop(); | 1031 redraw_timer_->Stop(); |
1031 } | 1032 } |
1032 } | 1033 } |
1033 } | 1034 } |
1034 | 1035 |
1035 void WebPluginDelegateImpl::StartIme() { | 1036 void WebPluginDelegateImpl::StartIme() { |
1036 // Currently the plugin IME implementation only works on 10.6. | 1037 // Currently the plugin IME implementation only works on 10.6. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 qd_manager_->SetFastPathEnabled(enabled); | 1209 qd_manager_->SetFastPathEnabled(enabled); |
1209 qd_port_.port = qd_manager_->port(); | 1210 qd_port_.port = qd_manager_->port(); |
1210 WindowlessSetWindow(); | 1211 WindowlessSetWindow(); |
1211 // Send a paint event so that the new buffer gets updated immediately. | 1212 // Send a paint event so that the new buffer gets updated immediately. |
1212 WindowlessPaint(buffer_context_, clip_rect_); | 1213 WindowlessPaint(buffer_context_, clip_rect_); |
1213 } | 1214 } |
1214 #endif // !NP_NO_QUICKDRAW | 1215 #endif // !NP_NO_QUICKDRAW |
1215 | 1216 |
1216 } // namespace npapi | 1217 } // namespace npapi |
1217 } // namespace webkit | 1218 } // namespace webkit |
OLD | NEW |