Bug 1180118 - Part 5: Add a RestyleHintData outparam to HasAttributeDependentStyle for use with eRestyle_SomeDescendants. r=bzbarsky

This commit is contained in:
Cameron McCormack 2015-08-05 22:42:21 +10:00
Родитель 3b50f73dd9
Коммит 9ae3b05332
14 изменённых файлов: 52 добавлений и 21 удалений

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

@ -1170,13 +1170,15 @@ RestyleManager::AttributeWillChange(Element* aElement,
int32_t aModType,
const nsAttrValue* aNewValue)
{
RestyleHintData rsdata;
nsRestyleHint rshint =
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
aAttribute,
aModType,
false,
aNewValue);
PostRestyleEvent(aElement, rshint, NS_STYLE_HINT_NONE);
aNewValue,
rsdata);
PostRestyleEvent(aElement, rshint, NS_STYLE_HINT_NONE, &rsdata);
}
// Forwarded nsIMutationObserver method, to handle restyling (and
@ -1259,14 +1261,15 @@ RestyleManager::AttributeChanged(Element* aElement,
// See if we can optimize away the style re-resolution -- must be called after
// the frame's AttributeChanged() in case it does something that affects the style
RestyleHintData rsdata;
nsRestyleHint rshint =
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
aAttribute,
aModType,
true,
aOldValue);
PostRestyleEvent(aElement, rshint, hint);
aOldValue,
rsdata);
PostRestyleEvent(aElement, rshint, hint, &rsdata);
}
/* static */ uint64_t

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

@ -210,7 +210,9 @@ CommonAnimationManager::HasDocumentStateDependentStyle(StateRuleProcessorData* a
}
nsRestyleHint
CommonAnimationManager::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
CommonAnimationManager::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
{
return nsRestyleHint(0);
}

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

@ -52,7 +52,8 @@ public:
virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) override;
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) override;
HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult) override;
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) override;
virtual void RulesMatching(ElementRuleProcessorData* aData) override;
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) override;

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

@ -62,7 +62,9 @@ SVGAttrAnimationRuleProcessor::HasDocumentStateDependentStyle(StateRuleProcessor
}
/* virtual */ nsRestyleHint
SVGAttrAnimationRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
SVGAttrAnimationRuleProcessor::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
{
return nsRestyleHint(0);
}

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

@ -44,7 +44,8 @@ public:
virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) override;
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) override;
HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult) override;
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) override;
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;

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

@ -2839,7 +2839,9 @@ EnumerateSelectors(nsTArray<nsCSSSelector*>& aSelectors, AttributeEnumData* aDat
}
nsRestyleHint
nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
nsCSSRuleProcessor::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
{
// We could try making use of aData->mModType, but :not rules make it a bit
// of a pain to do so... So just ignore it for now.

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

@ -144,7 +144,9 @@ public:
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) override;
HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
mozilla::RestyleHintData& aRestyleHintDataResult)
override;
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) override;

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

@ -144,7 +144,9 @@ nsHTMLCSSStyleSheet::HasDocumentStateDependentStyle(StateRuleProcessorData* aDat
// Test if style is dependent on attribute
/* virtual */ nsRestyleHint
nsHTMLCSSStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
nsHTMLCSSStyleSheet::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
{
// Perhaps should check that it's XUL, SVG, (or HTML) namespace, but
// it doesn't really matter.

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

@ -43,7 +43,8 @@ public:
virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) override;
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) override;
HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
mozilla::RestyleHintData& aRestyleHintDataResult) override;
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) override;
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;

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

@ -335,7 +335,9 @@ nsHTMLStyleSheet::HasDocumentStateDependentStyle(StateRuleProcessorData* aData)
}
/* virtual */ nsRestyleHint
nsHTMLStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
nsHTMLStyleSheet::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
{
// Do nothing on before-change checks
if (!aData->mAttrHasChanged) {

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

@ -45,7 +45,8 @@ public:
virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) override;
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) override;
HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
mozilla::RestyleHintData& aRestyleHintDataResult) override;
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) override;
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;

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

@ -115,8 +115,9 @@ public:
* only, and may err on the side of reporting more dependencies than
* really exist.
*/
virtual nsRestyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0;
virtual nsRestyleHint HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
mozilla::RestyleHintData& aRestyleHintDataResult) = 0;
/**
* Do any processing that needs to happen as a result of a change in

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

@ -2377,14 +2377,16 @@ struct MOZ_STACK_CLASS AttributeData : public AttributeRuleProcessorData {
aAttrHasChanged, aOtherValue, aTreeMatchContext),
mHint(nsRestyleHint(0))
{}
nsRestyleHint mHint;
nsRestyleHint mHint;
RestyleHintData mHintData;
};
static bool
SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData)
{
AttributeData* data = (AttributeData*)aData;
nsRestyleHint hint = aProcessor->HasAttributeDependentStyle(data);
nsRestyleHint hint =
aProcessor->HasAttributeDependentStyle(data, data->mHintData);
data->mHint = nsRestyleHint(data->mHint | hint);
return true; // continue
}
@ -2395,7 +2397,9 @@ nsStyleSet::HasAttributeDependentStyle(Element* aElement,
nsIAtom* aAttribute,
int32_t aModType,
bool aAttrHasChanged,
const nsAttrValue* aOtherValue)
const nsAttrValue* aOtherValue,
mozilla::RestyleHintData&
aRestyleHintDataResult)
{
TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
aElement->OwnerDoc());
@ -2403,6 +2407,11 @@ nsStyleSet::HasAttributeDependentStyle(Element* aElement,
AttributeData data(PresContext(), aElement, aAttribute,
aModType, aAttrHasChanged, aOtherValue, treeContext);
WalkRuleProcessors(SheetHasAttributeStyle, &data, false);
if (!(data.mHint & eRestyle_Subtree)) {
// No point keeping the list of selectors around if we are going to
// restyle the whole subtree unconditionally.
aRestyleHintDataResult = Move(data.mHintData);
}
return data.mHint;
}

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

@ -286,7 +286,9 @@ class nsStyleSet final
nsIAtom* aAttribute,
int32_t aModType,
bool aAttrHasChanged,
const nsAttrValue* aOtherValue);
const nsAttrValue* aOtherValue,
mozilla::RestyleHintData&
aRestyleHintDataResult);
/*
* Do any processing that needs to happen as a result of a change in