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.
This commit is contained in:
L. David Baron 2014-12-05 15:50:00 -08:00
parent cc6a4c1bb2
commit fccbbb258f
3 changed files with 21 additions and 0 deletions

View File

@ -2925,6 +2925,17 @@ nsCSSRuleProcessor::MediumFeaturesChanged(nsPresContext* aPresContext)
return (old != mRuleCascades);
}
UniquePtr<nsMediaQueryResultCacheKey>
nsCSSRuleProcessor::CloneMQCacheKey()
{
RuleCascadeData* c = mRuleCascades;
if (!c || !c->mCacheKey.HasFeatureConditions()) {
return UniquePtr<nsMediaQueryResultCacheKey>();
}
return MakeUnique<nsMediaQueryResultCacheKey>(c->mCacheKey);
}
/* virtual */ size_t
nsCSSRuleProcessor::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{

View File

@ -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<nsMediaQueryResultCacheKey> CloneMQCacheKey();
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf)
const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf)

View File

@ -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