Bug 1207084 - keep sheet level on tokenstream for use in ruledata when resolving variables, to fix hcm issues with CSS variables, r=heycam

--HG--
extra : commitid : LOEulYWs1jS
extra : rebase_source : b9741e3bc6a4a762a2f6295d8d81069aca66745f
extra : amend_source : 13dd115d63546f57127fe65163c2aaacf8c6b043
This commit is contained in:
Gijs Kruitbosch 2015-09-26 23:51:42 +02:00
Родитель ae6755a03e
Коммит 8884b0618e
4 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -262,6 +262,15 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
nsCSSValue* target = aRuleData->ValueFor(iProp);
if (target->GetUnit() == eCSSUnit_Null) {
const nsCSSValue *val = ValueAtIndex(i);
// In order for variable resolution to have the right information
// about the stylesheet level of a value, that level needs to be
// stored on the token stream. We can't do that at creation time
// because the CSS parser (which creates the object) has no idea
// about the stylesheet level, so we do it here instead, where
// the rule walking will have just updated aRuleData.
if (val->GetUnit() == eCSSUnit_TokenStream) {
val->GetTokenStreamValue()->mLevel = aRuleData->mLevel;
}
MapSinglePropertyInto(iProp, val, target, aRuleData);
}
}

Просмотреть файл

@ -23,6 +23,7 @@
#include "nsPresContext.h"
#include "nsStyleUtil.h"
#include "nsDeviceContext.h"
#include "nsStyleSet.h"
using namespace mozilla;
@ -2537,6 +2538,7 @@ nsCSSValueGradient::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) con
nsCSSValueTokenStream::nsCSSValueTokenStream()
: mPropertyID(eCSSProperty_UNKNOWN)
, mShorthandPropertyID(eCSSProperty_UNKNOWN)
, mLevel(nsStyleSet::eSheetTypeCount)
{
MOZ_COUNT_CTOR(nsCSSValueTokenStream);
}

Просмотреть файл

@ -1541,6 +1541,7 @@ public:
// mozilla::CSSStyleSheet* mSheet;
uint32_t mLineNumber;
uint32_t mLineOffset;
uint16_t mLevel; // an nsStyleSet::sheetType
private:
nsCSSValueTokenStream(const nsCSSValueTokenStream& aOther) = delete;

Просмотреть файл

@ -2180,6 +2180,12 @@ nsRuleNode::ResolveVariableReferences(const nsStyleStructID aSID,
&aContext->StyleVariables()->mVariables;
nsCSSValueTokenStream* tokenStream = value->GetTokenStreamValue();
MOZ_ASSERT(tokenStream->mLevel != nsStyleSet::eSheetTypeCount,
"Token stream should have a defined level");
AutoRestore<uint16_t> saveLevel(aRuleData->mLevel);
aRuleData->mLevel = tokenStream->mLevel;
// Note that ParsePropertyWithVariableReferences relies on the fact
// that the nsCSSValue in aRuleData for the property we are re-parsing
// is still the token stream value. When