зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1290218 Part 5: Subclass StyleSheetInfo to move the ServoStyleSheet raw sheet into its mInner. r=heycam
MozReview-Commit-ID: Cu0qp3e8L5n --HG-- extra : rebase_source : ab24fcba44e8ccfccbaf81f17e3511a2904a4ce4
This commit is contained in:
Родитель
3f6506d5fc
Коммит
5b02746302
|
@ -18,13 +18,24 @@ using namespace mozilla::dom;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
// -------------------------------
|
||||
// CSS Style Sheet Inner Data Container
|
||||
//
|
||||
|
||||
ServoStyleSheetInner::ServoStyleSheetInner(CORSMode aCORSMode,
|
||||
ReferrerPolicy aReferrerPolicy,
|
||||
const SRIMetadata& aIntegrity)
|
||||
: StyleSheetInfo(aCORSMode, aReferrerPolicy, aIntegrity)
|
||||
{
|
||||
}
|
||||
|
||||
ServoStyleSheet::ServoStyleSheet(css::SheetParsingMode aParsingMode,
|
||||
CORSMode aCORSMode,
|
||||
net::ReferrerPolicy aReferrerPolicy,
|
||||
const dom::SRIMetadata& aIntegrity)
|
||||
: StyleSheet(StyleBackendType::Servo, aParsingMode)
|
||||
{
|
||||
mInner = new StyleSheetInfo(aCORSMode, aReferrerPolicy, aIntegrity);
|
||||
mInner = new ServoStyleSheetInner(aCORSMode, aReferrerPolicy, aIntegrity);
|
||||
mInner->AddSheet(this);
|
||||
}
|
||||
|
||||
|
@ -54,7 +65,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||
bool
|
||||
ServoStyleSheet::HasRules() const
|
||||
{
|
||||
return mSheet && Servo_StyleSheet_HasRules(mSheet);
|
||||
return Inner()->mSheet && Servo_StyleSheet_HasRules(Inner()->mSheet);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -75,13 +86,13 @@ ServoStyleSheet::ParseSheet(css::Loader* aLoader,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ConvertUTF16toUTF8 input(aInput);
|
||||
if (!mSheet) {
|
||||
mSheet =
|
||||
if (!Inner()->mSheet) {
|
||||
Inner()->mSheet =
|
||||
Servo_StyleSheet_FromUTF8Bytes(aLoader, this, &input, mParsingMode,
|
||||
&baseString, base, referrer,
|
||||
principal).Consume();
|
||||
} else {
|
||||
Servo_StyleSheet_ClearAndUpdate(mSheet, aLoader, this, &input, base,
|
||||
Servo_StyleSheet_ClearAndUpdate(Inner()->mSheet, aLoader, this, &input, base,
|
||||
referrer, principal);
|
||||
}
|
||||
|
||||
|
@ -91,7 +102,7 @@ ServoStyleSheet::ParseSheet(css::Loader* aLoader,
|
|||
void
|
||||
ServoStyleSheet::LoadFailed()
|
||||
{
|
||||
mSheet = Servo_StyleSheet_Empty(mParsingMode).Consume();
|
||||
Inner()->mSheet = Servo_StyleSheet_Empty(mParsingMode).Consume();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -114,7 +125,8 @@ CSSRuleList*
|
|||
ServoStyleSheet::GetCssRulesInternal(ErrorResult& aRv)
|
||||
{
|
||||
if (!mRuleList) {
|
||||
RefPtr<ServoCssRules> rawRules = Servo_StyleSheet_GetRules(mSheet).Consume();
|
||||
RefPtr<ServoCssRules> rawRules =
|
||||
Servo_StyleSheet_GetRules(Inner()->mSheet).Consume();
|
||||
mRuleList = new ServoCSSRuleList(this, rawRules.forget());
|
||||
}
|
||||
return mRuleList;
|
||||
|
|
|
@ -23,6 +23,20 @@ class Loader;
|
|||
class Rule;
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Servo Style Sheet Inner Data Container
|
||||
//
|
||||
|
||||
struct ServoStyleSheetInner : public StyleSheetInfo
|
||||
{
|
||||
ServoStyleSheetInner(CORSMode aCORSMode,
|
||||
ReferrerPolicy aReferrerPolicy,
|
||||
const dom::SRIMetadata& aIntegrity);
|
||||
|
||||
RefPtr<RawServoStyleSheet> mSheet;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* CSS style sheet object that is a wrapper for a Servo Stylesheet.
|
||||
*/
|
||||
|
@ -53,10 +67,12 @@ public:
|
|||
*/
|
||||
void LoadFailed();
|
||||
|
||||
RawServoStyleSheet* RawSheet() const { return mSheet; }
|
||||
RawServoStyleSheet* RawSheet() const {
|
||||
return Inner()->mSheet;
|
||||
}
|
||||
void SetSheetForImport(RawServoStyleSheet* aSheet) {
|
||||
MOZ_ASSERT(!mSheet);
|
||||
mSheet = aSheet;
|
||||
MOZ_ASSERT(!Inner()->mSheet);
|
||||
Inner()->mSheet = aSheet;
|
||||
}
|
||||
|
||||
// WebIDL CSSStyleSheet API
|
||||
|
@ -73,6 +89,11 @@ public:
|
|||
protected:
|
||||
virtual ~ServoStyleSheet();
|
||||
|
||||
ServoStyleSheetInner* Inner() const
|
||||
{
|
||||
return static_cast<ServoStyleSheetInner*>(mInner);
|
||||
}
|
||||
|
||||
// Internal methods which do not have security check and completeness check.
|
||||
dom::CSSRuleList* GetCssRulesInternal(ErrorResult& aRv);
|
||||
uint32_t InsertRuleInternal(const nsAString& aRule,
|
||||
|
@ -84,7 +105,6 @@ protected:
|
|||
private:
|
||||
void DropRuleList();
|
||||
|
||||
RefPtr<RawServoStyleSheet> mSheet;
|
||||
RefPtr<ServoCSSRuleList> mRuleList;
|
||||
|
||||
friend class StyleSheet;
|
||||
|
|
Загрузка…
Ссылка в новой задаче