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> |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 bool IsSurfaceAvailableForCopy() const override; | 260 bool IsSurfaceAvailableForCopy() const override; |
261 void Show() override; | 261 void Show() override; |
262 void Hide() override; | 262 void Hide() override; |
263 bool IsShowing() override; | 263 bool IsShowing() override; |
264 void WasUnOccluded() override; | 264 void WasUnOccluded() override; |
265 void WasOccluded() override; | 265 void WasOccluded() override; |
266 gfx::Rect GetViewBounds() const override; | 266 gfx::Rect GetViewBounds() const override; |
267 void SetShowingContextMenu(bool showing) override; | 267 void SetShowingContextMenu(bool showing) override; |
268 void SetActive(bool active) override; | 268 void SetActive(bool active) override; |
269 void ShowDefinitionForSelection() override; | 269 void ShowDefinitionForSelection() override; |
270 bool SupportsSpeech() const override; | |
271 void SpeakSelection() override; | 270 void SpeakSelection() override; |
272 bool IsSpeaking() const override; | |
273 void StopSpeaking() override; | |
274 void SetBackgroundColor(SkColor color) override; | 271 void SetBackgroundColor(SkColor color) override; |
275 void SetNeedsBeginFrames(bool needs_begin_frames) override; | 272 void SetNeedsBeginFrames(bool needs_begin_frames) override; |
276 | 273 |
277 // Implementation of RenderWidgetHostViewBase. | 274 // Implementation of RenderWidgetHostViewBase. |
278 void InitAsPopup(RenderWidgetHostView* parent_host_view, | 275 void InitAsPopup(RenderWidgetHostView* parent_host_view, |
279 const gfx::Rect& pos) override; | 276 const gfx::Rect& pos) override; |
280 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; | 277 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; |
281 void Focus() override; | 278 void Focus() override; |
282 void UpdateCursor(const WebCursor& cursor) override; | 279 void UpdateCursor(const WebCursor& cursor) override; |
283 void SetIsLoading(bool is_loading) override; | 280 void SetIsLoading(bool is_loading) override; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 void OnDisplayMetricsChanged(const display::Display& display, | 362 void OnDisplayMetricsChanged(const display::Display& display, |
366 uint32_t metrics) override; | 363 uint32_t metrics) override; |
367 | 364 |
368 // Forwards the mouse event to the renderer. | 365 // Forwards the mouse event to the renderer. |
369 void ForwardMouseEvent(const blink::WebMouseEvent& event); | 366 void ForwardMouseEvent(const blink::WebMouseEvent& event); |
370 | 367 |
371 void KillSelf(); | 368 void KillSelf(); |
372 | 369 |
373 void SetTextInputActive(bool active); | 370 void SetTextInputActive(bool active); |
374 | 371 |
375 const std::string& selected_text() const { return selected_text_; } | 372 const base::string16& selected_text() const { return selected_text_; } |
376 const gfx::Range& composition_range() const { return composition_range_; } | 373 const gfx::Range& composition_range() const { return composition_range_; } |
377 const base::string16& selection_text() const { return selection_text_; } | 374 const base::string16& selection_text() const { return selection_text_; } |
378 size_t selection_text_offset() const { return selection_text_offset_; } | 375 size_t selection_text_offset() const { return selection_text_offset_; } |
379 | 376 |
380 // Returns true and stores first rectangle for character range if the | 377 // Returns true and stores first rectangle for character range if the |
381 // requested |range| is already cached, otherwise returns false. | 378 // requested |range| is already cached, otherwise returns false. |
382 // Exposed for testing. | 379 // Exposed for testing. |
383 CONTENT_EXPORT bool GetCachedFirstRectForCharacterRange( | 380 CONTENT_EXPORT bool GetCachedFirstRectForCharacterRange( |
384 NSRange range, NSRect* rect, NSRange* actual_range); | 381 NSRange range, NSRect* rect, NSRange* actual_range); |
385 | 382 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 friend class RenderWidgetHostViewMacTest; | 473 friend class RenderWidgetHostViewMacTest; |
477 | 474 |
478 // Returns whether this render view is a popup (autocomplete window). | 475 // Returns whether this render view is a popup (autocomplete window). |
479 bool IsPopup() const; | 476 bool IsPopup() const; |
480 | 477 |
481 // Shuts down the render_widget_host_. This is a separate function so we can | 478 // Shuts down the render_widget_host_. This is a separate function so we can |
482 // invoke it from the message loop. | 479 // invoke it from the message loop. |
483 void ShutdownHost(); | 480 void ShutdownHost(); |
484 | 481 |
485 // IPC message handlers. | 482 // IPC message handlers. |
| 483 // TODO(spqchan): Change |text| to be the type string16. |
486 void OnGetRenderedTextCompleted(const std::string& text); | 484 void OnGetRenderedTextCompleted(const std::string& text); |
487 | 485 |
488 // Send updated vsync parameters to the top level display. | 486 // Send updated vsync parameters to the top level display. |
489 void UpdateDisplayVSyncParameters(); | 487 void UpdateDisplayVSyncParameters(); |
490 | 488 |
491 // Dispatches a TTS session. | |
492 void SpeakText(const std::string& text); | |
493 | |
494 // Get the focused view that should be used for retrieving the text selection. | 489 // Get the focused view that should be used for retrieving the text selection. |
495 RenderWidgetHostViewBase* GetFocusedViewForTextSelection(); | 490 RenderWidgetHostViewBase* GetFocusedViewForTextSelection(); |
496 | 491 |
497 // Adds/Removes frame observer based on state. | 492 // Adds/Removes frame observer based on state. |
498 void UpdateNeedsBeginFramesInternal(); | 493 void UpdateNeedsBeginFramesInternal(); |
499 | 494 |
500 // The associated view. This is weak and is inserted into the view hierarchy | 495 // The associated view. This is weak and is inserted into the view hierarchy |
501 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the | 496 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the |
502 // destructor. | 497 // destructor. |
503 RenderWidgetHostViewCocoa* cocoa_view_; | 498 RenderWidgetHostViewCocoa* cocoa_view_; |
504 | 499 |
505 // Indicates if the page is loading. | 500 // Indicates if the page is loading. |
506 bool is_loading_; | 501 bool is_loading_; |
507 | 502 |
508 // Whether it's allowed to pause waiting for a new frame. | 503 // Whether it's allowed to pause waiting for a new frame. |
509 bool allow_pause_for_resize_or_repaint_; | 504 bool allow_pause_for_resize_or_repaint_; |
510 | 505 |
511 // The last scroll offset of the view. | 506 // The last scroll offset of the view. |
512 gfx::Vector2dF last_scroll_offset_; | 507 gfx::Vector2dF last_scroll_offset_; |
513 | 508 |
514 // The text to be shown in the tooltip, supplied by the renderer. | 509 // The text to be shown in the tooltip, supplied by the renderer. |
515 base::string16 tooltip_text_; | 510 base::string16 tooltip_text_; |
516 | 511 |
517 // True when this view acts as a platform view hack for a | 512 // True when this view acts as a platform view hack for a |
518 // RenderWidgetHostViewGuest. | 513 // RenderWidgetHostViewGuest. |
519 bool is_guest_view_hack_; | 514 bool is_guest_view_hack_; |
520 | 515 |
521 // selected text on the renderer. | 516 // Selected text on the renderer. |
522 std::string selected_text_; | 517 base::string16 selected_text_; |
523 | 518 |
524 // The window used for popup widgets. | 519 // The window used for popup widgets. |
525 base::scoped_nsobject<NSWindow> popup_window_; | 520 base::scoped_nsobject<NSWindow> popup_window_; |
526 | 521 |
527 // The fullscreen window used for pepper flash. | 522 // The fullscreen window used for pepper flash. |
528 base::scoped_nsobject<NSWindow> pepper_fullscreen_window_; | 523 base::scoped_nsobject<NSWindow> pepper_fullscreen_window_; |
529 base::scoped_nsobject<FullscreenWindowManager> fullscreen_window_manager_; | 524 base::scoped_nsobject<FullscreenWindowManager> fullscreen_window_manager_; |
530 // Our parent host view, if this is fullscreen. NULL otherwise. | 525 // Our parent host view, if this is fullscreen. NULL otherwise. |
531 RenderWidgetHostViewMac* fullscreen_parent_host_view_; | 526 RenderWidgetHostViewMac* fullscreen_parent_host_view_; |
532 | 527 |
(...skipping 10 matching lines...) Expand all Loading... |
543 std::vector<gfx::Rect> composition_bounds_; | 538 std::vector<gfx::Rect> composition_bounds_; |
544 | 539 |
545 // Whether a request for begin frames has been issued. | 540 // Whether a request for begin frames has been issued. |
546 bool needs_begin_frames_; | 541 bool needs_begin_frames_; |
547 | 542 |
548 // Whether a request to flush input has been issued. | 543 // Whether a request to flush input has been issued. |
549 bool needs_flush_input_; | 544 bool needs_flush_input_; |
550 | 545 |
551 // TODO(ekaramad): Remove the following locals and get the selection | 546 // TODO(ekaramad): Remove the following locals and get the selection |
552 // information directly from TextInputManager. | 547 // information directly from TextInputManager. |
553 // A buffer containing the text inside and around the current selection range. | 548 // A buffer containing the text inside and around the current selection |
| 549 // range. This is for text selected in an editable element. |
554 base::string16 selection_text_; | 550 base::string16 selection_text_; |
555 | 551 |
556 // The offset of the text stored in |selection_text_| relative to the start of | 552 // The offset of the text stored in |selection_text_| relative to the start of |
557 // the web page. | 553 // the web page. |
558 size_t selection_text_offset_; | 554 size_t selection_text_offset_; |
559 | 555 |
560 // The current selection range relative to the start of the web page. | 556 // The current selection range relative to the start of the web page. |
561 gfx::Range selection_range_; | 557 gfx::Range selection_range_; |
562 | 558 |
563 // Factory used to safely scope delayed calls to ShutdownHost(). | 559 // Factory used to safely scope delayed calls to ShutdownHost(). |
564 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; | 560 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; |
565 | 561 |
566 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 562 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
567 }; | 563 }; |
568 | 564 |
569 } // namespace content | 565 } // namespace content |
570 | 566 |
571 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 567 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |