2016-02-02 01:49:00 +03:00
|
|
|
/* -*- 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"
|
2016-02-16 17:08:00 +03:00
|
|
|
#include "mozilla/dom/Element.h"
|
2016-02-02 01:59:00 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "nsCSSPseudoElements.h"
|
2016-02-02 01:49:00 +03:00
|
|
|
#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:
|
2016-02-02 01:59:00 +03:00
|
|
|
virtual ~CSSPseudoElement();
|
2016-02-02 01:49:00 +03:00
|
|
|
|
|
|
|
public:
|
2016-02-15 03:51:34 +03:00
|
|
|
ParentObject GetParentObject() const;
|
2016-02-02 01:49:00 +03:00
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType GetType() const { return mPseudoType; }
|
2016-02-02 01:59:00 +03:00
|
|
|
void GetType(nsString& aRetVal) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(nsCSSPseudoElements::GetPseudoAtom(mPseudoType),
|
|
|
|
"All pseudo-types allowed by this class should have a"
|
|
|
|
" corresponding atom");
|
2016-02-18 21:35:00 +03:00
|
|
|
// Our atoms use one colon and we would like to return two colons syntax
|
|
|
|
// for the returned pseudo type string, so serialize this to the
|
|
|
|
// non-deprecated two colon syntax.
|
|
|
|
aRetVal.Assign(char16_t(':'));
|
|
|
|
aRetVal.Append(
|
|
|
|
nsDependentAtomString(nsCSSPseudoElements::GetPseudoAtom(mPseudoType)));
|
2016-02-02 01:59:00 +03:00
|
|
|
}
|
|
|
|
already_AddRefed<Element> ParentElement() const
|
|
|
|
{
|
|
|
|
RefPtr<Element> retVal(mParentElement);
|
|
|
|
return retVal.forget();
|
|
|
|
}
|
2016-02-02 01:49:00 +03:00
|
|
|
|
2016-03-22 03:33:02 +03:00
|
|
|
void GetAnimations(const AnimationFilter& filter,
|
|
|
|
nsTArray<RefPtr<Animation>>& aRetVal);
|
2016-02-02 01:49:00 +03:00
|
|
|
already_AddRefed<Animation>
|
|
|
|
Animate(JSContext* aContext,
|
2016-05-13 03:40:52 +03:00
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
2016-02-02 01:49:00 +03:00
|
|
|
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
|
|
|
ErrorResult& aError);
|
2016-02-02 01:59:00 +03:00
|
|
|
|
|
|
|
// Given an element:pseudoType pair, returns the CSSPseudoElement stored as a
|
|
|
|
// property on |aElement|. If there is no CSSPseudoElement for the specified
|
|
|
|
// pseudo-type on element, a new CSSPseudoElement will be created and stored
|
|
|
|
// on the element.
|
|
|
|
static already_AddRefed<CSSPseudoElement>
|
2016-02-17 23:37:00 +03:00
|
|
|
GetCSSPseudoElement(Element* aElement, CSSPseudoElementType aType);
|
2016-02-02 01:59:00 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Only ::before and ::after are supported.
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElement(Element* aElement, CSSPseudoElementType aType);
|
2016-02-02 01:59:00 +03:00
|
|
|
|
2016-02-17 23:37:00 +03:00
|
|
|
static nsIAtom* GetCSSPseudoElementPropertyAtom(CSSPseudoElementType aType);
|
2016-02-02 01:59:00 +03:00
|
|
|
|
|
|
|
// mParentElement needs to be an owning reference since if script is holding
|
|
|
|
// on to the pseudo-element, it needs to continue to be able to refer to
|
|
|
|
// the parent element.
|
|
|
|
RefPtr<Element> mParentElement;
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType mPseudoType;
|
2016-02-02 01:49:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_CSSPseudoElement_h
|