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/IOSurfaceAPI.h> | 9 #include <IOSurface/IOSurfaceAPI.h> |
10 #include <list> | 10 #include <list> |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 public: | 209 public: |
210 // The view will associate itself with the given widget. The native view must | 210 // The view will associate itself with the given widget. The native view must |
211 // be hooked up immediately to the view hierarchy, or else when it is | 211 // be hooked up immediately to the view hierarchy, or else when it is |
212 // deleted it will delete this out from under the caller. | 212 // deleted it will delete this out from under the caller. |
213 // | 213 // |
214 // When |is_guest_view_hack| is true, this view isn't really the view for | 214 // When |is_guest_view_hack| is true, this view isn't really the view for |
215 // the |widget|, a RenderWidgetHostViewGuest is. | 215 // the |widget|, a RenderWidgetHostViewGuest is. |
216 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated | 216 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated |
217 // to use RWHVChildFrame (http://crbug.com/330264). | 217 // to use RWHVChildFrame (http://crbug.com/330264). |
218 RenderWidgetHostViewMac(RenderWidgetHost* widget, bool is_guest_view_hack); | 218 RenderWidgetHostViewMac(RenderWidgetHost* widget, bool is_guest_view_hack); |
219 virtual ~RenderWidgetHostViewMac(); | 219 ~RenderWidgetHostViewMac() override; |
220 | 220 |
221 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } | 221 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } |
222 | 222 |
223 // |delegate| is used to separate out the logic from the NSResponder delegate. | 223 // |delegate| is used to separate out the logic from the NSResponder delegate. |
224 // |delegate| is retained by this class. | 224 // |delegate| is retained by this class. |
225 // |delegate| should be set at most once. | 225 // |delegate| should be set at most once. |
226 CONTENT_EXPORT void SetDelegate( | 226 CONTENT_EXPORT void SetDelegate( |
227 NSObject<RenderWidgetHostViewMacDelegate>* delegate); | 227 NSObject<RenderWidgetHostViewMacDelegate>* delegate); |
228 void SetAllowPauseForResizeOrRepaint(bool allow); | 228 void SetAllowPauseForResizeOrRepaint(bool allow); |
229 | 229 |
230 // RenderWidgetHostView implementation. | 230 // RenderWidgetHostView implementation. |
231 virtual bool OnMessageReceived(const IPC::Message& msg) override; | 231 bool OnMessageReceived(const IPC::Message& msg) override; |
232 virtual void InitAsChild(gfx::NativeView parent_view) override; | 232 void InitAsChild(gfx::NativeView parent_view) override; |
233 virtual RenderWidgetHost* GetRenderWidgetHost() const override; | 233 RenderWidgetHost* GetRenderWidgetHost() const override; |
234 virtual void SetSize(const gfx::Size& size) override; | 234 void SetSize(const gfx::Size& size) override; |
235 virtual void SetBounds(const gfx::Rect& rect) override; | 235 void SetBounds(const gfx::Rect& rect) override; |
236 virtual gfx::Vector2dF GetLastScrollOffset() const override; | 236 gfx::Vector2dF GetLastScrollOffset() const override; |
237 virtual gfx::NativeView GetNativeView() const override; | 237 gfx::NativeView GetNativeView() const override; |
238 virtual gfx::NativeViewId GetNativeViewId() const override; | 238 gfx::NativeViewId GetNativeViewId() const override; |
239 virtual gfx::NativeViewAccessible GetNativeViewAccessible() override; | 239 gfx::NativeViewAccessible GetNativeViewAccessible() override; |
240 virtual bool HasFocus() const override; | 240 bool HasFocus() const override; |
241 virtual bool IsSurfaceAvailableForCopy() const override; | 241 bool IsSurfaceAvailableForCopy() const override; |
242 virtual void Show() override; | 242 void Show() override; |
243 virtual void Hide() override; | 243 void Hide() override; |
244 virtual bool IsShowing() override; | 244 bool IsShowing() override; |
245 virtual gfx::Rect GetViewBounds() const override; | 245 gfx::Rect GetViewBounds() const override; |
246 virtual void SetShowingContextMenu(bool showing) override; | 246 void SetShowingContextMenu(bool showing) override; |
247 virtual void SetActive(bool active) override; | 247 void SetActive(bool active) override; |
248 virtual void SetTakesFocusOnlyOnMouseDown(bool flag) override; | 248 void SetTakesFocusOnlyOnMouseDown(bool flag) override; |
249 virtual void SetWindowVisibility(bool visible) override; | 249 void SetWindowVisibility(bool visible) override; |
250 virtual void WindowFrameChanged() override; | 250 void WindowFrameChanged() override; |
251 virtual void ShowDefinitionForSelection() override; | 251 void ShowDefinitionForSelection() override; |
252 virtual bool SupportsSpeech() const override; | 252 bool SupportsSpeech() const override; |
253 virtual void SpeakSelection() override; | 253 void SpeakSelection() override; |
254 virtual bool IsSpeaking() const override; | 254 bool IsSpeaking() const override; |
255 virtual void StopSpeaking() override; | 255 void StopSpeaking() override; |
256 virtual void SetBackgroundOpaque(bool opaque) override; | 256 void SetBackgroundOpaque(bool opaque) override; |
257 | 257 |
258 // Implementation of RenderWidgetHostViewBase. | 258 // Implementation of RenderWidgetHostViewBase. |
259 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 259 void InitAsPopup(RenderWidgetHostView* parent_host_view, |
260 const gfx::Rect& pos) override; | 260 const gfx::Rect& pos) override; |
261 virtual void InitAsFullscreen( | 261 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; |
262 RenderWidgetHostView* reference_host_view) override; | 262 void WasShown() override; |
263 virtual void WasShown() override; | 263 void WasHidden() override; |
264 virtual void WasHidden() override; | 264 void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override; |
265 virtual void MovePluginWindows( | 265 void Focus() override; |
266 const std::vector<WebPluginGeometry>& moves) override; | 266 void Blur() override; |
267 virtual void Focus() override; | 267 void UpdateCursor(const WebCursor& cursor) override; |
268 virtual void Blur() override; | 268 void SetIsLoading(bool is_loading) override; |
269 virtual void UpdateCursor(const WebCursor& cursor) override; | 269 void TextInputTypeChanged(ui::TextInputType type, |
270 virtual void SetIsLoading(bool is_loading) override; | 270 ui::TextInputMode input_mode, |
271 virtual void TextInputTypeChanged(ui::TextInputType type, | 271 bool can_compose_inline) override; |
272 ui::TextInputMode input_mode, | 272 void ImeCancelComposition() override; |
273 bool can_compose_inline) override; | 273 void ImeCompositionRangeChanged( |
274 virtual void ImeCancelComposition() override; | |
275 virtual void ImeCompositionRangeChanged( | |
276 const gfx::Range& range, | 274 const gfx::Range& range, |
277 const std::vector<gfx::Rect>& character_bounds) override; | 275 const std::vector<gfx::Rect>& character_bounds) override; |
278 virtual void RenderProcessGone(base::TerminationStatus status, | 276 void RenderProcessGone(base::TerminationStatus status, |
279 int error_code) override; | 277 int error_code) override; |
280 virtual void RenderWidgetHostGone() override; | 278 void RenderWidgetHostGone() override; |
281 virtual void Destroy() override; | 279 void Destroy() override; |
282 virtual void SetTooltipText(const base::string16& tooltip_text) override; | 280 void SetTooltipText(const base::string16& tooltip_text) override; |
283 virtual void SelectionChanged(const base::string16& text, | 281 void SelectionChanged(const base::string16& text, |
284 size_t offset, | 282 size_t offset, |
285 const gfx::Range& range) override; | 283 const gfx::Range& range) override; |
286 virtual void SelectionBoundsChanged( | 284 void SelectionBoundsChanged( |
287 const ViewHostMsg_SelectionBounds_Params& params) override; | 285 const ViewHostMsg_SelectionBounds_Params& params) override; |
288 virtual void CopyFromCompositingSurface( | 286 void CopyFromCompositingSurface( |
289 const gfx::Rect& src_subrect, | 287 const gfx::Rect& src_subrect, |
290 const gfx::Size& dst_size, | 288 const gfx::Size& dst_size, |
291 const base::Callback<void(bool, const SkBitmap&)>& callback, | 289 const base::Callback<void(bool, const SkBitmap&)>& callback, |
292 SkColorType color_type) override; | 290 SkColorType color_type) override; |
293 virtual void CopyFromCompositingSurfaceToVideoFrame( | 291 void CopyFromCompositingSurfaceToVideoFrame( |
294 const gfx::Rect& src_subrect, | 292 const gfx::Rect& src_subrect, |
295 const scoped_refptr<media::VideoFrame>& target, | 293 const scoped_refptr<media::VideoFrame>& target, |
296 const base::Callback<void(bool)>& callback) override; | 294 const base::Callback<void(bool)>& callback) override; |
297 virtual bool CanCopyToVideoFrame() const override; | 295 bool CanCopyToVideoFrame() const override; |
298 virtual bool CanSubscribeFrame() const override; | 296 bool CanSubscribeFrame() const override; |
299 virtual void BeginFrameSubscription( | 297 void BeginFrameSubscription( |
300 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override; | 298 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override; |
301 virtual void EndFrameSubscription() override; | 299 void EndFrameSubscription() override; |
302 virtual void OnSwapCompositorFrame( | 300 void OnSwapCompositorFrame(uint32 output_surface_id, |
303 uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) override; | 301 scoped_ptr<cc::CompositorFrame> frame) override; |
304 virtual BrowserAccessibilityManager* CreateBrowserAccessibilityManager( | 302 BrowserAccessibilityManager* CreateBrowserAccessibilityManager( |
305 BrowserAccessibilityDelegate* delegate) override; | 303 BrowserAccessibilityDelegate* delegate) override; |
306 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds) | 304 gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds) override; |
307 override; | 305 void AccessibilityShowMenu(const gfx::Point& point) override; |
308 virtual void AccessibilityShowMenu(const gfx::Point& point) override; | 306 bool PostProcessEventForPluginIme( |
309 virtual bool PostProcessEventForPluginIme( | |
310 const NativeWebKeyboardEvent& event) override; | 307 const NativeWebKeyboardEvent& event) override; |
311 | 308 |
312 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) override; | 309 bool HasAcceleratedSurface(const gfx::Size& desired_size) override; |
313 virtual void GetScreenInfo(blink::WebScreenInfo* results) override; | 310 void GetScreenInfo(blink::WebScreenInfo* results) override; |
314 virtual gfx::Rect GetBoundsInRootWindow() override; | 311 gfx::Rect GetBoundsInRootWindow() override; |
315 virtual gfx::GLSurfaceHandle GetCompositingSurface() override; | 312 gfx::GLSurfaceHandle GetCompositingSurface() override; |
316 | 313 |
317 virtual bool LockMouse() override; | 314 bool LockMouse() override; |
318 virtual void UnlockMouse() override; | 315 void UnlockMouse() override; |
319 virtual void WheelEventAck(const blink::WebMouseWheelEvent& event, | 316 void WheelEventAck(const blink::WebMouseWheelEvent& event, |
320 InputEventAckState ack_result) override; | 317 InputEventAckState ack_result) override; |
321 | 318 |
322 // IPC::Sender implementation. | 319 // IPC::Sender implementation. |
323 virtual bool Send(IPC::Message* message) override; | 320 bool Send(IPC::Message* message) override; |
324 | 321 |
325 virtual SkColorType PreferredReadbackFormat() override; | 322 SkColorType PreferredReadbackFormat() override; |
326 | 323 |
327 // gfx::DisplayObserver implementation. | 324 // gfx::DisplayObserver implementation. |
328 virtual void OnDisplayAdded(const gfx::Display& new_display) override; | 325 void OnDisplayAdded(const gfx::Display& new_display) override; |
329 virtual void OnDisplayRemoved(const gfx::Display& old_display) override; | 326 void OnDisplayRemoved(const gfx::Display& old_display) override; |
330 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | 327 void OnDisplayMetricsChanged(const gfx::Display& display, |
331 uint32_t metrics) override; | 328 uint32_t metrics) override; |
332 | 329 |
333 // Forwards the mouse event to the renderer. | 330 // Forwards the mouse event to the renderer. |
334 void ForwardMouseEvent(const blink::WebMouseEvent& event); | 331 void ForwardMouseEvent(const blink::WebMouseEvent& event); |
335 | 332 |
336 void KillSelf(); | 333 void KillSelf(); |
337 | 334 |
338 void SetTextInputActive(bool active); | 335 void SetTextInputActive(bool active); |
339 | 336 |
340 // Sends completed plugin IME notification and text back to the renderer. | 337 // Sends completed plugin IME notification and text back to the renderer. |
341 void PluginImeCompositionCompleted(const base::string16& text, int plugin_id); | 338 void PluginImeCompositionCompleted(const base::string16& text, int plugin_id); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 409 |
413 // Update the scale factor for the backing store and for any CALayers. | 410 // Update the scale factor for the backing store and for any CALayers. |
414 void UpdateBackingStoreScaleFactor(); | 411 void UpdateBackingStoreScaleFactor(); |
415 | 412 |
416 // Ensure that the display link is associated with the correct display. | 413 // Ensure that the display link is associated with the correct display. |
417 void UpdateDisplayLink(); | 414 void UpdateDisplayLink(); |
418 | 415 |
419 void PauseForPendingResizeOrRepaintsAndDraw(); | 416 void PauseForPendingResizeOrRepaintsAndDraw(); |
420 | 417 |
421 // DelegatedFrameHostClient implementation. | 418 // DelegatedFrameHostClient implementation. |
422 virtual ui::Compositor* GetCompositor() const override; | 419 ui::Compositor* GetCompositor() const override; |
423 virtual ui::Layer* GetLayer() override; | 420 ui::Layer* GetLayer() override; |
424 virtual RenderWidgetHostImpl* GetHost() override; | 421 RenderWidgetHostImpl* GetHost() override; |
425 virtual bool IsVisible() override; | 422 bool IsVisible() override; |
426 virtual scoped_ptr<ResizeLock> CreateResizeLock( | 423 scoped_ptr<ResizeLock> CreateResizeLock(bool defer_compositor_lock) override; |
427 bool defer_compositor_lock) override; | 424 gfx::Size DesiredFrameSize() override; |
428 virtual gfx::Size DesiredFrameSize() override; | 425 float CurrentDeviceScaleFactor() override; |
429 virtual float CurrentDeviceScaleFactor() override; | 426 gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) override; |
430 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) override; | 427 DelegatedFrameHost* GetDelegatedFrameHost() const override; |
431 virtual DelegatedFrameHost* GetDelegatedFrameHost() const override; | |
432 | 428 |
433 // BrowserCompositorViewMacClient implementation. | 429 // BrowserCompositorViewMacClient implementation. |
434 virtual bool BrowserCompositorViewShouldAckImmediately() const override; | 430 bool BrowserCompositorViewShouldAckImmediately() const override; |
435 virtual void BrowserCompositorViewFrameSwapped( | 431 void BrowserCompositorViewFrameSwapped( |
436 const std::vector<ui::LatencyInfo>& latency_info) override; | 432 const std::vector<ui::LatencyInfo>& latency_info) override; |
437 | 433 |
438 private: | 434 private: |
439 friend class RenderWidgetHostViewMacTest; | 435 friend class RenderWidgetHostViewMacTest; |
440 | 436 |
441 // Returns whether this render view is a popup (autocomplete window). | 437 // Returns whether this render view is a popup (autocomplete window). |
442 bool IsPopup() const; | 438 bool IsPopup() const; |
443 | 439 |
444 // Shuts down the render_widget_host_. This is a separate function so we can | 440 // Shuts down the render_widget_host_. This is a separate function so we can |
445 // invoke it from the message loop. | 441 // invoke it from the message loop. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 509 |
514 // The current caret bounds. | 510 // The current caret bounds. |
515 gfx::Rect caret_rect_; | 511 gfx::Rect caret_rect_; |
516 | 512 |
517 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 513 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
518 }; | 514 }; |
519 | 515 |
520 } // namespace content | 516 } // namespace content |
521 | 517 |
522 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 518 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |