2014-02-24 00:19:43 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#include "nsColorPickerProxy.h"
|
|
|
|
|
|
|
|
#include "mozilla/dom/TabChild.h"
|
|
|
|
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsColorPickerProxy, nsIColorPicker)
|
2014-02-24 00:19:43 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-01-30 20:05:36 +03:00
|
|
|
nsColorPickerProxy::Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle,
|
2018-11-30 13:46:48 +03:00
|
|
|
const nsAString& aInitialColor) {
|
2014-02-24 00:19:43 +04:00
|
|
|
TabChild* tabChild = TabChild::GetFrom(aParent);
|
|
|
|
if (!tabChild) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
tabChild->SendPColorPickerConstructor(this, nsString(aTitle),
|
2014-02-24 00:19:43 +04:00
|
|
|
nsString(aInitialColor));
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2018-11-30 13:46:48 +03:00
|
|
|
nsColorPickerProxy::Open(
|
|
|
|
nsIColorPickerShownCallback* aColorPickerShownCallback) {
|
2014-02-24 00:19:43 +04:00
|
|
|
NS_ENSURE_STATE(!mCallback);
|
|
|
|
mCallback = aColorPickerShownCallback;
|
|
|
|
|
|
|
|
SendOpen();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
mozilla::ipc::IPCResult nsColorPickerProxy::RecvUpdate(const nsString& aColor) {
|
2014-02-24 00:19:43 +04:00
|
|
|
if (mCallback) {
|
|
|
|
mCallback->Update(aColor);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-02-24 00:19:43 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
mozilla::ipc::IPCResult nsColorPickerProxy::Recv__delete__(
|
|
|
|
const nsString& aColor) {
|
2014-02-24 00:19:43 +04:00
|
|
|
if (mCallback) {
|
|
|
|
mCallback->Done(aColor);
|
|
|
|
mCallback = nullptr;
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-08-05 02:17:36 +03:00
|
|
|
}
|