2016-11-23 02:26:20 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=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/. */
|
|
|
|
|
|
|
|
/* representation of CSSStyleRule for stylo */
|
|
|
|
|
|
|
|
#ifndef mozilla_ServoStyleRule_h
|
|
|
|
#define mozilla_ServoStyleRule_h
|
|
|
|
|
2017-01-13 18:41:03 +03:00
|
|
|
#include "mozilla/BindingStyleRule.h"
|
2016-11-23 02:26:20 +03:00
|
|
|
#include "mozilla/ServoBindingTypes.h"
|
|
|
|
|
|
|
|
#include "nsIDOMCSSStyleRule.h"
|
2016-11-23 02:26:20 +03:00
|
|
|
#include "nsDOMCSSDeclaration.h"
|
2016-11-23 02:26:20 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
class ServoDeclarationBlock;
|
2016-11-23 02:53:01 +03:00
|
|
|
class ServoStyleRule;
|
2016-11-23 02:26:20 +03:00
|
|
|
|
|
|
|
class ServoStyleRuleDeclaration final : public nsDOMCSSDeclaration
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParent) final;
|
|
|
|
nsINode* GetParentObject() final;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DeclarationBlock* GetCSSDeclaration(Operation aOperation) final;
|
|
|
|
nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final;
|
|
|
|
nsIDocument* DocToUpdate() final;
|
|
|
|
void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) final;
|
2017-04-04 09:09:20 +03:00
|
|
|
URLExtraData* GetURLData() const final;
|
2016-11-23 02:26:20 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
// For accessing the constructor.
|
|
|
|
friend class ServoStyleRule;
|
|
|
|
|
|
|
|
explicit ServoStyleRuleDeclaration(
|
|
|
|
already_AddRefed<RawServoDeclarationBlock> aDecls);
|
|
|
|
~ServoStyleRuleDeclaration();
|
|
|
|
|
|
|
|
inline ServoStyleRule* Rule();
|
2017-04-04 09:07:44 +03:00
|
|
|
inline const ServoStyleRule* Rule() const;
|
2016-11-23 02:26:20 +03:00
|
|
|
|
|
|
|
RefPtr<ServoDeclarationBlock> mDecls;
|
|
|
|
};
|
|
|
|
|
2017-01-13 18:41:03 +03:00
|
|
|
class ServoStyleRule final : public BindingStyleRule
|
2016-11-23 02:26:20 +03:00
|
|
|
, public nsIDOMCSSStyleRule
|
|
|
|
{
|
|
|
|
public:
|
2016-11-23 02:26:20 +03:00
|
|
|
explicit ServoStyleRule(already_AddRefed<RawServoStyleRule> aRawRule);
|
2016-11-23 02:26:20 +03:00
|
|
|
|
2016-12-01 02:18:14 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ServoStyleRule,
|
2016-11-23 02:26:20 +03:00
|
|
|
css::Rule)
|
2017-04-01 00:13:12 +03:00
|
|
|
virtual bool IsCCLeaf() const final MOZ_MUST_OVERRIDE;
|
2016-11-23 02:26:20 +03:00
|
|
|
NS_DECL_NSIDOMCSSSTYLERULE
|
|
|
|
|
2017-01-13 18:41:02 +03:00
|
|
|
// WebIDL interface
|
2017-04-01 00:13:12 +03:00
|
|
|
uint16_t Type() const final;
|
|
|
|
void GetCssTextImpl(nsAString& aCssText) const final;
|
|
|
|
virtual nsICSSDeclaration* Style() final;
|
2017-01-13 18:41:02 +03:00
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
RawServoStyleRule* Raw() const { return mRawRule; }
|
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
// Methods of mozilla::css::Rule
|
|
|
|
int32_t GetType() const final { return css::Rule::STYLE_RULE; }
|
2017-01-13 18:41:02 +03:00
|
|
|
using Rule::GetType;
|
2016-11-23 02:26:20 +03:00
|
|
|
already_AddRefed<Rule> Clone() const final;
|
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
|
|
|
|
#ifdef DEBUG
|
|
|
|
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
~ServoStyleRule() {}
|
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
// For computing the offset of mDecls.
|
|
|
|
friend class ServoStyleRuleDeclaration;
|
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
RefPtr<RawServoStyleRule> mRawRule;
|
2016-11-23 02:26:20 +03:00
|
|
|
ServoStyleRuleDeclaration mDecls;
|
2016-11-23 02:26:20 +03:00
|
|
|
};
|
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
ServoStyleRule*
|
|
|
|
ServoStyleRuleDeclaration::Rule()
|
|
|
|
{
|
2017-04-04 09:07:44 +03:00
|
|
|
return reinterpret_cast<ServoStyleRule*>(
|
|
|
|
reinterpret_cast<uint8_t*>(this) - offsetof(ServoStyleRule, mDecls));
|
|
|
|
}
|
|
|
|
|
|
|
|
const ServoStyleRule*
|
|
|
|
ServoStyleRuleDeclaration::Rule() const
|
|
|
|
{
|
|
|
|
return reinterpret_cast<const ServoStyleRule*>(
|
|
|
|
reinterpret_cast<const uint8_t*>(this) - offsetof(ServoStyleRule, mDecls));
|
2016-11-23 02:26:20 +03:00
|
|
|
}
|
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ServoStyleRule_h
|