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