From 8f3a364f1f48e7e90f2802dbfe3e2a0fbf7fa800 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Sat, 16 Feb 2013 13:04:53 -0800 Subject: [PATCH] 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. --- layout/base/nsFrameManager.cpp | 4 ++-- layout/generic/nsFirstLetterFrame.cpp | 2 +- layout/generic/nsIFrame.h | 2 +- layout/inspector/src/inDOMUtils.cpp | 2 +- layout/style/nsComputedDOMStyle.cpp | 2 +- layout/style/nsRuleNode.cpp | 4 ++-- layout/style/nsStyleAnimation.cpp | 2 +- layout/style/nsStyleContext.cpp | 3 ++- layout/style/nsStyleContext.h | 6 +++--- layout/style/nsStyleSet.cpp | 14 +++++++------- layout/style/nsTransitionManager.cpp | 2 +- widget/xpwidgets/nsNativeTheme.cpp | 2 +- 12 files changed, 23 insertions(+), 22 deletions(-) diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index f7aea8e4382..c4c84ea8fc3 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -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()) { diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp index 6edfcab4572..75e3ad9fbf7 100644 --- a/layout/generic/nsFirstLetterFrame.cpp +++ b/layout/generic/nsFirstLetterFrame.cpp @@ -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); diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 6b1b2a7181f..17634a506e5 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -566,7 +566,7 @@ public: NS_DECL_QUERYFRAME_TARGET(nsIFrame) nsPresContext* PresContext() const { - return StyleContext()->GetRuleNode()->GetPresContext(); + return StyleContext()->RuleNode()->GetPresContext(); } /** diff --git a/layout/inspector/src/inDOMUtils.cpp b/layout/inspector/src/inDOMUtils.cpp index 53406193ee5..e8ea6b6703e 100644 --- a/layout/inspector/src/inDOMUtils.cpp +++ b/layout/inspector/src/inDOMUtils.cpp @@ -430,7 +430,7 @@ inDOMUtils::GetRuleNodeForContent(nsIContent* aContent, nsRefPtr sContext = nsComputedDOMStyle::GetStyleContextForElement(aContent->AsElement(), aPseudo, presShell); if (sContext) { - *aRuleNode = sContext->GetRuleNode(); + *aRuleNode = sContext->RuleNode(); sContext.forget(aStyleContext); } return NS_OK; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 8f4634ed1e5..20440bd1686 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -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 > rules; - for (nsRuleNode* ruleNode = sc->GetRuleNode(); + for (nsRuleNode* ruleNode = sc->RuleNode(); !ruleNode->IsRoot(); ruleNode = ruleNode->GetParent()) { if (ruleNode->GetLevel() == nsStyleSet::eAgentSheet || diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index fd0dbe90cd6..8a1fd0d7c4d 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -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) { diff --git a/layout/style/nsStyleAnimation.cpp b/layout/style/nsStyleAnimation.cpp index a2cc751d4ab..03e4701f9e9 100644 --- a/layout/style/nsStyleAnimation.cpp +++ b/layout/style/nsStyleAnimation.cpp @@ -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 diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index 79acaf44952..c0e2a9262f8 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -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()) diff --git a/layout/style/nsStyleContext.h b/layout/style/nsStyleContext.h index 76c1cfffa41..7dc1a2cb530 100644 --- a/layout/style/nsStyleContext.h +++ b/layout/style/nsStyleContext.h @@ -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 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; } /* diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 4766b946749..60524168d8b 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -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? diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index cbb678dc7b8..6a93b522c7d 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -265,7 +265,7 @@ nsTransitionManager::UpdateThrottledStyle(dom::Element* aElement, } nsStyleContext* oldStyle = primaryFrame->StyleContext(); - nsRuleNode* ruleNode = oldStyle->GetRuleNode(); + nsRuleNode* ruleNode = oldStyle->RuleNode(); nsTArray rules; do { if (ruleNode->IsRoot()) { diff --git a/widget/xpwidgets/nsNativeTheme.cpp b/widget/xpwidgets/nsNativeTheme.cpp index cf531a0da41..ba91981994f 100644 --- a/widget/xpwidgets/nsNativeTheme.cpp +++ b/widget/xpwidgets/nsNativeTheme.cpp @@ -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; }