Bug 1028497 - Part 3: Add skeleton implementations of CSSFontFaceLoadEvent, FontFace, FontFaceSet and FontFaceSource. r=jdaggett

This commit is contained in:
Cameron McCormack 2014-10-02 12:32:05 +10:00
parent 8c4dd6fb24
commit 0634734915
8 changed files with 403 additions and 1 deletions

View File

@ -106,6 +106,7 @@ class Element;
struct ElementRegistrationOptions;
class Event;
class EventTarget;
class FontFaceSet;
class FrameRequestCallback;
class ImportManager;
class OverfillCallback;
@ -2390,6 +2391,9 @@ public:
}
}
// FontFaceSource
mozilla::dom::FontFaceSet* GetFonts(mozilla::ErrorResult& aRv);
private:
uint64_t mWarnedAbout;
SelectorCache mSelectorCache;

View File

@ -223,6 +223,7 @@
#include "mozilla/dom/DOMStringList.h"
#include "nsWindowMemoryReporter.h"
#include "nsLocation.h"
#include "mozilla/dom/FontFaceSet.h"
#ifdef MOZ_MEDIA_NAVIGATOR
#include "mozilla/MediaManager.h"
@ -12415,3 +12416,9 @@ nsAutoSyncOperation::~nsAutoSyncOperation()
nsContentUtils::SetMicroTaskLevel(mMicroTaskLevel);
}
FontFaceSet*
nsIDocument::GetFonts(ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}

View File

@ -775,6 +775,9 @@ GK_ATOM(onlanguagechange, "onlanguagechange")
GK_ATOM(onlevelchange, "onlevelchange")
GK_ATOM(onLoad, "onLoad")
GK_ATOM(onload, "onload")
GK_ATOM(onloading, "onloading")
GK_ATOM(onloadingdone, "onloadingdone")
GK_ATOM(onloadingerror, "onloadingerror")
GK_ATOM(onpopstate, "onpopstate")
GK_ATOM(only, "only") // this one is not an event
GK_ATOM(onmessage, "onmessage")

139
layout/style/FontFace.cpp Normal file
View File

@ -0,0 +1,139 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/FontFace.h"
#include "mozilla/dom/FontFaceBinding.h"
#include "mozilla/dom/Promise.h"
using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FontFace, mParent, mLoaded)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FontFace)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(FontFace)
NS_IMPL_CYCLE_COLLECTING_RELEASE(FontFace)
FontFace::FontFace(nsISupports* aParent)
: mParent(aParent)
{
MOZ_COUNT_CTOR(FontFace);
SetIsDOMBinding();
}
FontFace::~FontFace()
{
MOZ_COUNT_DTOR(FontFace);
}
JSObject*
FontFace::WrapObject(JSContext* aCx)
{
return FontFaceBinding::Wrap(aCx, this);
}
already_AddRefed<FontFace>
FontFace::Constructor(const GlobalObject& aGlobal,
const nsAString& aFamily,
const StringOrArrayBufferOrArrayBufferView& aSource,
const FontFaceDescriptors& aDescriptors,
ErrorResult& aRV)
{
nsRefPtr<FontFace> obj = new FontFace(aGlobal.GetAsSupports());
return obj.forget();
}
void
FontFace::GetFamily(nsString& aResult)
{
}
void
FontFace::SetFamily(const nsAString& aValue, ErrorResult& aRv)
{
}
void
FontFace::GetStyle(nsString& aResult)
{
}
void
FontFace::SetStyle(const nsAString& aValue, ErrorResult& aRv)
{
}
void
FontFace::GetWeight(nsString& aResult)
{
}
void
FontFace::SetWeight(const nsAString& aValue, ErrorResult& aRv)
{
}
void
FontFace::GetStretch(nsString& aResult)
{
}
void
FontFace::SetStretch(const nsAString& aValue, ErrorResult& aRv)
{
}
void
FontFace::GetUnicodeRange(nsString& aResult)
{
}
void
FontFace::SetUnicodeRange(const nsAString& aValue, ErrorResult& aRv)
{
}
void
FontFace::GetVariant(nsString& aResult)
{
}
void
FontFace::SetVariant(const nsAString& aValue, ErrorResult& aRv)
{
}
void
FontFace::GetFeatureSettings(nsString& aResult)
{
}
void
FontFace::SetFeatureSettings(const nsAString& aValue, ErrorResult& aRv)
{
}
FontFaceLoadStatus
FontFace::Status()
{
return FontFaceLoadStatus::Unloaded;
}
Promise*
FontFace::Load()
{
return Loaded();
}
Promise*
FontFace::Loaded()
{
return nullptr;
}

