Bug 1288302 - Part 4: Perform final main thread work on style structs sourced from ServoComputedValues. r=xidorn

MozReview-Commit-ID: D6nQQ3yI4sx
This commit is contained in:
Cameron McCormack 2016-11-02 16:58:32 +08:00
Родитель 195dbb2d2a
Коммит 642cdb8e14
3 изменённых файлов: 46 добавлений и 1 удалений

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

@ -472,8 +472,24 @@ const void* nsStyleContext::StyleData(nsStyleStructID aSID)
mCachedInheritedData.mStyleStructs[aSID] = const_cast<void*>(newData);
}
} else {
// The Servo-backed StyleContextSource owns the struct.
newData = StyleStructFromServoComputedValues(aSID);
// perform any remaining main thread work on the struct
switch (aSID) {
#define STYLE_STRUCT(name_, checkdata_cb_) \
case eStyleStruct_##name_: { \
auto data = static_cast<const nsStyle##name_*>(newData); \
const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext()); \
break; \
}
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
default:
MOZ_ASSERT_UNREACHABLE("unexpected nsStyleStructID value");
break;
}
// The Servo-backed StyleContextSource owns the struct.
AddStyleBit(nsCachedStyleData::GetBitForSID(aSID));
// XXXbholley: Unconditionally caching reset structs here defeats the memory

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

@ -682,6 +682,8 @@ private:
newData = \
Servo_GetStyle##name_(mSource.AsServoComputedValues()); \
} \
/* perform any remaining main thread work on the struct */ \
const_cast<nsStyle##name_*>(newData)->FinishStyle(PresContext());\
/* the Servo-backed StyleContextSource owns the struct */ \
AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \
} \
@ -710,6 +712,8 @@ private:
} else { \
newData = \
Servo_GetStyle##name_(mSource.AsServoComputedValues()); \
/* perform any remaining main thread work on the struct */ \
const_cast<nsStyle##name_*>(newData)->FinishStyle(PresContext());\
/* The Servo-backed StyleContextSource owns the struct. \
* \
* XXXbholley: Unconditionally caching reset structs here \

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

@ -161,6 +161,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont
~nsStyleFont() {
MOZ_COUNT_DTOR(nsStyleFont);
}
void FinishStyle(nsPresContext* aPresContext) {}
nsChangeHint CalcDifference(const nsStyleFont& aNewData) const;
static nsChangeHint MaxDifference() {
@ -544,6 +545,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColor
~nsStyleColor() {
MOZ_COUNT_DTOR(nsStyleColor);
}
void FinishStyle(nsPresContext* aPresContext) {}
nscolor CalcComplexColor(const mozilla::StyleComplexColor& aColor) const {
return mozilla::LinearBlendColors(aColor.mColor, mColor,
@ -901,6 +903,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBackground {
explicit nsStyleBackground(StyleStructContext aContext);
nsStyleBackground(const nsStyleBackground& aOther);
~nsStyleBackground();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleBackground* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -953,6 +956,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleMargin
~nsStyleMargin() {
MOZ_COUNT_DTOR(nsStyleMargin);
}
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleMargin* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -1000,6 +1004,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePadding
~nsStylePadding() {
MOZ_COUNT_DTOR(nsStylePadding);
}
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStylePadding* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -1207,6 +1212,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder
explicit nsStyleBorder(StyleStructContext aContext);
nsStyleBorder(const nsStyleBorder& aBorder);
~nsStyleBorder();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleBorder* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -1436,6 +1442,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline
~nsStyleOutline() {
MOZ_COUNT_DTOR(nsStyleOutline);
}
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleOutline* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -1509,6 +1516,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList
explicit nsStyleList(StyleStructContext aContext);
nsStyleList(const nsStyleList& aStyleList);
~nsStyleList();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleList* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -1740,6 +1748,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition
explicit nsStylePosition(StyleStructContext aContext);
nsStylePosition(const nsStylePosition& aOther);
~nsStylePosition();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStylePosition* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -1976,6 +1985,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTextReset
explicit nsStyleTextReset(StyleStructContext aContext);
nsStyleTextReset(const nsStyleTextReset& aOther);
~nsStyleTextReset();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleTextReset* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -2024,6 +2034,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText
explicit nsStyleText(StyleStructContext aContext);
nsStyleText(const nsStyleText& aOther);
~nsStyleText();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleText* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -2242,6 +2253,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility
~nsStyleVisibility() {
MOZ_COUNT_DTOR(nsStyleVisibility);
}
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleVisibility* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -2749,6 +2761,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay
~nsStyleDisplay() {
MOZ_COUNT_DTOR(nsStyleDisplay);
}
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleDisplay* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3060,6 +3073,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTable
explicit nsStyleTable(StyleStructContext aContext);
nsStyleTable(const nsStyleTable& aOther);
~nsStyleTable();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleTable* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3091,6 +3105,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTableBorder
explicit nsStyleTableBorder(StyleStructContext aContext);
nsStyleTableBorder(const nsStyleTableBorder& aOther);
~nsStyleTableBorder();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleTableBorder* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3199,6 +3214,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleContent
explicit nsStyleContent(StyleStructContext aContext);
nsStyleContent(const nsStyleContent& aContent);
~nsStyleContent();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleContent* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3279,6 +3295,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUIReset
explicit nsStyleUIReset(StyleStructContext aContext);
nsStyleUIReset(const nsStyleUIReset& aOther);
~nsStyleUIReset();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleUIReset* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3351,6 +3368,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUserInterface
explicit nsStyleUserInterface(StyleStructContext aContext);
nsStyleUserInterface(const nsStyleUserInterface& aOther);
~nsStyleUserInterface();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleUserInterface* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3394,6 +3412,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleXUL
explicit nsStyleXUL(StyleStructContext aContext);
nsStyleXUL(const nsStyleXUL& aSource);
~nsStyleXUL();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleXUL* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3433,6 +3452,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn
explicit nsStyleColumn(StyleStructContext aContext);
nsStyleColumn(const nsStyleColumn& aSource);
~nsStyleColumn();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleColumn* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3557,6 +3577,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG
explicit nsStyleSVG(StyleStructContext aContext);
nsStyleSVG(const nsStyleSVG& aSource);
~nsStyleSVG();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleSVG* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3690,6 +3711,7 @@ struct nsStyleFilter
nsStyleFilter();
nsStyleFilter(const nsStyleFilter& aSource);
~nsStyleFilter();
void FinishStyle(nsPresContext* aPresContext) {}
nsStyleFilter& operator=(const nsStyleFilter& aOther);
@ -3746,6 +3768,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVGReset
explicit nsStyleSVGReset(StyleStructContext aContext);
nsStyleSVGReset(const nsStyleSVGReset& aSource);
~nsStyleSVGReset();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleSVGReset* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3798,6 +3821,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVariables
explicit nsStyleVariables(StyleStructContext aContext);
nsStyleVariables(const nsStyleVariables& aSource);
~nsStyleVariables();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleVariables* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@ -3828,6 +3852,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleEffects
explicit nsStyleEffects(StyleStructContext aContext);
nsStyleEffects(const nsStyleEffects& aSource);
~nsStyleEffects();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleEffects* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {