Skip to content

Commit

Permalink
Align EmbedLitePuppet widget API
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Apr 8, 2020
1 parent b581969 commit 95720b8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 43 deletions.
41 changes: 22 additions & 19 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.cpp
Expand Up @@ -253,12 +253,11 @@ EmbedLitePuppetWidget::CreateChild(const LayoutDeviceIntRect &aRect,
return NS_FAILED(rv) ? nullptr : widget.forget();
}

NS_IMETHODIMP
EmbedLitePuppetWidget::Destroy()
void EmbedLitePuppetWidget::Destroy()
{
LOGT();
if (mOnDestroyCalled) {
return NS_OK;
return;
}

mOnDestroyCalled = true;
Expand Down Expand Up @@ -290,8 +289,6 @@ EmbedLitePuppetWidget::Destroy()
#if DEBUG
DumpWidgetTree();
#endif

return NS_OK;
}

NS_IMETHODIMP
Expand Down Expand Up @@ -621,13 +618,13 @@ EmbedLitePuppetWidget::RemoveIMEComposition()
RefPtr<EmbedLitePuppetWidget> kungFuDeathGrip(this);

WidgetCompositionEvent textEvent(true, eCompositionChange, this);
textEvent.time = PR_Now() / 1000;
textEvent.mTime = PR_Now() / 1000;
textEvent.mData = mIMEComposingText;
nsEventStatus status;
DispatchEvent(&textEvent, status);

WidgetCompositionEvent event(true, eCompositionEnd, this);
event.time = PR_Now() / 1000;
event.mTime = PR_Now() / 1000;
DispatchEvent(&event, status);
}

