From fccbbb258f57442522138f0436c3d2f14e99a4e5 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Fri, 5 Dec 2014 15:50:00 -0800 Subject: [PATCH] Bug 1089417 patch 5 - Add method to save the current media query result cache key from a rule processor. r=heycam This is needed for patch 7. --- layout/style/nsCSSRuleProcessor.cpp | 11 +++++++++++ layout/style/nsCSSRuleProcessor.h | 7 +++++++ layout/style/nsIMediaList.h | 3 +++ 3 files changed, 21 insertions(+) diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 075096c9d6ad..7e491a36fd66 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -2925,6 +2925,17 @@ nsCSSRuleProcessor::MediumFeaturesChanged(nsPresContext* aPresContext) return (old != mRuleCascades); } +UniquePtr +nsCSSRuleProcessor::CloneMQCacheKey() +{ + RuleCascadeData* c = mRuleCascades; + if (!c || !c->mCacheKey.HasFeatureConditions()) { + return UniquePtr(); + } + + return MakeUnique(c->mCacheKey); +} + /* virtual */ size_t nsCSSRuleProcessor::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { diff --git a/layout/style/nsCSSRuleProcessor.h b/layout/style/nsCSSRuleProcessor.h index 5172ab9c8284..d711fe83579a 100644 --- a/layout/style/nsCSSRuleProcessor.h +++ b/layout/style/nsCSSRuleProcessor.h @@ -19,6 +19,7 @@ #include "nsTArray.h" #include "nsAutoPtr.h" #include "nsRuleWalker.h" +#include "mozilla/UniquePtr.h" struct CascadeEnumData; struct nsCSSSelector; @@ -120,6 +121,12 @@ public: virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) MOZ_OVERRIDE; + /** + * If this rule processor currently has a substantive media query + * result cache key, return a copy of it. + */ + mozilla::UniquePtr CloneMQCacheKey(); + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) diff --git a/layout/style/nsIMediaList.h b/layout/style/nsIMediaList.h index 81d7d0dc7c21..23b8e24c762a 100644 --- a/layout/style/nsIMediaList.h +++ b/layout/style/nsIMediaList.h @@ -82,6 +82,9 @@ public: void AddExpression(const nsMediaExpression* aExpression, bool aExpressionMatches); bool Matches(nsPresContext* aPresContext) const; + bool HasFeatureConditions() const { + return !mFeatureCache.IsEmpty(); + } /** * An operator== that implements list equality, which isn't quite as