зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1293596 (part 8) - Make nsIWidget::EnableDragDrop() infallible. r=jimm.
Its return value is only checked in one low-value assertion. The patch also does the following. - Removes the Android and GTK overloadings of EnableDragDrop(), which are identical to the nsBaseWidget one. - Streamlines the Windows implementation: fixes the indentation and takes advantage of infallible |new|. --HG-- extra : rebase_source : d090848cf5ea2e92c0188b07559c1e1f3899829f
This commit is contained in:
Родитель
367d94e34e
Коммит
00246f9dff
|
@ -3394,7 +3394,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
mWidget->EnableDragDrop(true);
|
||||
mWidget->Show(false);
|
||||
mWidget->Enable(false);
|
||||
|
|
|
@ -126,14 +126,12 @@ PluginWidgetParent::RecvCreate(nsresult* aResult)
|
|||
return false;
|
||||
}
|
||||
|
||||
DebugOnly<nsresult> drv;
|
||||
drv = mWidget->EnableDragDrop(true);
|
||||
NS_ASSERTION(NS_SUCCEEDED(drv), "widget call failure");
|
||||
mWidget->EnableDragDrop(true);
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
// For setup, initially GTK code expects 'window' to hold the parent.
|
||||
mWrapper->window = mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT);
|
||||
drv = mWrapper->CreateXEmbedWindow(false);
|
||||
DebugOnly<nsresult> drv = mWrapper->CreateXEmbedWindow(false);
|
||||
NS_ASSERTION(NS_SUCCEEDED(drv), "widget call failure");
|
||||
mWrapper->SetAllocation();
|
||||
PWLOG("Plugin XID=%p\n", (void*)mWrapper->window);
|
||||
|
|
|
@ -187,7 +187,6 @@ public:
|
|||
void SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
|
||||
NS_IMETHOD SetTitle(const nsAString& aTitle) override { return NS_OK; }
|
||||
NS_IMETHOD SetIcon(const nsAString& aIconSpec) override { return NS_OK; }
|
||||
NS_IMETHOD EnableDragDrop(bool aEnable) override { return NS_OK; }
|
||||
NS_IMETHOD CaptureMouse(bool aCapture) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
||||
bool aDoCapture) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
|
|
@ -1879,12 +1879,6 @@ nsWindow::WidgetToScreenOffset()
|
|||
return GdkPointToDevicePixels({ x, y });
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::EnableDragDrop(bool aEnable)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::CaptureMouse(bool aCapture)
|
||||
{
|
||||
|
|
|
@ -148,7 +148,6 @@ public:
|
|||
NS_IMETHOD SetIcon(const nsAString& aIconSpec) override;
|
||||
NS_IMETHOD SetWindowClass(const nsAString& xulWinType) override;
|
||||
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
NS_IMETHOD EnableDragDrop(bool aEnable) override;
|
||||
NS_IMETHOD CaptureMouse(bool aCapture) override;
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
||||
bool aDoCapture) override;
|
||||
|
|
|
@ -1599,11 +1599,6 @@ nsBaseWidget::SetNonClientMargins(LayoutDeviceIntMargin &margins)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBaseWidget::EnableDragDrop(bool aEnable)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t nsBaseWidget::GetMaxTouchPoints() const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -223,7 +223,7 @@ public:
|
|||
virtual MOZ_MUST_USE nsresult GetRestoredBounds(LayoutDeviceIntRect& aRect) override;
|
||||
NS_IMETHOD SetNonClientMargins(LayoutDeviceIntMargin& aMargins) override;
|
||||
virtual LayoutDeviceIntPoint GetClientOffset() override;
|
||||
NS_IMETHOD EnableDragDrop(bool aEnable) override;
|
||||
virtual void EnableDragDrop(bool aEnable) override {};
|
||||
NS_IMETHOD GetAttention(int32_t aCycleCount) override;
|
||||
virtual bool HasPendingInputEvent() override;
|
||||
NS_IMETHOD SetIcon(const nsAString &anIconSpec) override;
|
||||
|
|
|
@ -1374,10 +1374,9 @@ class nsIWidget : public nsISupports
|
|||
virtual bool AsyncPanZoomEnabled() const = 0;
|
||||
|
||||
/**
|
||||
* Enables the dropping of files to a widget (XXX this is temporary)
|
||||
*
|
||||
* Enables the dropping of files to a widget.
|
||||
*/
|
||||
NS_IMETHOD EnableDragDrop(bool aEnable) = 0;
|
||||
virtual void EnableDragDrop(bool aEnable) = 0;
|
||||
|
||||
/**
|
||||
* Enables/Disables system mouse capture.
|
||||
|
|
|
@ -3507,34 +3507,29 @@ nsWindow::ClientToWindowSize(const LayoutDeviceIntSize& aClientSize)
|
|||
*
|
||||
**************************************************************/
|
||||
|
||||
NS_IMETHODIMP nsWindow::EnableDragDrop(bool aEnable)
|
||||
void
|
||||
nsWindow::EnableDragDrop(bool aEnable)
|
||||
{
|
||||
NS_ASSERTION(mWnd, "nsWindow::EnableDragDrop() called after Destroy()");
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (aEnable) {
|
||||
if (nullptr == mNativeDragTarget) {
|
||||
mNativeDragTarget = new nsNativeDragTarget(this);
|
||||
if (nullptr != mNativeDragTarget) {
|
||||
mNativeDragTarget->AddRef();
|
||||
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,TRUE,FALSE)) {
|
||||
if (S_OK == ::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget)) {
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mNativeDragTarget) {
|
||||
mNativeDragTarget = new nsNativeDragTarget(this);
|
||||
mNativeDragTarget->AddRef();
|
||||
if (SUCCEEDED(::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,
|
||||
TRUE, FALSE))) {
|
||||
::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nullptr != mWnd && nullptr != mNativeDragTarget) {
|
||||
if (mWnd && mNativeDragTarget) {
|
||||
::RevokeDragDrop(mWnd);
|
||||
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget, FALSE, TRUE)) {
|
||||
rv = NS_OK;
|
||||
}
|
||||
::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget, FALSE, TRUE);
|
||||
mNativeDragTarget->DragCancel();
|
||||
NS_RELEASE(mNativeDragTarget);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
|
|
|
@ -165,7 +165,7 @@ public:
|
|||
virtual LayoutDeviceIntSize ClientToWindowSize(const LayoutDeviceIntSize& aClientSize) override;
|
||||
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
||||
nsEventStatus& aStatus) override;
|
||||
NS_IMETHOD EnableDragDrop(bool aEnable) override;
|
||||
virtual void EnableDragDrop(bool aEnable) override;
|
||||
NS_IMETHOD CaptureMouse(bool aCapture) override;
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener,
|
||||
bool aDoCapture) override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче