зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1228877 - Make nsStyleContext::HasChildThatUsesGrandancestorStyle by setting bit on grandchild's parent instead of grandchild. r=xidorn
--HG-- extra : commitid : 2tUmogO3bzN
This commit is contained in:
Родитель
9d5f02c429
Коммит
ed7a9954b6
|
@ -1703,29 +1703,18 @@ nsRuleNode::PropagateGrandancestorBit(nsStyleContext* aContext,
|
|||
{
|
||||
MOZ_ASSERT(aContext);
|
||||
MOZ_ASSERT(aContextInheritedFrom &&
|
||||
aContextInheritedFrom != aContext &&
|
||||
aContextInheritedFrom != aContext->GetParent(),
|
||||
"aContextInheritedFrom must be an ancestor of aContext's parent");
|
||||
aContextInheritedFrom != aContext,
|
||||
"aContextInheritedFrom must be an ancestor of aContext");
|
||||
|
||||
aContext->AddStyleBit(NS_STYLE_USES_GRANDANCESTOR_STYLE);
|
||||
|
||||
nsStyleContext* context = aContext->GetParent();
|
||||
for (nsStyleContext* context = aContext->GetParent();
|
||||
context != aContextInheritedFrom;
|
||||
context = context->GetParent()) {
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
nsStyleContext* parent = context->GetParent();
|
||||
if (!parent) {
|
||||
MOZ_ASSERT(false, "aContextInheritedFrom must be an ancestor of "
|
||||
"aContext's parent");
|
||||
break;
|
||||
}
|
||||
if (parent == aContextInheritedFrom) {
|
||||
break;
|
||||
}
|
||||
context->AddStyleBit(NS_STYLE_USES_GRANDANCESTOR_STYLE);
|
||||
context = parent;
|
||||
context->AddStyleBit(NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8040,7 +8029,7 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
|||
if (MOZ_LIKELY(parentContext)) {
|
||||
nsStyleContext* grandparentContext = parentContext->GetParent();
|
||||
if (MOZ_LIKELY(grandparentContext)) {
|
||||
aContext->AddStyleBit(NS_STYLE_USES_GRANDANCESTOR_STYLE);
|
||||
parentContext->AddStyleBit(NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE);
|
||||
}
|
||||
pos->mAlignSelf =
|
||||
parentPos->ComputedAlignSelf(parentContext->StyleDisplay(),
|
||||
|
@ -8100,7 +8089,7 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
|||
if (MOZ_LIKELY(parentContext)) {
|
||||
nsStyleContext* grandparentContext = parentContext->GetParent();
|
||||
if (MOZ_LIKELY(grandparentContext)) {
|
||||
aContext->AddStyleBit(NS_STYLE_USES_GRANDANCESTOR_STYLE);
|
||||
parentContext->AddStyleBit(NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE);
|
||||
}
|
||||
pos->mJustifySelf =
|
||||
parentPos->ComputedJustifySelf(parentContext->StyleDisplay(),
|
||||
|
|
|
@ -389,29 +389,6 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
|
|||
return result.forget();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
nsStyleContext::ListContainsStyleContextThatUsesGrandancestorStyle(const nsStyleContext* aHead)
|
||||
{
|
||||
if (aHead) {
|
||||
const nsStyleContext* child = aHead;
|
||||
do {
|
||||
if (child->UsesGrandancestorStyle()) {
|
||||
return true;
|
||||
}
|
||||
child = child->mNextSibling;
|
||||
} while (child != aHead);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
nsStyleContext::HasChildThatUsesGrandancestorStyle() const
|
||||
{
|
||||
return ListContainsStyleContextThatUsesGrandancestorStyle(mEmptyChild) ||
|
||||
ListContainsStyleContextThatUsesGrandancestorStyle(mChild);
|
||||
}
|
||||
|
||||
const void* nsStyleContext::StyleData(nsStyleStructID aSID)
|
||||
{
|
||||
const void* cachedData = GetCachedStyleData(aSID);
|
||||
|
@ -1567,8 +1544,8 @@ nsStyleContext::LogStyleContextTree(bool aFirst, uint32_t aStructs)
|
|||
if (IsStyleIfVisited()) {
|
||||
flags.AppendLiteral("IS_STYLE_IF_VISITED ");
|
||||
}
|
||||
if (UsesGrandancestorStyle()) {
|
||||
flags.AppendLiteral("USES_GRANDANCESTOR_STYLE ");
|
||||
if (HasChildThatUsesGrandancestorStyle()) {
|
||||
flags.AppendLiteral("CHILD_USES_GRANDANCESTOR_STYLE ");
|
||||
}
|
||||
if (IsShared()) {
|
||||
flags.AppendLiteral("IS_SHARED ");
|
||||
|
|
|
@ -247,21 +247,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// Does this style context, or any of its descendants, have any style values
|
||||
// that were computed based on this style context's grandparent style context
|
||||
// or any of the grandparent's ancestors?
|
||||
bool UsesGrandancestorStyle() const
|
||||
{ return !!(mBits & NS_STYLE_USES_GRANDANCESTOR_STYLE); }
|
||||
// Does any descendant of this style context have any style values
|
||||
// that were computed based on this style context's ancestors?
|
||||
bool HasChildThatUsesGrandancestorStyle() const
|
||||
{ return !!(mBits & NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE); }
|
||||
|
||||
// Is this style context shared with a sibling or cousin?
|
||||
// (See nsStyleSet::GetContext.)
|
||||
bool IsShared() const
|
||||
{ return !!(mBits & NS_STYLE_IS_SHARED); }
|
||||
|
||||
// Does this style context have any children that return true for
|
||||
// UsesGrandancestorStyle()?
|
||||
bool HasChildThatUsesGrandancestorStyle() const;
|
||||
|
||||
// Tell this style context to cache aStruct as the struct for aSID
|
||||
void SetStyle(nsStyleStructID aSID, void* aStruct);
|
||||
|
||||
|
@ -474,10 +469,6 @@ private:
|
|||
|
||||
void ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup);
|
||||
|
||||
// Helper function for HasChildThatUsesGrandancestorStyle.
|
||||
static bool ListContainsStyleContextThatUsesGrandancestorStyle(
|
||||
const nsStyleContext* aHead);
|
||||
|
||||
#ifdef DEBUG
|
||||
struct AutoCheckDependency {
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ struct nsStyleVisibility;
|
|||
#define NS_STYLE_RELEVANT_LINK_VISITED 0x004000000
|
||||
// See nsStyleContext::IsStyleIfVisited
|
||||
#define NS_STYLE_IS_STYLE_IF_VISITED 0x008000000
|
||||
// See nsStyleContext::UsesGrandancestorStyle
|
||||
#define NS_STYLE_USES_GRANDANCESTOR_STYLE 0x010000000
|
||||
// See nsStyleContext::HasChildThatUsesGrandancestorStyle
|
||||
#define NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE 0x010000000
|
||||
// See nsStyleContext::IsShared
|
||||
#define NS_STYLE_IS_SHARED 0x020000000
|
||||
// See nsStyleContext::AssertStructsNotUsedElsewhere
|
||||
|
|
Загрузка…
Ссылка в новой задаче