| 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 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include <IOSurface/IOSurface.h> | 9 #include <IOSurface/IOSurface.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <list> | 13 #include <list> |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <set> | 16 #include <set> |
| 17 #include <string> | 17 #include <string> |
| 18 #include <utility> | 18 #include <utility> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 #include "base/mac/scoped_nsobject.h" | 21 #include "base/mac/scoped_nsobject.h" |
| 22 #include "base/macros.h" | 22 #include "base/macros.h" |
| 23 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "cc/surfaces/surface_id.h" | 25 #include "cc/surfaces/surface_id.h" |
| 26 #include "content/browser/renderer_host/browser_compositor_view_mac.h" | 26 #include "content/browser/renderer_host/browser_compositor_view_mac.h" |
| 27 #include "content/browser/renderer_host/input/mouse_wheel_rails_filter_mac.h" | 27 #include "content/browser/renderer_host/input/mouse_wheel_rails_filter_mac.h" |
| 28 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 28 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 29 #include "content/browser/renderer_host/text_input_manager.h" |
| 29 #include "content/common/content_export.h" | 30 #include "content/common/content_export.h" |
| 30 #include "content/common/cursors/webcursor.h" | 31 #include "content/common/cursors/webcursor.h" |
| 31 #include "content/common/edit_command.h" | 32 #include "content/common/edit_command.h" |
| 32 #include "ipc/ipc_sender.h" | 33 #include "ipc/ipc_sender.h" |
| 33 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 34 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 34 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" | 35 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" |
| 35 #include "ui/accelerated_widget_mac/display_link_mac.h" | 36 #include "ui/accelerated_widget_mac/display_link_mac.h" |
| 36 #import "ui/base/cocoa/command_dispatcher.h" | 37 #import "ui/base/cocoa/command_dispatcher.h" |
| 37 #include "ui/base/cocoa/remote_layer_api.h" | 38 #include "ui/base/cocoa/remote_layer_api.h" |
| 38 #import "ui/base/cocoa/tool_tip_base_view.h" | 39 #import "ui/base/cocoa/tool_tip_base_view.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // Comment excerpted from render_widget_host.h: | 219 // Comment excerpted from render_widget_host.h: |
| 219 // | 220 // |
| 220 // "The lifetime of the RenderWidgetHost* is tied to the render process. | 221 // "The lifetime of the RenderWidgetHost* is tied to the render process. |
| 221 // If the render process dies, the RenderWidgetHost* goes away and all | 222 // If the render process dies, the RenderWidgetHost* goes away and all |
| 222 // references to it must become NULL." | 223 // references to it must become NULL." |
| 223 // | 224 // |
| 224 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 225 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
| 225 class CONTENT_EXPORT RenderWidgetHostViewMac | 226 class CONTENT_EXPORT RenderWidgetHostViewMac |
| 226 : public RenderWidgetHostViewBase, | 227 : public RenderWidgetHostViewBase, |
| 227 public BrowserCompositorMacClient, | 228 public BrowserCompositorMacClient, |
| 229 public TextInputManager::Observer, |
| 228 public ui::AcceleratedWidgetMacNSView, | 230 public ui::AcceleratedWidgetMacNSView, |
| 229 public IPC::Sender, | 231 public IPC::Sender, |
| 230 public display::DisplayObserver { | 232 public display::DisplayObserver { |
| 231 public: | 233 public: |
| 232 // The view will associate itself with the given widget. The native view must | 234 // The view will associate itself with the given widget. The native view must |
| 233 // be hooked up immediately to the view hierarchy, or else when it is | 235 // be hooked up immediately to the view hierarchy, or else when it is |
| 234 // deleted it will delete this out from under the caller. | 236 // deleted it will delete this out from under the caller. |
| 235 // | 237 // |
| 236 // When |is_guest_view_hack| is true, this view isn't really the view for | 238 // When |is_guest_view_hack| is true, this view isn't really the view for |
| 237 // the |widget|, a RenderWidgetHostViewGuest is. | 239 // the |widget|, a RenderWidgetHostViewGuest is. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 void StopSpeaking() override; | 277 void StopSpeaking() override; |
| 276 void SetBackgroundColor(SkColor color) override; | 278 void SetBackgroundColor(SkColor color) override; |
| 277 | 279 |
| 278 // Implementation of RenderWidgetHostViewBase. | 280 // Implementation of RenderWidgetHostViewBase. |
| 279 void InitAsPopup(RenderWidgetHostView* parent_host_view, | 281 void InitAsPopup(RenderWidgetHostView* parent_host_view, |
| 280 const gfx::Rect& pos) override; | 282 const gfx::Rect& pos) override; |
| 281 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; | 283 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; |
| 282 void Focus() override; | 284 void Focus() override; |
| 283 void UpdateCursor(const WebCursor& cursor) override; | 285 void UpdateCursor(const WebCursor& cursor) override; |
| 284 void SetIsLoading(bool is_loading) override; | 286 void SetIsLoading(bool is_loading) override; |
| 285 void TextInputStateChanged(const TextInputState& params) override; | |
| 286 void ImeCancelComposition() override; | 287 void ImeCancelComposition() override; |
| 287 void ImeCompositionRangeChanged( | 288 void ImeCompositionRangeChanged( |
| 288 const gfx::Range& range, | 289 const gfx::Range& range, |
| 289 const std::vector<gfx::Rect>& character_bounds) override; | 290 const std::vector<gfx::Rect>& character_bounds) override; |
| 290 void RenderProcessGone(base::TerminationStatus status, | 291 void RenderProcessGone(base::TerminationStatus status, |
| 291 int error_code) override; | 292 int error_code) override; |
| 292 void Destroy() override; | 293 void Destroy() override; |
| 293 void SetTooltipText(const base::string16& tooltip_text) override; | 294 void SetTooltipText(const base::string16& tooltip_text) override; |
| 294 void SelectionChanged(const base::string16& text, | 295 void SelectionChanged(const base::string16& text, |
| 295 size_t offset, | 296 size_t offset, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event, | 342 void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event, |
| 342 const ui::LatencyInfo& latency) override; | 343 const ui::LatencyInfo& latency) override; |
| 343 void ProcessTouchEvent(const blink::WebTouchEvent& event, | 344 void ProcessTouchEvent(const blink::WebTouchEvent& event, |
| 344 const ui::LatencyInfo& latency) override; | 345 const ui::LatencyInfo& latency) override; |
| 345 void ProcessGestureEvent(const blink::WebGestureEvent& event, | 346 void ProcessGestureEvent(const blink::WebGestureEvent& event, |
| 346 const ui::LatencyInfo& latency) override; | 347 const ui::LatencyInfo& latency) override; |
| 347 void TransformPointToLocalCoordSpace(const gfx::Point& point, | 348 void TransformPointToLocalCoordSpace(const gfx::Point& point, |
| 348 const cc::SurfaceId& original_surface, | 349 const cc::SurfaceId& original_surface, |
| 349 gfx::Point* transformed_point) override; | 350 gfx::Point* transformed_point) override; |
| 350 | 351 |
| 352 // TextInputManager::Observer implementation. |
| 353 void OnUpdateTextInputStateCalled(TextInputManager* text_input_manager, |
| 354 RenderWidgetHostViewBase* updated_view, |
| 355 bool did_update_state) override; |
| 351 // IPC::Sender implementation. | 356 // IPC::Sender implementation. |
| 352 bool Send(IPC::Message* message) override; | 357 bool Send(IPC::Message* message) override; |
| 353 | 358 |
| 354 // display::DisplayObserver implementation. | 359 // display::DisplayObserver implementation. |
| 355 void OnDisplayAdded(const display::Display& new_display) override; | 360 void OnDisplayAdded(const display::Display& new_display) override; |
| 356 void OnDisplayRemoved(const display::Display& old_display) override; | 361 void OnDisplayRemoved(const display::Display& old_display) override; |
| 357 void OnDisplayMetricsChanged(const display::Display& display, | 362 void OnDisplayMetricsChanged(const display::Display& display, |
| 358 uint32_t metrics) override; | 363 uint32_t metrics) override; |
| 359 | 364 |
| 360 // Forwards the mouse event to the renderer. | 365 // Forwards the mouse event to the renderer. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 403 |
| 399 WebContents* GetWebContents(); | 404 WebContents* GetWebContents(); |
| 400 | 405 |
| 401 // These member variables should be private, but the associated ObjC class | 406 // These member variables should be private, but the associated ObjC class |
| 402 // needs access to them and can't be made a friend. | 407 // needs access to them and can't be made a friend. |
| 403 | 408 |
| 404 // The associated Model. Can be NULL if Destroy() is called when | 409 // The associated Model. Can be NULL if Destroy() is called when |
| 405 // someone (other than superview) has retained |cocoa_view_|. | 410 // someone (other than superview) has retained |cocoa_view_|. |
| 406 RenderWidgetHostImpl* render_widget_host_; | 411 RenderWidgetHostImpl* render_widget_host_; |
| 407 | 412 |
| 408 // Current text input type. | |
| 409 ui::TextInputType text_input_type_; | |
| 410 bool can_compose_inline_; | |
| 411 | |
| 412 // The background CoreAnimation layer which is hosted by |cocoa_view_|. | 413 // The background CoreAnimation layer which is hosted by |cocoa_view_|. |
| 413 base::scoped_nsobject<CALayer> background_layer_; | 414 base::scoped_nsobject<CALayer> background_layer_; |
| 414 | 415 |
| 415 // Delegated frame management and compositor interface. | 416 // Delegated frame management and compositor interface. |
| 416 std::unique_ptr<BrowserCompositorMac> browser_compositor_; | 417 std::unique_ptr<BrowserCompositorMac> browser_compositor_; |
| 417 | 418 |
| 418 // Set when the currently-displayed frame is the minimum scale. Used to | 419 // Set when the currently-displayed frame is the minimum scale. Used to |
| 419 // determine if pinch gestures need to be thresholded. | 420 // determine if pinch gestures need to be thresholded. |
| 420 bool page_at_minimum_scale_; | 421 bool page_at_minimum_scale_; |
| 421 | 422 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 460 |
| 460 // AcceleratedWidgetMacNSView implementation. | 461 // AcceleratedWidgetMacNSView implementation. |
| 461 NSView* AcceleratedWidgetGetNSView() const override; | 462 NSView* AcceleratedWidgetGetNSView() const override; |
| 462 void AcceleratedWidgetGetVSyncParameters( | 463 void AcceleratedWidgetGetVSyncParameters( |
| 463 base::TimeTicks* timebase, base::TimeDelta* interval) const override; | 464 base::TimeTicks* timebase, base::TimeDelta* interval) const override; |
| 464 void AcceleratedWidgetSwapCompleted() override; | 465 void AcceleratedWidgetSwapCompleted() override; |
| 465 | 466 |
| 466 // Exposed for testing. | 467 // Exposed for testing. |
| 467 cc::SurfaceId SurfaceIdForTesting() const override; | 468 cc::SurfaceId SurfaceIdForTesting() const override; |
| 468 | 469 |
| 470 // Helper method to obtain ui::TextInputType for the active widget from the |
| 471 // TextInputManager. |
| 472 ui::TextInputType GetTextInputType(); |
| 473 |
| 469 private: | 474 private: |
| 470 friend class RenderWidgetHostViewMacTest; | 475 friend class RenderWidgetHostViewMacTest; |
| 471 | 476 |
| 472 // Returns whether this render view is a popup (autocomplete window). | 477 // Returns whether this render view is a popup (autocomplete window). |
| 473 bool IsPopup() const; | 478 bool IsPopup() const; |
| 474 | 479 |
| 475 // Shuts down the render_widget_host_. This is a separate function so we can | 480 // Shuts down the render_widget_host_. This is a separate function so we can |
| 476 // invoke it from the message loop. | 481 // invoke it from the message loop. |
| 477 void ShutdownHost(); | 482 void ShutdownHost(); |
| 478 | 483 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 543 |
| 539 // Factory used to safely scope delayed calls to ShutdownHost(). | 544 // Factory used to safely scope delayed calls to ShutdownHost(). |
| 540 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; | 545 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; |
| 541 | 546 |
| 542 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 547 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
| 543 }; | 548 }; |
| 544 | 549 |
| 545 } // namespace content | 550 } // namespace content |
| 546 | 551 |
| 547 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 552 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
| OLD | NEW |