Bug 1793579 [wpt PR 36253] - Set empty string for reflection of IDREF attributes...
[gecko.git] / widget / nsColorPickerProxy.cpp
blob95ca2bf192b55ac319668f12046b026e26f805ba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsColorPickerProxy.h"
9 #include "mozilla/dom/BrowserChild.h"
11 using namespace mozilla::dom;
13 NS_IMPL_ISUPPORTS(nsColorPickerProxy, nsIColorPicker)
15 NS_IMETHODIMP
16 nsColorPickerProxy::Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle,
17 const nsAString& aInitialColor) {
18 BrowserChild* browserChild = BrowserChild::GetFrom(aParent);
19 if (!browserChild) {
20 return NS_ERROR_FAILURE;
23 browserChild->SendPColorPickerConstructor(this, nsString(aTitle),
24 nsString(aInitialColor));
25 NS_ADDREF_THIS();
26 return NS_OK;
29 NS_IMETHODIMP
30 nsColorPickerProxy::Open(
31 nsIColorPickerShownCallback* aColorPickerShownCallback) {
32 NS_ENSURE_STATE(!mCallback);
33 mCallback = aColorPickerShownCallback;
35 SendOpen();
36 return NS_OK;
39 mozilla::ipc::IPCResult nsColorPickerProxy::RecvUpdate(
40 const nsAString& aColor) {
41 if (mCallback) {
42 mCallback->Update(aColor);
44 return IPC_OK();
47 mozilla::ipc::IPCResult nsColorPickerProxy::Recv__delete__(
48 const nsAString& aColor) {
49 if (mCallback) {
50 mCallback->Done(aColor);
51 mCallback = nullptr;
53 return IPC_OK();