Make GetParent on nsStyleContext return an

already_AddRefed<nsIStyleContext>.  Bug 171808, r=jkeiser, sr=dbaron
This commit is contained in:
bzbarsky%mit.edu 2002-10-09 01:46:15 +00:00
Родитель 96eb534f8f
Коммит a272a96238
27 изменённых файлов: 149 добавлений и 339 удалений

Просмотреть файл

@ -1589,8 +1589,7 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
// All information must necessarily be inherited from our parent style context.
// In the absence of any computed data in the rule tree and with
// no rules specified that didn't have values of 'inherit', we should check our parent.
nsCOMPtr<nsIStyleContext> parentContext =
dont_AddRef(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
if (parentContext) {
// We have a parent, and so we should just inherit from the parent.
// Set the inherit bits on our context. These bits tell the style context that
@ -2076,7 +2075,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext,
{
// walk up the contexts until a context with the desired generic font
nsAutoVoidArray contextPath;
nsCOMPtr<nsIStyleContext> higherContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> higherContext = aContext->GetParent();
while (higherContext) {
contextPath.AppendElement(higherContext);
const nsStyleFont* higherFont = (const nsStyleFont*)higherContext->GetStyleData(eStyleStruct_Font);
@ -2084,7 +2083,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext,
// done walking up the higher contexts
break;
}
higherContext = getter_AddRefs(higherContext->GetParent());
higherContext = higherContext->GetParent();
}
// re-apply the cascading rules, starting from the higher context
@ -2169,7 +2168,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSFont& fontData = NS_STATIC_CAST(const nsCSSFont&, aData);
nsStyleFont* font = nsnull;
@ -2298,7 +2297,7 @@ nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSText& textData = NS_STATIC_CAST(const nsCSSText&, aData);
nsStyleText* text = nsnull;
@ -2418,7 +2417,7 @@ nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSText& textData = NS_STATIC_CAST(const nsCSSText&, aData);
nsStyleTextReset* text;
@ -2504,7 +2503,7 @@ nsRuleNode::ComputeUserInterfaceData(nsStyleStruct* aStartData,
const RuleDetail& aRuleDetail,
PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSUserInterface& uiData = NS_STATIC_CAST(const nsCSSUserInterface&, aData);
nsStyleUserInterface* ui = nsnull;
@ -2614,7 +2613,7 @@ nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aDa
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSUserInterface& uiData = NS_STATIC_CAST(const nsCSSUserInterface&, aData);
nsStyleUIReset* ui;
@ -2703,7 +2702,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSDisplay& displayData = NS_STATIC_CAST(const nsCSSDisplay&, aData);
nsStyleDisplay* display;
@ -2956,7 +2955,7 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsCSSStruct
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSDisplay& displayData = NS_STATIC_CAST(const nsCSSDisplay&, aData);
nsStyleVisibility* visibility = nsnull;
@ -3066,7 +3065,7 @@ nsRuleNode::ComputeColorData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDa
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSColor& colorData = NS_STATIC_CAST(const nsCSSColor&, aData);
nsStyleColor* color = nsnull;
@ -3122,7 +3121,7 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSColor& colorData = NS_STATIC_CAST(const nsCSSColor&, aData);
nsStyleBackground* bg;
@ -3285,7 +3284,7 @@ nsRuleNode::ComputeMarginData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSMargin& marginData = NS_STATIC_CAST(const nsCSSMargin&, aData);
nsStyleMargin* margin;
@ -3350,7 +3349,7 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSMargin& marginData = NS_STATIC_CAST(const nsCSSMargin&, aData);
nsStyleBorder* border;
@ -3630,7 +3629,7 @@ nsRuleNode::ComputePaddingData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSMargin& marginData = NS_STATIC_CAST(const nsCSSMargin&, aData);
nsStylePadding* padding;
@ -3695,7 +3694,7 @@ nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSMargin& marginData = NS_STATIC_CAST(const nsCSSMargin&, aData);
nsStyleOutline* outline;
@ -3767,7 +3766,7 @@ nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSList& listData = NS_STATIC_CAST(const nsCSSList&, aData);
nsStyleList* list = nsnull;
@ -3883,7 +3882,7 @@ nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct, const nsCSSStruct&
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSPosition& posData = NS_STATIC_CAST(const nsCSSPosition&, aData);
nsStylePosition* pos;
@ -3991,7 +3990,7 @@ nsRuleNode::ComputeTableData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDa
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSTable& tableData = NS_STATIC_CAST(const nsCSSTable&, aData);
nsStyleTable* table;
@ -4061,7 +4060,7 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct, const nsCSSStruc
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSTable& tableData = NS_STATIC_CAST(const nsCSSTable&, aData);
nsStyleTableBorder* table = nsnull;
@ -4159,7 +4158,7 @@ nsRuleNode::ComputeContentData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSContent& contentData = NS_STATIC_CAST(const nsCSSContent&, aData);
nsStyleContent* content;
@ -4354,7 +4353,7 @@ nsRuleNode::ComputeQuotesData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSContent& contentData = NS_STATIC_CAST(const nsCSSContent&, aData);
nsStyleQuotes* quotes = nsnull;
@ -4447,7 +4446,7 @@ nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSXUL& xulData = NS_STATIC_CAST(const nsCSSXUL&, aData);
nsStyleXUL* xul = nsnull;
@ -4596,7 +4595,7 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
nsStyleSVG* svg = nsnull;
nsStyleSVG* parentSVG = svg;

Просмотреть файл

@ -73,7 +73,7 @@ public:
NS_DECL_ISUPPORTS
virtual nsIStyleContext* GetParent(void) const;
virtual already_AddRefed<nsIStyleContext> GetParent(void) const;
NS_IMETHOD GetFirstChild(nsIStyleContext** aContext);
NS_IMETHOD GetPseudoType(nsIAtom*& aPseudoTag) const;
@ -189,7 +189,7 @@ NS_IMPL_ADDREF(nsStyleContext)
NS_IMPL_RELEASE_WITH_DESTROY(nsStyleContext, Destroy())
NS_IMPL_QUERY_INTERFACE1(nsStyleContext, nsIStyleContext)
nsIStyleContext* nsStyleContext::GetParent(void) const
already_AddRefed<nsIStyleContext> nsStyleContext::GetParent(void) const
{
NS_IF_ADDREF(mParent);
return mParent;

Просмотреть файл

@ -102,8 +102,6 @@ struct nsRuleNodeList
// =====================================================
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
class StyleSetImpl : public nsIStyleSet
#ifdef MOZ_PERF_METRICS
, public nsITimeRecorder
@ -664,7 +662,7 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen
}
if (nsnull == mFrameConstructor) {
aSheet->QueryInterface(kIStyleFrameConstructionIID, (void **)&mFrameConstructor);
CallQueryInterface(aSheet, &mFrameConstructor);
}
ClearDocRuleProcessors();
}
@ -1412,7 +1410,7 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
nsresult result = NS_ERROR_NULL_POINTER;
if (aPresContext && aStyleContext && aNewStyleContext) {
nsIStyleContext* oldParent = aStyleContext->GetParent();
nsCOMPtr<nsIStyleContext> oldParent = aStyleContext->GetParent();
if (oldParent == aNewParentContext) {
result = NS_OK;
@ -1421,8 +1419,8 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
}
else { // really a new parent
nsIStyleContext* newChild = nsnull;
nsIAtom* pseudoTag = nsnull;
aStyleContext->GetPseudoType(pseudoTag);
nsCOMPtr<nsIAtom> pseudoTag;
aStyleContext->GetPseudoType(*getter_AddRefs(pseudoTag));
nsRuleNode* ruleNode;
aStyleContext->GetRuleNode(&ruleNode);
@ -1436,11 +1434,7 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
result = NS_NewStyleContext(aNewStyleContext, aNewParentContext, pseudoTag,
ruleNode, aPresContext);
}
NS_IF_RELEASE(pseudoTag);
}
NS_IF_RELEASE(oldParent);
}
return result;
}

