Bug 781360 patch 1: Rename nsStyleContext::GetRuleNode to RuleNode, since it can never return null. r=dholbert

This makes it conform to our convention that getters returning pointers
that can never be null do not begin with "Get".

nsStyleContext's rule node is never null because we require a rule node
in order to construct a style context.
This commit is contained in:
L. David Baron 2013-02-16 13:04:53 -08:00
parent d3639f9b99
commit 8f3a364f1f
12 changed files with 23 additions and 22 deletions

View File

@ -619,7 +619,7 @@ VerifyContextParent(nsPresContext* aPresContext, nsIFrame* aFrame,
// as the parent or it has a different rulenode from aContext _and_ has
// aContext->GetParent() as the parent.
if (childStyleIfVisited &&
!((childStyleIfVisited->GetRuleNode() != aContext->GetRuleNode() &&
!((childStyleIfVisited->RuleNode() != aContext->RuleNode() &&
childStyleIfVisited->GetParent() == aContext->GetParent()) ||
childStyleIfVisited->GetParent() ==
aContext->GetParent()->GetStyleIfVisited())) {
@ -1278,7 +1278,7 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
NS_ASSERTION(newContext, "failed to get new style context");
if (newContext) {
if (!parentContext) {
if (oldContext->GetRuleNode() == newContext->GetRuleNode() &&
if (oldContext->RuleNode() == newContext->RuleNode() &&
oldContext->IsLinkContext() == newContext->IsLinkContext() &&
oldContext->RelevantLinkVisited() ==
newContext->RelevantLinkVisited()) {

View File

@ -66,7 +66,7 @@ nsFirstLetterFrame::Init(nsIContent* aContent,
// a style context like we would for a text node.
nsStyleContext* parentStyleContext = mStyleContext->GetParent();
if (parentStyleContext) {
newSC = mStyleContext->GetRuleNode()->GetPresContext()->StyleSet()->
newSC = mStyleContext->RuleNode()->GetPresContext()->StyleSet()->
ResolveStyleForNonElement(parentStyleContext);
if (newSC)
SetStyleContextWithoutNotification(newSC);

View File

@ -566,7 +566,7 @@ public:
NS_DECL_QUERYFRAME_TARGET(nsIFrame)
nsPresContext* PresContext() const {
return StyleContext()->GetRuleNode()->GetPresContext();
return StyleContext()->RuleNode()->GetPresContext();
}
/**

View File

@ -430,7 +430,7 @@ inDOMUtils::GetRuleNodeForContent(nsIContent* aContent,
nsRefPtr<nsStyleContext> sContext =
nsComputedDOMStyle::GetStyleContextForElement(aContent->AsElement(), aPseudo, presShell);
if (sContext) {
*aRuleNode = sContext->GetRuleNode();
*aRuleNode = sContext->RuleNode();
sContext.forget(aStyleContext);
}
return NS_OK;

View File

@ -356,7 +356,7 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement,
if (aStyleType == eDefaultOnly) {
// We really only want the user and UA rules. Filter out the other ones.
nsTArray< nsCOMPtr<nsIStyleRule> > rules;
for (nsRuleNode* ruleNode = sc->GetRuleNode();
for (nsRuleNode* ruleNode = sc->RuleNode();
!ruleNode->IsRoot();
ruleNode = ruleNode->GetParent()) {
if (ruleNode->GetLevel() == nsStyleSet::eAgentSheet ||

View File

@ -3427,7 +3427,7 @@ nsRuleNode::SetGenericFont(nsPresContext* aPresContext,
// Note that we *do* need to do this for our own data, since what is
// in |fontData| in ComputeFontData is only for the rules below
// aStartStruct.
for (nsRuleNode* ruleNode = context->GetRuleNode(); ruleNode;
for (nsRuleNode* ruleNode = context->RuleNode(); ruleNode;
ruleNode = ruleNode->GetParent()) {
if (ruleNode->mNoneBits & fontBit)
// no more font rules on this branch, get out
@ -7942,7 +7942,7 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
bool haveExplicitUAInherit;
do {
haveExplicitUAInherit = false;
for (nsRuleNode* ruleNode = styleContext->GetRuleNode(); ruleNode;
for (nsRuleNode* ruleNode = styleContext->RuleNode(); ruleNode;
ruleNode = ruleNode->GetParent()) {
nsIStyleRule *rule = ruleNode->GetRule();
if (rule) {

View File

@ -2329,7 +2329,7 @@ nsStyleAnimation::ComputeValue(nsCSSProperty aProperty,
// context-sensitive. So if there's nothing cached, it's not context
// sensitive.
*aIsContextSensitive =
!tmpStyleContext->GetRuleNode()->NodeHasCachedData(sid);
!tmpStyleContext->RuleNode()->NodeHasCachedData(sid);
}
// If we're not concerned whether the property is context sensitive then just

View File

@ -50,6 +50,7 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
MOZ_STATIC_ASSERT((UINT32_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >=
nsCSSPseudoElements::ePseudo_MAX,
"pseudo element bits no longer fit in a uint32_t");
MOZ_ASSERT(aRuleNode);
mNextSibling = this;
mPrevSibling = this;
@ -57,7 +58,7 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
mParent->AddRef();
mParent->AddChild(this);
#ifdef DEBUG
nsRuleNode *r1 = mParent->GetRuleNode(), *r2 = aRuleNode;
nsRuleNode *r1 = mParent->RuleNode(), *r2 = aRuleNode;
while (r1->GetParent())
r1 = r1->GetParent();
while (r2->GetParent())

View File

@ -102,9 +102,9 @@ public:
// Find, if it already exists *and is easily findable* (i.e., near the
// start of the child list), a style context whose:
// * GetPseudo() matches aPseudoTag
// * GetRuleNode() matches aRules
// * RuleNode() matches aRules
// * !GetStyleIfVisited() == !aRulesIfVisited, and, if they're
// non-null, GetStyleIfVisited()->GetRuleNode() == aRulesIfVisited
// non-null, GetStyleIfVisited()->RuleNode() == aRulesIfVisited
// * RelevantLinkVisited() == aRelevantLinkVisited
already_AddRefed<nsStyleContext>
FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules,
@ -205,7 +205,7 @@ public:
#undef STYLE_STRUCT_RESET
#undef STYLE_STRUCT_INHERITED
nsRuleNode* GetRuleNode() { return mRuleNode; }
nsRuleNode* RuleNode() { return mRuleNode; }
void AddStyleBit(const uint32_t& aBit) { mBits |= aBit; }
/*

View File

@ -189,7 +189,7 @@ nsStyleSet::EndReconstruct()
mInReconstruct = false;
#ifdef DEBUG
for (int32_t i = mRoots.Length() - 1; i >= 0; --i) {
nsRuleNode *n = mRoots[i]->GetRuleNode();
nsRuleNode *n = mRoots[i]->RuleNode();
while (n->GetParent()) {
n = n->GetParent();
}
@ -808,12 +808,12 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
nsIStyleRule *oldAnimRule = GetAnimationRule(aRuleNode);
nsIStyleRule *animRule = PresContext()->AnimationManager()->
CheckAnimationRule(result, aElementForAnimation);
NS_ABORT_IF_FALSE(result->GetRuleNode() == aRuleNode,
NS_ABORT_IF_FALSE(result->RuleNode() == aRuleNode,
"unexpected rule node");
NS_ABORT_IF_FALSE(!result->GetStyleIfVisited() == !aVisitedRuleNode,
"unexpected visited rule node");
NS_ABORT_IF_FALSE(!aVisitedRuleNode ||
result->GetStyleIfVisited()->GetRuleNode() ==
result->GetStyleIfVisited()->RuleNode() ==
aVisitedRuleNode,
"unexpected visited rule node");
if (oldAnimRule != animRule) {
@ -1230,7 +1230,7 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
NS_ENSURE_FALSE(mInShutdown, nullptr);
nsRuleWalker ruleWalker(mRuleTree);
ruleWalker.SetCurrentNode(aBaseContext->GetRuleNode());
ruleWalker.SetCurrentNode(aBaseContext->RuleNode());
// FIXME: Perhaps this should be passed in, but it probably doesn't
// matter.
ruleWalker.SetLevel(eDocSheet, false, false);
@ -1242,7 +1242,7 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
nsRuleNode *visitedRuleNode = nullptr;
if (aBaseContext->GetStyleIfVisited()) {
ruleWalker.SetCurrentNode(aBaseContext->GetStyleIfVisited()->GetRuleNode());
ruleWalker.SetCurrentNode(aBaseContext->GetStyleIfVisited()->RuleNode());
for (int32_t i = 0; i < aRules.Count(); i++) {
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i));
}
@ -1663,7 +1663,7 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
nsIAtom* pseudoTag = aStyleContext->GetPseudo();
nsCSSPseudoElements::Type pseudoType = aStyleContext->GetPseudoType();
nsRuleNode* ruleNode = aStyleContext->GetRuleNode();
nsRuleNode* ruleNode = aStyleContext->RuleNode();
// Skip transition rules as needed just like
// nsTransitionManager::WalkTransitionRule would.
@ -1686,7 +1686,7 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
// particular, it doesn't change whether this is a style context for
// a link.
if (visitedContext) {
visitedRuleNode = visitedContext->GetRuleNode();
visitedRuleNode = visitedContext->RuleNode();
// Again, skip transition rules as needed
if (skipAnimationRules) {
// FIXME do something here for animations?

View File

@ -265,7 +265,7 @@ nsTransitionManager::UpdateThrottledStyle(dom::Element* aElement,
}
nsStyleContext* oldStyle = primaryFrame->StyleContext();
nsRuleNode* ruleNode = oldStyle->GetRuleNode();
nsRuleNode* ruleNode = oldStyle->RuleNode();
nsTArray<nsStyleSet::RuleAndLevel> rules;
do {
if (ruleNode->IsRoot()) {

View File

@ -39,7 +39,7 @@ nsNativeTheme::GetPresShell(nsIFrame* aFrame)
// this is a workaround for the egcs 1.1.2 not inliningg
// aFrame->GetPresContext(), which causes an undefined symbol
nsPresContext *context = aFrame->StyleContext()->GetRuleNode()->GetPresContext();
nsPresContext *context = aFrame->StyleContext()->RuleNode()->GetPresContext();
return context ? context->GetPresShell() : nullptr;
}