Skip to content

Instantly share code, notes, and snippets.

@Mossop
Created April 25, 2018 03:26
Show Gist options
  • Save Mossop/3edcb78c680d151b43e6dbe5245895bf to your computer and use it in GitHub Desktop.
Save Mossop/3edcb78c680d151b43e6dbe5245895bf to your computer and use it in GitHub Desktop.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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 "mozilla/dom/DocumentL10n.h"
#include "mozilla/dom/DocumentL10nBinding.h"
namespace mozilla {
namespace dom {
// Only needed for refcounted objects.
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DocumentL10n)
NS_IMPL_CYCLE_COLLECTING_ADDREF(DocumentL10n)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DocumentL10n)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DocumentL10n)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
DocumentL10n::DocumentL10n(nsIDocument* aDocument)
: mDocument(aDocument)
{
}
DocumentL10n::~DocumentL10n()
{
}
JSObject*
DocumentL10n::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return DocumentL10nBinding::Wrap(aCx, this, aGivenProto);
}
void
DocumentL10n::SetAttributes(JSContext* cx, Element& aElement, const nsAString& aId, JS::Handle<JS::Value> aArgs)
{
}
// Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
already_AddRefed<Promise>
DocumentL10n::FormatValue(JSContext* cx, const nsAString& aId, JS::Handle<JS::Value> aArgs)
{
return nullptr;
}
// Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
already_AddRefed<Promise>
DocumentL10n::FormatValues(JSContext* cx, const Sequence<JS::Value>& aKeys)
{
return nullptr;
}
} // namespace dom
} // namespace mozilla
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#ifndef mozilla_dom_DocumentL10n_h
#define mozilla_dom_DocumentL10n_h
#include "js/TypeDecls.h"
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "nsIDocument.h"
namespace mozilla {
namespace dom {
class Element;
class Promise;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
class DocumentL10n final : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DocumentL10n)
public:
DocumentL10n(nsIDocument* aDocument);
protected:
~DocumentL10n();
RefPtr<nsIDocument> mDocument;
public:
// TODO: return something sensible here, and change the return type
nsIDocument* GetParentObject() const { return mDocument; };
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void SetAttributes(JSContext* cx, Element& aElement, const nsAString& aId, JS::Handle<JS::Value> aArgs);
already_AddRefed<Promise> FormatValue(JSContext* cx, const nsAString& aId, JS::Handle<JS::Value> aArgs);
already_AddRefed<Promise> FormatValues(JSContext* cx, const Sequence<JS::Value>& aKeys);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_DocumentL10n_h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment