2012-11-21 01:40:15 +01:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "include/cef_base.h"
|
2013-01-12 00:00:39 +01:00
|
|
|
#include "include/cef_browser.h"
|
2012-11-21 01:40:15 +01:00
|
|
|
|
2013-01-12 00:00:39 +01:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2012-11-21 01:40:15 +01:00
|
|
|
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
|
|
|
|
|
|
|
namespace content {
|
|
|
|
class RenderWidgetHost;
|
|
|
|
class BackingStore;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CefBrowserHostImpl;
|
|
|
|
class CefWebContentsViewOSR;
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CefRenderWidgetHostViewOSR
|
|
|
|
//
|
|
|
|
// An object representing the "View" of a rendered web page. This object is
|
|
|
|
// responsible for sending paint events to the the CefRenderHandler
|
|
|
|
// when window rendering is disabled. It is the implementation of the
|
|
|
|
// RenderWidgetHostView that the cross-platform RenderWidgetHost object uses
|
|
|
|
// to display the data.
|
|
|
|
//
|
|
|
|
// Comment excerpted from render_widget_host.h:
|
|
|
|
//
|
|
|
|
// "The lifetime of the RenderWidgetHostHWND is tied to the render process.
|
|
|
|
// If the render process dies, the RenderWidgetHostHWND goes away and all
|
|
|
|
// references to it must become NULL."
|
|
|
|
//
|
|
|
|
// RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase {
|
2013-05-31 14:46:56 +02:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
public:
|
|
|
|
NSTextInputContext* GetNSTextInputContext();
|
|
|
|
void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent);
|
|
|
|
void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent);
|
|
|
|
|
2013-10-16 02:25:38 +02:00
|
|
|
bool GetCachedFirstRectForCharacterRange(gfx::Range range, gfx::Rect* rect,
|
|
|
|
gfx::Range* actual_range) const;
|
2013-05-31 14:46:56 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Returns composition character boundary rectangle. The |range| is
|
|
|
|
// composition based range. Also stores |actual_range| which is corresponding
|
|
|
|
// to actually used range for returned rectangle.
|
2013-10-16 02:25:38 +02:00
|
|
|
gfx::Rect GetFirstRectForCompositionRange(const gfx::Range& range,
|
|
|
|
gfx::Range* actual_range) const;
|
2013-05-31 14:46:56 +02:00
|
|
|
|
|
|
|
// Converts from given whole character range to composition oriented range. If
|
2013-10-16 02:25:38 +02:00
|
|
|
// the conversion failed, return gfx::Range::InvalidRange.
|
|
|
|
gfx::Range ConvertCharacterRangeToCompositionRange(
|
|
|
|
const gfx::Range& request_range) const;
|
2013-05-31 14:46:56 +02:00
|
|
|
|
|
|
|
// Returns true if there is line break in |range| and stores line breaking
|
|
|
|
// point to |line_breaking_point|. The |line_break_point| is valid only if
|
|
|
|
// this function returns true.
|
|
|
|
static bool GetLineBreakIndex(const std::vector<gfx::Rect>& bounds,
|
2013-10-16 02:25:38 +02:00
|
|
|
const gfx::Range& range,
|
2013-05-31 14:46:56 +02:00
|
|
|
size_t* line_break_point);
|
|
|
|
|
|
|
|
void DestroyNSTextInputOSR();
|
|
|
|
#endif // defined(OS_MACOSX)
|
|
|
|
|
2012-11-21 01:40:15 +01:00
|
|
|
public:
|
|
|
|
// RenderWidgetHostView methods.
|
2013-12-07 02:55:22 +01:00
|
|
|
virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE;
|
|
|
|
virtual content::RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE;
|
|
|
|
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
|
|
|
virtual void SetBounds(const gfx::Rect& rect) OVERRIDE;
|
|
|
|
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
|
|
|
virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE;
|
|
|
|
virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
|
|
|
|
virtual bool HasFocus() const OVERRIDE;
|
|
|
|
virtual bool IsSurfaceAvailableForCopy() const OVERRIDE;
|
|
|
|
virtual void Show() OVERRIDE;
|
|
|
|
virtual void Hide() OVERRIDE;
|
|
|
|
virtual bool IsShowing() OVERRIDE;
|
|
|
|
virtual gfx::Rect GetViewBounds() const OVERRIDE;
|
2013-04-16 21:23:00 +02:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
virtual void SetActive(bool active) OVERRIDE;
|
|
|
|
virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE;
|
|
|
|
virtual void SetWindowVisibility(bool visible) OVERRIDE;
|
|
|
|
virtual void WindowFrameChanged() OVERRIDE;
|
|
|
|
virtual void ShowDefinitionForSelection() OVERRIDE;
|
|
|
|
virtual bool SupportsSpeech() const OVERRIDE;
|
|
|
|
virtual void SpeakSelection() OVERRIDE;
|
|
|
|
virtual bool IsSpeaking() const OVERRIDE;
|
|
|
|
virtual void StopSpeaking() OVERRIDE;
|
|
|
|
#endif // defined(OS_MACOSX)
|
2013-06-27 19:40:04 +02:00
|
|
|
#if defined(TOOLKIT_GTK)
|
|
|
|
virtual GdkEventButton* GetLastMouseDown() OVERRIDE;
|
|
|
|
virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE;
|
|
|
|
#endif // defined(TOOLKIT_GTK)
|
2012-11-21 01:40:15 +01:00
|
|
|
|
|
|
|
// RenderWidgetHostViewPort methods.
|
|
|
|
virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
|
|
|
|
const gfx::Rect& pos) OVERRIDE;
|
|
|
|
virtual void InitAsFullscreen(
|
|
|
|
RenderWidgetHostView* reference_host_view) OVERRIDE;
|
|
|
|
virtual void WasShown() OVERRIDE;
|
|
|
|
virtual void WasHidden() OVERRIDE;
|
|
|
|
virtual void MovePluginWindows(
|
|
|
|
const gfx::Vector2d& scroll_offset,
|
2013-07-24 22:15:18 +02:00
|
|
|
const std::vector<content::WebPluginGeometry>& moves) OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual void Focus() OVERRIDE;
|
|
|
|
virtual void Blur() OVERRIDE;
|
2014-04-04 18:50:38 +02:00
|
|
|
virtual void UpdateCursor(const content::WebCursor& cursor) OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual void SetIsLoading(bool is_loading) OVERRIDE;
|
2013-06-22 04:06:32 +02:00
|
|
|
virtual void TextInputTypeChanged(ui::TextInputType type,
|
2013-10-16 02:25:38 +02:00
|
|
|
ui::TextInputMode mode,
|
|
|
|
bool can_compose_inline) OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual void ImeCancelComposition() OVERRIDE;
|
2013-10-24 23:40:32 +02:00
|
|
|
#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
|
2013-02-27 18:56:03 +01:00
|
|
|
virtual void ImeCompositionRangeChanged(
|
2013-10-16 02:25:38 +02:00
|
|
|
const gfx::Range& range,
|
2013-02-27 18:56:03 +01:00
|
|
|
const std::vector<gfx::Rect>& character_bounds) OVERRIDE;
|
2013-10-24 23:40:32 +02:00
|
|
|
#endif
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual void DidUpdateBackingStore(
|
|
|
|
const gfx::Rect& scroll_rect,
|
|
|
|
const gfx::Vector2d& scroll_delta,
|
2013-06-22 04:06:32 +02:00
|
|
|
const std::vector<gfx::Rect>& copy_rects,
|
2014-01-02 23:41:11 +01:00
|
|
|
const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE;
|
2013-07-24 22:15:18 +02:00
|
|
|
virtual void RenderProcessGone(base::TerminationStatus status,
|
2012-11-21 01:40:15 +01:00
|
|
|
int error_code) OVERRIDE;
|
|
|
|
#if defined(OS_WIN) && !defined(USE_AURA)
|
|
|
|
virtual void WillWmDestroy() OVERRIDE;
|
2013-12-07 02:55:22 +01:00
|
|
|
#endif
|
|
|
|
#if defined(OS_WIN) && defined(USE_AURA)
|
|
|
|
virtual void SetParentNativeViewAccessible(
|
|
|
|
gfx::NativeViewAccessible accessible_parent) OVERRIDE;
|
2013-12-17 23:04:35 +01:00
|
|
|
virtual gfx::NativeViewId GetParentForWindowlessPlugin() const OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
#endif
|
2013-11-08 22:28:56 +01:00
|
|
|
virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
|
2014-01-02 23:41:11 +01:00
|
|
|
virtual void CreateBrowserAccessibilityManagerIfNeeded() OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual void Destroy() OVERRIDE;
|
2013-12-17 23:04:35 +01:00
|
|
|
virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE;
|
2013-02-27 18:56:03 +01:00
|
|
|
virtual void SelectionBoundsChanged(
|
|
|
|
const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE;
|
|
|
|
virtual void ScrollOffsetChanged() OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual content::BackingStore*
|
|
|
|
AllocBackingStore(const gfx::Size& size) OVERRIDE;
|
|
|
|
virtual void CopyFromCompositingSurface(
|
|
|
|
const gfx::Rect& src_subrect,
|
|
|
|
const gfx::Size& dst_size,
|
2014-02-05 21:35:45 +01:00
|
|
|
const base::Callback<void(bool, const SkBitmap&)>& callback,
|
|
|
|
const SkBitmap::Config config) OVERRIDE;
|
2013-02-23 01:43:28 +01:00
|
|
|
virtual void CopyFromCompositingSurfaceToVideoFrame(
|
|
|
|
const gfx::Rect& src_subrect,
|
|
|
|
const scoped_refptr<media::VideoFrame>& target,
|
|
|
|
const base::Callback<void(bool)>& callback) OVERRIDE;
|
|
|
|
virtual bool CanCopyToVideoFrame() const OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual void OnAcceleratedCompositingStateChange() OVERRIDE;
|
2013-11-08 22:28:56 +01:00
|
|
|
virtual void AcceleratedSurfaceInitialized(
|
|
|
|
int host_id, int route_id) OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual void SetHasHorizontalScrollbar(
|
|
|
|
bool has_horizontal_scrollbar) OVERRIDE;
|
|
|
|
virtual void SetScrollOffsetPinning(
|
|
|
|
bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE;
|
|
|
|
virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE;
|
|
|
|
virtual void AcceleratedSurfaceBuffersSwapped(
|
|
|
|
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
|
|
|
|
int gpu_host_id) OVERRIDE;
|
|
|
|
virtual void AcceleratedSurfacePostSubBuffer(
|
|
|
|
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
|
|
|
|
int gpu_host_id) OVERRIDE;
|
|
|
|
virtual void AcceleratedSurfaceSuspend() OVERRIDE;
|
2013-02-27 18:56:03 +01:00
|
|
|
virtual void AcceleratedSurfaceRelease() OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
|
|
|
|
virtual bool LockMouse() OVERRIDE;
|
|
|
|
virtual void UnlockMouse() OVERRIDE;
|
|
|
|
|
|
|
|
#if defined(OS_WIN) && !defined(USE_AURA)
|
|
|
|
virtual void SetClickthroughRegion(SkRegion* region) OVERRIDE;
|
|
|
|
#endif
|
|
|
|
|
2013-04-16 21:23:00 +02:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
virtual bool PostProcessEventForPluginIme(
|
|
|
|
const content::NativeWebKeyboardEvent& event) OVERRIDE;
|
|
|
|
#endif
|
|
|
|
|
2013-01-12 00:00:39 +01:00
|
|
|
// RenderWidgetHostViewBase methods.
|
|
|
|
virtual void SetBackground(const SkBitmap& background) OVERRIDE;
|
|
|
|
|
|
|
|
void SendKeyEvent(const content::NativeWebKeyboardEvent& event);
|
2013-11-08 22:28:56 +01:00
|
|
|
void SendMouseEvent(const blink::WebMouseEvent& event);
|
|
|
|
void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event);
|
2013-01-12 00:00:39 +01:00
|
|
|
|
|
|
|
void Invalidate(const gfx::Rect& rect,
|
|
|
|
CefBrowserHost::PaintElementType type);
|
2012-11-21 01:40:15 +01:00
|
|
|
void Paint(const std::vector<gfx::Rect>& copy_rects);
|
2013-01-12 00:00:39 +01:00
|
|
|
bool InstallTransparency();
|
|
|
|
|
2013-04-16 21:23:00 +02:00
|
|
|
void OnScreenInfoChanged();
|
2013-12-07 02:55:22 +01:00
|
|
|
float GetDeviceScaleFactor() const;
|
2013-04-16 21:23:00 +02:00
|
|
|
|
2013-01-12 00:00:39 +01:00
|
|
|
void CancelWidget();
|
|
|
|
void NotifyShowWidget();
|
|
|
|
void NotifyHideWidget();
|
|
|
|
void NotifySizeWidget();
|
2012-11-21 01:40:15 +01:00
|
|
|
|
2013-05-31 14:46:56 +02:00
|
|
|
content::RenderWidgetHostImpl* get_render_widget_host_impl() const
|
|
|
|
{ return render_widget_host_; }
|
2012-11-21 01:40:15 +01:00
|
|
|
CefRefPtr<CefBrowserHostImpl> get_browser_impl() const;
|
|
|
|
void set_browser_impl(CefRefPtr<CefBrowserHostImpl> browser);
|
2013-01-12 00:00:39 +01:00
|
|
|
void set_popup_host_view(CefRenderWidgetHostViewOSR* popup_view);
|
|
|
|
void set_parent_host_view(CefRenderWidgetHostViewOSR* parent_view);
|
|
|
|
|
|
|
|
bool IsPopupWidget() const {
|
2013-11-08 22:28:56 +01:00
|
|
|
return popup_type_ != blink::WebPopupTypeNone;
|
2013-01-12 00:00:39 +01:00
|
|
|
}
|
2012-11-21 01:40:15 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class CefWebContentsViewOSR;
|
|
|
|
|
|
|
|
explicit CefRenderWidgetHostViewOSR(content::RenderWidgetHost* widget);
|
|
|
|
virtual ~CefRenderWidgetHostViewOSR();
|
|
|
|
|
2013-01-12 00:00:39 +01:00
|
|
|
// After calling this function, object gets deleted
|
|
|
|
void ShutdownHost();
|
|
|
|
|
|
|
|
// Factory used to safely scope delayed calls to ShutdownHost().
|
|
|
|
base::WeakPtrFactory<CefRenderWidgetHostViewOSR> weak_factory_;
|
|
|
|
|
2012-11-21 01:40:15 +01:00
|
|
|
// The associated Model. While |this| is being Destroyed,
|
|
|
|
// |render_widget_host_| is NULL and the Windows message loop is run one last
|
|
|
|
// time. Message handlers must check for a NULL |render_widget_host_|.
|
|
|
|
content::RenderWidgetHostImpl* render_widget_host_;
|
2013-01-12 00:00:39 +01:00
|
|
|
CefRenderWidgetHostViewOSR* parent_host_view_;
|
|
|
|
CefRenderWidgetHostViewOSR* popup_host_view_;
|
2012-11-21 01:40:15 +01:00
|
|
|
|
|
|
|
CefRefPtr<CefBrowserHostImpl> browser_impl_;
|
|
|
|
|
|
|
|
bool about_to_validate_and_paint_;
|
|
|
|
std::vector<gfx::Rect> pending_update_rects_;
|
|
|
|
|
2013-01-12 00:00:39 +01:00
|
|
|
gfx::Rect popup_position_;
|
|
|
|
|
2013-05-31 14:46:56 +02:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
NSTextInputContext* text_input_context_osr_mac_;
|
|
|
|
#endif // defined(OS_MACOSX)
|
|
|
|
|
2012-11-21 01:40:15 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefRenderWidgetHostViewOSR);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_
|