Bug 1367904 - Part 12: stylo: Fix assertions and behavior changes; r?bholley
MozReview-Commit-ID: EDItMT2jYxy
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5870,17 +5870,18 @@ nsCSSFrameConstructor::AddFrameConstruct
styleSet->StyleNewSubtree(element);
// Servo's should_traverse_children() in traversal.rs skips
// styling descendants of elements with a -moz-binding the
// first time. Thus call StyleNewChildren() again.
styleSet->StyleNewChildren(element);
styleContext =
- styleSet->ResolveStyleFor(element, nullptr, LazyComputeBehavior::Allow);
+ styleSet->ResolveStyleFor(element, styleContext->GetParentAllowServo()->AsServo(),
+ LazyComputeBehavior::Assert);
} else {
styleContext =
ResolveStyleContext(styleContext->GetParent(), aContent, &aState);
}
display = styleContext->StyleDisplay();
aStyleContext = styleContext;
}
--- a/layout/style/ServoStyleContext.h
+++ b/layout/style/ServoStyleContext.h
@@ -34,33 +34,29 @@ public:
void Release() {
Servo_StyleContext_Release(this);
}
/**
* Makes this context match |aOther| in terms of which style structs have
* been resolved.
*/
- void ResolveSameStructsAs(nsPresContext* aPresContext, ServoStyleContext* aOther) {
- // NB: This function is only called on newly-minted style contexts, but
- // those may already have resolved style structs given the SetStyleBits call
- // in FinishConstruction. So we carefully xor out the bits that are new so
- // that we don't call FinishStyle twice.
+ void ResolveSameStructsAs(nsPresContext* aPresContext, const ServoStyleContext* aOther) {
+ // Only resolve structs that are not already resolved in this struct.
uint64_t ourBits = mBits & NS_STYLE_INHERIT_MASK;
uint64_t otherBits = aOther->mBits & NS_STYLE_INHERIT_MASK;
- MOZ_ASSERT((otherBits | ourBits) == otherBits, "otherBits should be a superset");
- uint64_t newBits = (ourBits ^ otherBits) & NS_STYLE_INHERIT_MASK;
+ uint64_t newBits = otherBits & ~ourBits & NS_STYLE_INHERIT_MASK;
-#define STYLE_STRUCT(name_, checkdata_cb) \
+ #define STYLE_STRUCT(name_, checkdata_cb) \
if (nsStyle##name_::kHasFinishStyle && newBits & NS_STYLE_INHERIT_BIT(name_)) { \
const nsStyle##name_* data = Servo_GetStyle##name_(ComputedValues()); \
const_cast<nsStyle##name_*>(data)->FinishStyle(aPresContext); \
}
-#include "nsStyleStructList.h"
-#undef STYLE_STRUCT
+ #include "nsStyleStructList.h"
+ #undef STYLE_STRUCT
mBits |= newBits;
}
private:
nsPresContext* mPresContext;
RefPtr<ServoComputedValues> mSource;
};
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -434,17 +434,21 @@ nsStyleContext::CalcStyleDifference(nsSt
aEqualStructs,
aSamePointerStructs);
}
void
nsStyleContext::SetStyleIfVisited(already_AddRefed<nsStyleContext> aStyleIfVisited)
{
MOZ_ASSERT(!IsStyleIfVisited(), "this context is not visited data");
- NS_ASSERTION(!mStyleIfVisited, "should only be set once");
+ // XXXManishearth
+ // Servo currently mints fresh visited contexts on calls to GetContext()
+ // in line with the previous behavior.
+ // This is suboptimal and should be phased out when we phase out GetContext()
+ NS_ASSERTION(IsServo() || !mStyleIfVisited, "should only be set once");
mStyleIfVisited = aStyleIfVisited;
MOZ_ASSERT(mStyleIfVisited->IsStyleIfVisited(),
"other context is visited data");
MOZ_ASSERT(!mStyleIfVisited->GetStyleIfVisited(),
"other context does not have visited data");
NS_ASSERTION(GetStyleIfVisited()->GetPseudo() == GetPseudo(),