diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 7828fb930b0..2c788f813f3 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -38,9 +38,9 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsRuleNode.h" #include "nscore.h" #include "nsIServiceManager.h" -#include "nsRuleNode.h" #include "nsIDeviceContext.h" #include "nsILookAndFeel.h" #include "nsIPresShell.h" @@ -55,6 +55,9 @@ #include "nsStyleSet.h" #include "nsSize.h" #include "imgIRequest.h" +#include "nsRuleData.h" +#include "nsILanguageAtomService.h" +#include "nsIStyleRule.h" /* * For storage of an |nsRuleNode|'s children in a linked list. @@ -399,6 +402,7 @@ nsRuleNode::nsRuleNode(nsIPresContext* aContext, nsIStyleRule* aRule, nsRuleNode mNoneBits(0) { MOZ_COUNT_CTOR(nsRuleNode); + NS_IF_ADDREF(mRule); } PR_STATIC_CALLBACK(PLDHashOperator) @@ -421,6 +425,7 @@ nsRuleNode::~nsRuleNode() PL_DHashTableDestroy(children); } else if (HaveChildren()) ChildrenList()->Destroy(mPresContext); + NS_IF_RELEASE(mRule); } nsresult diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 678980fc234..cbd74b68d46 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -86,6 +86,7 @@ #include "nsDOMError.h" #include "nsIScriptGlobalObject.h" #include "nsIScriptContext.h" +#include "nsRuleData.h" #include "nsIPresState.h" #include "nsILayoutHistoryState.h" diff --git a/mozilla/content/html/content/src/nsHTMLBRElement.cpp b/mozilla/content/html/content/src/nsHTMLBRElement.cpp index 21a371fb012..df6ec05588a 100644 --- a/mozilla/content/html/content/src/nsHTMLBRElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBRElement.cpp @@ -42,7 +42,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLBRElement : public nsGenericHTMLElement, public nsIDOMHTMLBRElement diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 607dce95b6d..74cad154ad8 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -54,6 +54,7 @@ #include "nsIMarkupDocumentViewer.h" #include "nsMappedAttributes.h" #include "nsISupportsArray.h" +#include "nsRuleData.h" #include "nsIFrame.h" #include "nsIDocShell.h" #include "nsCOMPtr.h" diff --git a/mozilla/content/html/content/src/nsHTMLDivElement.cpp b/mozilla/content/html/content/src/nsHTMLDivElement.cpp index f522ceeb452..0ab809dd486 100644 --- a/mozilla/content/html/content/src/nsHTMLDivElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLDivElement.cpp @@ -42,7 +42,6 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" // XXX support missing nav attributes? gutter, cols, width diff --git a/mozilla/content/html/content/src/nsHTMLFontElement.cpp b/mozilla/content/html/content/src/nsHTMLFontElement.cpp index 6cf5a231526..3fbb28dbc53 100644 --- a/mozilla/content/html/content/src/nsHTMLFontElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFontElement.cpp @@ -45,7 +45,7 @@ #include "nsIPresContext.h" #include "nsMappedAttributes.h" #include "nsCSSStruct.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" #include "nsIDocument.h" class nsHTMLFontElement : public nsGenericHTMLElement, diff --git a/mozilla/content/html/content/src/nsHTMLHRElement.cpp b/mozilla/content/html/content/src/nsHTMLHRElement.cpp index 59cfc501659..755a0d69501 100644 --- a/mozilla/content/html/content/src/nsHTMLHRElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLHRElement.cpp @@ -43,7 +43,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLHRElement : public nsGenericHTMLElement, public nsIDOMHTMLHRElement, diff --git a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp index e00cf516838..012ce662bda 100644 --- a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp @@ -42,7 +42,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLHeadingElement : public nsGenericHTMLElement, public nsIDOMHTMLHeadingElement diff --git a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp index bba0dd9c121..2f633eed0e0 100644 --- a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp @@ -43,7 +43,7 @@ #include "nsIDocument.h" #include "nsMappedAttributes.h" #include "nsDOMError.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLIFrameElement : public nsGenericHTMLFrameElement, public nsIDOMHTMLIFrameElement diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index 4774171df2b..8fb1bf6d2d6 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -73,7 +73,7 @@ #include "nsILoadGroup.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" #include "nsIJSContextStack.h" #include "nsIView.h" diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index c3f6b974621..871c6b254f9 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -90,7 +90,7 @@ #include "nsIDOMEventReceiver.h" #include "nsMutationEvent.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" // input type=radio #include "nsIRadioControlFrame.h" diff --git a/mozilla/content/html/content/src/nsHTMLLIElement.cpp b/mozilla/content/html/content/src/nsHTMLLIElement.cpp index cc63e5b80dd..681c26d5361 100644 --- a/mozilla/content/html/content/src/nsHTMLLIElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLIElement.cpp @@ -42,7 +42,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLLIElement : public nsGenericHTMLElement, public nsIDOMHTMLLIElement diff --git a/mozilla/content/html/content/src/nsHTMLOListElement.cpp b/mozilla/content/html/content/src/nsHTMLOListElement.cpp index 2710a9209ca..d0f8bfc1904 100644 --- a/mozilla/content/html/content/src/nsHTMLOListElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOListElement.cpp @@ -44,7 +44,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLSharedListElement : public nsGenericHTMLElement, public nsIDOMHTMLOListElement, diff --git a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp index cf769348338..55f8066251b 100644 --- a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp @@ -42,7 +42,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" // XXX missing nav attributes diff --git a/mozilla/content/html/content/src/nsHTMLPreElement.cpp b/mozilla/content/html/content/src/nsHTMLPreElement.cpp index 9f73920a6f5..66be0877600 100644 --- a/mozilla/content/html/content/src/nsHTMLPreElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLPreElement.cpp @@ -42,7 +42,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" #include "nsCSSStruct.h" // XXX wrap, variable, cols, tabstop diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index d6ea328466b..224cdaa59d4 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -79,7 +79,7 @@ #include "nsIFrame.h" #include "nsDOMError.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLSelectElement; diff --git a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp index f8e2129e7f2..ab7c967c124 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp @@ -49,7 +49,7 @@ #include "nsHTMLAtoms.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" #include "nsMappedAttributes.h" #include "nsStyleContext.h" diff --git a/mozilla/content/html/content/src/nsHTMLSpanElement.cpp b/mozilla/content/html/content/src/nsHTMLSpanElement.cpp index aea191a5cc3..ef7877a7aee 100644 --- a/mozilla/content/html/content/src/nsHTMLSpanElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSpanElement.cpp @@ -42,7 +42,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIAtom.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLSpanElement : public nsGenericHTMLElement, public nsIDOMHTMLElement diff --git a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp index 0d00f036464..2c288c355d2 100644 --- a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp @@ -42,7 +42,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsMappedAttributes.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" class nsHTMLTableCaptionElement : public nsGenericHTMLElement, public nsIDOMHTMLTableCaptionElement diff --git a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp index 2cdef33b259..95dc9bcfbcf 100644 --- a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp @@ -44,7 +44,7 @@ #include "nsHTMLAtoms.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" #include "nsIDocument.h" class nsHTMLTableCellElement : public nsGenericHTMLElement, diff --git a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp index a08198e8193..b8a64356ac2 100644 --- a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp @@ -42,7 +42,7 @@ #include "nsHTMLAtoms.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" // use the same protection as ancient code did // http://lxr.mozilla.org/classic/source/lib/layout/laytable.c#46 diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp index 5ae7b389703..5f93f3362a4 100644 --- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -49,7 +49,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsHTMLParts.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" #include "nsStyleContext.h" #include "nsIDocument.h" diff --git a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp index ac30e2b6643..07251ebda2a 100644 --- a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp @@ -48,7 +48,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsHTMLParts.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" // temporary #include "nsIDocument.h" diff --git a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp index fc85206dc02..a6ad8ca278d 100644 --- a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -44,7 +44,7 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsContentList.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" #include "nsDOMError.h" #include "nsIDocument.h" diff --git a/mozilla/content/html/style/src/Makefile.in b/mozilla/content/html/style/src/Makefile.in index 5b4377f6b8a..07970b86d9e 100644 --- a/mozilla/content/html/style/src/Makefile.in +++ b/mozilla/content/html/style/src/Makefile.in @@ -108,6 +108,7 @@ EXPORTS = \ nsICSSOMFactory.h \ nsIHTMLCSSStyleSheet.h \ nsIInspectorCSSUtils.h \ + nsRuleData.h \ $(NULL) # we don't want the shared lib, but we want to force the creation of a static lib. diff --git a/mozilla/content/html/style/src/nsCSSDataBlock.cpp b/mozilla/content/html/style/src/nsCSSDataBlock.cpp index 2ae36fa0d11..41196561916 100644 --- a/mozilla/content/html/style/src/nsCSSDataBlock.cpp +++ b/mozilla/content/html/style/src/nsCSSDataBlock.cpp @@ -36,7 +36,7 @@ #include "nsCSSDataBlock.h" #include "nsCSSProps.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" /* * nsCSSCompressedDataBlock holds property-value pairs corresponding to diff --git a/mozilla/content/html/style/src/nsCSSStruct.h b/mozilla/content/html/style/src/nsCSSStruct.h index c27c0c0ff38..a5a06ad9d83 100644 --- a/mozilla/content/html/style/src/nsCSSStruct.h +++ b/mozilla/content/html/style/src/nsCSSStruct.h @@ -52,6 +52,7 @@ struct nsCSSStruct { // aren't CSS properties. Thus we use typedefs and inheritance // (forwards, when the rule data needs extra data) to make the rule data // structs from the declaration structs. +// NOTE: For compilation speed, this typedef also appears in nsRuleNode.h typedef nsCSSStruct nsRuleDataStruct; diff --git a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp index dc957ebd0f1..9007bb5856a 100644 --- a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp @@ -50,8 +50,8 @@ #include "nsIPresContext.h" #include "nsIDocument.h" #include "nsCOMPtr.h" - #include "nsRuleWalker.h" +#include "nsRuleData.h" /* * The CSSFirstLetterRule and CSSFirstLineRule exist so that we can fix diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index 812d37a0f4b..4b9bc5511b3 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -62,8 +62,8 @@ #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsCSSAnonBoxes.h" - #include "nsRuleWalker.h" +#include "nsRuleData.h" nsHTMLStyleSheet::HTMLColorRule::HTMLColorRule(nsHTMLStyleSheet* aSheet) : mSheet(aSheet) diff --git a/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp b/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp index fdf7e62c588..ac4fdf67843 100644 --- a/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp +++ b/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp @@ -38,6 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsInspectorCSSUtils.h" +#include "nsIStyleRule.h" #include "nsRuleNode.h" #include "nsString.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/content/html/style/src/nsRuleData.h b/mozilla/content/html/style/src/nsRuleData.h new file mode 100644 index 00000000000..d387aef80c1 --- /dev/null +++ b/mozilla/content/html/style/src/nsRuleData.h @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 Communicator client 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): + * Original Author: David W. Hyatt (hyatt@netscape.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either of 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 MPL, 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 MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsRuleData_h_ +#define nsRuleData_h_ + +#include "nsCSSStruct.h" +#include "nsRuleNode.h" + +struct nsRuleData +{ + nsStyleStructID mSID; + PRPackedBool mCanStoreInRuleTree; + nsIPresContext* mPresContext; + nsStyleContext* mStyleContext; + nsPostResolveFunc mPostResolveCallback; + nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures! + nsRuleDataDisplay* mDisplayData; + nsRuleDataMargin* mMarginData; + nsRuleDataList* mListData; + nsRuleDataPosition* mPositionData; + nsRuleDataTable* mTableData; + nsRuleDataColor* mColorData; + nsRuleDataContent* mContentData; + nsRuleDataText* mTextData; + nsRuleDataUserInterface* mUserInterfaceData; + nsRuleDataXUL* mXULData; + +#ifdef MOZ_SVG + nsRuleDataSVG* mSVGData; +#endif + + nsRuleDataColumn* mColumnData; + + nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext) + :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull), + mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), + mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull), + mUserInterfaceData(nsnull), mColumnData(nsnull) + { + mCanStoreInRuleTree = PR_TRUE; + mXULData = nsnull; +#ifdef MOZ_SVG + mSVGData = nsnull; +#endif + }; + ~nsRuleData() {}; +}; + +#endif diff --git a/mozilla/content/shared/public/nsRuleNode.h b/mozilla/content/shared/public/nsRuleNode.h index 9933101a091..ac53ba835e1 100644 --- a/mozilla/content/shared/public/nsRuleNode.h +++ b/mozilla/content/shared/public/nsRuleNode.h @@ -39,17 +39,21 @@ #ifndef nsRuleNode_h___ #define nsRuleNode_h___ -#include "nsCOMPtr.h" -#include "nsIStyleRule.h" -#include "nsFixedSizeAllocator.h" #include "nsIPresContext.h" -#include "nsCSSStruct.h" -#include "nsILanguageAtomService.h" #include "nsStyleStruct.h" class nsStyleContext; struct nsRuleList; struct PLDHashTable; +class nsILanguageAtomService; +struct nsRuleData; +class nsIStyleRule; +struct nsCSSStruct; +// Copy of typedef that's in nsCSSStruct.h, for compilation speed. +typedef nsCSSStruct nsRuleDataStruct; + +struct nsRuleDataFont; +class nsCSSValue; typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData); @@ -235,46 +239,6 @@ struct nsCachedStyleData ~nsCachedStyleData() {}; }; -struct nsRuleData -{ - nsStyleStructID mSID; - PRPackedBool mCanStoreInRuleTree; - nsIPresContext* mPresContext; - nsStyleContext* mStyleContext; - nsPostResolveFunc mPostResolveCallback; - nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures! - nsRuleDataDisplay* mDisplayData; - nsRuleDataMargin* mMarginData; - nsRuleDataList* mListData; - nsRuleDataPosition* mPositionData; - nsRuleDataTable* mTableData; - nsRuleDataColor* mColorData; - nsRuleDataContent* mContentData; - nsRuleDataText* mTextData; - nsRuleDataUserInterface* mUserInterfaceData; - nsRuleDataXUL* mXULData; - -#ifdef MOZ_SVG - nsRuleDataSVG* mSVGData; -#endif - - nsRuleDataColumn* mColumnData; - - nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext) - :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull), - mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), - mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull), - mUserInterfaceData(nsnull), mColumnData(nsnull) - { - mCanStoreInRuleTree = PR_TRUE; - mXULData = nsnull; -#ifdef MOZ_SVG - mSVGData = nsnull; -#endif - }; - ~nsRuleData() {}; -}; - class nsRuleNode { public: // for purposes of the RuleDetail (and related code), @@ -315,7 +279,7 @@ private: // most specific rule matched to the least // specific rule (which is the optimal order to // use for lookups of style properties. - nsCOMPtr mRule; // A pointer to our specific rule. + nsIStyleRule* mRule; // [STRONG] A pointer to our specific rule. // The children of this node are stored in either a hashtable or list // that maps from rules to our nsRuleNode children. When matching diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index c3ea09fb6ee..e6097d1c981 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -130,6 +130,7 @@ #include "nsImageLoadingContent.h" #include "nsStyleSet.h" #include "nsImageFrame.h" +#include "nsILanguageAtomService.h" // view stuff #include "nsViewsCID.h" diff --git a/mozilla/layout/style/nsCSSDataBlock.cpp b/mozilla/layout/style/nsCSSDataBlock.cpp index 2ae36fa0d11..41196561916 100644 --- a/mozilla/layout/style/nsCSSDataBlock.cpp +++ b/mozilla/layout/style/nsCSSDataBlock.cpp @@ -36,7 +36,7 @@ #include "nsCSSDataBlock.h" #include "nsCSSProps.h" -#include "nsRuleNode.h" +#include "nsRuleData.h" /* * nsCSSCompressedDataBlock holds property-value pairs corresponding to diff --git a/mozilla/layout/style/nsCSSStruct.h b/mozilla/layout/style/nsCSSStruct.h index c27c0c0ff38..a5a06ad9d83 100644 --- a/mozilla/layout/style/nsCSSStruct.h +++ b/mozilla/layout/style/nsCSSStruct.h @@ -52,6 +52,7 @@ struct nsCSSStruct { // aren't CSS properties. Thus we use typedefs and inheritance // (forwards, when the rule data needs extra data) to make the rule data // structs from the declaration structs. +// NOTE: For compilation speed, this typedef also appears in nsRuleNode.h typedef nsCSSStruct nsRuleDataStruct; diff --git a/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp b/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp index dc957ebd0f1..9007bb5856a 100644 --- a/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp @@ -50,8 +50,8 @@ #include "nsIPresContext.h" #include "nsIDocument.h" #include "nsCOMPtr.h" - #include "nsRuleWalker.h" +#include "nsRuleData.h" /* * The CSSFirstLetterRule and CSSFirstLineRule exist so that we can fix diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index 812d37a0f4b..4b9bc5511b3 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -62,8 +62,8 @@ #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsCSSAnonBoxes.h" - #include "nsRuleWalker.h" +#include "nsRuleData.h" nsHTMLStyleSheet::HTMLColorRule::HTMLColorRule(nsHTMLStyleSheet* aSheet) : mSheet(aSheet) diff --git a/mozilla/layout/style/nsInspectorCSSUtils.cpp b/mozilla/layout/style/nsInspectorCSSUtils.cpp index fdf7e62c588..ac4fdf67843 100644 --- a/mozilla/layout/style/nsInspectorCSSUtils.cpp +++ b/mozilla/layout/style/nsInspectorCSSUtils.cpp @@ -38,6 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsInspectorCSSUtils.h" +#include "nsIStyleRule.h" #include "nsRuleNode.h" #include "nsString.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/layout/style/nsRuleData.h b/mozilla/layout/style/nsRuleData.h new file mode 100644 index 00000000000..d387aef80c1 --- /dev/null +++ b/mozilla/layout/style/nsRuleData.h @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 Communicator client 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): + * Original Author: David W. Hyatt (hyatt@netscape.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either of 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 MPL, 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 MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsRuleData_h_ +#define nsRuleData_h_ + +#include "nsCSSStruct.h" +#include "nsRuleNode.h" + +struct nsRuleData +{ + nsStyleStructID mSID; + PRPackedBool mCanStoreInRuleTree; + nsIPresContext* mPresContext; + nsStyleContext* mStyleContext; + nsPostResolveFunc mPostResolveCallback; + nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures! + nsRuleDataDisplay* mDisplayData; + nsRuleDataMargin* mMarginData; + nsRuleDataList* mListData; + nsRuleDataPosition* mPositionData; + nsRuleDataTable* mTableData; + nsRuleDataColor* mColorData; + nsRuleDataContent* mContentData; + nsRuleDataText* mTextData; + nsRuleDataUserInterface* mUserInterfaceData; + nsRuleDataXUL* mXULData; + +#ifdef MOZ_SVG + nsRuleDataSVG* mSVGData; +#endif + + nsRuleDataColumn* mColumnData; + + nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext) + :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull), + mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), + mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull), + mUserInterfaceData(nsnull), mColumnData(nsnull) + { + mCanStoreInRuleTree = PR_TRUE; + mXULData = nsnull; +#ifdef MOZ_SVG + mSVGData = nsnull; +#endif + }; + ~nsRuleData() {}; +}; + +#endif diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index 7828fb930b0..2c788f813f3 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -38,9 +38,9 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsRuleNode.h" #include "nscore.h" #include "nsIServiceManager.h" -#include "nsRuleNode.h" #include "nsIDeviceContext.h" #include "nsILookAndFeel.h" #include "nsIPresShell.h" @@ -55,6 +55,9 @@ #include "nsStyleSet.h" #include "nsSize.h" #include "imgIRequest.h" +#include "nsRuleData.h" +#include "nsILanguageAtomService.h" +#include "nsIStyleRule.h" /* * For storage of an |nsRuleNode|'s children in a linked list. @@ -399,6 +402,7 @@ nsRuleNode::nsRuleNode(nsIPresContext* aContext, nsIStyleRule* aRule, nsRuleNode mNoneBits(0) { MOZ_COUNT_CTOR(nsRuleNode); + NS_IF_ADDREF(mRule); } PR_STATIC_CALLBACK(PLDHashOperator) @@ -421,6 +425,7 @@ nsRuleNode::~nsRuleNode() PL_DHashTableDestroy(children); } else if (HaveChildren()) ChildrenList()->Destroy(mPresContext); + NS_IF_RELEASE(mRule); } nsresult diff --git a/mozilla/layout/style/nsRuleNode.h b/mozilla/layout/style/nsRuleNode.h index 9933101a091..ac53ba835e1 100644 --- a/mozilla/layout/style/nsRuleNode.h +++ b/mozilla/layout/style/nsRuleNode.h @@ -39,17 +39,21 @@ #ifndef nsRuleNode_h___ #define nsRuleNode_h___ -#include "nsCOMPtr.h" -#include "nsIStyleRule.h" -#include "nsFixedSizeAllocator.h" #include "nsIPresContext.h" -#include "nsCSSStruct.h" -#include "nsILanguageAtomService.h" #include "nsStyleStruct.h" class nsStyleContext; struct nsRuleList; struct PLDHashTable; +class nsILanguageAtomService; +struct nsRuleData; +class nsIStyleRule; +struct nsCSSStruct; +// Copy of typedef that's in nsCSSStruct.h, for compilation speed. +typedef nsCSSStruct nsRuleDataStruct; + +struct nsRuleDataFont; +class nsCSSValue; typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData); @@ -235,46 +239,6 @@ struct nsCachedStyleData ~nsCachedStyleData() {}; }; -struct nsRuleData -{ - nsStyleStructID mSID; - PRPackedBool mCanStoreInRuleTree; - nsIPresContext* mPresContext; - nsStyleContext* mStyleContext; - nsPostResolveFunc mPostResolveCallback; - nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures! - nsRuleDataDisplay* mDisplayData; - nsRuleDataMargin* mMarginData; - nsRuleDataList* mListData; - nsRuleDataPosition* mPositionData; - nsRuleDataTable* mTableData; - nsRuleDataColor* mColorData; - nsRuleDataContent* mContentData; - nsRuleDataText* mTextData; - nsRuleDataUserInterface* mUserInterfaceData; - nsRuleDataXUL* mXULData; - -#ifdef MOZ_SVG - nsRuleDataSVG* mSVGData; -#endif - - nsRuleDataColumn* mColumnData; - - nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext) - :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull), - mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), - mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull), - mUserInterfaceData(nsnull), mColumnData(nsnull) - { - mCanStoreInRuleTree = PR_TRUE; - mXULData = nsnull; -#ifdef MOZ_SVG - mSVGData = nsnull; -#endif - }; - ~nsRuleData() {}; -}; - class nsRuleNode { public: // for purposes of the RuleDetail (and related code), @@ -315,7 +279,7 @@ private: // most specific rule matched to the least // specific rule (which is the optimal order to // use for lookups of style properties. - nsCOMPtr mRule; // A pointer to our specific rule. + nsIStyleRule* mRule; // [STRONG] A pointer to our specific rule. // The children of this node are stored in either a hashtable or list // that maps from rules to our nsRuleNode children. When matching