71
layout/style/FontFace.h Normal file
View File

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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_FontFace_h
#define mozilla_dom_FontFace_h
#include "nsWrapperCache.h"
#include "mozilla/dom/FontFaceBinding.h"
namespace mozilla {
namespace dom {
struct FontFaceDescriptors;
class Promise;
class StringOrArrayBufferOrArrayBufferView;
}
}
namespace mozilla {
namespace dom {
class FontFace MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FontFace)
nsISupports* GetParentObject() const { return mParent; }
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// Web IDL
static already_AddRefed<FontFace>
Constructor(const GlobalObject& aGlobal,
const nsAString& aFamily,
const mozilla::dom::StringOrArrayBufferOrArrayBufferView& aSource,
const mozilla::dom::FontFaceDescriptors& aDescriptors,
ErrorResult& aRV);
void GetFamily(nsString& aResult);
void SetFamily(const nsAString& aValue, mozilla::ErrorResult& aRv);
void GetStyle(nsString& aResult);
void SetStyle(const nsAString& aValue, mozilla::ErrorResult& aRv);
void GetWeight(nsString& aResult);
void SetWeight(const nsAString& aValue, mozilla::ErrorResult& aRv);
void GetStretch(nsString& aResult);
void SetStretch(const nsAString& aValue, mozilla::ErrorResult& aRv);
void GetUnicodeRange(nsString& aResult);
void SetUnicodeRange(const nsAString& aValue, mozilla::ErrorResult& aRv);
void GetVariant(nsString& aResult);
void SetVariant(const nsAString& aValue, mozilla::ErrorResult& aRv);
void GetFeatureSettings(nsString& aResult);
void SetFeatureSettings(const nsAString& aValue, mozilla::ErrorResult& aRv);
mozilla::dom::FontFaceLoadStatus Status();
mozilla::dom::Promise* Load();
mozilla::dom::Promise* Loaded();
private:
FontFace(nsISupports* aParent);
~FontFace();
nsCOMPtr<nsISupports> mParent;
nsRefPtr<mozilla::dom::Promise> mLoaded;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_FontFace_h)

View File

@ -0,0 +1,109 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 "FontFaceSet.h"
#include "mozilla/dom/FontFaceSetBinding.h"
#include "mozilla/dom/Promise.h"
using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_INHERITED(FontFaceSet,
DOMEventTargetHelper,
mReady)
NS_IMPL_ADDREF_INHERITED(FontFaceSet, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(FontFaceSet, DOMEventTargetHelper)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FontFaceSet)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
FontFaceSet::FontFaceSet(nsPIDOMWindow* aWindow)
: DOMEventTargetHelper(aWindow)
{
MOZ_COUNT_CTOR(FontFaceSet);
}
FontFaceSet::~FontFaceSet()
{
MOZ_COUNT_DTOR(FontFaceSet);
}
JSObject*
FontFaceSet::WrapObject(JSContext* aContext)
{
return FontFaceSetBinding::Wrap(aContext, this);
}
already_AddRefed<Promise>
FontFaceSet::Load(const nsAString& aFont,
const nsAString& aText,
ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
}
bool
FontFaceSet::Check(const nsAString& aFont,
const nsAString& aText,
ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return false;
}
Promise*
FontFaceSet::GetReady(ErrorResult& aRv)
{
if (!mReady) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
return mReady;
}
FontFaceSetLoadStatus
FontFaceSet::Status()
{
return FontFaceSetLoadStatus::Loaded;
}
FontFaceSet*
FontFaceSet::Add(FontFace& aFontFace, ErrorResult& aRv)
{
return this;
}
void
FontFaceSet::Clear()
{
}
bool
FontFaceSet::Delete(FontFace& aFontFace, ErrorResult& aRv)
{
return false;
}
bool
FontFaceSet::Has(FontFace& aFontFace)
{
return false;
}
FontFace*
FontFaceSet::IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = false;
return nullptr;
}
uint32_t
FontFaceSet::Length()
{
return 0;
}

View File

@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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_FontFaceSet_h
#define mozilla_dom_FontFaceSet_h
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/FontFaceSetBinding.h"
#include "nsPIDOMWindow.h"
class nsPIDOMWindow;
namespace mozilla {
namespace dom {
class FontFace;
class Promise;
}
}
namespace mozilla {
namespace dom {
class FontFaceSet MOZ_FINAL : public DOMEventTargetHelper
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FontFaceSet, DOMEventTargetHelper)
FontFaceSet(nsPIDOMWindow* aWindow);
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// Web IDL
IMPL_EVENT_HANDLER(loading)
IMPL_EVENT_HANDLER(loadingdone)
IMPL_EVENT_HANDLER(loadingerror)
already_AddRefed<mozilla::dom::Promise> Load(const nsAString& aFont,
const nsAString& aText,
mozilla::ErrorResult& aRv);
bool Check(const nsAString& aFont,
const nsAString& aText,
mozilla::ErrorResult& aRv);
mozilla::dom::Promise* GetReady(mozilla::ErrorResult& aRv);
mozilla::dom::FontFaceSetLoadStatus Status();
FontFaceSet* Add(FontFace& aFontFace, mozilla::ErrorResult& aRv);
void Clear();
bool Delete(FontFace& aFontFace, mozilla::ErrorResult& aRv);
bool Has(FontFace& aFontFace);
FontFace* IndexedGetter(uint32_t aIndex, bool& aFound);
uint32_t Length();
private:
~FontFaceSet();
nsRefPtr<mozilla::dom::Promise> mReady;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_FontFaceSet_h)

View File

@ -68,6 +68,8 @@ EXPORTS.mozilla.dom += [
'CSS.h',
'CSSRuleList.h',
'CSSValue.h',
'FontFace.h',
'FontFaceSet.h',
'MediaQueryList.h',
]
@ -94,6 +96,7 @@ UNIFIED_SOURCES += [
'CSSVariableValues.cpp',
'Declaration.cpp',
'ErrorReporter.cpp',
'FontFace.cpp',
'ImageLoader.cpp',
'Loader.cpp',
'MediaQueryList.cpp',
@ -135,8 +138,10 @@ UNIFIED_SOURCES += [
]
# nsCSSRuleProcessor.cpp needs to be built separately because it uses plarena.h.
# nsFontFaceLoader.cpp needs to be built separately because it forces NSPR logging.
# FontFaceSet.cpp and nsFontFaceLoader.cpp need to be built separately because
# they force NSPR logging.
SOURCES += [
'FontFaceSet.cpp',
'nsCSSRuleProcessor.cpp',
'nsFontFaceLoader.cpp',
]