зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1343964 part 7 - Use URLExtraData for declaration modification directly for Servo backend. r=heycam
MozReview-Commit-ID: 78JRYKk9hgV --HG-- extra : rebase_source : 1a86db507451637379e35ea17d9dbd88e8dc6902
This commit is contained in:
Родитель
3d5b648721
Коммит
987754e4dc
|
@ -94,9 +94,17 @@ void
|
|||
ServoStyleRuleDeclaration::GetCSSParsingEnvironment(
|
||||
CSSParsingEnvironment& aCSSParseEnv)
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("GetCSSParsingEnvironment "
|
||||
"shouldn't be calling for a Servo rule");
|
||||
GetCSSParsingEnvironmentForRule(Rule(), aCSSParseEnv);
|
||||
}
|
||||
|
||||
URLExtraData*
|
||||
ServoStyleRuleDeclaration::GetURLData() const
|
||||
{
|
||||
return GetURLDataForRule(Rule());
|
||||
}
|
||||
|
||||
// -- ServoStyleRule --------------------------------------------------
|
||||
|
||||
ServoStyleRule::ServoStyleRule(already_AddRefed<RawServoStyleRule> aRawRule)
|
||||
|
|
|
@ -33,6 +33,7 @@ protected:
|
|||
nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final;
|
||||
nsIDocument* DocToUpdate() final;
|
||||
void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) final;
|
||||
URLExtraData* GetURLData() const final;
|
||||
|
||||
private:
|
||||
// For accessing the constructor.
|
||||
|
|
|
@ -82,6 +82,8 @@ public:
|
|||
Inner()->mSheet = aSheet;
|
||||
}
|
||||
|
||||
URLExtraData* URLData() const { return Inner()->mURLData; }
|
||||
|
||||
// WebIDL CSSStyleSheet API
|
||||
// Can't be inline because we can't include ImportRule here. And can't be
|
||||
// called GetOwnerRule because that would be ambiguous with the ImportRule
|
||||
|
|
|
@ -1062,6 +1062,7 @@ public:
|
|||
virtual DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
|
||||
virtual nsresult SetCSSDeclaration(DeclarationBlock* aDecl) override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
URLExtraData* GetURLData() const final;
|
||||
virtual nsIDocument* DocToUpdate() override;
|
||||
|
||||
// Override |AddRef| and |Release| for being owned by StyleRule. Also, we
|
||||
|
@ -1120,6 +1121,13 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParse
|
|||
GetCSSParsingEnvironmentForRule(mRule, aCSSParseEnv);
|
||||
}
|
||||
|
||||
URLExtraData*
|
||||
DOMCSSDeclarationImpl::GetURLData() const
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("GetURLData shouldn't be calling on a Gecko rule");
|
||||
return GetURLDataForRule(mRule);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMCSSDeclarationImpl::GetParentRule(nsIDOMCSSRule **aParent)
|
||||
{
|
||||
|
|
|
@ -1602,6 +1602,13 @@ nsCSSKeyframeStyleDeclaration::GetCSSParsingEnvironment(CSSParsingEnvironment& a
|
|||
GetCSSParsingEnvironmentForRule(mRule, aCSSParseEnv);
|
||||
}
|
||||
|
||||
URLExtraData*
|
||||
nsCSSKeyframeStyleDeclaration::GetURLData() const
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("GetURLData shouldn't be calling on a Gecko rule");
|
||||
return GetURLDataForRule(mRule);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCSSKeyframeStyleDeclaration::GetParentRule(nsIDOMCSSRule **aParent)
|
||||
{
|
||||
|
@ -2112,6 +2119,13 @@ nsCSSPageStyleDeclaration::GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSP
|
|||
GetCSSParsingEnvironmentForRule(mRule, aCSSParseEnv);
|
||||
}
|
||||
|
||||
URLExtraData*
|
||||
nsCSSPageStyleDeclaration::GetURLData() const
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("GetURLData shouldn't be calling on a Gecko rule");
|
||||
return GetURLDataForRule(mRule);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCSSPageStyleDeclaration::GetParentRule(nsIDOMCSSRule** aParent)
|
||||
{
|
||||
|
|
|
@ -247,6 +247,7 @@ public:
|
|||
virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
|
||||
virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
mozilla::URLExtraData* GetURLData() const final;
|
||||
virtual nsIDocument* DocToUpdate() override;
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
@ -387,6 +388,7 @@ public:
|
|||
virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
|
||||
virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
mozilla::URLExtraData* GetURLData() const final;
|
||||
virtual nsIDocument* DocToUpdate() override;
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
|
|
@ -741,6 +741,13 @@ nsComputedDOMStyle::GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv
|
|||
aCSSParseEnv.mPrincipal = nullptr;
|
||||
}
|
||||
|
||||
URLExtraData*
|
||||
nsComputedDOMStyle::GetURLData() const
|
||||
{
|
||||
NS_RUNTIMEABORT("called nsComputedDOMStyle::GetURLData");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
nsComputedDOMStyle::ClearStyleContext()
|
||||
{
|
||||
|
|
|
@ -136,6 +136,7 @@ public:
|
|||
virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock*) override;
|
||||
virtual nsIDocument* DocToUpdate() override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
mozilla::URLExtraData* GetURLData() const final;
|
||||
|
||||
static already_AddRefed<nsROCSSPrimitiveValue>
|
||||
MatrixToCSSValue(const mozilla::gfx::Matrix4x4& aMatrix);
|
||||
|
|
|
@ -173,6 +173,12 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(CSSParsingEnvironment& aC
|
|||
aCSSParseEnv.mCSSLoader = doc->CSSLoader();
|
||||
}
|
||||
|
||||
URLExtraData*
|
||||
nsDOMCSSAttributeDeclaration::GetURLData() const
|
||||
{
|
||||
return mElement->GetURLDataForStyleAttr();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMCSSAttributeDeclaration::GetParentRule(nsIDOMCSSRule **aParent)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
// is owned by our current style rule.
|
||||
virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
mozilla::URLExtraData* GetURLData() const final;
|
||||
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
|
||||
|
||||
virtual nsINode* GetParentObject() override;
|
||||
|
|
|
@ -117,9 +117,17 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
|
|||
}
|
||||
|
||||
CSSParsingEnvironment env;
|
||||
GetCSSParsingEnvironment(env);
|
||||
if (!env.mPrincipal) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
URLExtraData* urlData = nullptr;
|
||||
if (olddecl->IsGecko()) {
|
||||
GetCSSParsingEnvironment(env);
|
||||
if (!env.mPrincipal) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
} else {
|
||||
urlData = GetURLData();
|
||||
if (!urlData) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
// For nsDOMCSSAttributeDeclaration, SetCSSDeclaration will lead to
|
||||
|
@ -131,9 +139,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
|
|||
|
||||
RefPtr<DeclarationBlock> newdecl;
|
||||
if (olddecl->IsServo()) {
|
||||
RefPtr<URLExtraData> data =
|
||||
new URLExtraData(env.mBaseURI, env.mSheetURI, env.mPrincipal);
|
||||
newdecl = ServoDeclarationBlock::FromCssText(aCssText, data);
|
||||
newdecl = ServoDeclarationBlock::FromCssText(aCssText, urlData);
|
||||
} else {
|
||||
RefPtr<css::Declaration> decl(new css::Declaration());
|
||||
decl->InitializeEmpty();
|
||||
|
@ -276,6 +282,15 @@ nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule,
|
|||
aCSSParseEnv.mCSSLoader = document ? document->CSSLoader() : nullptr;
|
||||
}
|
||||
|
||||
/* static */ URLExtraData*
|
||||
nsDOMCSSDeclaration::GetURLDataForRule(const css::Rule* aRule)
|
||||
{
|
||||
if (StyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr) {
|
||||
return sheet->AsServo()->URLData();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename GeckoFunc, typename ServoFunc>
|
||||
nsresult
|
||||
nsDOMCSSDeclaration::ModifyDeclaration(GeckoFunc aGeckoFunc,
|
||||
|
@ -287,9 +302,17 @@ nsDOMCSSDeclaration::ModifyDeclaration(GeckoFunc aGeckoFunc,
|
|||
}
|
||||
|
||||
CSSParsingEnvironment env;
|
||||
GetCSSParsingEnvironment(env);
|
||||
if (!env.mPrincipal) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
URLExtraData* urlData = nullptr;
|
||||
if (olddecl->IsGecko()) {
|
||||
GetCSSParsingEnvironment(env);
|
||||
if (!env.mPrincipal) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
} else {
|
||||
urlData = GetURLData();
|
||||
if (!urlData) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
// For nsDOMCSSAttributeDeclaration, SetCSSDeclaration will lead to
|
||||
|
|
|
@ -156,6 +156,13 @@ protected:
|
|||
static void GetCSSParsingEnvironmentForRule(mozilla::css::Rule* aRule,
|
||||
CSSParsingEnvironment& aCSSParseEnv);
|
||||
|
||||
// An implementation for GetURLData for callers wrapping a css::Rule.
|
||||
static mozilla::URLExtraData* GetURLDataForRule(const mozilla::css::Rule* aRule);
|
||||
|
||||
// Returns URL data for parsing url values in CSS.
|
||||
// Returns nullptr on failure.
|
||||
virtual mozilla::URLExtraData* GetURLData() const = 0;
|
||||
|
||||
nsresult ParsePropertyValue(const nsCSSPropertyID aPropID,
|
||||
const nsAString& aPropValue,
|
||||
bool aIsImportant);
|
||||
|
|
Загрузка…
Ссылка в новой задаче