widget/xpwidgets/nsColorPickerProxy.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/xpwidgets/nsColorPickerProxy.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsColorPickerProxy.h"
    1.11 +
    1.12 +#include "mozilla/dom/TabChild.h"
    1.13 +
    1.14 +using namespace mozilla::dom;
    1.15 +
    1.16 +NS_IMPL_ISUPPORTS(nsColorPickerProxy, nsIColorPicker)
    1.17 +
    1.18 +/* void init (in nsIDOMWindow parent, in AString title, in short mode); */
    1.19 +NS_IMETHODIMP
    1.20 +nsColorPickerProxy::Init(nsIDOMWindow* aParent, const nsAString& aTitle,
    1.21 +                         const nsAString& aInitialColor)
    1.22 +{
    1.23 +  TabChild* tabChild = TabChild::GetFrom(aParent);
    1.24 +  if (!tabChild) {
    1.25 +    return NS_ERROR_FAILURE;
    1.26 +  }
    1.27 +
    1.28 +  tabChild->SendPColorPickerConstructor(this,
    1.29 +                                        nsString(aTitle),
    1.30 +                                        nsString(aInitialColor));
    1.31 +  NS_ADDREF_THIS();
    1.32 +  return NS_OK;
    1.33 +}
    1.34 +
    1.35 +/* void open (in nsIColorPickerShownCallback aColorPickerShownCallback); */
    1.36 +NS_IMETHODIMP
    1.37 +nsColorPickerProxy::Open(nsIColorPickerShownCallback* aColorPickerShownCallback)
    1.38 +{
    1.39 +  NS_ENSURE_STATE(!mCallback);
    1.40 +  mCallback = aColorPickerShownCallback;
    1.41 +
    1.42 +  SendOpen();
    1.43 +  return NS_OK;
    1.44 +}
    1.45 +
    1.46 +bool
    1.47 +nsColorPickerProxy::RecvUpdate(const nsString& aColor)
    1.48 +{
    1.49 +  if (mCallback) {
    1.50 +    mCallback->Update(aColor);
    1.51 +  }
    1.52 +  return true;
    1.53 +}
    1.54 +
    1.55 +bool
    1.56 +nsColorPickerProxy::Recv__delete__(const nsString& aColor)
    1.57 +{
    1.58 +  if (mCallback) {
    1.59 +    mCallback->Done(aColor);
    1.60 +    mCallback = nullptr;
    1.61 +  }
    1.62 +  return true;
    1.63 +}
    1.64 \ No newline at end of file

mercurial