/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef RENDER_WIDGET_HOST_VIEW_QT_H #define RENDER_WIDGET_HOST_VIEW_QT_H #include "shared/shared_globals.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "ui/base/gestures/gesture_recognizer.h" #include "ui/base/gestures/gesture_types.h" #include #include #include class BackingStoreQt; QT_BEGIN_NAMESPACE class QEvent; class QFocusEvent; class QHoverEvent; class QKeyEvent; class QMouseEvent; class QTouchEvent; class QWheelEvent; QT_END_NAMESPACE class RenderWidgetHostViewQtDelegate; class WebContentsAdapterClient; struct MultipleMouseClickHelper { QPoint lastPressPosition; Qt::MouseButton lastPressButton; int clickCounter; ulong lastPressTimestamp; MultipleMouseClickHelper() : lastPressPosition(QPoint()) , lastPressButton(Qt::NoButton) , clickCounter(0) , lastPressTimestamp(0) { } }; class RenderWidgetHostViewQt : public content::RenderWidgetHostViewBase , public ui::GestureConsumer , public ui::GestureEventHelper , public base::SupportsWeakPtr { public: RenderWidgetHostViewQt(content::RenderWidgetHost* widget); ~RenderWidgetHostViewQt(); void setDelegate(RenderWidgetHostViewQtDelegate *delegate); void setAdapterClient(WebContentsAdapterClient *adapterClient); bool handleEvent(QEvent* event); cc::DelegatedFrameData *pendingDelegatedFrame() const { return m_pendingFrameData.get(); } void releaseAndAckDelegatedFrame(); BackingStoreQt* GetBackingStore(); virtual content::BackingStore *AllocBackingStore(const gfx::Size &size); virtual void InitAsChild(gfx::NativeView); virtual void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&); virtual void InitAsFullscreen(content::RenderWidgetHostView*); virtual content::RenderWidgetHost* GetRenderWidgetHost() const; virtual void SetSize(const gfx::Size& size); virtual void SetBounds(const gfx::Rect& rect); virtual gfx::Size GetPhysicalBackingSize() const; virtual gfx::NativeView GetNativeView() const; virtual gfx::NativeViewId GetNativeViewId() const; virtual gfx::NativeViewAccessible GetNativeViewAccessible(); virtual void Focus(); virtual bool HasFocus() const; virtual bool IsSurfaceAvailableForCopy() const; virtual void Show(); virtual void Hide(); virtual bool IsShowing(); virtual gfx::Rect GetViewBounds() const; virtual void SetBackground(const SkBitmap& background); virtual bool LockMouse(); virtual void UnlockMouse(); #if defined(TOOLKIT_GTK) virtual GdkEventButton* GetLastMouseDown(); virtual gfx::NativeView BuildInputMethodsGtkMenu(); #endif // defined(TOOLKIT_GTK) virtual void WasShown(); virtual void WasHidden(); virtual void MovePluginWindows(const gfx::Vector2d&, const std::vector&); virtual void Blur(); virtual void UpdateCursor(const WebCursor&); virtual void SetIsLoading(bool); virtual void TextInputTypeChanged(ui::TextInputType, bool, ui::TextInputMode); virtual void ImeCancelComposition(); virtual void ImeCompositionRangeChanged(const ui::Range&, const std::vector&); virtual void DidUpdateBackingStore(const gfx::Rect& scroll_rect, const gfx::Vector2d& scroll_delta, const std::vector& copy_rects, const ui::LatencyInfo&); virtual void RenderProcessGone(base::TerminationStatus, int); virtual void Destroy(); virtual void SetTooltipText(const string16&); virtual void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params&); virtual void ScrollOffsetChanged(); virtual void CopyFromCompositingSurface(const gfx::Rect& src_subrect, const gfx::Size& /* dst_size */, const base::Callback& callback); virtual void CopyFromCompositingSurfaceToVideoFrame(const gfx::Rect& src_subrect, const scoped_refptr& target, const base::Callback& callback); virtual bool CanCopyToVideoFrame() const; virtual void OnAcceleratedCompositingStateChange(); virtual void AcceleratedSurfaceBuffersSwapped(const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id); virtual void AcceleratedSurfacePostSubBuffer(const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, int gpu_host_id); virtual void AcceleratedSurfaceSuspend(); virtual void AcceleratedSurfaceRelease(); virtual bool HasAcceleratedSurface(const gfx::Size&); virtual void OnSwapCompositorFrame(uint32 output_surface_id, scoped_ptr frame) Q_DECL_OVERRIDE; virtual void GetScreenInfo(WebKit::WebScreenInfo* results); virtual gfx::Rect GetBoundsInRootWindow(); virtual gfx::GLSurfaceHandle GetCompositingSurface(); virtual void SetHasHorizontalScrollbar(bool); virtual void SetScrollOffsetPinning(bool, bool); virtual void OnAccessibilityNotifications(const std::vector&); virtual void ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) Q_DECL_OVERRIDE; // Overridden from ui::GestureEventHelper. virtual bool DispatchLongPressGestureEvent(ui::GestureEvent *event) Q_DECL_OVERRIDE; virtual bool DispatchCancelTouchEvent(ui::TouchEvent *event) Q_DECL_OVERRIDE; void handleMouseEvent(QMouseEvent*); void handleKeyEvent(QKeyEvent*); void handleWheelEvent(QWheelEvent*); void handleTouchEvent(QTouchEvent*); void handleHoverEvent(QHoverEvent*); void handleFocusEvent(QFocusEvent*); #if defined(OS_MACOSX) virtual void SetTakesFocusOnlyOnMouseDown(bool flag) { QT_NOT_YET_IMPLEMENTED } virtual void SetActive(bool active) { QT_NOT_YET_IMPLEMENTED } virtual bool IsSpeaking() const { QT_NOT_YET_IMPLEMENTED; return false; } virtual void SpeakSelection() { QT_NOT_YET_IMPLEMENTED } virtual bool PostProcessEventForPluginIme(const content::NativeWebKeyboardEvent& event) { QT_NOT_YET_IMPLEMENTED; return false; } virtual void AboutToWaitForBackingStoreMsg() { QT_NOT_YET_IMPLEMENTED } virtual void StopSpeaking() { QT_NOT_YET_IMPLEMENTED } virtual void SetWindowVisibility(bool visible) { QT_NOT_YET_IMPLEMENTED } virtual bool SupportsSpeech() const { QT_NOT_YET_IMPLEMENTED; return false; } virtual void ShowDefinitionForSelection() { QT_NOT_YET_IMPLEMENTED } virtual void WindowFrameChanged() { QT_NOT_YET_IMPLEMENTED } #endif // defined(OS_MACOSX) private: void Paint(const gfx::Rect& damage_rect); void SwapDelegatedFrame(uint32 output_surface_id, scoped_ptr frame_data, float frame_device_scale_factor, const ui::LatencyInfo& latency_info); void ProcessGestures(ui::GestureRecognizer::Gestures *gestures); int GetMappedTouch(int qtTouchId); void RemoveExpiredMappings(QTouchEvent *ev); bool IsPopup() const; content::RenderWidgetHostImpl *m_host; scoped_ptr m_gestureRecognizer; QMap m_touchIdMapping; WebKit::WebTouchEvent m_accumTouchEvent; scoped_ptr m_delegate; uint32 m_pendingOutputSurfaceId; scoped_ptr m_pendingFrameData; WebContentsAdapterClient *m_adapterClient; MultipleMouseClickHelper m_clickHelper; bool m_initPending; }; #endif // RENDER_WIDGET_HOST_VIEW_QT_H