| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 #include <list> |
| 10 | 11 |
| 11 #include "base/memory/scoped_nsobject.h" | 12 #include "base/memory/scoped_nsobject.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/time.h" | 15 #include "base/time.h" |
| 15 #include "content/browser/accessibility/browser_accessibility_delegate_mac.h" | 16 #include "content/browser/accessibility/browser_accessibility_delegate_mac.h" |
| 16 #include "content/browser/renderer_host/accelerated_surface_container_manager_ma
c.h" | 17 #include "content/browser/renderer_host/accelerated_surface_container_manager_ma
c.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 18 #include "content/common/edit_command.h" | 19 #include "content/common/edit_command.h" |
| 19 #import "content/public/browser/render_widget_host_view_mac_base.h" | 20 #import "content/public/browser/render_widget_host_view_mac_base.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" |
| 21 #include "ui/base/cocoa/base_view.h" | 22 #include "ui/base/cocoa/base_view.h" |
| 22 #include "webkit/glue/webcursor.h" | 23 #include "webkit/glue/webcursor.h" |
| 23 | 24 |
| 24 @class AcceleratedPluginView; | 25 @class AcceleratedPluginView; |
| 26 class CompositingIOSurfaceMac; |
| 25 @class FullscreenWindowManager; | 27 @class FullscreenWindowManager; |
| 26 class RenderWidgetHostViewMac; | 28 class RenderWidgetHostViewMac; |
| 27 @protocol RenderWidgetHostViewMacDelegate; | 29 @protocol RenderWidgetHostViewMacDelegate; |
| 28 class RenderWidgetHostViewMacEditCommandHelper; | 30 class RenderWidgetHostViewMacEditCommandHelper; |
| 29 @class ToolTip; | 31 @class ToolTip; |
| 30 | 32 |
| 31 namespace content { | 33 namespace content { |
| 32 class RenderWidgetHostImpl; | 34 class RenderWidgetHostImpl; |
| 33 } | 35 } |
| 34 | 36 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 int focusedPluginIdentifier_; | 121 int focusedPluginIdentifier_; |
| 120 | 122 |
| 121 // Whether or not plugin IME is currently enabled active. | 123 // Whether or not plugin IME is currently enabled active. |
| 122 BOOL pluginImeActive_; | 124 BOOL pluginImeActive_; |
| 123 | 125 |
| 124 // Whether the previous mouse event was ignored due to hitTest check. | 126 // Whether the previous mouse event was ignored due to hitTest check. |
| 125 BOOL mouseEventWasIgnored_; | 127 BOOL mouseEventWasIgnored_; |
| 126 | 128 |
| 127 // Event monitor for gesture-end events. | 129 // Event monitor for gesture-end events. |
| 128 id endGestureMonitor_; | 130 id endGestureMonitor_; |
| 131 |
| 132 // OpenGL Support: |
| 133 |
| 134 // recursive globalFrameDidChange protection: |
| 135 BOOL handlingGlobalFrameDidChange_; |
| 136 |
| 137 // Set to YES once a GL context is attached to this NSView; never set back to |
| 138 // NO. |
| 139 BOOL hasGLContext_; |
| 129 } | 140 } |
| 130 | 141 |
| 131 @property(nonatomic, readonly) NSRange selectedRange; | 142 @property(nonatomic, readonly) NSRange selectedRange; |
| 132 | 143 |
| 133 - (void)setCanBeKeyView:(BOOL)can; | 144 - (void)setCanBeKeyView:(BOOL)can; |
| 134 - (void)setTakesFocusOnlyOnMouseDown:(BOOL)b; | 145 - (void)setTakesFocusOnlyOnMouseDown:(BOOL)b; |
| 135 - (void)setCloseOnDeactivate:(BOOL)b; | 146 - (void)setCloseOnDeactivate:(BOOL)b; |
| 136 - (void)setToolTipAtMousePoint:(NSString *)string; | 147 - (void)setToolTipAtMousePoint:(NSString *)string; |
| 137 // True for always-on-top special windows (e.g. Balloons and Panels). | 148 // True for always-on-top special windows (e.g. Balloons and Panels). |
| 138 - (BOOL)acceptsMouseEventsWhenInactive; | 149 - (BOOL)acceptsMouseEventsWhenInactive; |
| 139 // Cancel ongoing composition (abandon the marked text). | 150 // Cancel ongoing composition (abandon the marked text). |
| 140 - (void)cancelComposition; | 151 - (void)cancelComposition; |
| 141 // Confirm ongoing composition. | 152 // Confirm ongoing composition. |
| 142 - (void)confirmComposition; | 153 - (void)confirmComposition; |
| 143 // Enables or disables plugin IME. | 154 // Enables or disables plugin IME. |
| 144 - (void)setPluginImeActive:(BOOL)active; | 155 - (void)setPluginImeActive:(BOOL)active; |
| 145 // Updates the current plugin focus state. | 156 // Updates the current plugin focus state. |
| 146 - (void)pluginFocusChanged:(BOOL)focused forPlugin:(int)pluginId; | 157 - (void)pluginFocusChanged:(BOOL)focused forPlugin:(int)pluginId; |
| 147 // Evaluates the event in the context of plugin IME, if plugin IME is enabled. | 158 // Evaluates the event in the context of plugin IME, if plugin IME is enabled. |
| 148 // Returns YES if the event was handled. | 159 // Returns YES if the event was handled. |
| 149 - (BOOL)postProcessEventForPluginIme:(NSEvent*)event; | 160 - (BOOL)postProcessEventForPluginIme:(NSEvent*)event; |
| 161 // Tell the view that a GL context was created and accelerated rendering may |
| 162 // ensue. |
| 163 - (void)addedGLContext; |
| 150 | 164 |
| 151 @end | 165 @end |
| 152 | 166 |
| 153 /////////////////////////////////////////////////////////////////////////////// | 167 /////////////////////////////////////////////////////////////////////////////// |
| 154 // RenderWidgetHostViewMac | 168 // RenderWidgetHostViewMac |
| 155 // | 169 // |
| 156 // An object representing the "View" of a rendered web page. This object is | 170 // An object representing the "View" of a rendered web page. This object is |
| 157 // responsible for displaying the content of the web page, and integrating with | 171 // responsible for displaying the content of the web page, and integrating with |
| 158 // the Cocoa view system. It is the implementation of the RenderWidgetHostView | 172 // the Cocoa view system. It is the implementation of the RenderWidgetHostView |
| 159 // that the cross-platform RenderWidgetHost object uses | 173 // that the cross-platform RenderWidgetHost object uses |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 315 |
| 302 void KillSelf(); | 316 void KillSelf(); |
| 303 | 317 |
| 304 void SetTextInputActive(bool active); | 318 void SetTextInputActive(bool active); |
| 305 | 319 |
| 306 // Sends completed plugin IME notification and text back to the renderer. | 320 // Sends completed plugin IME notification and text back to the renderer. |
| 307 void PluginImeCompositionCompleted(const string16& text, int plugin_id); | 321 void PluginImeCompositionCompleted(const string16& text, int plugin_id); |
| 308 | 322 |
| 309 const std::string& selected_text() const { return selected_text_; } | 323 const std::string& selected_text() const { return selected_text_; } |
| 310 | 324 |
| 311 void UpdateRootGpuViewVisibility(bool show_gpu_widget); | 325 // Call setNeedsDisplay on the cocoa_view_. The IOSurface will be drawn during |
| 312 | 326 // the next drawRect. The route_id and gpu_host_id are added to a list to be |
| 313 // When rendering transitions from gpu to software, the gpu widget can't be | 327 // acked when the SwapBuffers occurs in drawRect. |
| 314 // hidden until the software backing store has been updated. This method | 328 void CompositorSwapBuffers(uint64 surface_handle, |
| 315 // checks if the GPU view needs to be hidden and hides it if necessary. It | 329 int32 route_id, |
| 316 // should be called after the software backing store has been painted to. | 330 int32 gpu_host_id); |
| 317 void HandleDelayedGpuViewHiding(); | 331 // Ack pending SwapBuffers requests (queued up by CompositorSwapBuffers), if |
| 332 // any, to unblock the GPU process. Has no effect if there are no pending |
| 333 // requests. |
| 334 void AckPendingCompositorSwapBuffers(); |
| 318 | 335 |
| 319 // These member variables should be private, but the associated ObjC class | 336 // These member variables should be private, but the associated ObjC class |
| 320 // needs access to them and can't be made a friend. | 337 // needs access to them and can't be made a friend. |
| 321 | 338 |
| 322 // The associated Model. Can be NULL if Destroy() is called when | 339 // The associated Model. Can be NULL if Destroy() is called when |
| 323 // someone (other than superview) has retained |cocoa_view_|. | 340 // someone (other than superview) has retained |cocoa_view_|. |
| 324 content::RenderWidgetHostImpl* render_widget_host_; | 341 content::RenderWidgetHostImpl* render_widget_host_; |
| 325 | 342 |
| 326 // This is true when we are currently painting and thus should handle extra | 343 // This is true when we are currently painting and thus should handle extra |
| 327 // paint requests by expanding the invalid rect rather than actually painting. | 344 // paint requests by expanding the invalid rect rather than actually painting. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 352 ui::TextInputType text_input_type_; | 369 ui::TextInputType text_input_type_; |
| 353 bool can_compose_inline_; | 370 bool can_compose_inline_; |
| 354 | 371 |
| 355 typedef std::map<gfx::PluginWindowHandle, AcceleratedPluginView*> | 372 typedef std::map<gfx::PluginWindowHandle, AcceleratedPluginView*> |
| 356 PluginViewMap; | 373 PluginViewMap; |
| 357 PluginViewMap plugin_views_; // Weak values. | 374 PluginViewMap plugin_views_; // Weak values. |
| 358 | 375 |
| 359 // Helper class for managing instances of accelerated plug-ins. | 376 // Helper class for managing instances of accelerated plug-ins. |
| 360 AcceleratedSurfaceContainerManagerMac plugin_container_manager_; | 377 AcceleratedSurfaceContainerManagerMac plugin_container_manager_; |
| 361 | 378 |
| 379 scoped_ptr<CompositingIOSurfaceMac> compositing_iosurface_; |
| 380 |
| 362 NSWindow* pepper_fullscreen_window() const { | 381 NSWindow* pepper_fullscreen_window() const { |
| 363 return pepper_fullscreen_window_; | 382 return pepper_fullscreen_window_; |
| 364 } | 383 } |
| 365 | 384 |
| 366 private: | 385 private: |
| 367 friend class content::RenderWidgetHostView; | 386 friend class content::RenderWidgetHostView; |
| 368 | 387 |
| 369 // The view will associate itself with the given widget. The native view must | 388 // The view will associate itself with the given widget. The native view must |
| 370 // be hooked up immediately to the view hierarchy, or else when it is | 389 // be hooked up immediately to the view hierarchy, or else when it is |
| 371 // deleted it will delete this out from under the caller. | 390 // deleted it will delete this out from under the caller. |
| 372 explicit RenderWidgetHostViewMac(content::RenderWidgetHost* widget); | 391 explicit RenderWidgetHostViewMac(content::RenderWidgetHost* widget); |
| 373 | 392 |
| 374 // If the window is at the root of the plugin container hierachy, | |
| 375 // we need to update the geometry manually. | |
| 376 void UpdatePluginGeometry(gfx::PluginWindowHandle window, | |
| 377 int32 width, | |
| 378 int32 height); | |
| 379 | |
| 380 // Returns whether this render view is a popup (autocomplete window). | 393 // Returns whether this render view is a popup (autocomplete window). |
| 381 bool IsPopup() const; | 394 bool IsPopup() const; |
| 382 | 395 |
| 383 // Updates the display cursor if the current event is over the view's window. | 396 // Updates the display cursor if the current event is over the view's window. |
| 384 void UpdateCursorIfNecessary(); | 397 void UpdateCursorIfNecessary(); |
| 385 | 398 |
| 386 // Shuts down the render_widget_host_. This is a separate function so we can | 399 // Shuts down the render_widget_host_. This is a separate function so we can |
| 387 // invoke it from the message loop. | 400 // invoke it from the message loop. |
| 388 void ShutdownHost(); | 401 void ShutdownHost(); |
| 389 | 402 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 402 | 415 |
| 403 // The text to be shown in the tooltip, supplied by the renderer. | 416 // The text to be shown in the tooltip, supplied by the renderer. |
| 404 string16 tooltip_text_; | 417 string16 tooltip_text_; |
| 405 | 418 |
| 406 // Factory used to safely scope delayed calls to ShutdownHost(). | 419 // Factory used to safely scope delayed calls to ShutdownHost(). |
| 407 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; | 420 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; |
| 408 | 421 |
| 409 // selected text on the renderer. | 422 // selected text on the renderer. |
| 410 std::string selected_text_; | 423 std::string selected_text_; |
| 411 | 424 |
| 412 bool accelerated_compositing_active_; | 425 gfx::PluginWindowHandle compositing_surface_; |
| 413 | 426 |
| 414 // When rendering transitions from gpu to software, the gpu widget can't be | 427 // List of pending swaps for deferred acking: |
| 415 // hidden until the software backing store has been updated. This variable is | 428 // pairs of (route_id, gpu_host_id). |
| 416 // set when the gpu widget needs to be hidden once a paint is completed. | 429 std::list<std::pair<int32, int32> > pending_swap_buffers_acks_; |
| 417 bool needs_gpu_visibility_update_after_repaint_; | |
| 418 | |
| 419 gfx::PluginWindowHandle compositing_surface_; | |
| 420 | 430 |
| 421 // The fullscreen window used for pepper flash. | 431 // The fullscreen window used for pepper flash. |
| 422 scoped_nsobject<NSWindow> pepper_fullscreen_window_; | 432 scoped_nsobject<NSWindow> pepper_fullscreen_window_; |
| 423 scoped_nsobject<FullscreenWindowManager> fullscreen_window_manager_; | 433 scoped_nsobject<FullscreenWindowManager> fullscreen_window_manager_; |
| 424 | 434 |
| 425 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 435 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
| 426 }; | 436 }; |
| 427 | 437 |
| 428 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 438 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
| OLD | NEW |