Просмотреть файл

@ -397,7 +397,7 @@ static void PostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleDa
{
nsStyleText* text = (nsStyleText*)aStyleStruct;
if (text->mTextAlign == NS_STYLE_TEXT_ALIGN_DEFAULT) {
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aRuleData->mStyleContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aRuleData->mStyleContext->GetParent();
if (parentContext) {
const nsStyleText* parentStyleText =
@ -430,9 +430,13 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct,
{
if (!aStyleStruct || !aRuleData || !aRuleData->mPresContext) return;
nsCOMPtr<nsIStyleContext> tableContext = getter_AddRefs(aRuleData->mStyleContext->GetParent()); if (!tableContext) return;
nsCOMPtr<nsIStyleContext> tableContext = aRuleData->mStyleContext->GetParent();
if (!tableContext)
return;
if (!aGroup) {
tableContext = getter_AddRefs(tableContext->GetParent()); if (!tableContext) return;
tableContext = tableContext->GetParent();
if (!tableContext)
return;
}
const nsStyleTable* tableData =
@ -441,10 +445,14 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct,
(aRulesArg2 == tableData->mRules) ||
(aRulesArg3 == tableData->mRules))) {
const nsStyleBorder* tableBorderData =
(const nsStyleBorder*)tableContext->GetStyleData(eStyleStruct_Border); if (!tableBorderData) return;
(const nsStyleBorder*)tableContext->GetStyleData(eStyleStruct_Border);
if (!tableBorderData)
return;
PRUint8 tableBorderStyle = tableBorderData->GetBorderStyle(aSide);
nsStyleBorder* borderData = (nsStyleBorder*)aStyleStruct; if (!borderData) return;
nsStyleBorder* borderData = (nsStyleBorder*)aStyleStruct;
if (!borderData)
return;
PRUint8 borderStyle = borderData->GetBorderStyle(aSide);
// XXX It appears that the style system erronously applies the custom style rule after css style,
// consequently it does not properly fit into the casade. For now, assume that a border style of none

Просмотреть файл

@ -135,7 +135,7 @@ nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame,
nsCOMPtr<nsIAtom> frameType;
aFrame->GetFrameType(getter_AddRefs(frameType));
if (frameType == nsLayoutAtoms::tableOuterFrame) {
*aStyleContext = styleContext->GetParent();
*aStyleContext = styleContext->GetParent().get();
} else {
*aStyleContext = styleContext;
NS_ADDREF(*aStyleContext);

Просмотреть файл

@ -1575,8 +1575,7 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe
NS_NewInlineFrame(aPresShell, aWrapperFrame);
wrapperPseudo = nsCSSAtoms::mozGCWrapperInline;
}
nsCOMPtr<nsIStyleContext> parentSC =
dont_AddRef(aStyleContext->GetParent());
nsCOMPtr<nsIStyleContext> parentSC = aStyleContext->GetParent();
nsCOMPtr<nsIStyleContext> wrapperSC;
aPresContext->ResolvePseudoStyleContextFor(nsnull, wrapperPseudo,
parentSC, getter_AddRefs(wrapperSC));
@ -4004,8 +4003,7 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
if (NS_SUCCEEDED(rv)) {
// The placeholder frame gets a pseudo style context
nsCOMPtr<nsIStyleContext> placeholderStyle;
nsCOMPtr<nsIStyleContext> parentContext =
dont_AddRef(aStyleContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aStyleContext->GetParent();
aPresContext->ResolveStyleContextForNonElement(parentContext,
getter_AddRefs(placeholderStyle));
placeholderFrame->Init(aPresContext, aContent, aParentFrame,

Просмотреть файл

@ -2377,12 +2377,11 @@ nsCSSRendering::FindNonTransparentBackground(nsIStyleContext* aContext,
PRBool aStartAtParent /*= PR_FALSE*/)
{
const nsStyleBackground* result = nsnull;
nsIStyleContext* context;
nsCOMPtr<nsIStyleContext> context;
if (aStartAtParent) {
context = aContext->GetParent(); // balance ending release
context = aContext->GetParent();
} else {
context = aContext;
NS_IF_ADDREF(context); // balance ending release
}
NS_ASSERTION(context, "Cannot find NonTransparentBackground in a null context" );
@ -2391,11 +2390,8 @@ nsCSSRendering::FindNonTransparentBackground(nsIStyleContext* aContext,
if (0 == (result->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT))
break;
nsIStyleContext* last = context;
context = context->GetParent();
NS_RELEASE(last);
}
NS_IF_RELEASE(context);
return result;
}

Просмотреть файл

@ -1357,13 +1357,13 @@ VerifySameTree(nsIStyleContext* aContext1, nsIStyleContext* aContext2)
nsCOMPtr<nsIStyleContext> top2 = aContext2;
nsCOMPtr<nsIStyleContext> parent;
for (;;) {
parent = dont_AddRef(top1->GetParent());
parent = top1->GetParent();
if (!parent)
break;
top1 = parent;
}
for (;;) {
parent = dont_AddRef(top2->GetParent());
parent = top2->GetParent();
if (!parent)
break;
top2 = parent;
@ -1403,7 +1403,7 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame,
}
NS_ASSERTION(aContext, "Failure to get required contexts");
nsIStyleContext* actualParentContext = aContext->GetParent();
nsCOMPtr<nsIStyleContext> actualParentContext = aContext->GetParent();
if (aParentContext) {
if (aParentContext != actualParentContext) {
@ -1430,7 +1430,6 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame,
}
}
NS_IF_RELEASE(actualParentContext);
NS_IF_RELEASE(aParentContext);
NS_IF_RELEASE(aContext);
}
@ -1503,12 +1502,10 @@ FrameManager::DebugVerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFram
{
NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE);
if (aFrame) {
nsIStyleContext* context;
aFrame->GetStyleContext(&context);
nsIStyleContext* parentContext = context->GetParent();
nsCOMPtr<nsIStyleContext> context;
aFrame->GetStyleContext(getter_AddRefs(context));
nsCOMPtr<nsIStyleContext> parentContext = context->GetParent();
VerifyStyleTree(aPresContext, aFrame, parentContext);
NS_IF_RELEASE(parentContext);
NS_RELEASE(context);
}
return NS_OK;
}

Просмотреть файл

@ -1,150 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIStyleContext_h___
#define nsIStyleContext_h___
#include "nsISupports.h"
#include "nsColor.h"
#include "nsCoord.h"
#include "nsMargin.h"
#include "nsRect.h"
#include "nsFont.h"
#include "nsVoidArray.h"
#include "nsStyleCoord.h"
#include "nsStyleStruct.h"
#include "nsStyleConsts.h"
#include "nsChangeHint.h"
#include "nsCOMPtr.h"
#include "nsILanguageAtom.h"
class nsISizeOfHandler;
class nsIFrame;
class nsIStyleSet;
class nsIPresContext;
class nsISupportsArray;
class nsIStyleContext;
class nsRuleNode;
//----------------------------------------------------------------------
#define NS_ISTYLECONTEXT_IID \
{ 0x26a4d970, 0xa342, 0x11d1, \
{0x89, 0x74, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
class nsIStyleContext : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLECONTEXT_IID)
virtual PRBool Equals(const nsIStyleContext* aOther) const = 0;
virtual nsIStyleContext* GetParent(void) const = 0;
NS_IMETHOD GetFirstChild(nsIStyleContext** aContext)=0;
NS_IMETHOD GetPseudoType(nsIAtom*& aPseudoTag) const = 0;
NS_IMETHOD FindChildWithRules(const nsIAtom* aPseudoTag,
nsRuleNode* aRules,
nsIStyleContext*& aResult) = 0;
virtual PRBool HasTextDecorations()=0;
NS_IMETHOD GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding)=0;
// This method computes the effective difference between two contexts that are both at the
// same position in the style context tree. The |this| parameter must always
// be the old context. This method will only peek at style data on the old
// context, and will not instantiate new data in order to compute a difference.
// That is why the old context must always be used (since the new context will
// have no data on it yet) for determining the actual difference.
NS_IMETHOD CalcStyleDifference(nsIStyleContext* aOther, nsChangeHint& aHint) = 0;
NS_IMETHOD GetRuleNode(nsRuleNode** aResult)=0;
NS_IMETHOD AddStyleBit(const PRUint32& aBit)=0;
NS_IMETHOD GetStyleBits(PRUint32* aBits)=0;
#ifdef DEBUG
// debugging
virtual void List(FILE* out, PRInt32 aIndent) = 0;
virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize) = 0;
virtual void DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)=0;
#endif
// XXXdwh Make this function private. It should not be possible to call this
// function from layout.
// Fill a style struct with data.
NS_IMETHOD SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct) = 0;
// Get the data for a style struct.
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) = 0;
virtual const nsStyleStruct* GetStyleData(nsStyleStructID aSID) = 0;
// Avoid using this method at all costs. It defeats sharing of style data, forcing the context
// to have its own unique copy. At the moment the only supported structs are text, background, and
// display. Don't add support for new structs or use this method without careful consideration! -dwh
virtual nsStyleStruct* GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID) = 0;
// Used only for inline style.
virtual nsresult ClearCachedDataForRule(nsIStyleRule* aRule) = 0;
// Used to clear away the style data for a given style context if it matches the specified |aRule|.
// If |aRule| is null, then the style data is always blown away.
virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule) = 0;
};
// this is private to nsStyleSet, don't call it
extern NS_EXPORT nsresult
NS_NewStyleContext(nsIStyleContext** aInstancePtrResult,
nsIStyleContext* aParentContext,
nsIAtom* aPseudoType,
nsRuleNode* aRuleNode,
nsIPresContext* aPresContext);
// typesafe way to access style data. See nsStyleStruct.h and also
// overloaded function in nsIFrame.h.
template <class T>
inline void
GetStyleData(nsIStyleContext* aStyleContext, const T** aStyleStruct)
{
*aStyleStruct = NS_STATIC_CAST(const T*,
aStyleContext->GetStyleData(NS_GET_STYLESTRUCTID(T)));
}
#endif /* nsIStyleContext_h___ */

