Bug 1174575 - Part 1: Define CSSPseudoElement interface. r=birtles, r=smaug

Create CSSPseudoElement.webidl, CSSPseudoElement.h, and CSSPseudoElement.cpp.
This commit is contained in:
Boris Chiou 2016-02-01 23:49:00 +01:00
parent c96e12bdd2
commit fc4ed7c615
7 changed files with 133 additions and 0 deletions

View File

@ -0,0 +1,44 @@
/* -*- 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/CSSPseudoElement.h"
#include "mozilla/dom/CSSPseudoElementBinding.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(CSSPseudoElement)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(CSSPseudoElement, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(CSSPseudoElement, Release)
JSObject*
CSSPseudoElement::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return CSSPseudoElementBinding::Wrap(aCx, this, aGivenProto);
}
void
CSSPseudoElement::GetAnimations(nsTArray<RefPtr<Animation>>& aRetVal)
{
// Bug 1234403: Implement this API.
NS_NOTREACHED("CSSPseudoElement::GetAnimations() is not implemented yet.");
}
already_AddRefed<Animation>
CSSPseudoElement::Animate(
JSContext* aContext,
JS::Handle<JSObject*> aFrames,
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
ErrorResult& aError)
{
// Bug 1241784: Implement this API.
NS_NOTREACHED("CSSPseudoElement::Animate() is not implemented yet.");
return nullptr;
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,56 @@
/* -*- 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_CSSPseudoElement_h
#define mozilla_dom_CSSPseudoElement_h
#include "js/TypeDecls.h"
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsWrapperCache.h"
namespace mozilla {
namespace dom {
class Animation;
class Element;
class UnrestrictedDoubleOrKeyframeAnimationOptions;
class CSSPseudoElement final : public nsWrapperCache
{
public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CSSPseudoElement)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CSSPseudoElement)
protected:
virtual ~CSSPseudoElement() = default;
public:
ParentObject GetParentObject() const
{
// This will be implemented in later patch.
return ParentObject(nullptr, nullptr);
}
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
void GetType(nsString& aRetVal) const { }
already_AddRefed<Element> ParentElement() const { return nullptr; }
void GetAnimations(nsTArray<RefPtr<Animation>>& aRetVal);
already_AddRefed<Animation>
Animate(JSContext* aContext,
JS::Handle<JSObject*> aFrames,
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
ErrorResult& aError);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_CSSPseudoElement_h

View File

@ -12,6 +12,7 @@ EXPORTS.mozilla.dom += [
'AnimationEffectReadOnly.h',
'AnimationEffectTimingReadOnly.h',
'AnimationTimeline.h',
'CSSPseudoElement.h',
'DocumentTimeline.h',
'KeyframeEffect.h',
]
@ -35,6 +36,7 @@ UNIFIED_SOURCES += [
'AnimationUtils.cpp',
'AnimValuesStyleRule.cpp',
'ComputedTimingFunction.cpp',
'CSSPseudoElement.cpp',
'DocumentTimeline.cpp',
'EffectCompositor.cpp',
'EffectSet.cpp',

View File

@ -351,6 +351,8 @@ var interfaceNamesInGlobalScope =
"CSSPageRule",
// IMPORTANT: Do not change this list without review from a DOM peer!
"CSSPrimitiveValue",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSPseudoElement", release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
"CSSRule",
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -0,0 +1,25 @@
/* -*- Mode: IDL; 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/.
*
* The origin of this IDL file is
* https://drafts.csswg.org/css-pseudo/#CSSPseudoElement-interface
* https://drafts.csswg.org/cssom/#pseudoelement
*
* Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
// Both CSSOM and CSS Pseudo-Elements 4 provide contradictory definitions for
// this interface.
// What we implement here is a minimal subset of the two definitions which we
// ship behind a pref until the specification issues have been resolved.
[Func="nsDocument::IsWebAnimationsEnabled"]
interface CSSPseudoElement {
readonly attribute DOMString type;
readonly attribute Element parentElement;
};
// https://w3c.github.io/web-animations/#extensions-to-the-pseudoelement-interface
CSSPseudoElement implements Animatable;

View File

@ -97,6 +97,7 @@ WEBIDL_FILES = [
'CSSAnimation.webidl',
'CSSLexer.webidl',
'CSSPrimitiveValue.webidl',
'CSSPseudoElement.webidl',
'CSSRuleList.webidl',
'CSSStyleDeclaration.webidl',
'CSSStyleSheet.webidl',

View File

@ -2535,6 +2535,9 @@ pref("layout.spammy_warnings.enabled", false);
pref("layout.float-fragments-inside-column.enabled", true);
// Is support for the Web Animations API enabled?
// Before enabling this by default, make sure also CSSPseudoElement interface
// has been spec'ed properly, or we should add a separate pref for
// CSSPseudoElement interface. See Bug 1174575 for further details.
#ifdef RELEASE_BUILD
pref("dom.animations-api.core.enabled", false);
#else