2010-08-20 23:24:40 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-20 23:24:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This "puppet widget" isn't really a platform widget. It's intended
|
|
|
|
* to be used in widgetless rendering contexts, such as sandboxed
|
|
|
|
* content processes. If any "real" widgetry is needed, the request
|
|
|
|
* is forwarded to and/or data received from elsewhere.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef mozilla_widget_PuppetWidget_h__
|
|
|
|
#define mozilla_widget_PuppetWidget_h__
|
|
|
|
|
2014-06-10 06:02:21 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2012-05-08 21:36:07 +00:00
|
|
|
#include "nsBaseScreen.h"
|
2010-08-20 23:24:40 +00:00
|
|
|
#include "nsBaseWidget.h"
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 11:09:37 +00:00
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsIKeyEventInPluginCallback.h"
|
2012-05-08 21:36:07 +00:00
|
|
|
#include "nsIScreenManager.h"
|
2010-08-20 23:24:40 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2012-06-19 01:28:00 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2015-06-05 09:28:20 +00:00
|
|
|
#include "mozilla/ContentCache.h"
|
2014-03-20 15:46:29 +00:00
|
|
|
#include "mozilla/EventForwards.h"
|
2010-08-20 23:24:40 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2012-07-17 23:59:45 +00:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class TabChild;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
2012-07-17 23:59:45 +00:00
|
|
|
|
2010-08-20 23:24:40 +00:00
|
|
|
namespace widget {
|
|
|
|
|
2014-06-19 00:57:51 +00:00
|
|
|
struct AutoCacheNativeKeyCommands;
|
2014-04-21 20:40:09 +00:00
|
|
|
|
2015-02-18 06:27:53 +00:00
|
|
|
class PuppetWidget : public nsBaseWidget
|
2010-08-20 23:24:40 +00:00
|
|
|
{
|
2012-07-17 23:59:45 +00:00
|
|
|
typedef mozilla::dom::TabChild TabChild;
|
2014-06-10 06:02:21 +00:00
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
2010-08-20 23:24:40 +00:00
|
|
|
typedef nsBaseWidget Base;
|
2016-01-20 01:44:44 +00:00
|
|
|
typedef mozilla::CSSRect CSSRect;
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2010-08-20 23:24:40 +00:00
|
|
|
// The width and height of the "widget" are clamped to this.
|
|
|
|
static const size_t kMaxDimension;
|
|
|
|
|
|
|
|
public:
|
2014-09-01 03:33:13 +00:00
|
|
|
explicit PuppetWidget(TabChild* aTabChild);
|
2014-07-08 21:23:18 +00:00
|
|
|
|
|
|
|
protected:
|
2010-08-20 23:24:40 +00:00
|
|
|
virtual ~PuppetWidget();
|
|
|
|
|
2014-07-08 21:23:18 +00:00
|
|
|
public:
|
2010-08-20 23:24:40 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2016-08-18 23:03:17 +00:00
|
|
|
// PuppetWidget creation is infallible, hence InfallibleCreate(), which
|
|
|
|
// Create() calls.
|
2016-01-13 07:32:55 +00:00
|
|
|
using nsBaseWidget::Create; // for Create signature not overridden here
|
2016-08-18 23:03:17 +00:00
|
|
|
virtual nsresult Create(nsIWidget* aParent,
|
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const LayoutDeviceIntRect& aRect,
|
|
|
|
nsWidgetInitData* aInitData = nullptr)
|
|
|
|
override;
|
|
|
|
void InfallibleCreate(nsIWidget* aParent,
|
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const LayoutDeviceIntRect& aRect,
|
|
|
|
nsWidgetInitData* aInitData = nullptr);
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2012-08-29 15:26:18 +00:00
|
|
|
void InitIMEState();
|
|
|
|
|
2010-08-20 23:24:40 +00:00
|
|
|
virtual already_AddRefed<nsIWidget>
|
2015-11-16 08:35:18 +00:00
|
|
|
CreateChild(const LayoutDeviceIntRect& aRect,
|
|
|
|
nsWidgetInitData* aInitData = nullptr,
|
|
|
|
bool aForceUseIWidgetParent = false) override;
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2016-08-10 00:04:11 +00:00
|
|
|
virtual void Destroy() override;
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2016-12-21 00:12:54 +00:00
|
|
|
virtual void Show(bool aState) override;
|
2012-07-19 08:57:50 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsVisible() const override
|
2012-07-19 08:57:50 +00:00
|
|
|
{ return mVisible; }
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2016-08-25 03:43:27 +00:00
|
|
|
virtual void ConstrainPosition(bool /*ignored aAllowSlop*/,
|
|
|
|
int32_t* aX,
|
|
|
|
int32_t* aY) override
|
|
|
|
{ *aX = kMaxDimension; *aY = kMaxDimension; }
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2015-03-31 20:39:02 +00:00
|
|
|
// Widget position is controlled by the parent process via TabChild.
|
2016-12-19 09:54:03 +00:00
|
|
|
virtual void Move(double aX, double aY) override {}
|
|
|
|
|
|
|
|
virtual void Resize(double aWidth,
|
|
|
|
double aHeight,
|
|
|
|
bool aRepaint) override;
|
|
|
|
virtual void Resize(double aX,
|
|
|
|
double aY,
|
|
|
|
double aWidth,
|
|
|
|
double aHeight,
|
|
|
|
bool aRepaint) override
|
2015-03-31 20:39:02 +00:00
|
|
|
{
|
|
|
|
if (mBounds.x != aX || mBounds.y != aY) {
|
|
|
|
NotifyWindowMoved(aX, aY);
|
|
|
|
}
|
|
|
|
mBounds.x = aX;
|
|
|
|
mBounds.y = aY;
|
|
|
|
return Resize(aWidth, aHeight, aRepaint);
|
|
|
|
}
|
2010-08-20 23:24:40 +00:00
|
|
|
|
|
|
|
// XXX/cjones: copying gtk behavior here; unclear what disabling a
|
|
|
|
// widget is supposed to entail
|
2016-12-19 09:54:16 +00:00
|
|
|
virtual void Enable(bool aState) override
|
|
|
|
{ mEnabled = aState; }
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsEnabled() const override
|
2012-07-23 05:19:08 +00:00
|
|
|
{ return mEnabled; }
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2016-12-21 00:13:08 +00:00
|
|
|
virtual nsresult SetFocus(bool aRaise = false) override;
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2016-12-19 22:55:32 +00:00
|
|
|
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
|
2010-08-20 23:24:40 +00:00
|
|
|
|
|
|
|
// PuppetWidgets don't have native data, as they're purely nonnative.
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void* GetNativeData(uint32_t aDataType) override;
|
2015-08-12 15:00:26 +00:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
void SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
|
|
|
|
#endif
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2015-04-07 13:00:05 +00:00
|
|
|
// PuppetWidgets don't have any concept of titles.
|
2016-12-21 00:13:08 +00:00
|
|
|
virtual nsresult SetTitle(const nsAString& aTitle) override
|
2010-08-20 23:24:40 +00:00
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
2015-04-07 13:00:05 +00:00
|
|
|
|
2015-11-13 09:37:02 +00:00
|
|
|
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override
|
2015-11-09 23:22:25 +00:00
|
|
|
{ return LayoutDeviceIntPoint::FromUnknownPoint(GetWindowPosition() + GetChromeDimensions()); }
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2016-09-27 06:37:07 +00:00
|
|
|
int32_t RoundsWidgetCoordinatesTo() override;
|
|
|
|
|
2015-11-10 05:37:32 +00:00
|
|
|
void InitEvent(WidgetGUIEvent& aEvent,
|
2015-11-13 09:37:02 +00:00
|
|
|
LayoutDeviceIntPoint* aPoint = nullptr);
|
2010-09-24 03:28:15 +00:00
|
|
|
|
2016-12-21 00:18:40 +00:00
|
|
|
virtual nsresult DispatchEvent(WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aStatus) override;
|
2015-03-24 22:00:52 +00:00
|
|
|
nsEventStatus DispatchInputEvent(WidgetInputEvent* aEvent) override;
|
2015-04-14 16:24:32 +00:00
|
|
|
void SetConfirmedTargetAPZC(uint64_t aInputBlockId,
|
|
|
|
const nsTArray<ScrollableLayerGuid>& aTargets) const override;
|
2015-06-17 16:32:42 +00:00
|
|
|
void UpdateZoomConstraints(const uint32_t& aPresShellId,
|
|
|
|
const FrameMetrics::ViewID& aViewId,
|
|
|
|
const mozilla::Maybe<ZoomConstraints>& aConstraints) override;
|
2015-06-04 20:51:10 +00:00
|
|
|
bool AsyncPanZoomEnabled() const override;
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2016-12-21 04:27:20 +00:00
|
|
|
virtual bool
|
2014-03-20 15:46:29 +00:00
|
|
|
ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
|
|
|
|
const mozilla::WidgetKeyboardEvent& aEvent,
|
|
|
|
DoCommandCallback aCallback,
|
2015-03-21 16:28:04 +00:00
|
|
|
void* aCallbackData) override;
|
2014-03-20 15:46:29 +00:00
|
|
|
|
2014-06-19 00:57:51 +00:00
|
|
|
friend struct AutoCacheNativeKeyCommands;
|
2014-03-20 15:46:29 +00:00
|
|
|
|
2010-08-20 23:24:40 +00:00
|
|
|
//
|
|
|
|
// nsBaseWidget methods we override
|
|
|
|
//
|
|
|
|
|
2013-11-25 20:12:20 +00:00
|
|
|
// Documents loaded in child processes are always subdocuments of
|
|
|
|
// other docs in an ancestor process. To ensure that the
|
|
|
|
// backgrounds of those documents are painted like those of
|
|
|
|
// same-process subdocuments, we force the widget here to be
|
|
|
|
// transparent, which in turn will cause layout to use a transparent
|
|
|
|
// backstop background color.
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsTransparencyMode GetTransparencyMode() override
|
2013-11-25 20:12:20 +00:00
|
|
|
{ return eTransparencyTransparent; }
|
2012-09-05 16:23:45 +00:00
|
|
|
|
2011-08-09 19:38:26 +00:00
|
|
|
virtual LayerManager*
|
2013-04-24 18:42:40 +00:00
|
|
|
GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
|
2014-01-23 18:26:41 +00:00
|
|
|
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
|
2016-06-24 00:53:27 +00:00
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2016-09-20 08:19:32 +00:00
|
|
|
// This is used after a compositor reset.
|
|
|
|
LayerManager* RecreateLayerManager(PLayerTransactionChild* aShadowManager);
|
|
|
|
|
2016-12-21 04:27:20 +00:00
|
|
|
virtual void SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction) override;
|
|
|
|
virtual InputContext GetInputContext() override;
|
|
|
|
virtual NativeIMEContext GetNativeIMEContext() override;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference() override;
|
2010-09-24 03:28:15 +00:00
|
|
|
|
2016-12-21 00:13:08 +00:00
|
|
|
virtual void SetCursor(nsCursor aCursor) override;
|
|
|
|
virtual nsresult SetCursor(imgIContainer* aCursor,
|
|
|
|
uint32_t aHotspotX, uint32_t aHotspotY) override;
|
2015-05-20 01:28:57 +00:00
|
|
|
|
|
|
|
virtual void ClearCachedCursor() override;
|
2011-06-22 00:32:43 +00:00
|
|
|
|
2010-12-03 01:24:04 +00:00
|
|
|
// Gets the DPI of the screen corresponding to this widget.
|
|
|
|
// Contacts the parent process which gets the DPI from the
|
|
|
|
// proper widget there. TODO: Handle DPI changes that happen
|
|
|
|
// later on.
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual float GetDPI() override;
|
|
|
|
virtual double GetDefaultScaleInternal() override;
|
2010-12-03 01:24:04 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool NeedsPaint() override;
|
2012-11-08 03:51:55 +00:00
|
|
|
|
2016-07-22 23:36:45 +00:00
|
|
|
// Paint the widget immediately if any paints are queued up.
|
|
|
|
void PaintNowIfNeeded();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual TabChild* GetOwningTabChild() override { return mTabChild; }
|
2015-08-13 14:42:19 +00:00
|
|
|
|
2016-09-27 06:37:07 +00:00
|
|
|
void UpdateBackingScaleCache(float aDpi, int32_t aRounding, double aScale)
|
2014-05-23 14:36:50 +00:00
|
|
|
{
|
2015-08-13 14:42:19 +00:00
|
|
|
mDPI = aDpi;
|
2016-09-27 06:37:07 +00:00
|
|
|
mRounding = aRounding;
|
2015-08-13 14:42:19 +00:00
|
|
|
mDefaultScale = aScale;
|
2014-05-23 14:36:50 +00:00
|
|
|
}
|
2012-09-25 04:15:18 +00:00
|
|
|
|
2014-12-11 14:44:07 +00:00
|
|
|
nsIntSize GetScreenDimensions();
|
|
|
|
|
|
|
|
// Get the size of the chrome of the window that this tab belongs to.
|
|
|
|
nsIntPoint GetChromeDimensions();
|
|
|
|
|
|
|
|
// Get the screen position of the application window.
|
|
|
|
nsIntPoint GetWindowPosition();
|
|
|
|
|
2016-08-18 23:03:04 +00:00
|
|
|
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
2015-03-31 20:39:02 +00:00
|
|
|
|
2016-12-15 23:55:18 +00:00
|
|
|
virtual MOZ_MUST_USE nsresult
|
|
|
|
StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
|
|
|
|
int32_t aPanelX, int32_t aPanelY,
|
|
|
|
nsString& aCommitted) override;
|
2015-02-20 16:37:02 +00:00
|
|
|
|
2016-08-25 03:43:27 +00:00
|
|
|
virtual void SetPluginFocused(bool& aFocused) override;
|
2015-12-29 13:57:38 +00:00
|
|
|
virtual void DefaultProcOfPluginEvent(
|
|
|
|
const mozilla::WidgetPluginEvent& aEvent) override;
|
2015-02-20 16:37:02 +00:00
|
|
|
|
2015-04-14 15:36:36 +00:00
|
|
|
virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
|
|
|
|
int32_t aNativeKeyCode,
|
|
|
|
uint32_t aModifierFlags,
|
|
|
|
const nsAString& aCharacters,
|
|
|
|
const nsAString& aUnmodifiedCharacters,
|
|
|
|
nsIObserver* aObserver) override;
|
2015-11-13 09:37:02 +00:00
|
|
|
virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
|
2015-04-14 15:36:36 +00:00
|
|
|
uint32_t aNativeMessage,
|
|
|
|
uint32_t aModifierFlags,
|
|
|
|
nsIObserver* aObserver) override;
|
2015-11-13 09:37:02 +00:00
|
|
|
virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
|
2015-04-14 15:36:36 +00:00
|
|
|
nsIObserver* aObserver) override;
|
2015-11-13 09:37:02 +00:00
|
|
|
virtual nsresult SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint aPoint,
|
2015-04-14 15:36:36 +00:00
|
|
|
uint32_t aNativeMessage,
|
|
|
|
double aDeltaX,
|
|
|
|
double aDeltaY,
|
|
|
|
double aDeltaZ,
|
|
|
|
uint32_t aModifierFlags,
|
|
|
|
uint32_t aAdditionalFlags,
|
|
|
|
nsIObserver* aObserver) override;
|
|
|
|
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|
|
|
TouchPointerState aPointerState,
|
2016-04-15 10:39:36 +00:00
|
|
|
LayoutDeviceIntPoint aPoint,
|
2015-04-14 15:36:36 +00:00
|
|
|
double aPointerPressure,
|
|
|
|
uint32_t aPointerOrientation,
|
|
|
|
nsIObserver* aObserver) override;
|
2016-04-15 10:39:36 +00:00
|
|
|
virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
|
2015-04-14 15:36:36 +00:00
|
|
|
bool aLongTap,
|
|
|
|
nsIObserver* aObserver) override;
|
|
|
|
virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver) override;
|
2015-05-08 01:29:00 +00:00
|
|
|
virtual uint32_t GetMaxTouchPoints() const override;
|
2015-04-14 15:36:36 +00:00
|
|
|
|
2015-09-28 21:00:25 +00:00
|
|
|
virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) override;
|
2015-12-29 13:57:38 +00:00
|
|
|
|
2016-02-02 08:05:56 +00:00
|
|
|
virtual void SetCandidateWindowForPlugin(
|
|
|
|
const CandidateWindowPosition& aPosition) override;
|
2015-12-29 13:57:38 +00:00
|
|
|
|
2016-01-20 01:44:44 +00:00
|
|
|
virtual void ZoomToRect(const uint32_t& aPresShellId,
|
|
|
|
const FrameMetrics::ViewID& aViewId,
|
|
|
|
const CSSRect& aRect,
|
|
|
|
const uint32_t& aFlags) override;
|
2016-03-29 07:03:54 +00:00
|
|
|
|
|
|
|
virtual bool HasPendingInputEvent() override;
|
|
|
|
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 11:09:37 +00:00
|
|
|
void HandledWindowedPluginKeyEvent(const NativeEventData& aKeyEventData,
|
|
|
|
bool aIsConsumed);
|
|
|
|
virtual nsresult OnWindowedPluginKeyEvent(
|
|
|
|
const NativeEventData& aKeyEventData,
|
|
|
|
nsIKeyEventInPluginCallback* aCallback) override;
|
|
|
|
|
2016-04-26 08:18:04 +00:00
|
|
|
virtual void LookUpDictionary(
|
|
|
|
const nsAString& aText,
|
|
|
|
const nsTArray<mozilla::FontRange>& aFontRangeArray,
|
|
|
|
const bool aIsVertical,
|
|
|
|
const LayoutDeviceIntPoint& aPoint) override;
|
|
|
|
|
2014-11-12 20:59:19 +00:00
|
|
|
protected:
|
2015-01-28 06:27:31 +00:00
|
|
|
virtual nsresult NotifyIMEInternal(
|
2015-03-21 16:28:04 +00:00
|
|
|
const IMENotification& aIMENotification) override;
|
2015-01-28 06:27:31 +00:00
|
|
|
|
2010-08-20 23:24:40 +00:00
|
|
|
private:
|
2012-08-15 18:52:42 +00:00
|
|
|
nsresult Paint();
|
2010-08-20 23:24:40 +00:00
|
|
|
|
|
|
|
void SetChild(PuppetWidget* aChild);
|
|
|
|
|
2015-12-11 06:15:58 +00:00
|
|
|
nsresult RequestIMEToCommitComposition(bool aCancel);
|
2015-06-05 09:28:20 +00:00
|
|
|
nsresult NotifyIMEOfFocusChange(const IMENotification& aIMENotification);
|
2014-02-26 00:48:02 +00:00
|
|
|
nsresult NotifyIMEOfSelectionChange(const IMENotification& aIMENotification);
|
2015-07-17 04:30:01 +00:00
|
|
|
nsresult NotifyIMEOfCompositionUpdate(const IMENotification& aIMENotification);
|
2014-02-18 00:00:15 +00:00
|
|
|
nsresult NotifyIMEOfTextChange(const IMENotification& aIMENotification);
|
2014-09-11 13:46:17 +00:00
|
|
|
nsresult NotifyIMEOfMouseButtonEvent(const IMENotification& aIMENotification);
|
2015-06-05 09:28:20 +00:00
|
|
|
nsresult NotifyIMEOfPositionChange(const IMENotification& aIMENotification);
|
2014-12-15 09:37:00 +00:00
|
|
|
|
2015-06-05 09:28:20 +00:00
|
|
|
bool CacheEditorRect();
|
|
|
|
bool CacheCompositionRects(uint32_t& aStartOffset,
|
2015-11-13 09:37:02 +00:00
|
|
|
nsTArray<LayoutDeviceIntRect>& aRectArray,
|
2015-06-05 09:28:20 +00:00
|
|
|
uint32_t& aTargetCauseOffset);
|
2015-11-13 09:37:02 +00:00
|
|
|
bool GetCaretRect(LayoutDeviceIntRect& aCaretRect, uint32_t aCaretOffset);
|
2014-12-15 09:37:00 +00:00
|
|
|
uint32_t GetCaretOffset();
|
2010-09-24 03:28:15 +00:00
|
|
|
|
2015-07-22 01:09:02 +00:00
|
|
|
nsIWidgetListener* GetCurrentWidgetListener();
|
|
|
|
|
2016-04-26 00:23:21 +00:00
|
|
|
class PaintTask : public Runnable {
|
2010-08-20 23:24:40 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_NSIRUNNABLE
|
2017-02-11 06:11:48 +00:00
|
|
|
explicit PaintTask(PuppetWidget* widget)
|
|
|
|
: Runnable("PuppetWidget::PaintTask"), mWidget(widget) {}
|
2012-07-30 14:20:58 +00:00
|
|
|
void Revoke() { mWidget = nullptr; }
|
2010-08-20 23:24:40 +00:00
|
|
|
private:
|
|
|
|
PuppetWidget* mWidget;
|
|
|
|
};
|
|
|
|
|
2015-05-20 07:45:41 +00:00
|
|
|
class MemoryPressureObserver : public nsIObserver {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
explicit MemoryPressureObserver(PuppetWidget* aWidget) : mWidget(aWidget) {}
|
|
|
|
void Remove();
|
|
|
|
private:
|
|
|
|
virtual ~MemoryPressureObserver() {}
|
|
|
|
PuppetWidget* mWidget;
|
|
|
|
};
|
|
|
|
friend class MemoryPressureObserver;
|
|
|
|
|
2010-09-24 03:28:15 +00:00
|
|
|
// TabChild normally holds a strong reference to this PuppetWidget
|
2012-07-17 23:59:45 +00:00
|
|
|
// or its root ancestor, but each PuppetWidget also needs a
|
|
|
|
// reference back to TabChild (e.g. to delegate nsIWidget IME calls
|
|
|
|
// to chrome) So we hold a weak reference to TabChild here. Since
|
|
|
|
// it's possible for TabChild to outlive the PuppetWidget, we clear
|
|
|
|
// this weak reference in Destroy()
|
|
|
|
TabChild* mTabChild;
|
2010-08-20 23:24:40 +00:00
|
|
|
// The "widget" to which we delegate events if we don't have an
|
|
|
|
// event handler.
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<PuppetWidget> mChild;
|
2015-11-17 05:18:31 +00:00
|
|
|
LayoutDeviceIntRegion mDirtyRegion;
|
2010-08-20 23:24:40 +00:00
|
|
|
nsRevocableEventPtr<PaintTask> mPaintTask;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<MemoryPressureObserver> mMemoryPressureObserver;
|
2010-08-20 23:24:40 +00:00
|
|
|
// XXX/cjones: keeping this around until we teach LayerManager to do
|
|
|
|
// retained-content-only transactions
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<DrawTarget> mDrawTarget;
|
2010-09-24 03:28:15 +00:00
|
|
|
// IME
|
2014-01-29 09:32:39 +00:00
|
|
|
nsIMEUpdatePreference mIMEPreferenceOfParent;
|
2015-10-10 01:21:02 +00:00
|
|
|
InputContext mInputContext;
|
2015-12-11 06:15:57 +00:00
|
|
|
// mNativeIMEContext is initialized when this dispatches every composition
|
|
|
|
// event both from parent process's widget and TextEventDispatcher in same
|
|
|
|
// process. If it hasn't been started composition yet, this isn't necessary
|
|
|
|
// for XP code since there is no TextComposition instance which is caused by
|
|
|
|
// the PuppetWidget instance.
|
|
|
|
NativeIMEContext mNativeIMEContext;
|
2015-06-25 23:21:13 +00:00
|
|
|
ContentCacheInChild mContentCache;
|
2010-12-03 01:24:04 +00:00
|
|
|
|
|
|
|
// The DPI of the screen corresponding to this widget
|
|
|
|
float mDPI;
|
2016-09-27 06:37:07 +00:00
|
|
|
int32_t mRounding;
|
2013-05-01 23:06:19 +00:00
|
|
|
double mDefaultScale;
|
2014-03-20 15:46:29 +00:00
|
|
|
|
|
|
|
// Precomputed answers for ExecuteNativeKeyBinding
|
|
|
|
InfallibleTArray<mozilla::CommandInt> mSingleLineCommands;
|
|
|
|
InfallibleTArray<mozilla::CommandInt> mMultiLineCommands;
|
|
|
|
InfallibleTArray<mozilla::CommandInt> mRichTextCommands;
|
2015-05-20 01:28:57 +00:00
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> mCustomCursor;
|
|
|
|
uint32_t mCursorHotspotX, mCursorHotspotY;
|
2015-12-11 06:15:57 +00:00
|
|
|
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 11:09:37 +00:00
|
|
|
nsCOMArray<nsIKeyEventInPluginCallback> mKeyEventInPluginCallbacks;
|
|
|
|
|
2015-12-11 06:15:57 +00:00
|
|
|
protected:
|
|
|
|
bool mEnabled;
|
|
|
|
bool mVisible;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool mNeedIMEStateInit;
|
|
|
|
bool mNativeKeyCommandsValid;
|
2010-08-20 23:24:40 +00:00
|
|
|
};
|
|
|
|
|
2014-04-21 20:40:09 +00:00
|
|
|
struct AutoCacheNativeKeyCommands
|
|
|
|
{
|
2014-09-01 03:33:13 +00:00
|
|
|
explicit AutoCacheNativeKeyCommands(PuppetWidget* aWidget)
|
2014-04-21 20:40:09 +00:00
|
|
|
: mWidget(aWidget)
|
|
|
|
{
|
|
|
|
mSavedValid = mWidget->mNativeKeyCommandsValid;
|
|
|
|
mSavedSingleLine = mWidget->mSingleLineCommands;
|
|
|
|
mSavedMultiLine = mWidget->mMultiLineCommands;
|
|
|
|
mSavedRichText = mWidget->mRichTextCommands;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cache(const InfallibleTArray<mozilla::CommandInt>& aSingleLineCommands,
|
|
|
|
const InfallibleTArray<mozilla::CommandInt>& aMultiLineCommands,
|
|
|
|
const InfallibleTArray<mozilla::CommandInt>& aRichTextCommands)
|
|
|
|
{
|
|
|
|
mWidget->mNativeKeyCommandsValid = true;
|
|
|
|
mWidget->mSingleLineCommands = aSingleLineCommands;
|
|
|
|
mWidget->mMultiLineCommands = aMultiLineCommands;
|
|
|
|
mWidget->mRichTextCommands = aRichTextCommands;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CacheNoCommands()
|
|
|
|
{
|
|
|
|
mWidget->mNativeKeyCommandsValid = true;
|
|
|
|
mWidget->mSingleLineCommands.Clear();
|
|
|
|
mWidget->mMultiLineCommands.Clear();
|
|
|
|
mWidget->mRichTextCommands.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoCacheNativeKeyCommands()
|
|
|
|
{
|
|
|
|
mWidget->mNativeKeyCommandsValid = mSavedValid;
|
|
|
|
mWidget->mSingleLineCommands = mSavedSingleLine;
|
|
|
|
mWidget->mMultiLineCommands = mSavedMultiLine;
|
|
|
|
mWidget->mRichTextCommands = mSavedRichText;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PuppetWidget* mWidget;
|
|
|
|
bool mSavedValid;
|
|
|
|
InfallibleTArray<mozilla::CommandInt> mSavedSingleLine;
|
|
|
|
InfallibleTArray<mozilla::CommandInt> mSavedMultiLine;
|
|
|
|
InfallibleTArray<mozilla::CommandInt> mSavedRichText;
|
|
|
|
};
|
|
|
|
|
2012-05-08 21:36:07 +00:00
|
|
|
class PuppetScreen : public nsBaseScreen
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 03:33:13 +00:00
|
|
|
explicit PuppetScreen(void* nativeScreen);
|
2012-05-08 21:36:07 +00:00
|
|
|
~PuppetScreen();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetId(uint32_t* aId) override;
|
|
|
|
NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override;
|
|
|
|
NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override;
|
|
|
|
NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) override;
|
|
|
|
NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override;
|
|
|
|
NS_IMETHOD GetRotation(uint32_t* aRotation) override;
|
|
|
|
NS_IMETHOD SetRotation(uint32_t aRotation) override;
|
2012-05-08 21:36:07 +00:00
|
|
|
};
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class PuppetScreenManager final : public nsIScreenManager
|
2012-05-08 21:36:07 +00:00
|
|
|
{
|
2014-06-24 16:36:44 +00:00
|
|
|
~PuppetScreenManager();
|
|
|
|
|
2012-05-08 21:36:07 +00:00
|
|
|
public:
|
|
|
|
PuppetScreenManager();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISCREENMANAGER
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsCOMPtr<nsIScreen> mOneScreen;
|
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
2010-08-20 23:24:40 +00:00
|
|
|
|
|
|
|
#endif // mozilla_widget_PuppetWidget_h__
|