Bug 1274443 - Avoid calling ApplyStyleFixups for ServoComputedValues. r=heycam

This commit is contained in:
Bobby Holley 2016-05-19 20:50:46 -07:00
parent e4b157691b
commit 9c8af73cc2
2 changed files with 47 additions and 22 deletions

View File

@ -160,7 +160,10 @@ nsStyleContext::FinishConstruction(bool aSkipParentDisplayBasedStyleFixup)
mParent->AddChild(this);
}
ApplyStyleFixups(aSkipParentDisplayBasedStyleFixup);
SetStyleBits();
if (!mSource.IsServoComputedValues()) {
ApplyStyleFixups(aSkipParentDisplayBasedStyleFixup);
}
#define eStyleStruct_LastItem (nsStyleStructID_Length - 1)
NS_ASSERTION(NS_STYLE_INHERIT_MASK & NS_STYLE_INHERIT_BIT(LastItem),
@ -474,6 +477,9 @@ const void* nsStyleContext::StyleData(nsStyleStructID aSID)
void*
nsStyleContext::GetUniqueStyleData(const nsStyleStructID& aSID)
{
MOZ_ASSERT(!mSource.IsServoComputedValues(),
"Can't COW-mutate servo values from Gecko!");
// If we already own the struct and no kids could depend on it, then
// just return it. (We leak in this case if there are kids -- and this
// function really shouldn't be called for style contexts that could
@ -651,9 +657,46 @@ ShouldBlockifyChildren(const nsStyleDisplay* aStyleDisp)
NS_STYLE_DISPLAY_INLINE_GRID == displayVal;
}
void
nsStyleContext::SetStyleBits()
{
// XXXbholley: We should get this information directly from the
// ServoComputedValues rather than computing it here. This setup for
// ServoComputedValues-backed nsStyleContexts is probably not something
// we should ship.
//
// For example, NS_STYLE_IS_TEXT_COMBINED is still set in ApplyStyleFixups,
// which isn't called for ServoComputedValues.
// See if we have any text decorations.
// First see if our parent has text decorations. If our parent does, then we inherit the bit.
if (mParent && mParent->HasTextDecorationLines()) {
mBits |= NS_STYLE_HAS_TEXT_DECORATION_LINES;
} else {
// We might have defined a decoration.
if (StyleTextReset()->HasTextDecorationLines()) {
mBits |= NS_STYLE_HAS_TEXT_DECORATION_LINES;
}
}
if ((mParent && mParent->HasPseudoElementData()) || mPseudoTag) {
mBits |= NS_STYLE_HAS_PSEUDO_ELEMENT_DATA;
}
// Set the NS_STYLE_IN_DISPLAY_NONE_SUBTREE bit
const nsStyleDisplay* disp = StyleDisplay();
if ((mParent && mParent->IsInDisplayNoneSubtree()) ||
disp->mDisplay == NS_STYLE_DISPLAY_NONE) {
mBits |= NS_STYLE_IN_DISPLAY_NONE_SUBTREE;
}
}
void
nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
{
MOZ_ASSERT(!mSource.IsServoComputedValues(),
"Can't do Gecko style fixups on Servo values");
#define GET_UNIQUE_STYLE_DATA(name_) \
static_cast<nsStyle##name_*>(GetUniqueStyleData(eStyleStruct_##name_))
@ -675,21 +718,6 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
AddStyleBit(NS_STYLE_IS_TEXT_COMBINED);
}
// See if we have any text decorations.
// First see if our parent has text decorations. If our parent does, then we inherit the bit.
if (mParent && mParent->HasTextDecorationLines()) {
mBits |= NS_STYLE_HAS_TEXT_DECORATION_LINES;
} else {
// We might have defined a decoration.
if (StyleTextReset()->HasTextDecorationLines()) {
mBits |= NS_STYLE_HAS_TEXT_DECORATION_LINES;
}
}
if ((mParent && mParent->HasPseudoElementData()) || mPseudoTag) {
mBits |= NS_STYLE_HAS_PSEUDO_ELEMENT_DATA;
}
// CSS 2.1 10.1: Propagate the root element's 'direction' to the ICB.
// (PageContentFrame/CanvasFrame etc will inherit 'direction')
if (mPseudoTag == nsCSSAnonBoxes::viewport) {
@ -798,12 +826,8 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
}
}
// Set the NS_STYLE_IN_DISPLAY_NONE_SUBTREE bit
if ((mParent && mParent->IsInDisplayNoneSubtree()) ||
disp->mDisplay == NS_STYLE_DISPLAY_NONE) {
mBits |= NS_STYLE_IN_DISPLAY_NONE_SUBTREE;
}
// Note: This must come after the blockification above, otherwise we fail
// the grid-item-blockifying-001.html reftest.
if (mParent && ::ShouldSuppressLineBreak(this, disp, mParent,
mParent->StyleDisplay())) {
mBits |= NS_STYLE_SUPPRESS_LINEBREAK;

View File

@ -527,6 +527,7 @@ private:
void* GetUniqueStyleData(const nsStyleStructID& aSID);
void* CreateEmptyStyleData(const nsStyleStructID& aSID);
void SetStyleBits();
void ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup);
const void* StyleStructFromServoComputedValues(nsStyleStructID aSID) {