Expand Down Expand Up @@ -687,13 +684,17 @@ EmbedLitePuppetWidget::NeedsPaint()
LayerManager*
EmbedLitePuppetWidget::GetLayerManager(PLayerTransactionChild* aShadowManager,
LayersBackend aBackendHint,
LayerManagerPersistence aPersistence,
bool* aAllowRetaining)
LayerManagerPersistence aPersistence)
{
if (aAllowRetaining) {
*aAllowRetaining = true;
if (!mLayerManager) {
if (!mShutdownObserver) {
// We are shutting down, do not try to re-create a LayerManager
return nullptr;
}
}

// TODO: Check from nsBaseWidget.

if (mLayerManager) {
// This layer manager might be used for painting outside of DoDraw(), so we need
// to set the correct rotation on it.
Expand Down Expand Up @@ -799,6 +800,8 @@ void EmbedLitePuppetWidget::CreateCompositor()
MOZ_ASSERT(mWindow);
LayoutDeviceIntRect size = mWindow->GetSize();
CreateCompositor(size.width, size.height);

// See nsBaseWidget
}

void EmbedLitePuppetWidget::CreateCompositor(int aWidth, int aHeight)
Expand All @@ -808,10 +811,10 @@ void EmbedLitePuppetWidget::CreateCompositor(int aWidth, int aHeight)
}

void
EmbedLitePuppetWidget::DrawWindowUnderlay(LayerManagerComposite *aManager, LayoutDeviceIntRect aRect)
EmbedLitePuppetWidget::DrawWindowUnderlay(mozilla::widget::WidgetRenderingContext *aContext, LayoutDeviceIntRect aRect)
{
MOZ_ASSERT(mWindow);
Unused << aManager;
Unused << aContext;
Unused << aRect;
EmbedLiteWindow* window = EmbedLiteApp::GetInstance()->GetWindowByID(mWindow->GetUniqueID());
if (window) {
Expand All @@ -820,21 +823,21 @@ EmbedLitePuppetWidget::DrawWindowUnderlay(LayerManagerComposite *aManager, Layou
}

void
EmbedLitePuppetWidget::DrawWindowOverlay(LayerManagerComposite *aManager, LayoutDeviceIntRect aRect)
EmbedLitePuppetWidget::DrawWindowOverlay(mozilla::widget::WidgetRenderingContext *aContext, LayoutDeviceIntRect aRect)
{
MOZ_ASSERT(mWindow);
Unused << aManager;
Unused << aContext;
EmbedLiteWindow* window = EmbedLiteApp::GetInstance()->GetWindowByID(mWindow->GetUniqueID());
if (window) {
window->GetListener()->DrawOverlay(aRect.ToUnknownRect());
}
}

bool
EmbedLitePuppetWidget::PreRender(LayerManagerComposite *aManager)
EmbedLitePuppetWidget::PreRender(mozilla::widget::WidgetRenderingContext *aContext)
{
MOZ_ASSERT(mWindow);
Unused << aManager;
Unused << aContext;
if (!IsVisible() || !mActive) {
return false;
}
Expand All @@ -847,10 +850,10 @@ EmbedLitePuppetWidget::PreRender(LayerManagerComposite *aManager)
}

void
EmbedLitePuppetWidget::PostRender(LayerManagerComposite *aManager)
EmbedLitePuppetWidget::PostRender(mozilla::widget::WidgetRenderingContext *aContext)
{
MOZ_ASSERT(mWindow);
Unused << aManager;
Unused << aContext;
EmbedLiteWindow* window = EmbedLiteApp::GetInstance()->GetWindowByID(mWindow->GetUniqueID());
if (window) {
window->GetListener()->CompositingFinished();
Expand Down
46 changes: 22 additions & 24 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.h
Expand Up @@ -54,29 +54,29 @@ class EmbedLitePuppetWidget : public nsBaseWidget

NS_DECL_ISUPPORTS_INHERITED

NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent,
const LayoutDeviceIntRect& aRect,
nsWidgetInitData* aInitData = nullptr) override;
using nsBaseWidget::Create; // for Create signature not overridden here
virtual MOZ_MUST_USE nsresult Create(nsIWidget* aParent,
nsNativeWidget aNativeParent,
const LayoutDeviceIntRect& aRect,
nsWidgetInitData* aInitData = nullptr) override;

virtual already_AddRefed<nsIWidget>
CreateChild(const LayoutDeviceIntRect& aRect,
nsWidgetInitData* aInitData = nullptr,
bool aForceUseIWidgetParent = false) override;

NS_IMETHOD Destroy();
virtual void 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 {
virtual void ConstrainPosition(bool /*ignored aAllowSlop*/,
int32_t* aX,
int32_t* aY) override {
*aX = kMaxDimension;
*aY = kMaxDimension;
LOGNI();
return NS_OK;
}
// We're always at <0, 0>, and so ignore move requests.
NS_IMETHOD Move(double aX, double aY) override {
Expand Down Expand Up @@ -125,33 +125,31 @@ class EmbedLitePuppetWidget : public nsBaseWidget
return LayoutDeviceIntPoint(0, 0);
}
NS_IMETHOD DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus) override;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener,
bool aDoCapture) override {
virtual void CaptureRollupEvents(nsIRollupListener* aListener,
bool aDoCapture) override {
LOGNI();
return NS_ERROR_UNEXPECTED;
}
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
const InputContextAction& aAction) override;
NS_IMETHOD_(InputContext) GetInputContext() override;
NS_IMETHOD_(NativeIMEContext) GetNativeIMEContext() override;
virtual nsIMEUpdatePreference GetIMEUpdatePreference() override;

NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) override {
virtual void ReparentNativeWidget(nsIWidget* aNewParent) override {
(void)aNewParent;
LOGNI();
return NS_ERROR_UNEXPECTED;
}

virtual LayoutDeviceIntRect GetNaturalBounds() override;
virtual bool NeedsPaint() override;

virtual LayerManager*
GetLayerManager(PLayerTransactionChild* aShadowManager,
LayersBackend aBackendHint,
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nullptr) override;
virtual LayerManager *GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;

// TODO: Re-write this
virtual mozilla::layers::CompositorBridgeParent* NewCompositorParent(int aSurfaceWidth,
int aSurfaceHeight) override;
int aSurfaceHeight);
virtual void CreateCompositor() override;
virtual void CreateCompositor(int aWidth, int aHeight) override;

Expand All @@ -172,18 +170,18 @@ class EmbedLitePuppetWidget : public nsBaseWidget
* Always called from the compositing thread. Puppet Widget passes the call
* forward to the EmbedLiteCompositorBridgeParent.
*/
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override;
virtual void DrawWindowUnderlay(mozilla::widget::WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) override;

/**
* Called after the LayerManager draws the layer tree
*
* Always called from the compositing thread. Puppet Widget passes the call
* forward to the EmbedLiteCompositorBridgeParent.
*/
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override;
virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) override;

virtual bool PreRender(LayerManagerComposite* aManager) override;
virtual void PostRender(LayerManagerComposite* aManager) override;
virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override;
virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) override;

NS_IMETHOD SetParent(nsIWidget* aNewParent) override;
virtual nsIWidget* GetParent(void) override;
Expand Down

0 comments on commit 95720b8

Please sign in to comment.