Просмотреть файл

@ -794,21 +794,17 @@ nsStyleUnit
nsBlockReflowContext::GetRealMarginLeftUnit()
{
nsStyleUnit unit = eStyleUnit_Inherit;
nsIStyleContext* sc;
mFrame->GetStyleContext(&sc);
while ((nsnull != sc) && (eStyleUnit_Inherit == unit)) {
nsCOMPtr<nsIStyleContext> sc;
mFrame->GetStyleContext(getter_AddRefs(sc));
while (sc && eStyleUnit_Inherit == unit) {
// Get parent style context
nsIStyleContext* psc;
psc = sc->GetParent();
NS_RELEASE(sc);
sc = psc;
if (nsnull != sc) {
sc = sc->GetParent();
if (sc) {
const nsStyleMargin* margin = (const nsStyleMargin*)
sc->GetStyleData(eStyleStruct_Margin);
unit = margin->mMargin.GetLeftUnit();
}
}
NS_IF_RELEASE(sc);
return unit;
}
@ -819,20 +815,16 @@ nsStyleUnit
nsBlockReflowContext::GetRealMarginRightUnit()
{
nsStyleUnit unit = eStyleUnit_Inherit;
nsIStyleContext* sc;
mFrame->GetStyleContext(&sc);
while ((nsnull != sc) && (eStyleUnit_Inherit == unit)) {
nsCOMPtr<nsIStyleContext> sc;
mFrame->GetStyleContext(getter_AddRefs(sc));
while (sc && eStyleUnit_Inherit == unit) {
// Get parent style context
nsIStyleContext* psc;
psc = sc->GetParent();
NS_RELEASE(sc);
sc = psc;
if (nsnull != sc) {
sc = sc->GetParent();
if (sc) {
const nsStyleMargin* margin = (const nsStyleMargin*)
sc->GetStyleData(eStyleStruct_Margin);
unit = margin->mMargin.GetRightUnit();
}
}
NS_IF_RELEASE(sc);
return unit;
}

Просмотреть файл

@ -137,12 +137,11 @@ nsFirstLetterFrame::Init(nsIPresContext* aPresContext,
// Get proper style context for ourselves. We're creating the frame
// that represents everything *except* the first letter, so just create
// a style context like we would for a text node.
nsIStyleContext* parentStyleContext = aContext->GetParent();
nsCOMPtr<nsIStyleContext> parentStyleContext = aContext->GetParent();
if (parentStyleContext) {
rv = aPresContext->ResolveStyleContextForNonElement(
parentStyleContext,
getter_AddRefs(newSC));
NS_RELEASE(parentStyleContext);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -1804,7 +1804,7 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext,
nscolor overColor;
nscolor underColor;
nscolor strikeColor;
nsIStyleContext* context = aStyleContext;
nsCOMPtr<nsIStyleContext> context = aStyleContext;
PRBool useOverride = PR_FALSE;
nscolor overrideColor;
@ -1814,7 +1814,6 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext,
NS_STYLE_TEXT_DECORATION_LINE_THROUGH; // A mask of all possible decorations.
PRBool hasDecorations = context->HasTextDecorations();
NS_ADDREF(context);
do { // find decoration colors
const nsStyleTextReset* styleText =
(const nsStyleTextReset*)context->GetStyleData(eStyleStruct_TextReset);
@ -1848,13 +1847,12 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext,
}
}
if (0 != decorMask) {
nsIStyleContext* lastContext = context;
context = context->GetParent();
hasDecorations = context->HasTextDecorations();
NS_RELEASE(lastContext);
if (context) {
hasDecorations = context->HasTextDecorations();
}
}
} while ((nsnull != context) && hasDecorations && (0 != decorMask));
NS_IF_RELEASE(context);
} while (context && hasDecorations && (0 != decorMask));
nscoord offset;
nscoord size;

Просмотреть файл

@ -794,21 +794,17 @@ nsStyleUnit
nsBlockReflowContext::GetRealMarginLeftUnit()
{
nsStyleUnit unit = eStyleUnit_Inherit;
nsIStyleContext* sc;
mFrame->GetStyleContext(&sc);
while ((nsnull != sc) && (eStyleUnit_Inherit == unit)) {
nsCOMPtr<nsIStyleContext> sc;
mFrame->GetStyleContext(getter_AddRefs(sc));
while (sc && eStyleUnit_Inherit == unit) {
// Get parent style context
nsIStyleContext* psc;
psc = sc->GetParent();
NS_RELEASE(sc);
sc = psc;
if (nsnull != sc) {
sc = sc->GetParent();
if (sc) {
const nsStyleMargin* margin = (const nsStyleMargin*)
sc->GetStyleData(eStyleStruct_Margin);
unit = margin->mMargin.GetLeftUnit();
}
}
NS_IF_RELEASE(sc);
return unit;
}
@ -819,20 +815,16 @@ nsStyleUnit
nsBlockReflowContext::GetRealMarginRightUnit()
{
nsStyleUnit unit = eStyleUnit_Inherit;
nsIStyleContext* sc;
mFrame->GetStyleContext(&sc);
while ((nsnull != sc) && (eStyleUnit_Inherit == unit)) {
nsCOMPtr<nsIStyleContext> sc;
mFrame->GetStyleContext(getter_AddRefs(sc));
while (sc && eStyleUnit_Inherit == unit) {
// Get parent style context
nsIStyleContext* psc;
psc = sc->GetParent();
NS_RELEASE(sc);
sc = psc;
if (nsnull != sc) {
sc = sc->GetParent();
if (sc) {
const nsStyleMargin* margin = (const nsStyleMargin*)
sc->GetStyleData(eStyleStruct_Margin);
unit = margin->mMargin.GetRightUnit();
}
}
NS_IF_RELEASE(sc);
return unit;
}

Просмотреть файл

@ -137,12 +137,11 @@ nsFirstLetterFrame::Init(nsIPresContext* aPresContext,
// Get proper style context for ourselves. We're creating the frame
// that represents everything *except* the first letter, so just create
// a style context like we would for a text node.
nsIStyleContext* parentStyleContext = aContext->GetParent();
nsCOMPtr<nsIStyleContext> parentStyleContext = aContext->GetParent();
if (parentStyleContext) {
rv = aPresContext->ResolveStyleContextForNonElement(
parentStyleContext,
getter_AddRefs(newSC));
NS_RELEASE(parentStyleContext);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -1357,13 +1357,13 @@ VerifySameTree(nsIStyleContext* aContext1, nsIStyleContext* aContext2)
nsCOMPtr<nsIStyleContext> top2 = aContext2;
nsCOMPtr<nsIStyleContext> parent;
for (;;) {
parent = dont_AddRef(top1->GetParent());
parent = top1->GetParent();
if (!parent)
break;
top1 = parent;
}
for (;;) {
parent = dont_AddRef(top2->GetParent());
parent = top2->GetParent();
if (!parent)
break;
top2 = parent;
@ -1403,7 +1403,7 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame,
}
NS_ASSERTION(aContext, "Failure to get required contexts");
nsIStyleContext* actualParentContext = aContext->GetParent();
nsCOMPtr<nsIStyleContext> actualParentContext = aContext->GetParent();
if (aParentContext) {
if (aParentContext != actualParentContext) {
@ -1430,7 +1430,6 @@ VerifyContextParent(nsIPresContext* aPresContext, nsIFrame* aFrame,
}
}
NS_IF_RELEASE(actualParentContext);
NS_IF_RELEASE(aParentContext);
NS_IF_RELEASE(aContext);
}
@ -1503,12 +1502,10 @@ FrameManager::DebugVerifyStyleTree(nsIPresContext* aPresContext, nsIFrame* aFram
{
NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE);
if (aFrame) {
nsIStyleContext* context;
aFrame->GetStyleContext(&context);
nsIStyleContext* parentContext = context->GetParent();
nsCOMPtr<nsIStyleContext> context;
aFrame->GetStyleContext(getter_AddRefs(context));
nsCOMPtr<nsIStyleContext> parentContext = context->GetParent();
VerifyStyleTree(aPresContext, aFrame, parentContext);
NS_IF_RELEASE(parentContext);
NS_RELEASE(context);
}
return NS_OK;
}

Просмотреть файл

@ -1804,7 +1804,7 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext,
nscolor overColor;
nscolor underColor;
nscolor strikeColor;
nsIStyleContext* context = aStyleContext;
nsCOMPtr<nsIStyleContext> context = aStyleContext;
PRBool useOverride = PR_FALSE;
nscolor overrideColor;
@ -1814,7 +1814,6 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext,
NS_STYLE_TEXT_DECORATION_LINE_THROUGH; // A mask of all possible decorations.
PRBool hasDecorations = context->HasTextDecorations();
NS_ADDREF(context);
do { // find decoration colors
const nsStyleTextReset* styleText =
(const nsStyleTextReset*)context->GetStyleData(eStyleStruct_TextReset);
@ -1848,13 +1847,12 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext,
}
}
if (0 != decorMask) {
nsIStyleContext* lastContext = context;
context = context->GetParent();
hasDecorations = context->HasTextDecorations();
NS_RELEASE(lastContext);
if (context) {
hasDecorations = context->HasTextDecorations();
}
}
} while ((nsnull != context) && hasDecorations && (0 != decorMask));
NS_IF_RELEASE(context);
} while (context && hasDecorations && (0 != decorMask));
nscoord offset;
nscoord size;

Просмотреть файл

@ -1575,8 +1575,7 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresShell* aPresShe
NS_NewInlineFrame(aPresShell, aWrapperFrame);
wrapperPseudo = nsCSSAtoms::mozGCWrapperInline;
}
nsCOMPtr<nsIStyleContext> parentSC =
dont_AddRef(aStyleContext->GetParent());
nsCOMPtr<nsIStyleContext> parentSC = aStyleContext->GetParent();
nsCOMPtr<nsIStyleContext> wrapperSC;
aPresContext->ResolvePseudoStyleContextFor(nsnull, wrapperPseudo,
parentSC, getter_AddRefs(wrapperSC));
@ -4004,8 +4003,7 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
if (NS_SUCCEEDED(rv)) {
// The placeholder frame gets a pseudo style context
nsCOMPtr<nsIStyleContext> placeholderStyle;
nsCOMPtr<nsIStyleContext> parentContext =
dont_AddRef(aStyleContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aStyleContext->GetParent();
aPresContext->ResolveStyleContextForNonElement(parentContext,
getter_AddRefs(placeholderStyle));
placeholderFrame->Init(aPresContext, aContent, aParentFrame,

Просмотреть файл

@ -2377,12 +2377,11 @@ nsCSSRendering::FindNonTransparentBackground(nsIStyleContext* aContext,
PRBool aStartAtParent /*= PR_FALSE*/)
{
const nsStyleBackground* result = nsnull;
nsIStyleContext* context;
nsCOMPtr<nsIStyleContext> context;
if (aStartAtParent) {
context = aContext->GetParent(); // balance ending release
context = aContext->GetParent();
} else {
context = aContext;
NS_IF_ADDREF(context); // balance ending release
}
NS_ASSERTION(context, "Cannot find NonTransparentBackground in a null context" );
@ -2391,11 +2390,8 @@ nsCSSRendering::FindNonTransparentBackground(nsIStyleContext* aContext,
if (0 == (result->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT))
break;
nsIStyleContext* last = context;
context = context->GetParent();
NS_RELEASE(last);
}
NS_IF_RELEASE(context);
return result;
}

Просмотреть файл

@ -1468,7 +1468,7 @@ nsMathMLChar::Stretch(nsIPresContext* aPresContext,
// mStyleContext is a leaf context used only when stretching happens.
// For the base size, the default font should come from the parent context
nsAutoString fontName;
nsCOMPtr<nsIStyleContext> parentContext(dont_AddRef(mStyleContext->GetParent()));
nsCOMPtr<nsIStyleContext> parentContext(mStyleContext->GetParent());
const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*,
parentContext->GetStyleData(eStyleStruct_Font));
nsFont theFont(font->mFont);
@ -1868,7 +1868,7 @@ nsMathMLChar::Paint(nsIPresContext* aPresContext,
const nsRect* aSelectedRect)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIStyleContext> parentContext(dont_AddRef(mStyleContext->GetParent()));
nsCOMPtr<nsIStyleContext> parentContext(mStyleContext->GetParent());
nsIStyleContext* styleContext = mStyleContext;
if (NS_STRETCH_DIRECTION_UNSUPPORTED == mDirection) {

Просмотреть файл

@ -596,7 +596,7 @@ nsMathMLContainerFrame::PropagateScriptStyleFor(nsIPresContext* aPresContext,
nsCOMPtr<nsIStyleContext> oldStyleContext;
aFrame->GetStyleContext(getter_AddRefs(oldStyleContext));
nsCOMPtr<nsIStyleContext> parentContext(dont_AddRef(oldStyleContext->GetParent()));
nsCOMPtr<nsIStyleContext> parentContext(oldStyleContext->GetParent());
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));

Просмотреть файл

@ -397,7 +397,7 @@ static void PostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleDa
{
nsStyleText* text = (nsStyleText*)aStyleStruct;
if (text->mTextAlign == NS_STYLE_TEXT_ALIGN_DEFAULT) {
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aRuleData->mStyleContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aRuleData->mStyleContext->GetParent();
if (parentContext) {
const nsStyleText* parentStyleText =
@ -430,9 +430,13 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct,
{
if (!aStyleStruct || !aRuleData || !aRuleData->mPresContext) return;
nsCOMPtr<nsIStyleContext> tableContext = getter_AddRefs(aRuleData->mStyleContext->GetParent()); if (!tableContext) return;
nsCOMPtr<nsIStyleContext> tableContext = aRuleData->mStyleContext->GetParent();
if (!tableContext)
return;
if (!aGroup) {
tableContext = getter_AddRefs(tableContext->GetParent()); if (!tableContext) return;
tableContext = tableContext->GetParent();
if (!tableContext)
return;
}
const nsStyleTable* tableData =
@ -441,10 +445,14 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct,
(aRulesArg2 == tableData->mRules) ||
(aRulesArg3 == tableData->mRules))) {
const nsStyleBorder* tableBorderData =
(const nsStyleBorder*)tableContext->GetStyleData(eStyleStruct_Border); if (!tableBorderData) return;
(const nsStyleBorder*)tableContext->GetStyleData(eStyleStruct_Border);
if (!tableBorderData)
return;
PRUint8 tableBorderStyle = tableBorderData->GetBorderStyle(aSide);
nsStyleBorder* borderData = (nsStyleBorder*)aStyleStruct; if (!borderData) return;
nsStyleBorder* borderData = (nsStyleBorder*)aStyleStruct;
if (!borderData)
return;
PRUint8 borderStyle = borderData->GetBorderStyle(aSide);
// XXX It appears that the style system erronously applies the custom style rule after css style,
// consequently it does not properly fit into the casade. For now, assume that a border style of none

Просмотреть файл

@ -135,7 +135,7 @@ nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame,
nsCOMPtr<nsIAtom> frameType;
aFrame->GetFrameType(getter_AddRefs(frameType));
if (frameType == nsLayoutAtoms::tableOuterFrame) {
*aStyleContext = styleContext->GetParent();
*aStyleContext = styleContext->GetParent().get();
} else {
*aStyleContext = styleContext;
NS_ADDREF(*aStyleContext);

Просмотреть файл

@ -1589,8 +1589,7 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
// All information must necessarily be inherited from our parent style context.
// In the absence of any computed data in the rule tree and with
// no rules specified that didn't have values of 'inherit', we should check our parent.
nsCOMPtr<nsIStyleContext> parentContext =
dont_AddRef(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
if (parentContext) {
// We have a parent, and so we should just inherit from the parent.
// Set the inherit bits on our context. These bits tell the style context that
@ -2076,7 +2075,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext,
{
// walk up the contexts until a context with the desired generic font
nsAutoVoidArray contextPath;
nsCOMPtr<nsIStyleContext> higherContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> higherContext = aContext->GetParent();
while (higherContext) {
contextPath.AppendElement(higherContext);
const nsStyleFont* higherFont = (const nsStyleFont*)higherContext->GetStyleData(eStyleStruct_Font);
@ -2084,7 +2083,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext,
// done walking up the higher contexts
break;
}
higherContext = getter_AddRefs(higherContext->GetParent());
higherContext = higherContext->GetParent();
}
// re-apply the cascading rules, starting from the higher context
@ -2169,7 +2168,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSFont& fontData = NS_STATIC_CAST(const nsCSSFont&, aData);
nsStyleFont* font = nsnull;
@ -2298,7 +2297,7 @@ nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSText& textData = NS_STATIC_CAST(const nsCSSText&, aData);
nsStyleText* text = nsnull;
@ -2418,7 +2417,7 @@ nsRuleNode::ComputeTextResetData(nsStyleStruct* aStartData, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSText& textData = NS_STATIC_CAST(const nsCSSText&, aData);
nsStyleTextReset* text;
@ -2504,7 +2503,7 @@ nsRuleNode::ComputeUserInterfaceData(nsStyleStruct* aStartData,
const RuleDetail& aRuleDetail,
PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSUserInterface& uiData = NS_STATIC_CAST(const nsCSSUserInterface&, aData);
nsStyleUserInterface* ui = nsnull;
@ -2614,7 +2613,7 @@ nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aDa
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSUserInterface& uiData = NS_STATIC_CAST(const nsCSSUserInterface&, aData);
nsStyleUIReset* ui;
@ -2703,7 +2702,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSDisplay& displayData = NS_STATIC_CAST(const nsCSSDisplay&, aData);
nsStyleDisplay* display;
@ -2956,7 +2955,7 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsCSSStruct
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSDisplay& displayData = NS_STATIC_CAST(const nsCSSDisplay&, aData);
nsStyleVisibility* visibility = nsnull;
@ -3066,7 +3065,7 @@ nsRuleNode::ComputeColorData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDa
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSColor& colorData = NS_STATIC_CAST(const nsCSSColor&, aData);
nsStyleColor* color = nsnull;
@ -3122,7 +3121,7 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSColor& colorData = NS_STATIC_CAST(const nsCSSColor&, aData);
nsStyleBackground* bg;
@ -3285,7 +3284,7 @@ nsRuleNode::ComputeMarginData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSMargin& marginData = NS_STATIC_CAST(const nsCSSMargin&, aData);
nsStyleMargin* margin;
@ -3350,7 +3349,7 @@ nsRuleNode::ComputeBorderData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSMargin& marginData = NS_STATIC_CAST(const nsCSSMargin&, aData);
nsStyleBorder* border;
@ -3630,7 +3629,7 @@ nsRuleNode::ComputePaddingData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSMargin& marginData = NS_STATIC_CAST(const nsCSSMargin&, aData);
nsStylePadding* padding;
@ -3695,7 +3694,7 @@ nsRuleNode::ComputeOutlineData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSMargin& marginData = NS_STATIC_CAST(const nsCSSMargin&, aData);
nsStyleOutline* outline;
@ -3767,7 +3766,7 @@ nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSList& listData = NS_STATIC_CAST(const nsCSSList&, aData);
nsStyleList* list = nsnull;
@ -3883,7 +3882,7 @@ nsRuleNode::ComputePositionData(nsStyleStruct* aStartStruct, const nsCSSStruct&
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSPosition& posData = NS_STATIC_CAST(const nsCSSPosition&, aData);
nsStylePosition* pos;
@ -3991,7 +3990,7 @@ nsRuleNode::ComputeTableData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDa
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSTable& tableData = NS_STATIC_CAST(const nsCSSTable&, aData);
nsStyleTable* table;
@ -4061,7 +4060,7 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct, const nsCSSStruc
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSTable& tableData = NS_STATIC_CAST(const nsCSSTable&, aData);
nsStyleTableBorder* table = nsnull;
@ -4159,7 +4158,7 @@ nsRuleNode::ComputeContentData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSContent& contentData = NS_STATIC_CAST(const nsCSSContent&, aData);
nsStyleContent* content;
@ -4354,7 +4353,7 @@ nsRuleNode::ComputeQuotesData(nsStyleStruct* aStartStruct, const nsCSSStruct& aD
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSContent& contentData = NS_STATIC_CAST(const nsCSSContent&, aData);
nsStyleQuotes* quotes = nsnull;
@ -4447,7 +4446,7 @@ nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
const nsCSSXUL& xulData = NS_STATIC_CAST(const nsCSSXUL&, aData);
nsStyleXUL* xul = nsnull;
@ -4596,7 +4595,7 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited)
{
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parentContext = aContext->GetParent();
nsStyleSVG* svg = nsnull;
nsStyleSVG* parentSVG = svg;

Просмотреть файл

@ -73,7 +73,7 @@ public:
NS_DECL_ISUPPORTS
virtual nsIStyleContext* GetParent(void) const;
virtual already_AddRefed<nsIStyleContext> GetParent(void) const;
NS_IMETHOD GetFirstChild(nsIStyleContext** aContext);
NS_IMETHOD GetPseudoType(nsIAtom*& aPseudoTag) const;
@ -189,7 +189,7 @@ NS_IMPL_ADDREF(nsStyleContext)
NS_IMPL_RELEASE_WITH_DESTROY(nsStyleContext, Destroy())
NS_IMPL_QUERY_INTERFACE1(nsStyleContext, nsIStyleContext)
nsIStyleContext* nsStyleContext::GetParent(void) const
already_AddRefed<nsIStyleContext> nsStyleContext::GetParent(void) const
{
NS_IF_ADDREF(mParent);
return mParent;

Просмотреть файл

@ -102,8 +102,6 @@ struct nsRuleNodeList
// =====================================================
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
class StyleSetImpl : public nsIStyleSet
#ifdef MOZ_PERF_METRICS
, public nsITimeRecorder
@ -664,7 +662,7 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen
}
if (nsnull == mFrameConstructor) {
aSheet->QueryInterface(kIStyleFrameConstructionIID, (void **)&mFrameConstructor);
CallQueryInterface(aSheet, &mFrameConstructor);
}
ClearDocRuleProcessors();
}
@ -1412,7 +1410,7 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
nsresult result = NS_ERROR_NULL_POINTER;
if (aPresContext && aStyleContext && aNewStyleContext) {
nsIStyleContext* oldParent = aStyleContext->GetParent();
nsCOMPtr<nsIStyleContext> oldParent = aStyleContext->GetParent();
if (oldParent == aNewParentContext) {
result = NS_OK;
@ -1421,8 +1419,8 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
}
else { // really a new parent
nsIStyleContext* newChild = nsnull;
nsIAtom* pseudoTag = nsnull;
aStyleContext->GetPseudoType(pseudoTag);
nsCOMPtr<nsIAtom> pseudoTag;
aStyleContext->GetPseudoType(*getter_AddRefs(pseudoTag));
nsRuleNode* ruleNode;
aStyleContext->GetRuleNode(&ruleNode);
@ -1436,11 +1434,7 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
result = NS_NewStyleContext(aNewStyleContext, aNewParentContext, pseudoTag,
ruleNode, aPresContext);
}
NS_IF_RELEASE(pseudoTag);
}
NS_IF_RELEASE(oldParent);
}
return result;
}

Просмотреть файл

@ -356,7 +356,7 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext,
if (str.IsEmpty()) {
aContent->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
NS_LITERAL_STRING("vertical"), PR_FALSE);
nsCOMPtr<nsIStyleContext> parent = dont_AddRef(aContext->GetParent());
nsCOMPtr<nsIStyleContext> parent = aContext->GetParent();
aPresContext->ResolveStyleContextFor(aContent, parent,
getter_AddRefs(newContext));
aContext = newContext;

Просмотреть файл

@ -345,14 +345,13 @@ nsTextBoxFrame::PaintTitle(nsIPresContext* aPresContext,
nscolor overColor;
nscolor underColor;
nscolor strikeColor;
nsIStyleContext* context = mStyleContext;
nsCOMPtr<nsIStyleContext> context = mStyleContext;
PRUint8 decorations = NS_STYLE_TEXT_DECORATION_NONE; // Begin with no decorations
PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_UNDERLINE | NS_STYLE_TEXT_DECORATION_OVERLINE |
NS_STYLE_TEXT_DECORATION_LINE_THROUGH; // A mask of all possible decorations.
PRBool hasDecorations = context->HasTextDecorations();
NS_ADDREF(context);
do { // find decoration colors
const nsStyleTextReset* styleText =
(const nsStyleTextReset*)context->GetStyleData(eStyleStruct_TextReset);
@ -378,13 +377,12 @@ nsTextBoxFrame::PaintTitle(nsIPresContext* aPresContext,
}
}
if (0 != decorMask) {
nsIStyleContext* lastContext = context;
context = context->GetParent();
hasDecorations = context->HasTextDecorations();
NS_RELEASE(lastContext);
if (context) {
hasDecorations = context->HasTextDecorations();
}
}
} while ((nsnull != context) && hasDecorations && (0 != decorMask));
NS_IF_RELEASE(context);
} while (context && hasDecorations && (0 != decorMask));
nsStyleFont* fontStyle = (nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);