mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1345206 - Extract CSSPageRule base class. r=xidorn
Extract a `CSSPageRule` base class from the existing Gecko `nsCSSPageRule` class. This will be used in the next commit as the parent of a new `ServoPageRule` for the Servo variant. MozReview-Commit-ID: 1F3FWfVKH29 --HG-- extra : rebase_source : 5186cf2e233f3a757676a0127752faa8cc748cd4
This commit is contained in:
parent
ef7df34c21
commit
0ccdacdf3a
@ -241,11 +241,6 @@ DOMInterfaces = {
|
||||
'headerFile': 'nsCSSRules.h',
|
||||
},
|
||||
|
||||
'CSSPageRule': {
|
||||
'nativeType': 'nsCSSPageRule',
|
||||
'headerFile': 'nsCSSRules.h',
|
||||
},
|
||||
|
||||
'CSSPrimitiveValue': {
|
||||
'nativeType': 'nsROCSSPrimitiveValue',
|
||||
},
|
||||
|
36
layout/style/CSSPageRule.cpp
Normal file
36
layout/style/CSSPageRule.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#include "mozilla/dom/CSSPageRule.h"
|
||||
|
||||
#include "mozilla/dom/CSSPageRuleBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(CSSPageRule, css::Rule)
|
||||
NS_IMPL_RELEASE_INHERITED(CSSPageRule, css::Rule)
|
||||
|
||||
// QueryInterface implementation for CSSPageRule
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CSSPageRule)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSPageRule)
|
||||
NS_INTERFACE_MAP_END_INHERITING(css::Rule)
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSPageRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
||||
{
|
||||
NS_ADDREF(*aStyle = Style());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
CSSPageRule::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return CSSPageRuleBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
52
layout/style/CSSPageRule.h
Normal file
52
layout/style/CSSPageRule.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_CSSPageRule_h
|
||||
#define mozilla_dom_CSSPageRule_h
|
||||
|
||||
#include "mozilla/css/Rule.h"
|
||||
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsIDOMCSSPageRule.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class CSSPageRule : public css::Rule
|
||||
, public nsIDOMCSSPageRule
|
||||
{
|
||||
protected:
|
||||
using Rule::Rule;
|
||||
virtual ~CSSPageRule() {};
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMCSSPageRule interface
|
||||
NS_DECL_NSIDOMCSSPAGERULE
|
||||
|
||||
virtual bool IsCCLeaf() const override = 0;
|
||||
|
||||
int32_t GetType() const final { return Rule::PAGE_RULE; }
|
||||
using Rule::GetType;
|
||||
|
||||
// WebIDL interfaces
|
||||
uint16_t Type() const final { return nsIDOMCSSRule::PAGE_RULE; }
|
||||
virtual void GetCssTextImpl(nsAString& aCssText) const override = 0;
|
||||
virtual nsICSSDeclaration* Style() = 0;
|
||||
|
||||
virtual size_t
|
||||
SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
|
||||
|
||||
JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_CSSPageRule_h
|
@ -131,6 +131,7 @@ EXPORTS.mozilla.dom += [
|
||||
'CSSLexer.h',
|
||||
'CSSMediaRule.h',
|
||||
'CSSNamespaceRule.h',
|
||||
'CSSPageRule.h',
|
||||
'CSSRuleList.h',
|
||||
'CSSValue.h',
|
||||
'FontFace.h',
|
||||
@ -160,6 +161,7 @@ UNIFIED_SOURCES += [
|
||||
'CSS.cpp',
|
||||
'CSSLexer.cpp',
|
||||
'CSSMediaRule.cpp',
|
||||
'CSSPageRule.cpp',
|
||||
'CSSRuleList.cpp',
|
||||
'CSSStyleSheet.cpp',
|
||||
'CSSVariableDeclarations.cpp',
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "mozilla/dom/CSSImportRuleBinding.h"
|
||||
#include "mozilla/dom/CSSSupportsRuleBinding.h"
|
||||
#include "mozilla/dom/CSSMozDocumentRuleBinding.h"
|
||||
#include "mozilla/dom/CSSPageRuleBinding.h"
|
||||
#include "mozilla/dom/CSSFontFaceRuleBinding.h"
|
||||
#include "mozilla/dom/CSSFontFeatureValuesRuleBinding.h"
|
||||
#include "mozilla/dom/CSSKeyframeRuleBinding.h"
|
||||
@ -2161,7 +2160,7 @@ nsCSSPageStyleDeclaration::GetParentObject()
|
||||
|
||||
nsCSSPageRule::nsCSSPageRule(const nsCSSPageRule& aCopy)
|
||||
// copy everything except our reference count and mDOMDeclaration
|
||||
: Rule(aCopy)
|
||||
: dom::CSSPageRule(aCopy)
|
||||
, mDeclaration(new css::Declaration(*aCopy.mDeclaration))
|
||||
{
|
||||
mDeclaration->SetOwningRule(this);
|
||||
@ -2182,20 +2181,20 @@ nsCSSPageRule::Clone() const
|
||||
return clone.forget();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsCSSPageRule, mozilla::css::Rule)
|
||||
NS_IMPL_RELEASE_INHERITED(nsCSSPageRule, mozilla::css::Rule)
|
||||
NS_IMPL_ADDREF_INHERITED(nsCSSPageRule, dom::CSSPageRule)
|
||||
NS_IMPL_RELEASE_INHERITED(nsCSSPageRule, dom::CSSPageRule)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsCSSPageRule)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsCSSPageRule,
|
||||
mozilla::css::Rule)
|
||||
dom::CSSPageRule)
|
||||
if (tmp->mDOMDeclaration) {
|
||||
tmp->mDOMDeclaration->DropReference();
|
||||
tmp->mDOMDeclaration = nullptr;
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsCSSPageRule,
|
||||
mozilla::css::Rule)
|
||||
dom::CSSPageRule)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDOMDeclaration)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
@ -2208,8 +2207,7 @@ nsCSSPageRule::IsCCLeaf() const
|
||||
|
||||
// QueryInterface implementation for nsCSSPageRule
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsCSSPageRule)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSPageRule)
|
||||
NS_INTERFACE_MAP_END_INHERITING(mozilla::css::Rule)
|
||||
NS_INTERFACE_MAP_END_INHERITING(dom::CSSPageRule)
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
@ -2229,18 +2227,6 @@ nsCSSPageRule::List(FILE* out, int32_t aIndent) const
|
||||
}
|
||||
#endif
|
||||
|
||||
/* virtual */ int32_t
|
||||
nsCSSPageRule::GetType() const
|
||||
{
|
||||
return Rule::PAGE_RULE;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
nsCSSPageRule::Type() const
|
||||
{
|
||||
return nsIDOMCSSRule::PAGE_RULE;
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSPageRule::GetCssTextImpl(nsAString& aCssText) const
|
||||
{
|
||||
@ -2251,13 +2237,6 @@ nsCSSPageRule::GetCssTextImpl(nsAString& aCssText) const
|
||||
aCssText.AppendLiteral(" }");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCSSPageRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
||||
{
|
||||
NS_ADDREF(*aStyle = Style());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsICSSDeclaration*
|
||||
nsCSSPageRule::Style()
|
||||
{
|
||||
@ -2287,13 +2266,6 @@ nsCSSPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
return aMallocSizeOf(this);
|
||||
}
|
||||
|
||||
/* virtual */ JSObject*
|
||||
nsCSSPageRule::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return CSSPageRuleBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
CSSSupportsRule::CSSSupportsRule(bool aConditionMet,
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "mozilla/SheetType.h"
|
||||
#include "mozilla/css/GroupRule.h"
|
||||
#include "mozilla/dom/CSSMediaRule.h"
|
||||
#include "mozilla/dom/CSSPageRule.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCSSPropertyID.h"
|
||||
#include "nsCSSValue.h"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "nsIDOMCSSFontFeatureValuesRule.h"
|
||||
#include "nsIDOMCSSGroupingRule.h"
|
||||
#include "nsIDOMCSSMozDocumentRule.h"
|
||||
#include "nsIDOMCSSPageRule.h"
|
||||
#include "nsIDOMCSSSupportsRule.h"
|
||||
#include "nsIDOMCSSKeyframeRule.h"
|
||||
#include "nsIDOMCSSKeyframesRule.h"
|
||||
@ -405,13 +405,12 @@ protected:
|
||||
nsCSSPageRule* MOZ_NON_OWNING_REF mRule;
|
||||
};
|
||||
|
||||
class nsCSSPageRule final : public mozilla::css::Rule,
|
||||
public nsIDOMCSSPageRule
|
||||
class nsCSSPageRule final : public mozilla::dom::CSSPageRule
|
||||
{
|
||||
public:
|
||||
nsCSSPageRule(mozilla::css::Declaration* aDeclaration,
|
||||
uint32_t aLineNumber, uint32_t aColumnNumber)
|
||||
: mozilla::css::Rule(aLineNumber, aColumnNumber)
|
||||
: mozilla::dom::CSSPageRule(aLineNumber, aColumnNumber)
|
||||
, mDeclaration(aDeclaration)
|
||||
{
|
||||
mDeclaration->SetOwningRule(this);
|
||||
@ -421,23 +420,17 @@ private:
|
||||
~nsCSSPageRule();
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsCSSPageRule, mozilla::css::Rule)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsCSSPageRule, mozilla::dom::CSSPageRule)
|
||||
virtual bool IsCCLeaf() const override;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
|
||||
#endif
|
||||
virtual int32_t GetType() const override;
|
||||
using Rule::GetType;
|
||||
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
|
||||
|
||||
// nsIDOMCSSPageRule interface
|
||||
NS_DECL_NSIDOMCSSPAGERULE
|
||||
|
||||
// WebIDL interface
|
||||
uint16_t Type() const override;
|
||||
void GetCssTextImpl(nsAString& aCssText) const override;
|
||||
nsICSSDeclaration* Style();
|
||||
// WebIDL interfaces
|
||||
virtual void GetCssTextImpl(nsAString& aCssText) const override;
|
||||
virtual nsICSSDeclaration* Style() override;
|
||||
|
||||
mozilla::css::Declaration* Declaration() { return mDeclaration; }
|
||||
|
||||
@ -445,9 +438,6 @@ public:
|
||||
|
||||
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
private:
|
||||
RefPtr<mozilla::css::Declaration> mDeclaration;
|
||||
// lazily created when needed:
|
||||
|
Loading…
Reference in New Issue
Block a user