2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2014-02-24 00:19:43 +04: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/. */
|
|
|
|
|
|
|
|
#include "nsColorPickerProxy.h"
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
#include "mozilla/dom/BrowserChild.h"
|
2014-02-24 00:19:43 +04:00
|
|
|
|
|
|
|
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,
|
2014-02-24 00:19:43 +04:00
|
|
|
const nsAString& aInitialColor) {
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild* browserChild = BrowserChild::GetFrom(aParent);
|
|
|
|
if (!browserChild) {
|
2014-02-24 00:19:43 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
browserChild->SendPColorPickerConstructor(this, nsString(aTitle),
|
|
|
|
nsString(aInitialColor));
|
2014-02-24 00:19:43 +04:00
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsColorPickerProxy::Open(
|
|
|
|
nsIColorPickerShownCallback* aColorPickerShownCallback) {
|
|
|
|
NS_ENSURE_STATE(!mCallback);
|
|
|
|
mCallback = aColorPickerShownCallback;
|
|
|
|
|
|
|
|
SendOpen();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult nsColorPickerProxy::RecvUpdate(const nsString& aColor) {
|
|
|
|
if (mCallback) {
|
|
|
|
mCallback->Update(aColor);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-02-24 00:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult nsColorPickerProxy::Recv__delete__(
|
|
|
|
const nsString& aColor) {
|
|
|
|
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
|
|
|
}
|