Bug 1216431 patch 3 - Cache structs that are stored with conditions on the rule node all the time, rather than only when freshly computed. r=heycam

This is another case similar to the problem fixed in bug 1209603 patch 9.

This should make things faster by caching structs on the style context
more reliably.

--HG--
extra : commitid : GdalxPoI0wr
extra : rebase_source : 103e678a237f723b386b517d478e70214a75467e
This commit is contained in:
L. David Baron 2015-10-23 08:57:35 +09:00
Родитель 6d81ecb5c0
Коммит 98f6eaaddc
2 изменённых файлов: 31 добавлений и 10 удалений

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

@ -66,6 +66,30 @@ using std::min;
using namespace mozilla;
using namespace mozilla::dom;
void*
nsConditionalResetStyleData::GetConditionalStyleData(nsStyleStructID aSID,
nsStyleContext* aStyleContext) const
{
Entry* e = static_cast<Entry*>(mEntries[aSID]);
MOZ_ASSERT(e, "if mConditionalBits bit is set, we must have at least one "
"conditional style struct");
do {
if (e->mConditions.Matches(aStyleContext)) {
void* data = e->mStyleStruct;
// For reset structs with conditions, we cache the data on the
// style context.
// Tell the style context that it doesn't own the data
aStyleContext->AddStyleBit(GetBitForSID(aSID));
aStyleContext->SetStyle(aSID, data);
return data;
}
e = e->mNext;
} while (e);
return nullptr;
}
#define NS_SET_IMAGE_REQUEST(method_, context_, request_) \
if ((context_)->PresContext()->IsDynamic()) { \
method_(request_); \

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

@ -164,18 +164,15 @@ struct nsConditionalResetStyleData
if (!(mConditionalBits & GetBitForSID(aSID))) {
return mEntries[aSID];
}
Entry* e = static_cast<Entry*>(mEntries[aSID]);
MOZ_ASSERT(e, "if mConditionalBits bit is set, we must have at least one "
"conditional style struct");
do {
if (e->mConditions.Matches(aStyleContext)) {
return e->mStyleStruct;
}
e = e->mNext;
} while (e);
return nullptr;
return GetConditionalStyleData(aSID, aStyleContext);
}
private:
// non-inline helper for GetStyleData
void* GetConditionalStyleData(nsStyleStructID aSID,
nsStyleContext* aStyleContext) const;
public:
void SetStyleData(nsStyleStructID aSID, void* aStyleStruct) {
MOZ_ASSERT(!(mConditionalBits & GetBitForSID(aSID)),
"rule node should not have unconditional and conditional style "