mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
f3297ff565
- Bug 1161802 part 1 - Add FullscreenChanged callback in WidgetListener. r=roc (caee485f4) - Bug 1058712, e10s, support for copy image command, r=ehsan,mconley (42d1bcc2c) - Bug 1122090 - Make ContentHelper take a LayoutDeviceIntPoint instead of an nsIntPoint. r=botond (21588cadb) - Bug 1122090 - Send the allowed behaviour notification to APZ for touch blocks when touch-action is enabled. r=botond (5bb0aad4a) - remove unneeded include (b77797920) - Add wheel transaction support to APZ. (bug 1142866 part 1, r=kats) (a4ed2150a) - End APZ wheel transactions when the mouse moves out of frame. (bug 1142866 part 2, r=kats,botond) (b26b0eb89) - Add APZ support for test.mousescroll callbacks. (bug 1142866 part 3, r=kats) (424ef3ad7) - Add helper for applying async transforms to widget input events. (bug 1143567 part 1, r=kats) (221cf7b02) - Ensure input events account for APZ transforms on Gtk. (bug 1143567 part 2, r=kats) (a62991076) - Allow synthetic input events to be dispatched asynchronously. (bug 1146243, r=kats) (0878aac4e) - Bug 1120300 - Export WritingModes.h as mozilla/WritingModes.h. r=jfkthame (67838dec2) - Bug 1075670 - Make event.screen[XY] work in content processes (r=smaug,kats,tn,joshmoz) (7c800e2a1) - Bug 1150563 - Intermittent test_compartments.js | test_measure - [test_measure : 125] At least 10ms counted for built-in statistics (0) - false == true;r=yoric (72ce9c7fc) - Bug 1143847 - Fix bogus asserts in x64 Assembler::finish(). r=sunfish (36aecaf48) - pointer style (a1a5a7b0f) - Bug 1148232 - OdinMonkey: Mark x86 disassembler code as MOZ_COLD and use MOZ_RELEASE_ASSERT r=luke (346cf1fdd) - Bug 1148232 - OdinMonkey: Update an asm.js error message r=luke (98c72b0b1) - Bug 1148232 - OdinMonkey: Update tests to avoid using legacy syntax. r=luke (d212510f3) - Bug 1148232 - OdinMonkey: Misc CheckArrayAccess cleanups r=luke (e5cda1cf0) - pointer style (23135ba24) - Bug 1148232 - OdinMonkey: Always put asm.js heap alignment masks just before their accesses r=luke (d604adf5d) - pointer style (9a5d58741) - Bug 1148232 - IonMonkey: Delete unused code r=luke (ea5bc5edc) - pointer style (73be379e1) - Bug 1143704 part 1 - Make Emit1/Emit2 return bool instead of ptrdiff_t. r=luke (2ca42caa9) - pointer style (eb30078f0) - Bug 1143704 part 2 - Make Emit3/EmitCall/EmitBackPatchOp return bool instead of ptrdiff_t. r=jorendorff (7275c56af) - Bug 1143704 part 3 - Make EmitLoopHead return bool instead of ptrdiff_t. r=shu (aff098096) - Bug 1143704 part 4 - Turn Emit1 into a BytecodeEmitter method. r=bhackett (5ca0356ba) - Bug 1143704 part 5 - Add a cx member to BytecodeEmitter. r=Waldo (8ce42c388) - Bug 1143704 part 6 - Move more functions into BytecodeEmitter. r=efaust (b26f60b2f) - pointer style (39e0e76ab) - Bug 1143704 part 7 - Move more functions into BytecodeEmitter. r=bhackett (7397bc2e5) - pointer style (f08664ab1) - Bug 1143704 part 8 - Move more functions into BytecodeEmitter. r=luke (2b0411545) - pointer style (5042217ea) - Bug 1143704 part 9 - Move more functions into BytecodeEmitter. r=shu (97501236a) - pointer style (4248e54fa) - Bug 1143704 part 10 - Move more functions into BytecodeEmitter. r=efaust (cd1fcb6a4) - pointer style (06026238e) - Bug 1143704 part 11 - Move more functions into BytecodeEmitter. r=jorendorff (300cdd416) - Bug 1145491 part 1. Only do the fast path for JSOP_BINDGNAME when the script doesn't have a polluted global. r=luke,jandem (75d663d20) - Bug 1145491 part 2. Only do the fast path for JSOP_GETGNAME when the script doesn't have a polluted global. r=luke,jandem (776bb0b37) - Bug 1145491 part 3. Only do the fast path for JSOP_SETGNAME and JSOP_STRICTSETGNAME when the script doesn't have a polluted global. r=luke,jandem (dfc5781e2) - Bug 537013 - Make the find bar exist on a per-tab basis. r=dao (cf361fd57) - Bug 1145491 part 4. Emit JSOP_IMPLICITTHIS for JSOP_GETGNAME as well, because otherwise bareword calls in polluted-global scripts won't work right. r=luk (2a4c829e2) - Bug 1145491 part 5. Fix up various other places that check for JSOP_GET/SETNAME without checking for the GNAME versions too. r=luke (08ebda6b5) - pointer style (dbdd1393a) - Bug 1145491 part 6. Fix script cloning to propagate the polluted-global-scope state to the lambda templates in the script. r=luke (a0c85b629) - pointer style (906b885ff) - Bug 1145491 part 7. Stop checking compileAndGo before emitting GNAME ops. r=luke (33e64a432)
366 lines
12 KiB
C++
366 lines
12 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* vim: sw=2 ts=8 et :
|
|
*/
|
|
/* 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/. */
|
|
|
|
/**
|
|
* 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__
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
#include "mozilla/RefPtr.h"
|
|
#include "nsBaseScreen.h"
|
|
#include "nsBaseWidget.h"
|
|
#include "nsIScreenManager.h"
|
|
#include "nsThreadUtils.h"
|
|
#include "mozilla/Attributes.h"
|
|
#include "mozilla/EventForwards.h"
|
|
|
|
class gfxASurface;
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
class TabChild;
|
|
} // namespace dom
|
|
|
|
namespace widget {
|
|
|
|
struct AutoCacheNativeKeyCommands;
|
|
|
|
class PuppetWidget : public nsBaseWidget
|
|
{
|
|
typedef mozilla::dom::TabChild TabChild;
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
|
typedef nsBaseWidget Base;
|
|
|
|
// The width and height of the "widget" are clamped to this.
|
|
static const size_t kMaxDimension;
|
|
|
|
public:
|
|
explicit PuppetWidget(TabChild* aTabChild);
|
|
|
|
protected:
|
|
virtual ~PuppetWidget();
|
|
|
|
public:
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_IMETHOD Create(nsIWidget* aParent,
|
|
nsNativeWidget aNativeParent,
|
|
const nsIntRect& aRect,
|
|
nsWidgetInitData* aInitData = nullptr) override;
|
|
|
|
void InitIMEState();
|
|
|
|
virtual already_AddRefed<nsIWidget>
|
|
CreateChild(const nsIntRect &aRect,
|
|
nsWidgetInitData *aInitData = nullptr,
|
|
bool aForceUseIWidgetParent = false) override;
|
|
|
|
NS_IMETHOD Destroy() override;
|
|
|
|
NS_IMETHOD Show(bool aState) override;
|
|
|
|
virtual bool IsVisible() const override
|
|
{ return mVisible; }
|
|
|
|
NS_IMETHOD ConstrainPosition(bool /*ignored aAllowSlop*/,
|
|
int32_t* aX,
|
|
int32_t* aY) override
|
|
{ *aX = kMaxDimension; *aY = kMaxDimension; return NS_OK; }
|
|
|
|
// Widget position is controlled by the parent process via TabChild.
|
|
NS_IMETHOD Move(double aX, double aY) override
|
|
{ return NS_OK; }
|
|
|
|
NS_IMETHOD Resize(double aWidth,
|
|
double aHeight,
|
|
bool aRepaint) override;
|
|
NS_IMETHOD Resize(double aX,
|
|
double aY,
|
|
double aWidth,
|
|
double aHeight,
|
|
bool aRepaint) override
|
|
{
|
|
if (mBounds.x != aX || mBounds.y != aY) {
|
|
NotifyWindowMoved(aX, aY);
|
|
}
|
|
mBounds.x = aX;
|
|
mBounds.y = aY;
|
|
return Resize(aWidth, aHeight, aRepaint);
|
|
}
|
|
|
|
// XXX/cjones: copying gtk behavior here; unclear what disabling a
|
|
// widget is supposed to entail
|
|
NS_IMETHOD Enable(bool aState) override
|
|
{ mEnabled = aState; return NS_OK; }
|
|
virtual bool IsEnabled() const override
|
|
{ return mEnabled; }
|
|
|
|
NS_IMETHOD SetFocus(bool aRaise = false) override;
|
|
|
|
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
|
|
|
|
NS_IMETHOD Invalidate(const nsIntRect& aRect) override;
|
|
|
|
// This API is going away, steer clear.
|
|
virtual void Scroll(const nsIntPoint& aDelta,
|
|
const nsTArray<nsIntRect>& aDestRects,
|
|
const nsTArray<Configuration>& aReconfigureChildren)
|
|
{ /* dead man walking */ }
|
|
|
|
// PuppetWidgets don't have native data, as they're purely nonnative.
|
|
virtual void* GetNativeData(uint32_t aDataType) override;
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) override
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
// PuppetWidgets don't have any concept of titles.
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle) override
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() override
|
|
{ return LayoutDeviceIntPoint::FromUntyped(GetWindowPosition() + GetChromeDimensions()); }
|
|
|
|
void InitEvent(WidgetGUIEvent& aEvent, nsIntPoint* aPoint = nullptr);
|
|
|
|
NS_IMETHOD DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
|
|
nsEventStatus DispatchAPZAwareEvent(WidgetInputEvent* aEvent) override;
|
|
nsEventStatus DispatchInputEvent(WidgetInputEvent* aEvent) override;
|
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener,
|
|
bool aDoCapture) override
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
NS_IMETHOD_(bool)
|
|
ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
|
|
const mozilla::WidgetKeyboardEvent& aEvent,
|
|
DoCommandCallback aCallback,
|
|
void* aCallbackData) override;
|
|
|
|
friend struct AutoCacheNativeKeyCommands;
|
|
|
|
//
|
|
// nsBaseWidget methods we override
|
|
//
|
|
|
|
// 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.
|
|
virtual nsTransparencyMode GetTransparencyMode() override
|
|
{ return eTransparencyTransparent; }
|
|
|
|
virtual LayerManager*
|
|
GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
|
|
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
|
bool* aAllowRetaining = nullptr) override;
|
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
|
const InputContextAction& aAction) override;
|
|
NS_IMETHOD_(InputContext) GetInputContext() override;
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference() override;
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor) override;
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
|
uint32_t aHotspotX, uint32_t aHotspotY) override
|
|
{
|
|
return nsBaseWidget::SetCursor(aCursor, aHotspotX, aHotspotY);
|
|
}
|
|
|
|
// 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.
|
|
virtual float GetDPI() override;
|
|
virtual double GetDefaultScaleInternal() override;
|
|
|
|
virtual bool NeedsPaint() override;
|
|
|
|
virtual TabChild* GetOwningTabChild() override { return mTabChild; }
|
|
virtual void ClearBackingScaleCache()
|
|
{
|
|
mDPI = -1;
|
|
mDefaultScale = -1;
|
|
}
|
|
|
|
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();
|
|
|
|
NS_IMETHOD GetScreenBounds(nsIntRect &aRect) override;
|
|
|
|
NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
|
|
int32_t aPanelX, int32_t aPanelY,
|
|
nsString& aCommitted) override;
|
|
|
|
NS_IMETHOD SetPluginFocused(bool& aFocused) override;
|
|
|
|
protected:
|
|
bool mEnabled;
|
|
bool mVisible;
|
|
|
|
virtual nsresult NotifyIMEInternal(
|
|
const IMENotification& aIMENotification) override;
|
|
|
|
private:
|
|
nsresult Paint();
|
|
|
|
void SetChild(PuppetWidget* aChild);
|
|
|
|
nsresult IMEEndComposition(bool aCancel);
|
|
nsresult NotifyIMEOfFocusChange(bool aFocus);
|
|
nsresult NotifyIMEOfSelectionChange(const IMENotification& aIMENotification);
|
|
nsresult NotifyIMEOfUpdateComposition();
|
|
nsresult NotifyIMEOfTextChange(const IMENotification& aIMENotification);
|
|
nsresult NotifyIMEOfMouseButtonEvent(const IMENotification& aIMENotification);
|
|
nsresult NotifyIMEOfEditorRect();
|
|
nsresult NotifyIMEOfPositionChange();
|
|
|
|
bool GetEditorRect(mozilla::LayoutDeviceIntRect& aEditorRect);
|
|
bool GetCompositionRects(uint32_t& aStartOffset,
|
|
nsTArray<mozilla::LayoutDeviceIntRect>& aRectArray,
|
|
uint32_t& aTargetCauseOffset);
|
|
bool GetCaretRect(mozilla::LayoutDeviceIntRect& aCaretRect, uint32_t aCaretOffset);
|
|
uint32_t GetCaretOffset();
|
|
|
|
class PaintTask : public nsRunnable {
|
|
public:
|
|
NS_DECL_NSIRUNNABLE
|
|
explicit PaintTask(PuppetWidget* widget) : mWidget(widget) {}
|
|
void Revoke() { mWidget = nullptr; }
|
|
private:
|
|
PuppetWidget* mWidget;
|
|
};
|
|
|
|
// TabChild normally holds a strong reference to this PuppetWidget
|
|
// 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;
|
|
// The "widget" to which we delegate events if we don't have an
|
|
// event handler.
|
|
nsRefPtr<PuppetWidget> mChild;
|
|
nsIntRegion mDirtyRegion;
|
|
nsRevocableEventPtr<PaintTask> mPaintTask;
|
|
// XXX/cjones: keeping this around until we teach LayerManager to do
|
|
// retained-content-only transactions
|
|
mozilla::RefPtr<DrawTarget> mDrawTarget;
|
|
// IME
|
|
nsIMEUpdatePreference mIMEPreferenceOfParent;
|
|
// Latest seqno received through events
|
|
uint32_t mIMELastReceivedSeqno;
|
|
// Chrome's seqno value when last blur occurred
|
|
// arriving events with seqno up to this should be discarded
|
|
// Note that if seqno overflows (~50 days at 1 ms increment rate),
|
|
// events will be discarded until new focus/blur occurs
|
|
uint32_t mIMELastBlurSeqno;
|
|
bool mNeedIMEStateInit;
|
|
|
|
// The DPI of the screen corresponding to this widget
|
|
float mDPI;
|
|
double mDefaultScale;
|
|
|
|
// Precomputed answers for ExecuteNativeKeyBinding
|
|
bool mNativeKeyCommandsValid;
|
|
InfallibleTArray<mozilla::CommandInt> mSingleLineCommands;
|
|
InfallibleTArray<mozilla::CommandInt> mMultiLineCommands;
|
|
InfallibleTArray<mozilla::CommandInt> mRichTextCommands;
|
|
};
|
|
|
|
struct AutoCacheNativeKeyCommands
|
|
{
|
|
explicit AutoCacheNativeKeyCommands(PuppetWidget* aWidget)
|
|
: 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;
|
|
};
|
|
|
|
class PuppetScreen : public nsBaseScreen
|
|
{
|
|
public:
|
|
explicit PuppetScreen(void* nativeScreen);
|
|
~PuppetScreen();
|
|
|
|
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;
|
|
};
|
|
|
|
class PuppetScreenManager final : public nsIScreenManager
|
|
{
|
|
~PuppetScreenManager();
|
|
|
|
public:
|
|
PuppetScreenManager();
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSISCREENMANAGER
|
|
|
|
protected:
|
|
nsCOMPtr<nsIScreen> mOneScreen;
|
|
};
|
|
|
|
} // namespace widget
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_widget_PuppetWidget_h__
|