From 9fb7f507f071cc2b2fe272e69e62751ae2535ddd Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 20 Jun 2014 12:32:49 +0200 Subject: [PATCH] Bug 1022855 - Rename nsCSSStyleSheet to mozilla::CSSStyleSheet; r=heycam --HG-- rename : layout/style/nsCSSStyleSheet.cpp => layout/style/CSSStyleSheet.cpp rename : layout/style/nsCSSStyleSheet.h => layout/style/CSSStyleSheet.h --- chrome/src/nsChromeRegistry.cpp | 12 +- content/base/public/nsIDocument.h | 6 +- .../base/public/nsIStyleSheetLinkingElement.h | 7 +- content/base/src/ShadowRoot.cpp | 6 +- content/base/src/ShadowRoot.h | 6 +- content/base/src/StyleSheetList.cpp | 2 +- content/base/src/StyleSheetList.h | 7 +- content/base/src/nsContentSink.cpp | 2 +- content/base/src/nsContentSink.h | 3 +- content/base/src/nsDocument.cpp | 22 +- content/base/src/nsDocument.h | 9 +- content/base/src/nsStyleLinkElement.cpp | 6 +- content/base/src/nsStyleLinkElement.h | 10 +- content/base/src/nsTreeSanitizer.cpp | 12 +- content/html/content/src/HTMLLinkElement.cpp | 5 +- content/html/content/src/HTMLStyleElement.cpp | 4 +- content/html/document/src/nsHTMLDocument.cpp | 2 +- content/svg/document/src/SVGDocument.cpp | 4 +- content/xml/document/src/nsXMLContentSink.cpp | 5 +- content/xml/document/src/nsXMLContentSink.h | 3 +- content/xul/document/src/XULDocument.cpp | 6 +- content/xul/document/src/XULDocument.h | 4 +- .../xul/document/src/nsXULPrototypeCache.cpp | 6 +- .../xul/document/src/nsXULPrototypeCache.h | 10 +- dom/bindings/Bindings.conf | 4 +- dom/xbl/nsBindingManager.cpp | 6 +- dom/xbl/nsBindingManager.h | 7 +- dom/xbl/nsXBLPrototypeBinding.cpp | 10 +- dom/xbl/nsXBLPrototypeBinding.h | 14 +- dom/xbl/nsXBLPrototypeResources.cpp | 16 +- dom/xbl/nsXBLPrototypeResources.h | 17 +- dom/xbl/nsXBLResourceLoader.cpp | 8 +- dom/xbl/nsXBLResourceLoader.h | 3 +- dom/xslt/xslt/txMozillaXMLOutput.cpp | 4 +- dom/xslt/xslt/txMozillaXMLOutput.h | 2 +- editor/idl/nsIEditorStyleSheets.idl | 14 +- editor/libeditor/base/nsEditor.cpp | 4 +- editor/libeditor/base/nsEditor.h | 8 +- editor/libeditor/base/nsStyleSheetTxns.cpp | 8 +- editor/libeditor/base/nsStyleSheetTxns.h | 20 +- editor/libeditor/html/nsHTMLEditor.cpp | 20 +- editor/libeditor/html/nsHTMLEditor.h | 13 +- js/xpconnect/src/event_impl_gen.conf.in | 2 +- layout/base/nsDocumentViewer.cpp | 10 +- layout/base/nsPresContext.cpp | 6 +- layout/base/nsPresShell.cpp | 6 +- layout/base/nsPresShell.h | 7 +- layout/base/nsStyleSheetService.cpp | 4 +- layout/inspector/inCSSValueSearch.cpp | 4 +- layout/inspector/inDOMUtils.cpp | 4 +- layout/style/CSSRuleList.h | 6 +- ...{nsCSSStyleSheet.cpp => CSSStyleSheet.cpp} | 315 +++++++++--------- .../{nsCSSStyleSheet.h => CSSStyleSheet.h} | 165 ++++----- layout/style/ErrorReporter.cpp | 8 +- layout/style/ErrorReporter.h | 9 +- layout/style/GroupRule.h | 5 +- layout/style/ImportRule.h | 7 +- layout/style/Loader.cpp | 58 ++-- layout/style/Loader.h | 28 +- layout/style/Rule.h | 12 +- layout/style/StyleRule.cpp | 12 +- layout/style/StyleRule.h | 13 +- layout/style/moz.build | 4 +- layout/style/nsCSSParser.cpp | 20 +- layout/style/nsCSSParser.h | 10 +- layout/style/nsCSSRuleProcessor.cpp | 6 +- layout/style/nsCSSRuleProcessor.h | 10 +- layout/style/nsCSSRules.cpp | 50 +-- layout/style/nsCSSRules.h | 2 +- layout/style/nsCSSValue.cpp | 2 +- layout/style/nsCSSValue.h | 7 +- layout/style/nsDOMCSSDeclaration.cpp | 4 +- layout/style/nsICSSLoaderObserver.h | 7 +- layout/style/nsIMediaList.h | 9 +- layout/style/nsIStyleSheet.h | 2 +- layout/style/nsLayoutStylesheetCache.cpp | 34 +- layout/style/nsLayoutStylesheetCache.h | 63 ++-- layout/style/nsStyleSet.cpp | 44 +-- layout/style/nsStyleSet.h | 4 +- layout/style/test/ParseCSS.cpp | 6 +- 80 files changed, 684 insertions(+), 618 deletions(-) rename layout/style/{nsCSSStyleSheet.cpp => CSSStyleSheet.cpp} (86%) rename layout/style/{nsCSSStyleSheet.h => CSSStyleSheet.h} (66%) diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index b19d383138d9..2ad8ac1ef314 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -16,7 +16,8 @@ #include "nsNetUtil.h" #include "nsString.h" -#include "nsCSSStyleSheet.h" +#include "mozilla/CSSStyleSheet.h" +#include "mozilla/dom/URL.h" #include "nsIConsoleService.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" @@ -27,9 +28,10 @@ #include "nsIPresShell.h" #include "nsIScriptError.h" #include "nsIWindowMediator.h" -#include "mozilla/dom/URL.h" nsChromeRegistry* nsChromeRegistry::gChromeRegistry; + +using namespace mozilla; using mozilla::dom::IsChromeURI; //////////////////////////////////////////////////////////////////////////////// @@ -415,7 +417,7 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow) if (IsChromeURI(uri)) { // Reload the sheet. - nsRefPtr newSheet; + nsRefPtr newSheet; rv = document->LoadChromeSheetSync(uri, true, getter_AddRefs(newSheet)); if (NS_FAILED(rv)) return rv; @@ -454,12 +456,12 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow) // Iterate over our old sheets and kick off a sync load of the new // sheet if and only if it's a chrome URL. for (i = 0; i < count; i++) { - nsRefPtr sheet = do_QueryObject(oldSheets[i]); + nsRefPtr sheet = do_QueryObject(oldSheets[i]); nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr; if (uri && IsChromeURI(uri)) { // Reload the sheet. - nsRefPtr newSheet; + nsRefPtr newSheet; // XXX what about chrome sheets that have a title or are disabled? This // only works by sheer dumb luck. document->LoadChromeSheetSync(uri, false, getter_AddRefs(newSheet)); diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 17a9c9b0bcc1..60f9522d126c 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -29,7 +29,6 @@ class imgIRequest; class nsAString; class nsBindingManager; -class nsCSSStyleSheet; class nsIDocShell; class nsDocShell; class nsDOMNavigationTiming; @@ -83,6 +82,7 @@ class nsIGlobalObject; struct nsCSSSelectorList; namespace mozilla { +class CSSStyleSheet; class ErrorResult; class EventStates; @@ -779,7 +779,7 @@ public: * TODO We can get rid of the whole concept of delayed loading if we fix * bug 77999. */ - virtual void EnsureOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet) = 0; + virtual void EnsureOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet) = 0; /** * Get the number of (document) stylesheets @@ -1836,7 +1836,7 @@ public: * DO NOT USE FOR UNTRUSTED CONTENT. */ virtual nsresult LoadChromeSheetSync(nsIURI* aURI, bool aIsAgentSheet, - nsCSSStyleSheet** aSheet) = 0; + mozilla::CSSStyleSheet** aSheet) = 0; /** * Returns true if the locale used for the document specifies a direction of diff --git a/content/base/public/nsIStyleSheetLinkingElement.h b/content/base/public/nsIStyleSheetLinkingElement.h index dc455dfdc78e..c42216550339 100644 --- a/content/base/public/nsIStyleSheetLinkingElement.h +++ b/content/base/public/nsIStyleSheetLinkingElement.h @@ -16,7 +16,10 @@ class nsIURI; { 0xb2, 0xe9, 0x63, 0x52, 0x8c, 0x87, 0x99, 0x7a } } class nsIStyleSheet; -class nsCSSStyleSheet; + +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla class nsIStyleSheetLinkingElement : public nsISupports { public: @@ -29,7 +32,7 @@ public: * @param aStyleSheet the style sheet associated with this * element. */ - NS_IMETHOD SetStyleSheet(nsCSSStyleSheet* aStyleSheet) = 0; + NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) = 0; /** * Used to obtain the style sheet linked in by this element. diff --git a/content/base/src/ShadowRoot.cpp b/content/base/src/ShadowRoot.cpp index 3084a2975f9f..1c195cbb469a 100644 --- a/content/base/src/ShadowRoot.cpp +++ b/content/base/src/ShadowRoot.cpp @@ -137,7 +137,7 @@ ShadowRoot::StyleSheetChanged() } void -ShadowRoot::InsertSheet(nsCSSStyleSheet* aSheet, +ShadowRoot::InsertSheet(CSSStyleSheet* aSheet, nsIContent* aLinkingContent) { nsCOMPtr @@ -168,7 +168,7 @@ ShadowRoot::InsertSheet(nsCSSStyleSheet* aSheet, } void -ShadowRoot::RemoveSheet(nsCSSStyleSheet* aSheet) +ShadowRoot::RemoveSheet(CSSStyleSheet* aSheet) { mProtoBinding->RemoveStyleSheet(aSheet); @@ -719,7 +719,7 @@ ShadowRootStyleSheetList::~ShadowRootStyleSheetList() MOZ_COUNT_DTOR(ShadowRootStyleSheetList); } -nsCSSStyleSheet* +CSSStyleSheet* ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound) { aFound = aIndex < mShadowRoot->mProtoBinding->SheetCount(); diff --git a/content/base/src/ShadowRoot.h b/content/base/src/ShadowRoot.h index 3bbf85c5d7e9..d8724c62b1ee 100644 --- a/content/base/src/ShadowRoot.h +++ b/content/base/src/ShadowRoot.h @@ -48,8 +48,8 @@ public: void AddToIdTable(Element* aElement, nsIAtom* aId); void RemoveFromIdTable(Element* aElement, nsIAtom* aId); - void InsertSheet(nsCSSStyleSheet* aSheet, nsIContent* aLinkingContent); - void RemoveSheet(nsCSSStyleSheet* aSheet); + void InsertSheet(CSSStyleSheet* aSheet, nsIContent* aLinkingContent); + void RemoveSheet(CSSStyleSheet* aSheet); bool ApplyAuthorStyles(); void SetApplyAuthorStyles(bool aApplyAuthorStyles); StyleSheetList* StyleSheets(); @@ -187,7 +187,7 @@ public: } virtual uint32_t Length() MOZ_OVERRIDE; - virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE; + virtual CSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE; protected: nsRefPtr mShadowRoot; diff --git a/content/base/src/StyleSheetList.cpp b/content/base/src/StyleSheetList.cpp index b40833656a2e..d1d29c7bffde 100644 --- a/content/base/src/StyleSheetList.cpp +++ b/content/base/src/StyleSheetList.cpp @@ -5,8 +5,8 @@ #include "mozilla/dom/StyleSheetList.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/dom/StyleSheetListBinding.h" -#include "nsCSSStyleSheet.h" namespace mozilla { namespace dom { diff --git a/content/base/src/StyleSheetList.h b/content/base/src/StyleSheetList.h index 3c272020cfb2..59c5c9ac4356 100644 --- a/content/base/src/StyleSheetList.h +++ b/content/base/src/StyleSheetList.h @@ -9,10 +9,11 @@ #include "nsIDOMStyleSheetList.h" #include "nsWrapperCache.h" -class nsCSSStyleSheet; class nsINode; namespace mozilla { +class CSSStyleSheet; + namespace dom { class StyleSheetList : public nsIDOMStyleSheetList @@ -34,8 +35,8 @@ public: virtual nsINode* GetParentObject() const = 0; virtual uint32_t Length() = 0; - virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0; - nsCSSStyleSheet* Item(uint32_t aIndex) + virtual CSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0; + CSSStyleSheet* Item(uint32_t aIndex) { bool dummy = false; return IndexedGetter(aIndex, dummy); diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index 9d940edce96d..a2fb8f275d6e 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -207,7 +207,7 @@ nsContentSink::Init(nsIDocument* aDoc, } NS_IMETHODIMP -nsContentSink::StyleSheetLoaded(nsCSSStyleSheet* aSheet, +nsContentSink::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) { diff --git a/content/base/src/nsContentSink.h b/content/base/src/nsContentSink.h index fa210318d078..85473cafbd0b 100644 --- a/content/base/src/nsContentSink.h +++ b/content/base/src/nsContentSink.h @@ -86,7 +86,8 @@ class nsContentSink : public nsICSSLoaderObserver, NS_DECL_NSITIMERCALLBACK // nsICSSLoaderObserver - NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate, + NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet, + bool aWasAlternate, nsresult aStatus) MOZ_OVERRIDE; virtual nsresult ProcessMETATag(nsIContent* aContent); diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 760435dc492c..124721cce76e 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -761,7 +761,7 @@ nsDOMStyleSheetList::Length() return mLength; } -nsCSSStyleSheet* +CSSStyleSheet* nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound) { if (!mDocument || aIndex >= (uint32_t)mDocument->GetNumberOfStyleSheets()) { @@ -773,7 +773,7 @@ nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound) nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(aIndex); NS_ASSERTION(sheet, "Must have a sheet"); - return static_cast(sheet); + return static_cast(sheet); } void @@ -3970,7 +3970,7 @@ nsDocument::RemoveChildAt(uint32_t aIndex, bool aNotify) } void -nsDocument::EnsureOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet) +nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet) { // Contains() takes nsISupport*, so annoyingly we have to cast here if (mOnDemandBuiltInUASheets.Contains(static_cast(aSheet))) { @@ -3982,7 +3982,7 @@ nsDocument::EnsureOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet) } void -nsDocument::AddOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet) +nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet) { // Contains() takes nsISupport*, so annoyingly we have to cast here MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(static_cast(aSheet))); @@ -4280,7 +4280,7 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetUR // Loading the sheet sync. nsRefPtr loader = new mozilla::css::Loader(); - nsRefPtr sheet; + nsRefPtr sheet; nsresult rv = loader->LoadSheetSync(aSheetURI, aType == eAgentSheet, true, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); @@ -9331,7 +9331,7 @@ namespace { class StubCSSLoaderObserver MOZ_FINAL : public nsICSSLoaderObserver { public: NS_IMETHOD - StyleSheetLoaded(nsCSSStyleSheet*, bool, nsresult) + StyleSheetLoaded(CSSStyleSheet*, bool, nsresult) { return NS_OK; } @@ -9357,7 +9357,7 @@ nsDocument::PreloadStyle(nsIURI* uri, const nsAString& charset, nsresult nsDocument::LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet, - nsCSSStyleSheet** sheet) + CSSStyleSheet** sheet) { return CSSLoader()->LoadSheetSync(uri, isAgentSheet, isAgentSheet, sheet); } @@ -9706,10 +9706,10 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer) } int32_t sheetsCount = GetNumberOfStyleSheets(); for (int32_t i = 0; i < sheetsCount; ++i) { - nsRefPtr sheet = do_QueryObject(GetStyleSheetAt(i)); + nsRefPtr sheet = do_QueryObject(GetStyleSheetAt(i)); if (sheet) { if (sheet->IsApplicable()) { - nsRefPtr clonedSheet = + nsRefPtr clonedSheet = sheet->Clone(nullptr, nullptr, clonedDoc, nullptr); NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!"); if (clonedSheet) { @@ -9722,11 +9722,11 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer) sheetsCount = thisAsDoc->mOnDemandBuiltInUASheets.Count(); // Iterate backwards to maintain order for (int32_t i = sheetsCount - 1; i >= 0; --i) { - nsRefPtr sheet = + nsRefPtr sheet = do_QueryObject(thisAsDoc->mOnDemandBuiltInUASheets[i]); if (sheet) { if (sheet->IsApplicable()) { - nsRefPtr clonedSheet = + nsRefPtr clonedSheet = sheet->Clone(nullptr, nullptr, clonedDoc, nullptr); NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!"); if (clonedSheet) { diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 605bd8ebe27f..4ed89f70d92f 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -457,7 +457,8 @@ public: } virtual uint32_t Length() MOZ_OVERRIDE; - virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE; + virtual mozilla::CSSStyleSheet* + IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE; protected: int32_t mLength; @@ -780,7 +781,7 @@ public: virtual Element* FindContentForSubDocument(nsIDocument *aDocument) const MOZ_OVERRIDE; virtual Element* GetRootElementInternal() const MOZ_OVERRIDE; - virtual void EnsureOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet) MOZ_OVERRIDE; + virtual void EnsureOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet) MOZ_OVERRIDE; /** * Get the (document) style sheets owned by this document. @@ -932,7 +933,7 @@ public: virtual nsViewportInfo GetViewportInfo(const mozilla::ScreenIntSize& aDisplaySize) MOZ_OVERRIDE; private: - void AddOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet); + void AddOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet); nsRadioGroupStruct* GetRadioGroupInternal(const nsAString& aName) const; void SendToConsole(nsCOMArray& aMessages); @@ -1080,7 +1081,7 @@ public: const nsAString& aCrossOriginAttr) MOZ_OVERRIDE; virtual nsresult LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet, - nsCSSStyleSheet** sheet) MOZ_OVERRIDE; + mozilla::CSSStyleSheet** sheet) MOZ_OVERRIDE; virtual nsISupports* GetCurrentContentSink() MOZ_OVERRIDE; diff --git a/content/base/src/nsStyleLinkElement.cpp b/content/base/src/nsStyleLinkElement.cpp index acfa98a4e29b..771a0a52fe68 100644 --- a/content/base/src/nsStyleLinkElement.cpp +++ b/content/base/src/nsStyleLinkElement.cpp @@ -12,12 +12,12 @@ #include "nsStyleLinkElement.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/FragmentOrElement.h" #include "mozilla/dom/ShadowRoot.h" #include "mozilla/Preferences.h" -#include "nsCSSStyleSheet.h" #include "nsIContent.h" #include "nsIDocument.h" #include "nsIDOMComment.h" @@ -60,7 +60,7 @@ nsStyleLinkElement::Traverse(nsCycleCollectionTraversalCallback &cb) } NS_IMETHODIMP -nsStyleLinkElement::SetStyleSheet(nsCSSStyleSheet* aStyleSheet) +nsStyleLinkElement::SetStyleSheet(CSSStyleSheet* aStyleSheet) { if (mStyleSheet) { mStyleSheet->SetOwningNode(nullptr); @@ -262,7 +262,7 @@ UpdateIsElementInStyleScopeFlagOnSubtree(Element* aElement) static Element* GetScopeElement(nsIStyleSheet* aSheet) { - nsRefPtr cssStyleSheet = do_QueryObject(aSheet); + nsRefPtr cssStyleSheet = do_QueryObject(aSheet); if (!cssStyleSheet) { return nullptr; } diff --git a/content/base/src/nsStyleLinkElement.h b/content/base/src/nsStyleLinkElement.h index 7323e20dc1c0..d3b3f6c23e4d 100644 --- a/content/base/src/nsStyleLinkElement.h +++ b/content/base/src/nsStyleLinkElement.h @@ -14,11 +14,11 @@ #define nsStyleLinkElement_h___ #include "mozilla/Attributes.h" +#include "mozilla/CORSMode.h" +#include "mozilla/CSSStyleSheet.h" #include "nsCOMPtr.h" #include "nsIStyleSheetLinkingElement.h" -#include "nsCSSStyleSheet.h" #include "nsTArray.h" -#include "mozilla/CORSMode.h" class nsIDocument; class nsIURI; @@ -37,10 +37,10 @@ public: NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) MOZ_OVERRIDE = 0; - nsCSSStyleSheet* GetSheet() const { return mStyleSheet; } + mozilla::CSSStyleSheet* GetSheet() const { return mStyleSheet; } // nsIStyleSheetLinkingElement - NS_IMETHOD SetStyleSheet(nsCSSStyleSheet* aStyleSheet) MOZ_OVERRIDE; + NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) MOZ_OVERRIDE; NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet) MOZ_OVERRIDE; NS_IMETHOD InitStyleLinkElement(bool aDontLoadStyle) MOZ_OVERRIDE; NS_IMETHOD UpdateStyleSheet(nsICSSLoaderObserver* aObserver, @@ -122,7 +122,7 @@ private: bool* aIsAlternate, bool aForceUpdate); - nsRefPtr mStyleSheet; + nsRefPtr mStyleSheet; protected: bool mDontLoadStyle; bool mUpdatesEnabled; diff --git a/content/base/src/nsTreeSanitizer.cpp b/content/base/src/nsTreeSanitizer.cpp index e8bfd7e4d4f8..9a4af7917d53 100644 --- a/content/base/src/nsTreeSanitizer.cpp +++ b/content/base/src/nsTreeSanitizer.cpp @@ -4,16 +4,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/ArrayUtils.h" - #include "nsTreeSanitizer.h" -#include "nsCSSParser.h" -#include "nsCSSProperty.h" + +#include "mozilla/ArrayUtils.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Declaration.h" #include "mozilla/css/StyleRule.h" #include "mozilla/css/Rule.h" +#include "nsCSSParser.h" +#include "nsCSSProperty.h" #include "nsUnicharInputStream.h" -#include "nsCSSStyleSheet.h" #include "nsIDOMCSSRule.h" #include "nsAttrName.h" #include "nsIScriptSecurityManager.h" @@ -1098,7 +1098,7 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal, // -moz-binding is blacklisted. bool didSanitize = false; // Create a sheet to hold the parsed CSS - nsRefPtr sheet = new nsCSSStyleSheet(CORS_NONE); + nsRefPtr sheet = new CSSStyleSheet(CORS_NONE); sheet->SetURIs(aDocument->GetDocumentURI(), nullptr, aBaseURI); sheet->SetPrincipal(aDocument->NodePrincipal()); // Create the CSS parser, and parse the CSS text. diff --git a/content/html/content/src/HTMLLinkElement.cpp b/content/html/content/src/HTMLLinkElement.cpp index aa38749e869b..37b2c16d0643 100644 --- a/content/html/content/src/HTMLLinkElement.cpp +++ b/content/html/content/src/HTMLLinkElement.cpp @@ -81,7 +81,7 @@ NS_IMPL_ELEMENT_CLONE(HTMLLinkElement) bool HTMLLinkElement::Disabled() { - nsCSSStyleSheet* ss = GetSheet(); + CSSStyleSheet* ss = GetSheet(); return ss && ss->Disabled(); } @@ -95,11 +95,10 @@ HTMLLinkElement::GetMozDisabled(bool* aDisabled) void HTMLLinkElement::SetDisabled(bool aDisabled) { - nsCSSStyleSheet* ss = GetSheet(); + CSSStyleSheet* ss = GetSheet(); if (ss) { ss->SetDisabled(aDisabled); } - } NS_IMETHODIMP diff --git a/content/html/content/src/HTMLStyleElement.cpp b/content/html/content/src/HTMLStyleElement.cpp index 9902f22917b7..b3b60cf11e27 100644 --- a/content/html/content/src/HTMLStyleElement.cpp +++ b/content/html/content/src/HTMLStyleElement.cpp @@ -69,7 +69,7 @@ HTMLStyleElement::GetMozDisabled(bool* aDisabled) bool HTMLStyleElement::Disabled() { - nsCSSStyleSheet* ss = GetSheet(); + CSSStyleSheet* ss = GetSheet(); return ss && ss->Disabled(); } @@ -83,7 +83,7 @@ HTMLStyleElement::SetMozDisabled(bool aDisabled) void HTMLStyleElement::SetDisabled(bool aDisabled) { - nsCSSStyleSheet* ss = GetSheet(); + CSSStyleSheet* ss = GetSheet(); if (ss) { ss->SetDisabled(aDisabled); } diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 7b823c8b42c1..607c0c81452a 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -2756,7 +2756,7 @@ nsHTMLDocument::EditingStateChanged() rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("resource://gre/res/contenteditable.css")); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr sheet; + nsRefPtr sheet; rv = LoadChromeSheetSync(uri, true, getter_AddRefs(sheet)); NS_ENSURE_TRUE(sheet, rv); diff --git a/content/svg/document/src/SVGDocument.cpp b/content/svg/document/src/SVGDocument.cpp index b70541dfb8e2..c537bcf7dcfb 100644 --- a/content/svg/document/src/SVGDocument.cpp +++ b/content/svg/document/src/SVGDocument.cpp @@ -143,7 +143,7 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded() nsCOMPtr uri; NS_NewURI(getter_AddRefs(uri), spec); if (uri) { - nsRefPtr cssSheet; + nsRefPtr cssSheet; cssLoader->LoadSheetSync(uri, true, true, getter_AddRefs(cssSheet)); if (cssSheet) { EnsureOnDemandBuiltInUASheet(cssSheet); @@ -155,7 +155,7 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded() } } - nsCSSStyleSheet* sheet = nsLayoutStylesheetCache::NumberControlSheet(); + CSSStyleSheet* sheet = nsLayoutStylesheetCache::NumberControlSheet(); if (sheet) { // number-control.css can be behind a pref EnsureOnDemandBuiltInUASheet(sheet); diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index 5e47e3d3cab3..db3f7feb7ff9 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -20,7 +20,7 @@ #include "DocumentType.h" #include "nsHTMLParts.h" #include "nsCRT.h" -#include "nsCSSStyleSheet.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" #include "nsGkAtoms.h" #include "nsContentUtils.h" @@ -63,6 +63,7 @@ #include "mozilla/dom/HTMLTemplateElement.h" #include "mozilla/dom/ProcessingInstruction.h" +using namespace mozilla; using namespace mozilla::dom; // XXX Open Issues: @@ -414,7 +415,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, } NS_IMETHODIMP -nsXMLContentSink::StyleSheetLoaded(nsCSSStyleSheet* aSheet, +nsXMLContentSink::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) { diff --git a/content/xml/document/src/nsXMLContentSink.h b/content/xml/document/src/nsXMLContentSink.h index d1bfa0955d11..44f902b6808d 100644 --- a/content/xml/document/src/nsXMLContentSink.h +++ b/content/xml/document/src/nsXMLContentSink.h @@ -83,7 +83,8 @@ public: NS_IMETHOD OnTransformDone(nsresult aResult, nsIDocument *aResultDocument) MOZ_OVERRIDE; // nsICSSLoaderObserver - NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate, + NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet, + bool aWasAlternate, nsresult aStatus) MOZ_OVERRIDE; static bool ParsePIData(const nsString &aData, nsString &aHref, nsString &aTitle, nsString &aMedia, diff --git a/content/xul/document/src/XULDocument.cpp b/content/xul/document/src/XULDocument.cpp index d648ffb024f5..deb00497bd3a 100644 --- a/content/xul/document/src/XULDocument.cpp +++ b/content/xul/document/src/XULDocument.cpp @@ -71,7 +71,7 @@ #include "nsIParser.h" #include "nsCharsetSource.h" #include "nsIParserService.h" -#include "nsCSSStyleSheet.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" #include "nsIScriptError.h" #include "nsIStyleSheetLinkingElement.h" @@ -3288,7 +3288,7 @@ XULDocument::DoneWalking() } NS_IMETHODIMP -XULDocument::StyleSheetLoaded(nsCSSStyleSheet* aSheet, +XULDocument::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) { @@ -3939,7 +3939,7 @@ XULDocument::AddPrototypeSheets() for (int32_t i = 0; i < sheets.Count(); i++) { nsCOMPtr uri = sheets[i]; - nsRefPtr incompleteSheet; + nsRefPtr incompleteSheet; rv = CSSLoader()->LoadSheet(uri, mCurrentPrototype->DocumentPrincipal(), EmptyCString(), this, diff --git a/content/xul/document/src/XULDocument.h b/content/xul/document/src/XULDocument.h index c3a34460e838..cc48b264ce7c 100644 --- a/content/xul/document/src/XULDocument.h +++ b/content/xul/document/src/XULDocument.h @@ -163,7 +163,7 @@ public: NS_DECL_NSIDOMXULDOCUMENT // nsICSSLoaderObserver - NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, + NS_IMETHOD StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) MOZ_OVERRIDE; @@ -336,7 +336,7 @@ protected: * An array of style sheets, that will be added (preserving order) to the * document after all of them are loaded (in DoneWalking). */ - nsTArray > mOverlaySheets; + nsTArray> mOverlaySheets; nsCOMPtr mCommandDispatcher; // [OWNER] of the focus tracker diff --git a/content/xul/document/src/nsXULPrototypeCache.cpp b/content/xul/document/src/nsXULPrototypeCache.cpp index 97c9316857d5..91331055f55b 100644 --- a/content/xul/document/src/nsXULPrototypeCache.cpp +++ b/content/xul/document/src/nsXULPrototypeCache.cpp @@ -7,7 +7,6 @@ #include "plstr.h" #include "nsXULPrototypeDocument.h" -#include "nsCSSStyleSheet.h" #include "nsIServiceManager.h" #include "nsIURI.h" @@ -24,6 +23,7 @@ #include "js/TracingAPI.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/Preferences.h" #include "mozilla/scache/StartupCache.h" #include "mozilla/scache/StartupCacheUtils.h" @@ -172,7 +172,7 @@ nsXULPrototypeCache::PutPrototype(nsXULPrototypeDocument* aDocument) } nsresult -nsXULPrototypeCache::PutStyleSheet(nsCSSStyleSheet* aStyleSheet) +nsXULPrototypeCache::PutStyleSheet(CSSStyleSheet* aStyleSheet) { nsIURI* uri = aStyleSheet->GetSheetURI(); @@ -239,7 +239,7 @@ FlushSkinXBL(nsIURI* aKey, nsRefPtr& aDocInfo, void* aClosure } static PLDHashOperator -FlushSkinSheets(nsIURI* aKey, nsRefPtr& aSheet, void* aClosure) +FlushSkinSheets(nsIURI* aKey, nsRefPtr& aSheet, void* aClosure) { nsAutoCString str; aSheet->GetSheetURI()->GetPath(str); diff --git a/content/xul/document/src/nsXULPrototypeCache.h b/content/xul/document/src/nsXULPrototypeCache.h index 52cc071d06a8..2926836ab301 100644 --- a/content/xul/document/src/nsXULPrototypeCache.h +++ b/content/xul/document/src/nsXULPrototypeCache.h @@ -19,7 +19,9 @@ #include "mozilla/scache/StartupCache.h" -class nsCSSStyleSheet; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla /** * The XUL prototype cache can be used to store and retrieve shared data for @@ -72,7 +74,7 @@ public: * Get a style sheet by URI. If the style sheet is not in the cache, * returns nullptr. */ - nsCSSStyleSheet* GetStyleSheet(nsIURI* aURI) { + mozilla::CSSStyleSheet* GetStyleSheet(nsIURI* aURI) { return mStyleSheetTable.GetWeak(aURI); } @@ -80,7 +82,7 @@ public: * Store a style sheet in the cache. The key, style sheet's URI is obtained * from the style sheet itself. */ - nsresult PutStyleSheet(nsCSSStyleSheet* aStyleSheet); + nsresult PutStyleSheet(mozilla::CSSStyleSheet* aStyleSheet); /** * Write the XUL prototype document to a cache file. The proto must be @@ -121,7 +123,7 @@ protected: void FlushSkinFiles(); nsRefPtrHashtable mPrototypeTable; // owns the prototypes - nsRefPtrHashtable mStyleSheetTable; + nsRefPtrHashtable mStyleSheetTable; nsJSThingHashtable mScriptTable; nsRefPtrHashtable mXBLDocTable; diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 1b71956fa442..c448a651171e 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -263,7 +263,7 @@ DOMInterfaces = { }, 'CSSStyleSheet': { - 'nativeType': 'nsCSSStyleSheet', + 'nativeType': 'mozilla::CSSStyleSheet', 'binaryNames': { 'ownerRule': 'DOMOwnerRule' }, }, @@ -1066,7 +1066,7 @@ DOMInterfaces = { }, 'StyleSheet': { - 'nativeType': 'nsCSSStyleSheet', + 'nativeType': 'mozilla::CSSStyleSheet', }, 'SVGAnimatedLengthList': { diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index a3f70a766be8..2c4dfc531bf4 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -813,8 +813,8 @@ static PLDHashOperator EnumAppendAllSheets(nsRefPtrHashKey *aKey, void* aClosure) { nsIContent *boundContent = aKey->GetKey(); - nsTArray* array = - static_cast*>(aClosure); + nsTArray* array = + static_cast*>(aClosure); for (nsXBLBinding *binding = boundContent->GetXBLBinding(); binding; binding = binding->GetBaseBinding()) { binding->PrototypeBinding()->AppendStyleSheetsTo(*array); @@ -823,7 +823,7 @@ EnumAppendAllSheets(nsRefPtrHashKey *aKey, void* aClosure) } void -nsBindingManager::AppendAllSheets(nsTArray& aArray) +nsBindingManager::AppendAllSheets(nsTArray& aArray) { if (mBoundContentSet) { mBoundContentSet->EnumerateEntries(EnumAppendAllSheets, &aArray); diff --git a/dom/xbl/nsBindingManager.h b/dom/xbl/nsBindingManager.h index 67b88967b18e..fe14a4333ed4 100644 --- a/dom/xbl/nsBindingManager.h +++ b/dom/xbl/nsBindingManager.h @@ -30,7 +30,10 @@ class nsXBLBinding; template class nsRefPtr; typedef nsTArray > nsBindingList; class nsIPrincipal; -class nsCSSStyleSheet; + +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla class nsBindingManager MOZ_FINAL : public nsStubMutationObserver { @@ -116,7 +119,7 @@ public: nsresult MediumFeaturesChanged(nsPresContext* aPresContext, bool* aRulesChanged); - void AppendAllSheets(nsTArray& aArray); + void AppendAllSheets(nsTArray& aArray); void Traverse(nsIContent *aContent, nsCycleCollectionTraversalCallback &cb); diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp index 55fb57b50e6f..ff50c3f74d27 100644 --- a/dom/xbl/nsXBLPrototypeBinding.cpp +++ b/dom/xbl/nsXBLPrototypeBinding.cpp @@ -1686,14 +1686,14 @@ nsXBLPrototypeBinding::EnsureResources() } void -nsXBLPrototypeBinding::AppendStyleSheet(nsCSSStyleSheet* aSheet) +nsXBLPrototypeBinding::AppendStyleSheet(CSSStyleSheet* aSheet) { EnsureResources(); mResources->AppendStyleSheet(aSheet); } void -nsXBLPrototypeBinding::RemoveStyleSheet(nsCSSStyleSheet* aSheet) +nsXBLPrototypeBinding::RemoveStyleSheet(CSSStyleSheet* aSheet) { if (!mResources) { MOZ_ASSERT(false, "Trying to remove a sheet that does not exist."); @@ -1703,13 +1703,13 @@ nsXBLPrototypeBinding::RemoveStyleSheet(nsCSSStyleSheet* aSheet) mResources->RemoveStyleSheet(aSheet); } void -nsXBLPrototypeBinding::InsertStyleSheetAt(size_t aIndex, nsCSSStyleSheet* aSheet) +nsXBLPrototypeBinding::InsertStyleSheetAt(size_t aIndex, CSSStyleSheet* aSheet) { EnsureResources(); mResources->InsertStyleSheetAt(aIndex, aSheet); } -nsCSSStyleSheet* +CSSStyleSheet* nsXBLPrototypeBinding::StyleSheetAt(size_t aIndex) const { MOZ_ASSERT(mResources); @@ -1730,7 +1730,7 @@ nsXBLPrototypeBinding::HasStyleSheets() const void nsXBLPrototypeBinding::AppendStyleSheetsTo( - nsTArray& aResult) const + nsTArray& aResult) const { if (mResources) { mResources->AppendStyleSheetsTo(aResult); diff --git a/dom/xbl/nsXBLPrototypeBinding.h b/dom/xbl/nsXBLPrototypeBinding.h index d6b9b62638c8..2fb88d1461d9 100644 --- a/dom/xbl/nsXBLPrototypeBinding.h +++ b/dom/xbl/nsXBLPrototypeBinding.h @@ -25,6 +25,10 @@ class nsXBLAttributeEntry; class nsXBLBinding; class nsXBLProtoImplField; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla + // *********************************************************************/ // The XBLPrototypeBinding class @@ -113,13 +117,13 @@ public: void SetInitialAttributes(nsIContent* aBoundElement, nsIContent* aAnonymousContent); - void AppendStyleSheet(nsCSSStyleSheet* aSheet); - void RemoveStyleSheet(nsCSSStyleSheet* aSheet); - void InsertStyleSheetAt(size_t aIndex, nsCSSStyleSheet* aSheet); - nsCSSStyleSheet* StyleSheetAt(size_t aIndex) const; + void AppendStyleSheet(mozilla::CSSStyleSheet* aSheet); + void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet); + void InsertStyleSheetAt(size_t aIndex, mozilla::CSSStyleSheet* aSheet); + mozilla::CSSStyleSheet* StyleSheetAt(size_t aIndex) const; size_t SheetCount() const; bool HasStyleSheets() const; - void AppendStyleSheetsTo(nsTArray& aResult) const; + void AppendStyleSheetsTo(nsTArray& aResult) const; nsIStyleRuleProcessor* GetRuleProcessor(); diff --git a/dom/xbl/nsXBLPrototypeResources.cpp b/dom/xbl/nsXBLPrototypeResources.cpp index c4a31d7bf247..0253acfc30d4 100644 --- a/dom/xbl/nsXBLPrototypeResources.cpp +++ b/dom/xbl/nsXBLPrototypeResources.cpp @@ -80,18 +80,18 @@ nsXBLPrototypeResources::FlushSkinSheets() // they'll still be in the chrome cache. mRuleProcessor = nullptr; - nsTArray> oldSheets; + nsTArray> oldSheets; oldSheets.SwapElements(mStyleSheetList); mozilla::css::Loader* cssLoader = doc->CSSLoader(); for (size_t i = 0, count = oldSheets.Length(); i < count; ++i) { - nsCSSStyleSheet* oldSheet = oldSheets[i]; + CSSStyleSheet* oldSheet = oldSheets[i]; nsIURI* uri = oldSheet->GetSheetURI(); - nsRefPtr newSheet; + nsRefPtr newSheet; if (IsChromeURI(uri)) { if (NS_FAILED(cssLoader->LoadSheetSync(uri, getter_AddRefs(newSheet)))) continue; @@ -138,25 +138,25 @@ nsXBLPrototypeResources::GatherRuleProcessor() } void -nsXBLPrototypeResources::AppendStyleSheet(nsCSSStyleSheet* aSheet) +nsXBLPrototypeResources::AppendStyleSheet(CSSStyleSheet* aSheet) { mStyleSheetList.AppendElement(aSheet); } void -nsXBLPrototypeResources::RemoveStyleSheet(nsCSSStyleSheet* aSheet) +nsXBLPrototypeResources::RemoveStyleSheet(CSSStyleSheet* aSheet) { DebugOnly found = mStyleSheetList.RemoveElement(aSheet); MOZ_ASSERT(found, "Trying to remove a sheet that does not exist."); } void -nsXBLPrototypeResources::InsertStyleSheetAt(size_t aIndex, nsCSSStyleSheet* aSheet) +nsXBLPrototypeResources::InsertStyleSheetAt(size_t aIndex, CSSStyleSheet* aSheet) { mStyleSheetList.InsertElementAt(aIndex, aSheet); } -nsCSSStyleSheet* +CSSStyleSheet* nsXBLPrototypeResources::StyleSheetAt(size_t aIndex) const { return mStyleSheetList[aIndex]; @@ -176,7 +176,7 @@ nsXBLPrototypeResources::HasStyleSheets() const void nsXBLPrototypeResources::AppendStyleSheetsTo( - nsTArray& aResult) const + nsTArray& aResult) const { aResult.AppendElements(mStyleSheetList); } diff --git a/dom/xbl/nsXBLPrototypeResources.h b/dom/xbl/nsXBLPrototypeResources.h index 9f0085ea37c5..e4faab469db4 100644 --- a/dom/xbl/nsXBLPrototypeResources.h +++ b/dom/xbl/nsXBLPrototypeResources.h @@ -10,12 +10,15 @@ #include "nsICSSLoaderObserver.h" class nsCSSRuleProcessor; -class nsCSSStyleSheet; class nsIAtom; class nsIContent; class nsXBLPrototypeBinding; class nsXBLResourceLoader; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla + // *********************************************************************/ // The XBLPrototypeResources class @@ -36,13 +39,13 @@ public: void ClearLoader(); - void AppendStyleSheet(nsCSSStyleSheet* aSheet); - void RemoveStyleSheet(nsCSSStyleSheet* aSheet); - void InsertStyleSheetAt(size_t aIndex, nsCSSStyleSheet* aSheet); - nsCSSStyleSheet* StyleSheetAt(size_t aIndex) const; + void AppendStyleSheet(mozilla::CSSStyleSheet* aSheet); + void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet); + void InsertStyleSheetAt(size_t aIndex, mozilla::CSSStyleSheet* aSheet); + mozilla::CSSStyleSheet* StyleSheetAt(size_t aIndex) const; size_t SheetCount() const; bool HasStyleSheets() const; - void AppendStyleSheetsTo(nsTArray& aResult) const; + void AppendStyleSheetsTo(nsTArray& aResult) const; /** * Recreates mRuleProcessor to represent the current list of style sheets @@ -58,7 +61,7 @@ private: nsRefPtr mLoader; // A list of loaded stylesheets for this binding. - nsTArray> mStyleSheetList; + nsTArray> mStyleSheetList; // The list of stylesheets converted to a rule processor. nsRefPtr mRuleProcessor; diff --git a/dom/xbl/nsXBLResourceLoader.cpp b/dom/xbl/nsXBLResourceLoader.cpp index c31635f28cde..e6a03a9a64ea 100644 --- a/dom/xbl/nsXBLResourceLoader.cpp +++ b/dom/xbl/nsXBLResourceLoader.cpp @@ -5,7 +5,6 @@ #include "nsTArray.h" #include "nsString.h" -#include "nsCSSStyleSheet.h" #include "nsIStyleRuleProcessor.h" #include "nsIDocument.h" #include "nsIContent.h" @@ -17,6 +16,7 @@ #include "nsIDocumentObserver.h" #include "imgILoader.h" #include "imgRequestProxy.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" #include "nsIURI.h" #include "nsNetUtil.h" @@ -29,6 +29,8 @@ #include "nsStyleSet.h" #include "nsIScriptSecurityManager.h" +using namespace mozilla; + NS_IMPL_CYCLE_COLLECTION(nsXBLResourceLoader, mBoundElements) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXBLResourceLoader) @@ -135,7 +137,7 @@ nsXBLResourceLoader::LoadResources(bool* aResult) CheckLoadURIWithPrincipal(docPrincipal, url, nsIScriptSecurityManager::ALLOW_CHROME); if (NS_SUCCEEDED(rv)) { - nsRefPtr sheet; + nsRefPtr sheet; rv = cssLoader->LoadSheetSync(url, getter_AddRefs(sheet)); NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!"); if (NS_SUCCEEDED(rv)) @@ -164,7 +166,7 @@ nsXBLResourceLoader::LoadResources(bool* aResult) // nsICSSLoaderObserver NS_IMETHODIMP -nsXBLResourceLoader::StyleSheetLoaded(nsCSSStyleSheet* aSheet, +nsXBLResourceLoader::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) { diff --git a/dom/xbl/nsXBLResourceLoader.h b/dom/xbl/nsXBLResourceLoader.h index d51c13964e35..d45207346e61 100644 --- a/dom/xbl/nsXBLResourceLoader.h +++ b/dom/xbl/nsXBLResourceLoader.h @@ -29,7 +29,8 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS(nsXBLResourceLoader) // nsICSSLoaderObserver - NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate, + NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet, + bool aWasAlternate, nsresult aStatus) MOZ_OVERRIDE; void LoadResources(bool* aResult); diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp index 72c221c77a3a..19c79f5b1d78 100644 --- a/dom/xslt/xslt/txMozillaXMLOutput.cpp +++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp @@ -23,12 +23,12 @@ #include "nsIConsoleService.h" #include "nsIDOMDocumentFragment.h" #include "nsNameSpaceManager.h" -#include "nsCSSStyleSheet.h" #include "txStringUtils.h" #include "txURIUtils.h" #include "nsIHTMLDocument.h" #include "nsIStyleSheetLinkingElement.h" #include "nsIDocumentTransformer.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/EncodingUtils.h" @@ -981,7 +981,7 @@ txTransformNotifier::ScriptEvaluated(nsresult aResult, } NS_IMETHODIMP -txTransformNotifier::StyleSheetLoaded(nsCSSStyleSheet* aSheet, +txTransformNotifier::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) { diff --git a/dom/xslt/xslt/txMozillaXMLOutput.h b/dom/xslt/xslt/txMozillaXMLOutput.h index 634285469517..f6b6eefab7be 100644 --- a/dom/xslt/xslt/txMozillaXMLOutput.h +++ b/dom/xslt/xslt/txMozillaXMLOutput.h @@ -38,7 +38,7 @@ public: NS_DECL_NSISCRIPTLOADEROBSERVER // nsICSSLoaderObserver - NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, + NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) MOZ_OVERRIDE; diff --git a/editor/idl/nsIEditorStyleSheets.idl b/editor/idl/nsIEditorStyleSheets.idl index 400bb2a5ebde..70b7b1398ddc 100644 --- a/editor/idl/nsIEditorStyleSheets.idl +++ b/editor/idl/nsIEditorStyleSheets.idl @@ -6,10 +6,12 @@ #include "nsISupports.idl" %{C++ -class nsCSSStyleSheet; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla %} -[ptr] native nsCSSStyleSheet(nsCSSStyleSheet); +[ptr] native CSSStyleSheet(mozilla::CSSStyleSheet); [scriptable, uuid(4805e682-49b9-11d3-9ce4-ed60bd6cb5bc)] @@ -75,17 +77,17 @@ interface nsIEditorStyleSheets : nsISupports */ void enableStyleSheet(in AString aURL, in boolean aEnable); - /** Get the nsCSSStyleSheet associated with the given URL. + /** Get the CSSStyleSheet associated with the given URL. * * @param aURL The style sheet's URL * @return the style sheet */ - [noscript] nsCSSStyleSheet getStyleSheetForURL(in AString aURL); + [noscript] CSSStyleSheet getStyleSheetForURL(in AString aURL); - /** Get the URL associated with the given nsCSSStyleSheet. + /** Get the URL associated with the given CSSStyleSheet. * * @param aStyleSheet The style sheet * @return the style sheet's URL */ - [noscript] AString getURLForStyleSheet(in nsCSSStyleSheet aStyleSheet); + [noscript] AString getURLForStyleSheet(in CSSStyleSheet aStyleSheet); }; diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index b92143aa6012..cd565a5242e7 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -4426,7 +4426,7 @@ nsEditor::CreateTxnForIMEText(const nsAString& aStringToInsert, NS_IMETHODIMP -nsEditor::CreateTxnForAddStyleSheet(nsCSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn) +nsEditor::CreateTxnForAddStyleSheet(CSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn) { nsRefPtr txn = new AddStyleSheetTxn(); @@ -4442,7 +4442,7 @@ nsEditor::CreateTxnForAddStyleSheet(nsCSSStyleSheet* aSheet, AddStyleSheetTxn* * NS_IMETHODIMP -nsEditor::CreateTxnForRemoveStyleSheet(nsCSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn) +nsEditor::CreateTxnForRemoveStyleSheet(CSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn) { nsRefPtr txn = new RemoveStyleSheetTxn(); diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h index 78e63650c77a..c5f450801897 100644 --- a/editor/libeditor/base/nsEditor.h +++ b/editor/libeditor/base/nsEditor.h @@ -39,7 +39,6 @@ class InsertTextTxn; class JoinElementTxn; class RemoveStyleSheetTxn; class SplitElementTxn; -class nsCSSStyleSheet; class nsIAtom; class nsIContent; class nsIDOMCharacterData; @@ -68,6 +67,7 @@ class nsString; class nsTransactionManager; namespace mozilla { +class CSSStyleSheet; class ErrorResult; class TextComposition; @@ -321,11 +321,13 @@ protected: /** create a transaction for adding a style sheet */ - NS_IMETHOD CreateTxnForAddStyleSheet(nsCSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn); + NS_IMETHOD CreateTxnForAddStyleSheet(mozilla::CSSStyleSheet* aSheet, + AddStyleSheetTxn* *aTxn); /** create a transaction for removing a style sheet */ - NS_IMETHOD CreateTxnForRemoveStyleSheet(nsCSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn); + NS_IMETHOD CreateTxnForRemoveStyleSheet(mozilla::CSSStyleSheet* aSheet, + RemoveStyleSheetTxn* *aTxn); NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement, uint32_t aOffset, diff --git a/editor/libeditor/base/nsStyleSheetTxns.cpp b/editor/libeditor/base/nsStyleSheetTxns.cpp index d214972a9af5..a8fb1d2bfed5 100644 --- a/editor/libeditor/base/nsStyleSheetTxns.cpp +++ b/editor/libeditor/base/nsStyleSheetTxns.cpp @@ -8,7 +8,7 @@ #include "nsAString.h" #include "nsCOMPtr.h" // for nsCOMPtr, do_QueryInterface, etc -#include "nsCSSStyleSheet.h" // for nsCSSStyleSheet +#include "mozilla/CSSStyleSheet.h" // for mozilla::CSSStyleSheet #include "nsDebug.h" // for NS_ENSURE_TRUE #include "nsError.h" // for NS_OK, etc #include "nsIDOMDocument.h" // for nsIDOMDocument @@ -17,6 +17,8 @@ #include "nsIEditor.h" // for nsIEditor #include "nsStyleSheetTxns.h" +using namespace mozilla; + class nsIStyleSheet; static void @@ -58,7 +60,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AddStyleSheetTxn) NS_INTERFACE_MAP_END_INHERITING(EditTxn) NS_IMETHODIMP -AddStyleSheetTxn::Init(nsIEditor *aEditor, nsCSSStyleSheet *aSheet) +AddStyleSheetTxn::Init(nsIEditor *aEditor, CSSStyleSheet *aSheet) { NS_ENSURE_TRUE(aEditor && aSheet, NS_ERROR_INVALID_ARG); @@ -108,7 +110,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RemoveStyleSheetTxn) NS_INTERFACE_MAP_END_INHERITING(EditTxn) NS_IMETHODIMP -RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsCSSStyleSheet *aSheet) +RemoveStyleSheetTxn::Init(nsIEditor *aEditor, CSSStyleSheet *aSheet) { NS_ENSURE_TRUE(aEditor && aSheet, NS_ERROR_INVALID_ARG); diff --git a/editor/libeditor/base/nsStyleSheetTxns.h b/editor/libeditor/base/nsStyleSheetTxns.h index 1b5e72d6af9e..dcc58202e8b6 100644 --- a/editor/libeditor/base/nsStyleSheetTxns.h +++ b/editor/libeditor/base/nsStyleSheetTxns.h @@ -8,10 +8,10 @@ #include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN #include "nsAutoPtr.h" // for nsRefPtr -#include "nsCSSStyleSheet.h" // for nsCSSStyleSheet +#include "mozilla/CSSStyleSheet.h" // for mozilla::CSSStyleSheet #include "nsCycleCollectionParticipant.h" #include "nsID.h" // for REFNSIID -#include "nsISupportsImpl.h" // for nsCSSStyleSheet::Release +#include "nsISupportsImpl.h" // for CSSStyleSheet::Release #include "nscore.h" // for NS_IMETHOD class nsIEditor; @@ -23,8 +23,8 @@ public: * @param aEditor the object providing core editing operations * @param aSheet the stylesheet to add */ - NS_IMETHOD Init(nsIEditor *aEditor, - nsCSSStyleSheet *aSheet); + NS_IMETHOD Init(nsIEditor* aEditor, + mozilla::CSSStyleSheet* aSheet); AddStyleSheetTxn(); @@ -35,8 +35,8 @@ public: protected: - nsIEditor* mEditor; // the editor that created this transaction - nsRefPtr mSheet; // the style sheet to add + nsIEditor* mEditor; // the editor that created this transaction + nsRefPtr mSheet; // the style sheet to add }; @@ -48,8 +48,8 @@ public: * @param aEditor the object providing core editing operations * @param aSheet the stylesheet to remove */ - NS_IMETHOD Init(nsIEditor *aEditor, - nsCSSStyleSheet *aSheet); + NS_IMETHOD Init(nsIEditor* aEditor, + mozilla::CSSStyleSheet* aSheet); RemoveStyleSheetTxn(); @@ -60,8 +60,8 @@ public: protected: - nsIEditor* mEditor; // the editor that created this transaction - nsRefPtr mSheet; // the style sheet to remove + nsIEditor* mEditor; // the editor that created this transaction + nsRefPtr mSheet; // the style sheet to remove }; diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index e7d26a6e0fe6..df4703ce06e1 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -36,8 +36,8 @@ #include "nsILinkHandler.h" #include "nsIInlineSpellChecker.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" -#include "nsCSSStyleSheet.h" #include "nsIDOMStyleSheet.h" #include "nsIContent.h" @@ -2854,7 +2854,7 @@ nsHTMLEditor::ReplaceStyleSheet(const nsAString& aURL) NS_IMETHODIMP nsHTMLEditor::RemoveStyleSheet(const nsAString &aURL) { - nsRefPtr sheet; + nsRefPtr sheet; nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED); @@ -2894,7 +2894,7 @@ nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL) // We MUST ONLY load synchronous local files (no @import) // XXXbz Except this will actually try to load remote files // synchronously, of course.. - nsRefPtr sheet; + nsRefPtr sheet; // Editor override style sheets may want to style Gecko anonymous boxes rv = ps->GetDocument()->CSSLoader()-> LoadSheetSync(uaURI, true, true, getter_AddRefs(sheet)); @@ -2938,7 +2938,7 @@ nsHTMLEditor::ReplaceOverrideStyleSheet(const nsAString& aURL) NS_IMETHODIMP nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL) { - nsRefPtr sheet; + nsRefPtr sheet; GetStyleSheetForURL(aURL, getter_AddRefs(sheet)); // Make sure we remove the stylesheet from our internal list in all @@ -2961,7 +2961,7 @@ nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL) NS_IMETHODIMP nsHTMLEditor::EnableStyleSheet(const nsAString &aURL, bool aEnable) { - nsRefPtr sheet; + nsRefPtr sheet; nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(sheet, NS_OK); // Don't fail if sheet not found @@ -2976,7 +2976,7 @@ nsHTMLEditor::EnableStyleSheet(const nsAString &aURL, bool aEnable) bool nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL) { - nsRefPtr sheet; + nsRefPtr sheet; nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, false); @@ -2995,7 +2995,7 @@ nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL) nsresult nsHTMLEditor::AddNewStyleSheetToList(const nsAString &aURL, - nsCSSStyleSheet *aStyleSheet) + CSSStyleSheet* aStyleSheet) { uint32_t countSS = mStyleSheets.Length(); uint32_t countU = mStyleSheetURLs.Length(); @@ -3027,7 +3027,7 @@ nsHTMLEditor::RemoveStyleSheetFromList(const nsAString &aURL) NS_IMETHODIMP nsHTMLEditor::GetStyleSheetForURL(const nsAString &aURL, - nsCSSStyleSheet **aStyleSheet) + CSSStyleSheet** aStyleSheet) { NS_ENSURE_ARG_POINTER(aStyleSheet); *aStyleSheet = 0; @@ -3047,7 +3047,7 @@ nsHTMLEditor::GetStyleSheetForURL(const nsAString &aURL, } NS_IMETHODIMP -nsHTMLEditor::GetURLForStyleSheet(nsCSSStyleSheet *aStyleSheet, +nsHTMLEditor::GetURLForStyleSheet(CSSStyleSheet* aStyleSheet, nsAString &aURL) { // is it already in the list? @@ -3425,7 +3425,7 @@ nsHTMLEditor::DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed) NS_IMETHODIMP -nsHTMLEditor::StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate, +nsHTMLEditor::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) { nsresult rv = NS_OK; diff --git a/editor/libeditor/html/nsHTMLEditor.h b/editor/libeditor/html/nsHTMLEditor.h index 92401b43725b..7b0fd008be55 100644 --- a/editor/libeditor/html/nsHTMLEditor.h +++ b/editor/libeditor/html/nsHTMLEditor.h @@ -329,8 +329,8 @@ public: NS_IMETHOD GetRootElement(nsIDOMElement **aRootElement); /* ------------ nsICSSLoaderObserver -------------- */ - NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet*aSheet, bool aWasAlternate, - nsresult aStatus); + NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet, + bool aWasAlternate, nsresult aStatus); /* ------------ Utility Routines, not part of public API -------------- */ NS_IMETHOD TypedText(const nsAString& aString, ETypingAction aAction); @@ -375,12 +375,13 @@ public: // Dealing with the internal style sheet lists: NS_IMETHOD GetStyleSheetForURL(const nsAString &aURL, - nsCSSStyleSheet **_retval); - NS_IMETHOD GetURLForStyleSheet(nsCSSStyleSheet *aStyleSheet, nsAString &aURL); + mozilla::CSSStyleSheet** _retval); + NS_IMETHOD GetURLForStyleSheet(mozilla::CSSStyleSheet* aStyleSheet, + nsAString& aURL); // Add a url + known style sheet to the internal lists: nsresult AddNewStyleSheetToList(const nsAString &aURL, - nsCSSStyleSheet *aStyleSheet); + mozilla::CSSStyleSheet* aStyleSheet); nsresult RemoveStyleSheetFromList(const nsAString &aURL); @@ -774,7 +775,7 @@ protected: // Maintain a list of associated style sheets and their urls. nsTArray mStyleSheetURLs; - nsTArray > mStyleSheets; + nsTArray> mStyleSheets; // an array for holding default style settings nsTArray mDefaultStyles; diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index 1989fc230728..51b0712f745c 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -51,7 +51,7 @@ exclude_automatic_type_include = [ xpidl_to_native = [ ['nsIDOMDocument', 'nsIDocument', 'nsIDocument'], ['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'], - ['nsIDOMCSSStyleSheet', 'nsCSSStyleSheet', 'nsIStyleSheet'], + ['nsIDOMCSSStyleSheet', 'mozilla::CSSStyleSheet', 'nsIStyleSheet'], ['nsIDOMWindow', 'nsGlobalWindow', 'nsIDOMEventTarget'] ] diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index f11146064230..5cd95e167c91 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -21,7 +21,6 @@ #include "nsPresContext.h" #include "nsIPresShell.h" #include "nsStyleSet.h" -#include "nsCSSStyleSheet.h" #include "nsIFrame.h" #include "nsIWritablePropertyBag2.h" #include "nsSubDocumentFrame.h" @@ -49,6 +48,7 @@ #include "nsNetUtil.h" #include "nsIContentViewerEdit.h" #include "nsIContentViewerFile.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" #include "nsIMarkupDocumentViewer.h" #include "nsIInterfaceRequestor.h" @@ -2215,7 +2215,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument, } // Handle the user sheets. - nsCSSStyleSheet* sheet = nullptr; + CSSStyleSheet* sheet = nullptr; if (nsContentUtils::IsInChromeDocshell(aDocument)) { sheet = nsLayoutStylesheetCache::UserChromeSheet(); } @@ -2233,7 +2233,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument, nsCOMPtr ds(mContainer); nsCOMPtr chromeHandler; nsCOMPtr uri; - nsRefPtr csssheet; + nsRefPtr csssheet; if (ds) { ds->GetChromeEventHandler(getter_AddRefs(chromeHandler)); @@ -2302,8 +2302,8 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument, // Make sure to clone the quirk sheet so that it can be usefully // enabled/disabled as needed. - nsRefPtr quirkClone; - nsCSSStyleSheet* quirkSheet; + nsRefPtr quirkClone; + CSSStyleSheet* quirkSheet; if (!nsLayoutStylesheetCache::UASheet() || !(quirkSheet = nsLayoutStylesheetCache::QuirkSheet()) || !(quirkClone = quirkSheet->Clone(nullptr, nullptr, nullptr, nullptr)) || diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 759972d7a4aa..d73b3fbc1694 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2255,14 +2255,14 @@ nsPresContext::RebuildCounterStyles() void nsPresContext::EnsureSafeToHandOutCSSRules() { - nsCSSStyleSheet::EnsureUniqueInnerResult res = + CSSStyleSheet::EnsureUniqueInnerResult res = mShell->StyleSet()->EnsureUniqueInnerOnCSSSheets(); - if (res == nsCSSStyleSheet::eUniqueInner_AlreadyUnique) { + if (res == CSSStyleSheet::eUniqueInner_AlreadyUnique) { // Nothing to do. return; } - MOZ_ASSERT(res == nsCSSStyleSheet::eUniqueInner_ClonedInner); + MOZ_ASSERT(res == CSSStyleSheet::eUniqueInner_ClonedInner); RebuildAllStyleData(nsChangeHint(0)); } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index aecb7af87a7c..9fa7b0765d8f 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -24,6 +24,7 @@ #include "prlog.h" #include "mozilla/ArrayUtils.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventStateManager.h" #include "mozilla/EventStates.h" @@ -48,7 +49,6 @@ #include "mozilla/dom/ShadowRoot.h" #include "mozilla/dom/PointerEvent.h" #include "nsIDocument.h" -#include "nsCSSStyleSheet.h" #include "nsAnimationManager.h" #include "nsNameSpaceManager.h" // for Pref-related rule management (bugs 22963,20760,31816) #include "nsFrame.h" @@ -1384,7 +1384,7 @@ nsresult PresShell::CreatePreferenceStyleSheet() { NS_ASSERTION(!mPrefStyleSheet, "prefStyleSheet already exists"); - mPrefStyleSheet = new nsCSSStyleSheet(CORS_NONE); + mPrefStyleSheet = new CSSStyleSheet(CORS_NONE); nsCOMPtr uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), "about:PreferenceStyleSheet", nullptr); if (NS_FAILED(rv)) { @@ -4616,7 +4616,7 @@ PresShell::RecordStyleSheetChange(nsIStyleSheet* aStyleSheet) if (mStylesHaveChanged) return; - nsRefPtr cssStyleSheet = do_QueryObject(aStyleSheet); + nsRefPtr cssStyleSheet = do_QueryObject(aStyleSheet); if (cssStyleSheet) { Element* scopeElement = cssStyleSheet->GetScopeElement(); if (scopeElement) { diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index ed73de136b42..e5c6a5f99a19 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -39,7 +39,6 @@ class nsRange; class nsIDragService; -class nsCSSStyleSheet; struct RangePaintInfo; struct nsCallbackEventRequest; @@ -50,6 +49,10 @@ class ReflowCountMgr; class nsPresShellEventCB; class nsAutoCauseReflowNotifier; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla + // 250ms. This is actually pref-controlled, but we use this value if we fail // to get the pref for any reason. #define PAINTLOCK_EVENT_DELAY 250 @@ -754,7 +757,7 @@ protected: nsPoint mMouseLocation; // mStyleSet owns it but we maintain a ref, may be null - nsRefPtr mPrefStyleSheet; + nsRefPtr mPrefStyleSheet; // Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after // we finish reflowing mCurrentReflowRoot. diff --git a/layout/base/nsStyleSheetService.cpp b/layout/base/nsStyleSheetService.cpp index cf8b810a1f56..33fedf8a8457 100644 --- a/layout/base/nsStyleSheetService.cpp +++ b/layout/base/nsStyleSheetService.cpp @@ -8,12 +8,12 @@ #include "nsStyleSheetService.h" #include "nsIStyleSheet.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/MemoryReporting.h" #include "mozilla/unused.h" #include "mozilla/css/Loader.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/ipc/URIUtils.h" -#include "nsCSSStyleSheet.h" #include "nsIURI.h" #include "nsCOMPtr.h" #include "nsICategoryManager.h" @@ -186,7 +186,7 @@ nsStyleSheetService::LoadAndRegisterSheetInternal(nsIURI *aSheetURI, nsRefPtr loader = new css::Loader(); - nsRefPtr sheet; + nsRefPtr sheet; // Allow UA sheets, but not user sheets, to use unsafe rules nsresult rv = loader->LoadSheetSync(aSheetURI, aSheetType == AGENT_SHEET, true, getter_AddRefs(sheet)); diff --git a/layout/inspector/inCSSValueSearch.cpp b/layout/inspector/inCSSValueSearch.cpp index 7db4fd9f81f7..8b2f2d4d9ad4 100644 --- a/layout/inspector/inCSSValueSearch.cpp +++ b/layout/inspector/inCSSValueSearch.cpp @@ -4,8 +4,8 @@ #include "inCSSValueSearch.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/dom/StyleSheetList.h" -#include "nsCSSStyleSheet.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsReadableUtils.h" @@ -98,7 +98,7 @@ inCSSValueSearch::SearchSync() uint32_t length = sheets->Length(); for (uint32_t i = 0; i < length; ++i) { - nsRefPtr sheet = sheets->Item(i); + nsRefPtr sheet = sheets->Item(i); SearchStyleSheet(sheet, baseURI); } diff --git a/layout/inspector/inDOMUtils.cpp b/layout/inspector/inDOMUtils.cpp index b2ca9261f0a8..825a63dfbd1d 100644 --- a/layout/inspector/inDOMUtils.cpp +++ b/layout/inspector/inDOMUtils.cpp @@ -32,8 +32,8 @@ #include "nsIAtom.h" #include "nsRange.h" #include "nsContentList.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/dom/Element.h" -#include "nsCSSStyleSheet.h" #include "nsRuleWalker.h" #include "nsRuleProcessorData.h" #include "nsCSSRuleProcessor.h" @@ -874,7 +874,7 @@ NS_IMETHODIMP inDOMUtils::ParseStyleSheet(nsIDOMCSSStyleSheet *aSheet, const nsAString& aInput) { - nsRefPtr sheet = do_QueryObject(aSheet); + nsRefPtr sheet = do_QueryObject(aSheet); NS_ENSURE_ARG_POINTER(sheet); return sheet->ParseSheet(aInput); diff --git a/layout/style/CSSRuleList.h b/layout/style/CSSRuleList.h index 933916aa6ee7..538a6e8e67ab 100644 --- a/layout/style/CSSRuleList.h +++ b/layout/style/CSSRuleList.h @@ -10,9 +10,9 @@ #include "nsIDOMCSSRuleList.h" #include "nsWrapperCache.h" -class nsCSSStyleSheet; - namespace mozilla { +class CSSStyleSheet; + namespace dom { // IID for the CSSRuleList interface @@ -35,7 +35,7 @@ public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CSSRuleList) - virtual nsCSSStyleSheet* GetParentObject() = 0; + virtual CSSStyleSheet* GetParentObject() = 0; virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE MOZ_FINAL; NS_IMETHOD diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp similarity index 86% rename from layout/style/nsCSSStyleSheet.cpp rename to layout/style/CSSStyleSheet.cpp index 1d709a1b6465..5935c544459d 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -6,7 +6,7 @@ /* representation of a CSS style sheet */ -#include "nsCSSStyleSheet.h" +#include "mozilla/CSSStyleSheet.h" #include "nsIAtom.h" #include "nsCSSRuleProcessor.h" @@ -47,16 +47,15 @@ using namespace mozilla; using namespace mozilla::dom; - // ------------------------------- // Style Rule List for the DOM // class CSSRuleListImpl : public CSSRuleList { public: - CSSRuleListImpl(nsCSSStyleSheet *aStyleSheet); + CSSRuleListImpl(CSSStyleSheet *aStyleSheet); - virtual nsCSSStyleSheet* GetParentObject() MOZ_OVERRIDE; + virtual CSSStyleSheet* GetParentObject() MOZ_OVERRIDE; virtual nsIDOMCSSRule* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE; @@ -68,10 +67,10 @@ public: protected: virtual ~CSSRuleListImpl(); - nsCSSStyleSheet* mStyleSheet; + CSSStyleSheet* mStyleSheet; }; -CSSRuleListImpl::CSSRuleListImpl(nsCSSStyleSheet *aStyleSheet) +CSSRuleListImpl::CSSRuleListImpl(CSSStyleSheet *aStyleSheet) { // Not reference counted to avoid circular references. // The style sheet will tell us when its going away. @@ -82,7 +81,7 @@ CSSRuleListImpl::~CSSRuleListImpl() { } -nsCSSStyleSheet* +CSSStyleSheet* CSSRuleListImpl::GetParentObject() { return mStyleSheet; @@ -545,7 +544,7 @@ nsMediaList::Matches(nsPresContext* aPresContext, } nsresult -nsMediaList::SetStyleSheet(nsCSSStyleSheet *aSheet) +nsMediaList::SetStyleSheet(CSSStyleSheet* aSheet) { NS_ASSERTION(aSheet == mStyleSheet || !aSheet || !mStyleSheet, "multiple style sheets competing for one media list"); @@ -572,7 +571,7 @@ nsMediaList::GetMediaText(nsAString& aMediaText) return NS_OK; } -// "sheet" should be an nsCSSStyleSheet and "doc" should be an +// "sheet" should be a CSSStyleSheet and "doc" should be an // nsCOMPtr #define BEGIN_MEDIA_CHANGE(sheet, doc) \ if (sheet) { \ @@ -715,13 +714,15 @@ nsMediaList::Append(const nsAString& aNewMedium) return rv; } +namespace mozilla { + // ------------------------------- // CSS Style Sheet Inner Data Container // -nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheet* aPrimarySheet, - CORSMode aCORSMode) +CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheet* aPrimarySheet, + CORSMode aCORSMode) : mSheets(), mCORSMode(aCORSMode), mComplete(false) @@ -729,7 +730,7 @@ nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheet* aPrimarySheet, , mPrincipalSet(false) #endif { - MOZ_COUNT_CTOR(nsCSSStyleSheetInner); + MOZ_COUNT_CTOR(CSSStyleSheetInner); mSheets.AppendElement(aPrimarySheet); mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1"); @@ -741,24 +742,24 @@ nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheet* aPrimarySheet, static bool SetStyleSheetReference(css::Rule* aRule, void* aSheet) { if (aRule) { - aRule->SetStyleSheet(static_cast(aSheet)); + aRule->SetStyleSheet(static_cast(aSheet)); } return true; } struct ChildSheetListBuilder { - nsRefPtr* sheetSlot; - nsCSSStyleSheet* parent; + nsRefPtr* sheetSlot; + CSSStyleSheet* parent; - void SetParentLinks(nsCSSStyleSheet* aSheet) { + void SetParentLinks(CSSStyleSheet* aSheet) { aSheet->mParent = parent; aSheet->SetOwningDocument(parent->mDocument); } - static void ReparentChildList(nsCSSStyleSheet* aPrimarySheet, - nsCSSStyleSheet* aFirstChild) + static void ReparentChildList(CSSStyleSheet* aPrimarySheet, + CSSStyleSheet* aFirstChild) { - for (nsCSSStyleSheet *child = aFirstChild; child; child = child->mNext) { + for (CSSStyleSheet *child = aFirstChild; child; child = child->mNext) { child->mParent = aPrimarySheet; child->SetOwningDocument(aPrimarySheet->mDocument); } @@ -766,7 +767,7 @@ struct ChildSheetListBuilder { }; bool -nsCSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) +CSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) { int32_t type = aRule->GetType(); if (type < css::Rule::IMPORT_RULE) { @@ -783,7 +784,7 @@ nsCSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) static_cast(aBuilder); // XXXbz We really need to decomtaminate all this stuff. Is there a reason - // that I can't just QI to ImportRule and get an nsCSSStyleSheet + // that I can't just QI to ImportRule and get a CSSStyleSheet // directly from it? nsCOMPtr importRule(do_QueryInterface(aRule)); NS_ASSERTION(importRule, "GetType lied"); @@ -793,7 +794,7 @@ nsCSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) // Have to do this QI to be safe, since XPConnect can fake // nsIDOMCSSStyleSheets - nsRefPtr cssSheet = do_QueryObject(childSheet); + nsRefPtr cssSheet = do_QueryObject(childSheet); if (!cssSheet) { return true; } @@ -805,10 +806,10 @@ nsCSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) } size_t -nsCSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const +CSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; - const nsCSSStyleSheet* s = this; + const CSSStyleSheet* s = this; while (s) { n += aMallocSizeOf(s); @@ -836,8 +837,8 @@ nsCSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const return n; } -nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheetInner& aCopy, - nsCSSStyleSheet* aPrimarySheet) +CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy, + CSSStyleSheet* aPrimarySheet) : mSheets(), mSheetURI(aCopy.mSheetURI), mOriginalSheetURI(aCopy.mOriginalSheetURI), @@ -849,37 +850,37 @@ nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheetInner& aCopy, , mPrincipalSet(aCopy.mPrincipalSet) #endif { - MOZ_COUNT_CTOR(nsCSSStyleSheetInner); + MOZ_COUNT_CTOR(CSSStyleSheetInner); AddSheet(aPrimarySheet); aCopy.mOrderedRules.EnumerateForwards(css::GroupRule::CloneRuleInto, &mOrderedRules); mOrderedRules.EnumerateForwards(SetStyleSheetReference, aPrimarySheet); ChildSheetListBuilder builder = { &mFirstChild, aPrimarySheet }; - mOrderedRules.EnumerateForwards(nsCSSStyleSheet::RebuildChildList, &builder); + mOrderedRules.EnumerateForwards(CSSStyleSheet::RebuildChildList, &builder); RebuildNameSpaces(); } -nsCSSStyleSheetInner::~nsCSSStyleSheetInner() +CSSStyleSheetInner::~CSSStyleSheetInner() { - MOZ_COUNT_DTOR(nsCSSStyleSheetInner); + MOZ_COUNT_DTOR(CSSStyleSheetInner); mOrderedRules.EnumerateForwards(SetStyleSheetReference, nullptr); } -nsCSSStyleSheetInner* -nsCSSStyleSheetInner::CloneFor(nsCSSStyleSheet* aPrimarySheet) +CSSStyleSheetInner* +CSSStyleSheetInner::CloneFor(CSSStyleSheet* aPrimarySheet) { - return new nsCSSStyleSheetInner(*this, aPrimarySheet); + return new CSSStyleSheetInner(*this, aPrimarySheet); } void -nsCSSStyleSheetInner::AddSheet(nsCSSStyleSheet* aSheet) +CSSStyleSheetInner::AddSheet(CSSStyleSheet* aSheet) { mSheets.AppendElement(aSheet); } void -nsCSSStyleSheetInner::RemoveSheet(nsCSSStyleSheet* aSheet) +CSSStyleSheetInner::RemoveSheet(CSSStyleSheet* aSheet) { if (1 == mSheets.Length()) { NS_ASSERTION(aSheet == mSheets.ElementAt(0), "bad parent"); @@ -927,7 +928,7 @@ CreateNameSpace(css::Rule* aRule, void* aNameSpacePtr) } void -nsCSSStyleSheetInner::RebuildNameSpaces() +CSSStyleSheetInner::RebuildNameSpaces() { // Just nuke our existing namespace map, if any if (NS_SUCCEEDED(CreateNamespaceMap())) { @@ -936,7 +937,7 @@ nsCSSStyleSheetInner::RebuildNameSpaces() } nsresult -nsCSSStyleSheetInner::CreateNamespaceMap() +CSSStyleSheetInner::CreateNamespaceMap() { mNameSpaceMap = nsXMLNameSpaceMap::Create(false); NS_ENSURE_TRUE(mNameSpaceMap, NS_ERROR_OUT_OF_MEMORY); @@ -947,7 +948,7 @@ nsCSSStyleSheetInner::CreateNamespaceMap() } size_t -nsCSSStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const +CSSStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mOrderedRules.SizeOfExcludingThis(css::Rule::SizeOfCOMArrayElementIncludingThis, @@ -972,7 +973,7 @@ nsCSSStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const // CSS Style Sheet // -nsCSSStyleSheet::nsCSSStyleSheet(CORSMode aCORSMode) +CSSStyleSheet::CSSStyleSheet(CORSMode aCORSMode) : mTitle(), mParent(nullptr), mOwnerRule(nullptr), @@ -983,16 +984,16 @@ nsCSSStyleSheet::nsCSSStyleSheet(CORSMode aCORSMode) mScopeElement(nullptr), mRuleProcessors(nullptr) { - mInner = new nsCSSStyleSheetInner(this, aCORSMode); + mInner = new CSSStyleSheetInner(this, aCORSMode); SetIsDOMBinding(); } -nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy, - nsCSSStyleSheet* aParentToUse, - css::ImportRule* aOwnerRuleToUse, - nsIDocument* aDocumentToUse, - nsINode* aOwningNodeToUse) +CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy, + CSSStyleSheet* aParentToUse, + css::ImportRule* aOwnerRuleToUse, + nsIDocument* aDocumentToUse, + nsINode* aOwningNodeToUse) : mTitle(aCopy.mTitle), mParent(aParentToUse), mOwnerRule(aOwnerRuleToUse), @@ -1022,9 +1023,9 @@ nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy, SetIsDOMBinding(); } -nsCSSStyleSheet::~nsCSSStyleSheet() +CSSStyleSheet::~CSSStyleSheet() { - for (nsCSSStyleSheet* child = mInner->mFirstChild; + for (CSSStyleSheet* child = mInner->mFirstChild; child; child = child->mNext) { // XXXbz this is a little bogus; see the XXX comment where we @@ -1047,7 +1048,7 @@ nsCSSStyleSheet::~nsCSSStyleSheet() } void -nsCSSStyleSheet::DropRuleCollection() +CSSStyleSheet::DropRuleCollection() { if (mRuleCollection) { mRuleCollection->DropReference(); @@ -1056,7 +1057,7 @@ nsCSSStyleSheet::DropRuleCollection() } void -nsCSSStyleSheet::DropMedia() +CSSStyleSheet::DropMedia() { if (mMedia) { mMedia->SetStyleSheet(nullptr); @@ -1065,7 +1066,7 @@ nsCSSStyleSheet::DropMedia() } void -nsCSSStyleSheet::UnlinkInner() +CSSStyleSheet::UnlinkInner() { // We can only have a cycle through our inner if we have a unique inner, // because otherwise there are no JS wrappers for anything in the inner. @@ -1082,13 +1083,13 @@ nsCSSStyleSheet::UnlinkInner() // don't want to do any addrefing in the process, just to make sure // we don't confuse the cycle collector (though on the face of it, // addref/release pairs during unlink should probably be ok). - nsRefPtr child; + nsRefPtr child; child.swap(mInner->mFirstChild); while (child) { MOZ_ASSERT(child->mParent == this, "We have a unique inner!"); child->mParent = nullptr; child->mDocument = nullptr; - nsRefPtr next; + nsRefPtr next; // Null out child->mNext, but don't let it die yet next.swap(child->mNext); // Switch to looking at the old value of child->mNext next iteration @@ -1099,7 +1100,7 @@ nsCSSStyleSheet::UnlinkInner() } void -nsCSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb) +CSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb) { // We can only have a cycle through our inner if we have a unique inner, // because otherwise there are no JS wrappers for anything in the inner. @@ -1107,7 +1108,7 @@ nsCSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb) return; } - nsRefPtr* childSheetSlot = &mInner->mFirstChild; + nsRefPtr* childSheetSlot = &mInner->mFirstChild; while (*childSheetSlot) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "child sheet"); cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIStyleSheet*, childSheetSlot->get())); @@ -1121,26 +1122,26 @@ nsCSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb) } } -// QueryInterface implementation for nsCSSStyleSheet -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSStyleSheet) +// QueryInterface implementation for CSSStyleSheet +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSStyleSheet) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsIStyleSheet) NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet) NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleSheet) - if (aIID.Equals(NS_GET_IID(nsCSSStyleSheet))) + if (aIID.Equals(NS_GET_IID(CSSStyleSheet))) foundInterface = reinterpret_cast(this); else NS_INTERFACE_MAP_END -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCSSStyleSheet) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCSSStyleSheet) +NS_IMPL_CYCLE_COLLECTING_ADDREF(CSSStyleSheet) +NS_IMPL_CYCLE_COLLECTING_RELEASE(CSSStyleSheet) -NS_IMPL_CYCLE_COLLECTION_CLASS(nsCSSStyleSheet) +NS_IMPL_CYCLE_COLLECTION_CLASS(CSSStyleSheet) -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSStyleSheet) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSStyleSheet) tmp->DropMedia(); // We do not unlink mNext; our parent will handle that. If we // unlinked it here, our parent would not be able to walk its list @@ -1152,7 +1153,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSStyleSheet) tmp->ClearRuleCascades(); NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSStyleSheet) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CSSStyleSheet) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMedia) // We do not traverse mNext; our parent will handle that. See // comments in Unlink for why. @@ -1161,10 +1162,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSStyleSheet) tmp->TraverseInner(cb); NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsCSSStyleSheet) +NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(CSSStyleSheet) nsresult -nsCSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor) +CSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor) { if (! mRuleProcessors) { mRuleProcessors = new nsAutoTArray(); @@ -1178,7 +1179,7 @@ nsCSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor) } nsresult -nsCSSStyleSheet::DropRuleProcessor(nsCSSRuleProcessor* aProcessor) +CSSStyleSheet::DropRuleProcessor(nsCSSRuleProcessor* aProcessor) { if (!mRuleProcessors) return NS_ERROR_FAILURE; @@ -1189,8 +1190,8 @@ nsCSSStyleSheet::DropRuleProcessor(nsCSSRuleProcessor* aProcessor) void -nsCSSStyleSheet::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, - nsIURI* aBaseURI) +CSSStyleSheet::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, + nsIURI* aBaseURI) { NS_PRECONDITION(aSheetURI && aBaseURI, "null ptr"); @@ -1203,7 +1204,7 @@ nsCSSStyleSheet::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, } void -nsCSSStyleSheet::SetPrincipal(nsIPrincipal* aPrincipal) +CSSStyleSheet::SetPrincipal(nsIPrincipal* aPrincipal) { NS_PRECONDITION(!mInner->mPrincipalSet, "Should have an inner whose principal has not yet been set"); @@ -1216,26 +1217,26 @@ nsCSSStyleSheet::SetPrincipal(nsIPrincipal* aPrincipal) } /* virtual */ nsIURI* -nsCSSStyleSheet::GetSheetURI() const +CSSStyleSheet::GetSheetURI() const { return mInner->mSheetURI; } /* virtual */ nsIURI* -nsCSSStyleSheet::GetBaseURI() const +CSSStyleSheet::GetBaseURI() const { return mInner->mBaseURI; } /* virtual */ void -nsCSSStyleSheet::GetType(nsString& aType) const +CSSStyleSheet::GetType(nsString& aType) const { aType.AssignLiteral("text/css"); } bool -nsCSSStyleSheet::UseForPresentation(nsPresContext* aPresContext, - nsMediaQueryResultCacheKey& aKey) const +CSSStyleSheet::UseForPresentation(nsPresContext* aPresContext, + nsMediaQueryResultCacheKey& aKey) const { if (mMedia) { return mMedia->Matches(aPresContext, &aKey); @@ -1245,25 +1246,25 @@ nsCSSStyleSheet::UseForPresentation(nsPresContext* aPresContext, void -nsCSSStyleSheet::SetMedia(nsMediaList* aMedia) +CSSStyleSheet::SetMedia(nsMediaList* aMedia) { mMedia = aMedia; } /* virtual */ bool -nsCSSStyleSheet::HasRules() const +CSSStyleSheet::HasRules() const { return StyleRuleCount() != 0; } /* virtual */ bool -nsCSSStyleSheet::IsApplicable() const +CSSStyleSheet::IsApplicable() const { return !mDisabled && mInner->mComplete; } /* virtual */ void -nsCSSStyleSheet::SetEnabled(bool aEnabled) +CSSStyleSheet::SetEnabled(bool aEnabled) { // Internal method, so callers must handle BeginUpdate/EndUpdate bool oldDisabled = mDisabled; @@ -1279,13 +1280,13 @@ nsCSSStyleSheet::SetEnabled(bool aEnabled) } /* virtual */ bool -nsCSSStyleSheet::IsComplete() const +CSSStyleSheet::IsComplete() const { return mInner->mComplete; } /* virtual */ void -nsCSSStyleSheet::SetComplete() +CSSStyleSheet::SetComplete() { NS_ASSERTION(!mDirty, "Can't set a dirty sheet complete!"); mInner->mComplete = true; @@ -1305,25 +1306,25 @@ nsCSSStyleSheet::SetComplete() } /* virtual */ nsIStyleSheet* -nsCSSStyleSheet::GetParentSheet() const +CSSStyleSheet::GetParentSheet() const { return mParent; } /* virtual */ nsIDocument* -nsCSSStyleSheet::GetOwningDocument() const +CSSStyleSheet::GetOwningDocument() const { return mDocument; } /* virtual */ void -nsCSSStyleSheet::SetOwningDocument(nsIDocument* aDocument) +CSSStyleSheet::SetOwningDocument(nsIDocument* aDocument) { // not ref counted mDocument = aDocument; // Now set the same document on all our child sheets.... // XXXbz this is a little bogus; see the XXX comment where we // declare mFirstChild. - for (nsCSSStyleSheet* child = mInner->mFirstChild; + for (CSSStyleSheet* child = mInner->mFirstChild; child; child = child->mNext) { if (child->mParent == this) { child->SetOwningDocument(aDocument); @@ -1332,7 +1333,7 @@ nsCSSStyleSheet::SetOwningDocument(nsIDocument* aDocument) } uint64_t -nsCSSStyleSheet::FindOwningWindowInnerID() const +CSSStyleSheet::FindOwningWindowInnerID() const { uint64_t windowID = 0; if (mDocument) { @@ -1346,7 +1347,7 @@ nsCSSStyleSheet::FindOwningWindowInnerID() const if (windowID == 0 && mOwnerRule) { nsCOMPtr sheet = static_cast(mOwnerRule)->GetStyleSheet(); if (sheet) { - nsRefPtr cssSheet = do_QueryObject(sheet); + nsRefPtr cssSheet = do_QueryObject(sheet); if (cssSheet) { windowID = cssSheet->FindOwningWindowInnerID(); } @@ -1361,12 +1362,12 @@ nsCSSStyleSheet::FindOwningWindowInnerID() const } void -nsCSSStyleSheet::AppendStyleSheet(nsCSSStyleSheet* aSheet) +CSSStyleSheet::AppendStyleSheet(CSSStyleSheet* aSheet) { NS_PRECONDITION(nullptr != aSheet, "null arg"); WillDirty(); - nsRefPtr* tail = &mInner->mFirstChild; + nsRefPtr* tail = &mInner->mFirstChild; while (*tail) { tail = &(*tail)->mNext; } @@ -1380,12 +1381,12 @@ nsCSSStyleSheet::AppendStyleSheet(nsCSSStyleSheet* aSheet) } void -nsCSSStyleSheet::InsertStyleSheetAt(nsCSSStyleSheet* aSheet, int32_t aIndex) +CSSStyleSheet::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex) { NS_PRECONDITION(nullptr != aSheet, "null arg"); WillDirty(); - nsRefPtr* tail = &mInner->mFirstChild; + nsRefPtr* tail = &mInner->mFirstChild; while (*tail && aIndex) { --aIndex; tail = &(*tail)->mNext; @@ -1401,7 +1402,7 @@ nsCSSStyleSheet::InsertStyleSheetAt(nsCSSStyleSheet* aSheet, int32_t aIndex) } void -nsCSSStyleSheet::PrependStyleRule(css::Rule* aRule) +CSSStyleSheet::PrependStyleRule(css::Rule* aRule) { NS_PRECONDITION(nullptr != aRule, "null arg"); @@ -1417,7 +1418,7 @@ nsCSSStyleSheet::PrependStyleRule(css::Rule* aRule) } void -nsCSSStyleSheet::AppendStyleRule(css::Rule* aRule) +CSSStyleSheet::AppendStyleRule(css::Rule* aRule) { NS_PRECONDITION(nullptr != aRule, "null arg"); @@ -1437,7 +1438,7 @@ nsCSSStyleSheet::AppendStyleRule(css::Rule* aRule) } void -nsCSSStyleSheet::ReplaceStyleRule(css::Rule* aOld, css::Rule* aNew) +CSSStyleSheet::ReplaceStyleRule(css::Rule* aOld, css::Rule* aNew) { NS_PRECONDITION(mInner->mOrderedRules.Count() != 0, "can't have old rule"); NS_PRECONDITION(mInner->mComplete, "No replacing in an incomplete sheet!"); @@ -1458,13 +1459,13 @@ nsCSSStyleSheet::ReplaceStyleRule(css::Rule* aOld, css::Rule* aNew) } int32_t -nsCSSStyleSheet::StyleRuleCount() const +CSSStyleSheet::StyleRuleCount() const { return mInner->mOrderedRules.Count(); } css::Rule* -nsCSSStyleSheet::GetStyleRuleAt(int32_t aIndex) const +CSSStyleSheet::GetStyleRuleAt(int32_t aIndex) const { // Important: If this function is ever made scriptable, we must add // a security check here. See GetCssRules below for an example. @@ -1472,14 +1473,14 @@ nsCSSStyleSheet::GetStyleRuleAt(int32_t aIndex) const } int32_t -nsCSSStyleSheet::StyleSheetCount() const +CSSStyleSheet::StyleSheetCount() const { // XXX Far from an ideal way to do this, but the hope is that // it won't be done too often. If it is, we might want to // consider storing the children in an array. int32_t count = 0; - const nsCSSStyleSheet* child = mInner->mFirstChild; + const CSSStyleSheet* child = mInner->mFirstChild; while (child) { count++; child = child->mNext; @@ -1488,8 +1489,8 @@ nsCSSStyleSheet::StyleSheetCount() const return count; } -nsCSSStyleSheet::EnsureUniqueInnerResult -nsCSSStyleSheet::EnsureUniqueInner() +CSSStyleSheet::EnsureUniqueInnerResult +CSSStyleSheet::EnsureUniqueInner() { mDirty = true; @@ -1498,7 +1499,7 @@ nsCSSStyleSheet::EnsureUniqueInner() if (mInner->mSheets.Length() == 1) { return eUniqueInner_AlreadyUnique; } - nsCSSStyleSheetInner* clone = mInner->CloneFor(this); + CSSStyleSheetInner* clone = mInner->CloneFor(this); MOZ_ASSERT(clone); mInner->RemoveSheet(this); mInner = clone; @@ -1510,25 +1511,25 @@ nsCSSStyleSheet::EnsureUniqueInner() } void -nsCSSStyleSheet::AppendAllChildSheets(nsTArray& aArray) +CSSStyleSheet::AppendAllChildSheets(nsTArray& aArray) { - for (nsCSSStyleSheet* child = mInner->mFirstChild; child; + for (CSSStyleSheet* child = mInner->mFirstChild; child; child = child->mNext) { aArray.AppendElement(child); } } -already_AddRefed -nsCSSStyleSheet::Clone(nsCSSStyleSheet* aCloneParent, - css::ImportRule* aCloneOwnerRule, - nsIDocument* aCloneDocument, - nsINode* aCloneOwningNode) const +already_AddRefed +CSSStyleSheet::Clone(CSSStyleSheet* aCloneParent, + css::ImportRule* aCloneOwnerRule, + nsIDocument* aCloneDocument, + nsINode* aCloneOwningNode) const { - nsRefPtr clone = new nsCSSStyleSheet(*this, - aCloneParent, - aCloneOwnerRule, - aCloneDocument, - aCloneOwningNode); + nsRefPtr clone = new CSSStyleSheet(*this, + aCloneParent, + aCloneOwnerRule, + aCloneDocument, + aCloneOwningNode); return clone.forget(); } @@ -1552,7 +1553,7 @@ struct ListEnumData { }; /* virtual */ void -nsCSSStyleSheet::List(FILE* out, int32_t aIndent) const +CSSStyleSheet::List(FILE* out, int32_t aIndent) const { int32_t index; @@ -1575,7 +1576,7 @@ nsCSSStyleSheet::List(FILE* out, int32_t aIndent) const } fputs("\n", out); - for (const nsCSSStyleSheet* child = mInner->mFirstChild; + for (const CSSStyleSheet* child = mInner->mFirstChild; child; child = child->mNext) { child->List(out, aIndent + 1); @@ -1587,7 +1588,7 @@ nsCSSStyleSheet::List(FILE* out, int32_t aIndent) const #endif void -nsCSSStyleSheet::ClearRuleCascades() +CSSStyleSheet::ClearRuleCascades() { if (mRuleProcessors) { nsCSSRuleProcessor **iter = mRuleProcessors->Elements(), @@ -1597,13 +1598,13 @@ nsCSSStyleSheet::ClearRuleCascades() } } if (mParent) { - nsCSSStyleSheet* parent = (nsCSSStyleSheet*)mParent; + CSSStyleSheet* parent = (CSSStyleSheet*)mParent; parent->ClearRuleCascades(); } } void -nsCSSStyleSheet::WillDirty() +CSSStyleSheet::WillDirty() { if (mInner->mComplete) { EnsureUniqueInner(); @@ -1611,7 +1612,7 @@ nsCSSStyleSheet::WillDirty() } void -nsCSSStyleSheet::DidDirty() +CSSStyleSheet::DidDirty() { NS_ABORT_IF_FALSE(!mInner->mComplete || mDirty, "caller must have called WillDirty()"); @@ -1619,7 +1620,7 @@ nsCSSStyleSheet::DidDirty() } nsresult -nsCSSStyleSheet::SubjectSubsumesInnerPrincipal() +CSSStyleSheet::SubjectSubsumesInnerPrincipal() { nsCOMPtr subjectPrincipal = nsContentUtils::SubjectPrincipal(); if (subjectPrincipal->Subsumes(mInner->mPrincipal)) { @@ -1650,7 +1651,7 @@ nsCSSStyleSheet::SubjectSubsumesInnerPrincipal() } nsresult -nsCSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule) +CSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule) { if (!mInner->mNameSpaceMap) { nsresult rv = mInner->CreateNamespaceMap(); @@ -1663,30 +1664,30 @@ nsCSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule) // nsIDOMStyleSheet interface NS_IMETHODIMP -nsCSSStyleSheet::GetType(nsAString& aType) +CSSStyleSheet::GetType(nsAString& aType) { aType.AssignLiteral("text/css"); return NS_OK; } NS_IMETHODIMP -nsCSSStyleSheet::GetDisabled(bool* aDisabled) +CSSStyleSheet::GetDisabled(bool* aDisabled) { *aDisabled = Disabled(); return NS_OK; } NS_IMETHODIMP -nsCSSStyleSheet::SetDisabled(bool aDisabled) +CSSStyleSheet::SetDisabled(bool aDisabled) { // DOM method, so handle BeginUpdate/EndUpdate MOZ_AUTO_DOC_UPDATE(mDocument, UPDATE_STYLE, true); - nsCSSStyleSheet::SetEnabled(!aDisabled); + CSSStyleSheet::SetEnabled(!aDisabled); return NS_OK; } NS_IMETHODIMP -nsCSSStyleSheet::GetOwnerNode(nsIDOMNode** aOwnerNode) +CSSStyleSheet::GetOwnerNode(nsIDOMNode** aOwnerNode) { nsCOMPtr ownerNode = do_QueryInterface(GetOwnerNode()); ownerNode.forget(aOwnerNode); @@ -1694,7 +1695,7 @@ nsCSSStyleSheet::GetOwnerNode(nsIDOMNode** aOwnerNode) } NS_IMETHODIMP -nsCSSStyleSheet::GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet) +CSSStyleSheet::GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet) { NS_ENSURE_ARG_POINTER(aParentStyleSheet); @@ -1704,7 +1705,7 @@ nsCSSStyleSheet::GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet) } NS_IMETHODIMP -nsCSSStyleSheet::GetHref(nsAString& aHref) +CSSStyleSheet::GetHref(nsAString& aHref) { if (mInner->mOriginalSheetURI) { nsAutoCString str; @@ -1718,27 +1719,27 @@ nsCSSStyleSheet::GetHref(nsAString& aHref) } /* virtual */ void -nsCSSStyleSheet::GetTitle(nsString& aTitle) const +CSSStyleSheet::GetTitle(nsString& aTitle) const { aTitle = mTitle; } NS_IMETHODIMP -nsCSSStyleSheet::GetTitle(nsAString& aTitle) +CSSStyleSheet::GetTitle(nsAString& aTitle) { aTitle.Assign(mTitle); return NS_OK; } NS_IMETHODIMP -nsCSSStyleSheet::GetMedia(nsIDOMMediaList** aMedia) +CSSStyleSheet::GetMedia(nsIDOMMediaList** aMedia) { NS_ADDREF(*aMedia = Media()); return NS_OK; } nsMediaList* -nsCSSStyleSheet::Media() +CSSStyleSheet::Media() { if (!mMedia) { mMedia = new nsMediaList(); @@ -1749,20 +1750,20 @@ nsCSSStyleSheet::Media() } NS_IMETHODIMP -nsCSSStyleSheet::GetOwnerRule(nsIDOMCSSRule** aOwnerRule) +CSSStyleSheet::GetOwnerRule(nsIDOMCSSRule** aOwnerRule) { NS_IF_ADDREF(*aOwnerRule = GetOwnerRule()); return NS_OK; } nsIDOMCSSRule* -nsCSSStyleSheet::GetDOMOwnerRule() const +CSSStyleSheet::GetDOMOwnerRule() const { return mOwnerRule ? mOwnerRule->GetDOMRule() : nullptr; } NS_IMETHODIMP -nsCSSStyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules) +CSSStyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules) { ErrorResult rv; nsCOMPtr rules = GetCssRules(rv); @@ -1771,7 +1772,7 @@ nsCSSStyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules) } CSSRuleList* -nsCSSStyleSheet::GetCssRules(ErrorResult& aRv) +CSSStyleSheet::GetCssRules(ErrorResult& aRv) { // No doing this on incomplete sheets! if (!mInner->mComplete) { @@ -1796,9 +1797,9 @@ nsCSSStyleSheet::GetCssRules(ErrorResult& aRv) } NS_IMETHODIMP -nsCSSStyleSheet::InsertRule(const nsAString& aRule, - uint32_t aIndex, - uint32_t* aReturn) +CSSStyleSheet::InsertRule(const nsAString& aRule, + uint32_t aIndex, + uint32_t* aReturn) { //-- Security check: Only scripts whose principal subsumes that of the // style sheet can modify rule collections. @@ -1815,14 +1816,14 @@ RuleHasPendingChildSheet(css::Rule *cssRule) NS_ASSERTION(importRule, "Rule which has type IMPORT_RULE and does not implement nsIDOMCSSImportRule!"); nsCOMPtr childSheet; importRule->GetStyleSheet(getter_AddRefs(childSheet)); - nsRefPtr cssSheet = do_QueryObject(childSheet); + nsRefPtr cssSheet = do_QueryObject(childSheet); return cssSheet != nullptr && !cssSheet->IsComplete(); } nsresult -nsCSSStyleSheet::InsertRuleInternal(const nsAString& aRule, - uint32_t aIndex, - uint32_t* aReturn) +CSSStyleSheet::InsertRuleInternal(const nsAString& aRule, + uint32_t aIndex, + uint32_t* aReturn) { // No doing this if the sheet is not complete! if (!mInner->mComplete) { @@ -1930,7 +1931,7 @@ nsCSSStyleSheet::InsertRuleInternal(const nsAString& aRule, } NS_IMETHODIMP -nsCSSStyleSheet::DeleteRule(uint32_t aIndex) +CSSStyleSheet::DeleteRule(uint32_t aIndex) { // No doing this if the sheet is not complete! if (!mInner->mComplete) { @@ -1974,7 +1975,7 @@ nsCSSStyleSheet::DeleteRule(uint32_t aIndex) } nsresult -nsCSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex) +CSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex) { NS_ENSURE_ARG_POINTER(aGroup); NS_ASSERTION(mInner->mComplete, "No deleting from an incomplete sheet!"); @@ -2005,10 +2006,10 @@ nsCSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex) } nsresult -nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, - css::GroupRule* aGroup, - uint32_t aIndex, - uint32_t* _retval) +CSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, + css::GroupRule* aGroup, + uint32_t aIndex, + uint32_t* _retval) { NS_ASSERTION(mInner->mComplete, "No inserting into an incomplete sheet!"); // check that the group actually belongs to this sheet! @@ -2071,8 +2072,8 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, } nsresult -nsCSSStyleSheet::ReplaceRuleInGroup(css::GroupRule* aGroup, - css::Rule* aOld, css::Rule* aNew) +CSSStyleSheet::ReplaceRuleInGroup(css::GroupRule* aGroup, + css::Rule* aOld, css::Rule* aNew) { NS_PRECONDITION(mInner->mComplete, "No replacing in an incomplete sheet!"); NS_ASSERTION(this == aGroup->GetStyleSheet(), "group doesn't belong to this sheet"); @@ -2086,9 +2087,9 @@ nsCSSStyleSheet::ReplaceRuleInGroup(css::GroupRule* aGroup, // nsICSSLoaderObserver implementation NS_IMETHODIMP -nsCSSStyleSheet::StyleSheetLoaded(nsCSSStyleSheet* aSheet, - bool aWasAlternate, - nsresult aStatus) +CSSStyleSheet::StyleSheetLoaded(CSSStyleSheet* aSheet, + bool aWasAlternate, + nsresult aStatus) { if (aSheet->GetParentSheet() == nullptr) { return NS_OK; // ignore if sheet has been detached already (see parseSheet) @@ -2108,7 +2109,7 @@ nsCSSStyleSheet::StyleSheetLoaded(nsCSSStyleSheet* aSheet, } nsresult -nsCSSStyleSheet::ParseSheet(const nsAString& aInput) +CSSStyleSheet::ParseSheet(const nsAString& aInput) { // Not doing this if the sheet is not complete! if (!mInner->mComplete) { @@ -2141,7 +2142,7 @@ nsCSSStyleSheet::ParseSheet(const nsAString& aInput) } // nuke child sheets list and current namespace map - for (nsCSSStyleSheet* child = mInner->mFirstChild; child; child = child->mNext) { + for (CSSStyleSheet* child = mInner->mFirstChild; child; child = child->mNext) { NS_ASSERTION(child->mParent == this, "Child sheet is not parented to this!"); child->mParent = nullptr; child->mDocument = nullptr; @@ -2173,14 +2174,16 @@ nsCSSStyleSheet::ParseSheet(const nsAString& aInput) } /* virtual */ nsIURI* -nsCSSStyleSheet::GetOriginalURI() const +CSSStyleSheet::GetOriginalURI() const { return mInner->mOriginalSheetURI; } /* virtual */ JSObject* -nsCSSStyleSheet::WrapObject(JSContext* aCx) +CSSStyleSheet::WrapObject(JSContext* aCx) { return CSSStyleSheetBinding::Wrap(aCx, this); } + +} // namespace mozilla diff --git a/layout/style/nsCSSStyleSheet.h b/layout/style/CSSStyleSheet.h similarity index 66% rename from layout/style/nsCSSStyleSheet.h rename to layout/style/CSSStyleSheet.h index 2385a91c4ab6..a3ec2140aa44 100644 --- a/layout/style/nsCSSStyleSheet.h +++ b/layout/style/CSSStyleSheet.h @@ -6,8 +6,8 @@ /* representation of a CSS style sheet */ -#ifndef nsCSSStyleSheet_h_ -#define nsCSSStyleSheet_h_ +#ifndef mozilla_CSSStyleSheet_h +#define mozilla_CSSStyleSheet_h #include "mozilla/Attributes.h" #include "mozilla/MemoryReporting.h" @@ -26,16 +26,20 @@ #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" -class nsXMLNameSpaceMap; +class CSSRuleListImpl; class nsCSSRuleProcessor; +class nsICSSRuleList; class nsIPrincipal; class nsIURI; class nsMediaList; class nsMediaQueryResultCacheKey; -class nsCSSStyleSheet; class nsPresContext; +class nsXMLNameSpaceMap; namespace mozilla { +class ChildSheetListBuilder; +class CSSStyleSheet; + namespace css { class Rule; class GroupRule; @@ -44,48 +48,48 @@ class ImportRule; namespace dom { class CSSRuleList; } -} // ------------------------------- // CSS Style Sheet Inner Data Container // -class nsCSSStyleSheetInner { +class CSSStyleSheetInner +{ public: - friend class nsCSSStyleSheet; - friend class nsCSSRuleProcessor; + friend class mozilla::CSSStyleSheet; + friend class ::nsCSSRuleProcessor; private: - nsCSSStyleSheetInner(nsCSSStyleSheet* aPrimarySheet, - mozilla::CORSMode aCORSMode); - nsCSSStyleSheetInner(nsCSSStyleSheetInner& aCopy, - nsCSSStyleSheet* aPrimarySheet); - ~nsCSSStyleSheetInner(); + CSSStyleSheetInner(CSSStyleSheet* aPrimarySheet, + CORSMode aCORSMode); + CSSStyleSheetInner(CSSStyleSheetInner& aCopy, + CSSStyleSheet* aPrimarySheet); + ~CSSStyleSheetInner(); - nsCSSStyleSheetInner* CloneFor(nsCSSStyleSheet* aPrimarySheet); - void AddSheet(nsCSSStyleSheet* aSheet); - void RemoveSheet(nsCSSStyleSheet* aSheet); + CSSStyleSheetInner* CloneFor(CSSStyleSheet* aPrimarySheet); + void AddSheet(CSSStyleSheet* aSheet); + void RemoveSheet(CSSStyleSheet* aSheet); void RebuildNameSpaces(); // Create a new namespace map nsresult CreateNamespaceMap(); - size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; - nsAutoTArray mSheets; + nsAutoTArray mSheets; nsCOMPtr mSheetURI; // for error reports, etc. nsCOMPtr mOriginalSheetURI; // for GetHref. Can be null. nsCOMPtr mBaseURI; // for resolving relative URIs nsCOMPtr mPrincipal; - nsCOMArray mOrderedRules; + nsCOMArray mOrderedRules; nsAutoPtr mNameSpaceMap; // Linked list of child sheets. This is al fundamentally broken, because // each of the child sheets has a unique parent... We can only hope (and // currently this is the case) that any time page JS can get ts hands on a // child sheet that means we've already ensured unique inners throughout its // parent chain and things are good. - nsRefPtr mFirstChild; - mozilla::CORSMode mCORSMode; + nsRefPtr mFirstChild; + CORSMode mCORSMode; bool mComplete; #ifdef DEBUG @@ -98,25 +102,23 @@ private: // CSS Style Sheet // -class CSSRuleListImpl; - -// CID for the nsCSSStyleSheet class +// CID for the CSSStyleSheet class // ca926f30-2a7e-477e-8467-803fb32af20a #define NS_CSS_STYLE_SHEET_IMPL_CID \ { 0xca926f30, 0x2a7e, 0x477e, \ { 0x84, 0x67, 0x80, 0x3f, 0xb3, 0x2a, 0xf2, 0x0a } } -class nsCSSStyleSheet MOZ_FINAL : public nsIStyleSheet, - public nsIDOMCSSStyleSheet, - public nsICSSLoaderObserver, - public nsWrapperCache +class CSSStyleSheet MOZ_FINAL : public nsIStyleSheet, + public nsIDOMCSSStyleSheet, + public nsICSSLoaderObserver, + public nsWrapperCache { public: - nsCSSStyleSheet(mozilla::CORSMode aCORSMode); + CSSStyleSheet(CORSMode aCORSMode); NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSStyleSheet, + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(CSSStyleSheet, nsIStyleSheet) NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_SHEET_IMPL_CID) @@ -141,20 +143,20 @@ public: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; #endif - void AppendStyleSheet(nsCSSStyleSheet* aSheet); - void InsertStyleSheetAt(nsCSSStyleSheet* aSheet, int32_t aIndex); + void AppendStyleSheet(CSSStyleSheet* aSheet); + void InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex); // XXX do these belong here or are they generic? - void PrependStyleRule(mozilla::css::Rule* aRule); - void AppendStyleRule(mozilla::css::Rule* aRule); - void ReplaceStyleRule(mozilla::css::Rule* aOld, mozilla::css::Rule* aNew); + void PrependStyleRule(css::Rule* aRule); + void AppendStyleRule(css::Rule* aRule); + void ReplaceStyleRule(css::Rule* aOld, css::Rule* aNew); int32_t StyleRuleCount() const; - mozilla::css::Rule* GetStyleRuleAt(int32_t aIndex) const; + css::Rule* GetStyleRuleAt(int32_t aIndex) const; - nsresult DeleteRuleFromGroup(mozilla::css::GroupRule* aGroup, uint32_t aIndex); - nsresult InsertRuleIntoGroup(const nsAString& aRule, mozilla::css::GroupRule* aGroup, uint32_t aIndex, uint32_t* _retval); - nsresult ReplaceRuleInGroup(mozilla::css::GroupRule* aGroup, mozilla::css::Rule* aOld, mozilla::css::Rule* aNew); + nsresult DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex); + nsresult InsertRuleIntoGroup(const nsAString& aRule, css::GroupRule* aGroup, uint32_t aIndex, uint32_t* _retval); + nsresult ReplaceRuleInGroup(css::GroupRule* aGroup, css::Rule* aOld, css::Rule* aNew); int32_t StyleSheetCount() const; @@ -182,15 +184,15 @@ public: void SetMedia(nsMediaList* aMedia); void SetOwningNode(nsINode* aOwningNode) { mOwningNode = aOwningNode; /* Not ref counted */ } - void SetOwnerRule(mozilla::css::ImportRule* aOwnerRule) { mOwnerRule = aOwnerRule; /* Not ref counted */ } - mozilla::css::ImportRule* GetOwnerRule() const { return mOwnerRule; } + void SetOwnerRule(css::ImportRule* aOwnerRule) { mOwnerRule = aOwnerRule; /* Not ref counted */ } + css::ImportRule* GetOwnerRule() const { return mOwnerRule; } nsXMLNameSpaceMap* GetNameSpaceMap() const { return mInner->mNameSpaceMap; } - already_AddRefed Clone(nsCSSStyleSheet* aCloneParent, - mozilla::css::ImportRule* aCloneOwnerRule, - nsIDocument* aCloneDocument, - nsINode* aCloneOwningNode) const; + already_AddRefed Clone(CSSStyleSheet* aCloneParent, + css::ImportRule* aCloneOwnerRule, + nsIDocument* aCloneDocument, + nsINode* aCloneOwningNode) const; bool IsModified() const { return mDirty; } @@ -214,7 +216,7 @@ public: virtual nsIURI* GetOriginalURI() const; // nsICSSLoaderObserver interface - NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate, + NS_IMETHOD StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) MOZ_OVERRIDE; enum EnsureUniqueInnerResult { @@ -227,7 +229,7 @@ public: EnsureUniqueInnerResult EnsureUniqueInner(); // Append all of this sheet's child sheets to aArray. - void AppendAllChildSheets(nsTArray& aArray); + void AppendAllChildSheets(nsTArray& aArray); bool UseForPresentation(nsPresContext* aPresContext, nsMediaQueryResultCacheKey& aKey) const; @@ -242,15 +244,15 @@ public: // Function used as a callback to rebuild our inner's child sheet // list after we clone a unique inner for ourselves. - static bool RebuildChildList(mozilla::css::Rule* aRule, void* aBuilder); + static bool RebuildChildList(css::Rule* aRule, void* aBuilder); - size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; // Get this style sheet's CORS mode - mozilla::CORSMode GetCORSMode() const { return mInner->mCORSMode; } + CORSMode GetCORSMode() const { return mInner->mCORSMode; } - mozilla::dom::Element* GetScopeElement() const { return mScopeElement; } - void SetScopeElement(mozilla::dom::Element* aScopeElement) + dom::Element* GetScopeElement() const { return mScopeElement; } + void SetScopeElement(dom::Element* aScopeElement) { mScopeElement = aScopeElement; } @@ -259,15 +261,15 @@ public: // Our nsIStyleSheet::GetType is a const method, so it ends up // ambiguous with with the XPCOM version. Just disambiguate. void GetType(nsString& aType) { - const_cast(this)->GetType(aType); + const_cast(this)->GetType(aType); } // Our XPCOM GetHref is fine for WebIDL nsINode* GetOwnerNode() const { return mOwningNode; } - nsCSSStyleSheet* GetParentStyleSheet() const { return mParent; } + CSSStyleSheet* GetParentStyleSheet() const { return mParent; } // Our nsIStyleSheet::GetTitle is a const method, so it ends up // ambiguous with with the XPCOM version. Just disambiguate. void GetTitle(nsString& aTitle) { - const_cast(this)->GetTitle(aTitle); + const_cast(this)->GetTitle(aTitle); } nsMediaList* Media(); bool Disabled() const { return mDisabled; } @@ -278,40 +280,39 @@ public: // called GetOwnerRule because that would be ambiguous with the ImportRule // version. nsIDOMCSSRule* GetDOMOwnerRule() const; - mozilla::dom::CSSRuleList* GetCssRules(mozilla::ErrorResult& aRv); + dom::CSSRuleList* GetCssRules(ErrorResult& aRv); uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex, - mozilla::ErrorResult& aRv) { + ErrorResult& aRv) { uint32_t retval; aRv = InsertRule(aRule, aIndex, &retval); return retval; } - void DeleteRule(uint32_t aIndex, mozilla::ErrorResult& aRv) { + void DeleteRule(uint32_t aIndex, ErrorResult& aRv) { aRv = DeleteRule(aIndex); } // WebIDL miscellaneous bits - mozilla::dom::ParentObject GetParentObject() const { + dom::ParentObject GetParentObject() const { if (mOwningNode) { - return mozilla::dom::ParentObject(mOwningNode); + return dom::ParentObject(mOwningNode); } - return mozilla::dom::ParentObject(static_cast(mParent), - mParent); + return dom::ParentObject(static_cast(mParent), mParent); } virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; private: - nsCSSStyleSheet(const nsCSSStyleSheet& aCopy, - nsCSSStyleSheet* aParentToUse, - mozilla::css::ImportRule* aOwnerRuleToUse, - nsIDocument* aDocumentToUse, - nsINode* aOwningNodeToUse); + CSSStyleSheet(const CSSStyleSheet& aCopy, + CSSStyleSheet* aParentToUse, + css::ImportRule* aOwnerRuleToUse, + nsIDocument* aDocumentToUse, + nsINode* aOwningNodeToUse); - nsCSSStyleSheet(const nsCSSStyleSheet& aCopy) MOZ_DELETE; - nsCSSStyleSheet& operator=(const nsCSSStyleSheet& aCopy) MOZ_DELETE; + CSSStyleSheet(const CSSStyleSheet& aCopy) MOZ_DELETE; + CSSStyleSheet& operator=(const CSSStyleSheet& aCopy) MOZ_DELETE; protected: - virtual ~nsCSSStyleSheet(); + virtual ~CSSStyleSheet(); void ClearRuleCascades(); @@ -325,7 +326,7 @@ protected: nsresult SubjectSubsumesInnerPrincipal(); // Add the namespace mapping from this @namespace rule to our namespace map - nsresult RegisterNamespaceRule(mozilla::css::Rule* aRule); + nsresult RegisterNamespaceRule(css::Rule* aRule); // Drop our reference to mRuleCollection void DropRuleCollection(); @@ -341,26 +342,28 @@ protected: protected: nsString mTitle; nsRefPtr mMedia; - nsRefPtr mNext; - nsCSSStyleSheet* mParent; // weak ref - mozilla::css::ImportRule* mOwnerRule; // weak ref + nsRefPtr mNext; + CSSStyleSheet* mParent; // weak ref + css::ImportRule* mOwnerRule; // weak ref nsRefPtr mRuleCollection; nsIDocument* mDocument; // weak ref; parents maintain this for their children nsINode* mOwningNode; // weak ref bool mDisabled; bool mDirty; // has been modified - nsRefPtr mScopeElement; + nsRefPtr mScopeElement; - nsCSSStyleSheetInner* mInner; + CSSStyleSheetInner* mInner; nsAutoTArray* mRuleProcessors; - friend class nsMediaList; - friend class nsCSSRuleProcessor; - friend struct ChildSheetListBuilder; + friend class ::nsMediaList; + friend class ::nsCSSRuleProcessor; + friend struct mozilla::ChildSheetListBuilder; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsCSSStyleSheet, NS_CSS_STYLE_SHEET_IMPL_CID) +NS_DEFINE_STATIC_IID_ACCESSOR(CSSStyleSheet, NS_CSS_STYLE_SHEET_IMPL_CID) -#endif /* !defined(nsCSSStyleSheet_h_) */ +} // namespace mozilla + +#endif /* !defined(mozilla_CSSStyleSheet_h) */ diff --git a/layout/style/ErrorReporter.cpp b/layout/style/ErrorReporter.cpp index 6473610829fc..cf35e939dc32 100644 --- a/layout/style/ErrorReporter.cpp +++ b/layout/style/ErrorReporter.cpp @@ -6,11 +6,12 @@ /* diagnostic reporting for CSS style sheet parser */ #include "mozilla/css/ErrorReporter.h" + +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" #include "nsCSSScanner.h" -#include "nsCSSStyleSheet.h" #include "nsIConsoleService.h" #include "nsIDocument.h" #include "nsIFactory.h" @@ -22,8 +23,7 @@ #ifdef CSS_REPORT_PARSE_ERRORS -using mozilla::Preferences; -namespace services = mozilla::services; +using namespace mozilla; namespace { class ShortTermURISpecCache : public nsRunnable { @@ -132,7 +132,7 @@ ErrorReporter::ReleaseGlobals() } ErrorReporter::ErrorReporter(const nsCSSScanner& aScanner, - const nsCSSStyleSheet* aSheet, + const CSSStyleSheet* aSheet, const Loader* aLoader, nsIURI* aURI) : mScanner(&aScanner), mSheet(aSheet), mLoader(aLoader), mURI(aURI), diff --git a/layout/style/ErrorReporter.h b/layout/style/ErrorReporter.h index b5c21fdd6866..3a57a3be5ccd 100644 --- a/layout/style/ErrorReporter.h +++ b/layout/style/ErrorReporter.h @@ -14,11 +14,12 @@ #include "nsString.h" struct nsCSSToken; -class nsCSSStyleSheet; class nsCSSScanner; class nsIURI; namespace mozilla { +class CSSStyleSheet; + namespace css { class Loader; @@ -28,7 +29,7 @@ class Loader; class MOZ_STACK_CLASS ErrorReporter { public: ErrorReporter(const nsCSSScanner &aScanner, - const nsCSSStyleSheet *aSheet, + const CSSStyleSheet *aSheet, const Loader *aLoader, nsIURI *aURI); ~ErrorReporter(); @@ -67,7 +68,7 @@ private: nsString mErrorLine; nsString mFileName; const nsCSSScanner *mScanner; - const nsCSSStyleSheet *mSheet; + const CSSStyleSheet *mSheet; const Loader *mLoader; nsIURI *mURI; uint64_t mInnerWindowID; @@ -79,7 +80,7 @@ private: #ifndef CSS_REPORT_PARSE_ERRORS inline ErrorReporter::ErrorReporter(const nsCSSScanner&, - const nsCSSStyleSheet*, + const CSSStyleSheet*, const Loader*, nsIURI*) {} inline ErrorReporter::~ErrorReporter() {} diff --git a/layout/style/GroupRule.h b/layout/style/GroupRule.h index 725750e686f9..6adc51dd8e57 100644 --- a/layout/style/GroupRule.h +++ b/layout/style/GroupRule.h @@ -22,6 +22,9 @@ class nsPresContext; class nsMediaQueryResultCacheKey; namespace mozilla { + +class CSSStyleSheet; + namespace css { class GroupRuleRuleList; @@ -41,7 +44,7 @@ public: // implement part of nsIStyleRule and Rule DECL_STYLE_RULE_INHERIT_NO_DOMRULE - virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); + virtual void SetStyleSheet(CSSStyleSheet* aSheet); // to help implement nsIStyleRule #ifdef DEBUG diff --git a/layout/style/ImportRule.h b/layout/style/ImportRule.h index 48b2e54250ef..69a3fc35a700 100644 --- a/layout/style/ImportRule.h +++ b/layout/style/ImportRule.h @@ -18,6 +18,9 @@ class nsMediaList; class nsString; namespace mozilla { + +class CSSStyleSheet; + namespace css { class ImportRule MOZ_FINAL : public Rule, @@ -47,7 +50,7 @@ public: virtual int32_t GetType() const; virtual already_AddRefed Clone() const; - void SetSheet(nsCSSStyleSheet*); + void SetSheet(CSSStyleSheet*); virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; @@ -60,7 +63,7 @@ public: private: nsString mURLSpec; nsRefPtr mMedia; - nsRefPtr mChildSheet; + nsRefPtr mChildSheet; }; } // namespace css diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 371d5db04103..1a6ad5805c80 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -38,10 +38,10 @@ #include "nsIHttpChannelInternal.h" #include "nsIScriptError.h" #include "nsMimeTypes.h" -#include "nsCSSStyleSheet.h" #include "nsIStyleSheetLinkingElement.h" #include "nsICSSLoaderObserver.h" #include "nsCSSParser.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/ImportRule.h" #include "nsThreadUtils.h" #include "nsGkAtoms.h" @@ -113,7 +113,7 @@ public: SheetLoadData(Loader* aLoader, const nsSubstring& aTitle, nsIURI* aURI, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, nsIStyleSheetLinkingElement* aOwningElement, bool aIsAlternate, nsICSSLoaderObserver* aObserver, @@ -122,7 +122,7 @@ public: // Data for loading a sheet linked from an @import rule SheetLoadData(Loader* aLoader, nsIURI* aURI, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, SheetLoadData* aParentData, nsICSSLoaderObserver* aObserver, nsIPrincipal* aLoaderPrincipal); @@ -130,7 +130,7 @@ public: // Data for loading a non-document sheet SheetLoadData(Loader* aLoader, nsIURI* aURI, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, bool aSyncLoad, bool aAllowUnsafeRules, bool aUseSystemPrincipal, @@ -165,7 +165,7 @@ public: uint32_t mLineNumber; // The sheet we're loading data for - nsRefPtr mSheet; + nsRefPtr mSheet; // Linked list of datas for the same URI as us SheetLoadData* mNext; // strong ref @@ -308,7 +308,7 @@ NS_IMPL_ISUPPORTS(SheetLoadData, nsIUnicharStreamLoaderObserver, nsIRunnable, SheetLoadData::SheetLoadData(Loader* aLoader, const nsSubstring& aTitle, nsIURI* aURI, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, nsIStyleSheetLinkingElement* aOwningElement, bool aIsAlternate, nsICSSLoaderObserver* aObserver, @@ -340,7 +340,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader, SheetLoadData::SheetLoadData(Loader* aLoader, nsIURI* aURI, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, SheetLoadData* aParentData, nsICSSLoaderObserver* aObserver, nsIPrincipal* aLoaderPrincipal) @@ -381,7 +381,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader, SheetLoadData::SheetLoadData(Loader* aLoader, nsIURI* aURI, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, bool aSyncLoad, bool aAllowUnsafeRules, bool aUseSystemPrincipal, @@ -970,7 +970,7 @@ Loader::IsAlternate(const nsAString& aTitle, bool aHasAlternateRel) /* static */ PLDHashOperator Loader::RemoveEntriesWithURI(URIPrincipalAndCORSModeHashKey* aKey, - nsRefPtr &aSheet, + nsRefPtr& aSheet, void* aUserData) { nsIURI* obsoleteURI = static_cast(aUserData); @@ -1050,7 +1050,7 @@ Loader::CheckLoadAllowed(nsIPrincipal* aSourcePrincipal, } /** - * CreateSheet() creates an nsCSSStyleSheet object for the given URI, + * CreateSheet() creates a CSSStyleSheet object for the given URI, * if any. If there is no URI given, we just create a new style sheet * object. Otherwise, we check for an existing style sheet object for * that uri in various caches and clone it if we find it. Cloned @@ -1068,7 +1068,7 @@ Loader::CreateSheet(nsIURI* aURI, const nsAString& aTitle, StyleSheetState& aSheetState, bool *aIsAlternate, - nsCSSStyleSheet** aSheet) + CSSStyleSheet** aSheet) { LOG(("css::Loader::CreateSheet")); NS_PRECONDITION(aSheet, "Null out param!"); @@ -1086,7 +1086,7 @@ Loader::CreateSheet(nsIURI* aURI, if (aURI) { aSheetState = eSheetComplete; - nsRefPtr sheet; + nsRefPtr sheet; // First, the XUL cache #ifdef MOZ_XUL @@ -1210,7 +1210,7 @@ Loader::CreateSheet(nsIURI* aURI, originalURI = aURI; } - nsRefPtr sheet = new nsCSSStyleSheet(aCORSMode); + nsRefPtr sheet = new CSSStyleSheet(aCORSMode); sheet->SetURIs(sheetURI, originalURI, baseURI); sheet.forget(aSheet); } @@ -1228,7 +1228,7 @@ Loader::CreateSheet(nsIURI* aURI, * the sheet had "alternate" in its rel. */ void -Loader::PrepareSheet(nsCSSStyleSheet* aSheet, +Loader::PrepareSheet(CSSStyleSheet* aSheet, const nsSubstring& aTitle, const nsSubstring& aMediaString, nsMediaList* aMediaList, @@ -1272,7 +1272,7 @@ Loader::PrepareSheet(nsCSSStyleSheet* aSheet, * as determined by CompareDocumentPosition. */ nsresult -Loader::InsertSheetInDoc(nsCSSStyleSheet* aSheet, +Loader::InsertSheetInDoc(CSSStyleSheet* aSheet, nsIContent* aLinkingContent, nsIDocument* aDocument) { @@ -1352,8 +1352,8 @@ Loader::InsertSheetInDoc(nsCSSStyleSheet* aSheet, * to put it anyway. So just append for now. */ nsresult -Loader::InsertChildSheet(nsCSSStyleSheet* aSheet, - nsCSSStyleSheet* aParentSheet, +Loader::InsertChildSheet(CSSStyleSheet* aSheet, + CSSStyleSheet* aParentSheet, ImportRule* aParentRule) { LOG(("css::Loader::InsertChildSheet")); @@ -1814,7 +1814,7 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus, // parent sheet anyway, so that if someone then accesses it via // CSSOM we won't have extra clones of the inner lying around. data = aLoadData; - nsCSSStyleSheet* sheet = aLoadData->mSheet; + CSSStyleSheet* sheet = aLoadData->mSheet; while (data) { if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) { sheet = data->mSheet; @@ -1880,7 +1880,7 @@ Loader::LoadInlineStyle(nsIContent* aElement, // load data or to CreateSheet(). Also, OK to use CORS_NONE for the CORS // mode. StyleSheetState state; - nsRefPtr sheet; + nsRefPtr sheet; nsresult rv = CreateSheet(nullptr, aElement, nullptr, CORS_NONE, false, false, aTitle, state, aIsAlternate, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); @@ -1959,7 +1959,7 @@ Loader::LoadStyleLink(nsIContent* aElement, LOG((" Passed load check")); StyleSheetState state; - nsRefPtr sheet; + nsRefPtr sheet; rv = CreateSheet(aURL, aElement, principal, aCORSMode, false, aHasAlternateRel, aTitle, state, aIsAlternate, getter_AddRefs(sheet)); @@ -2043,7 +2043,7 @@ HaveAncestorDataWithURI(SheetLoadData *aData, nsIURI *aURI) } nsresult -Loader::LoadChildSheet(nsCSSStyleSheet* aParentSheet, +Loader::LoadChildSheet(CSSStyleSheet* aParentSheet, nsIURI* aURL, nsMediaList* aMedia, ImportRule* aParentRule) @@ -2114,7 +2114,7 @@ Loader::LoadChildSheet(nsCSSStyleSheet* aParentSheet, // Now that we know it's safe to load this (passes security check and not a // loop) do so. - nsRefPtr sheet; + nsRefPtr sheet; bool isAlternate; StyleSheetState state; const nsSubstring& empty = EmptyString(); @@ -2157,7 +2157,7 @@ Loader::LoadChildSheet(nsCSSStyleSheet* aParentSheet, nsresult Loader::LoadSheetSync(nsIURI* aURL, bool aAllowUnsafeRules, bool aUseSystemPrincipal, - nsCSSStyleSheet** aSheet) + CSSStyleSheet** aSheet) { LOG(("css::Loader::LoadSheetSync")); return InternalLoadNonDocumentSheet(aURL, aAllowUnsafeRules, @@ -2170,7 +2170,7 @@ Loader::LoadSheet(nsIURI* aURL, nsIPrincipal* aOriginPrincipal, const nsCString& aCharset, nsICSSLoaderObserver* aObserver, - nsCSSStyleSheet** aSheet) + CSSStyleSheet** aSheet) { LOG(("css::Loader::LoadSheet(aURL, aObserver, aSheet) api call")); NS_PRECONDITION(aSheet, "aSheet is null"); @@ -2198,7 +2198,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL, bool aUseSystemPrincipal, nsIPrincipal* aOriginPrincipal, const nsCString& aCharset, - nsCSSStyleSheet** aSheet, + CSSStyleSheet** aSheet, nsICSSLoaderObserver* aObserver, CORSMode aCORSMode) { @@ -2226,7 +2226,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL, StyleSheetState state; bool isAlternate; - nsRefPtr sheet; + nsRefPtr sheet; bool syncLoad = (aObserver == nullptr); const nsSubstring& empty = EmptyString(); @@ -2268,7 +2268,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL, nsresult Loader::PostLoadEvent(nsIURI* aURI, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, nsICSSLoaderObserver* aObserver, bool aWasAlternate, nsIStyleSheetLinkingElement* aElement) @@ -2450,7 +2450,7 @@ Loader::StartAlternateLoads() static PLDHashOperator TraverseSheet(URIPrincipalAndCORSModeHashKey*, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, void* aClosure) { nsCycleCollectionTraversalCallback* cb = @@ -2483,7 +2483,7 @@ struct SheetMemoryCounter { static size_t CountSheetMemory(URIPrincipalAndCORSModeHashKey* /* unused */, - const nsRefPtr& aSheet, + const nsRefPtr& aSheet, mozilla::MallocSizeOf aMallocSizeOf, void* /* unused */) { diff --git a/layout/style/Loader.h b/layout/style/Loader.h index 734d5ebd8cbb..54caa90aaf0b 100644 --- a/layout/style/Loader.h +++ b/layout/style/Loader.h @@ -23,7 +23,6 @@ class nsIAtom; class nsICSSLoaderObserver; -class nsCSSStyleSheet; class nsIContent; class nsIDocument; class nsCSSParser; @@ -32,6 +31,7 @@ class nsIStyleSheetLinkingElement; class nsCycleCollectionTraversalCallback; namespace mozilla { +class CSSStyleSheet; namespace dom { class Element; } @@ -222,7 +222,7 @@ public: * @param aRule the @import rule importing this child. This is used to * properly order the child sheet list of aParentSheet. */ - nsresult LoadChildSheet(nsCSSStyleSheet* aParentSheet, + nsresult LoadChildSheet(CSSStyleSheet* aParentSheet, nsIURI* aURL, nsMediaList* aMedia, ImportRule* aRule); @@ -256,12 +256,12 @@ public: */ nsresult LoadSheetSync(nsIURI* aURL, bool aEnableUnsafeRules, bool aUseSystemPrincipal, - nsCSSStyleSheet** aSheet); + CSSStyleSheet** aSheet); /** * As above, but aUseSystemPrincipal and aEnableUnsafeRules are assumed false. */ - nsresult LoadSheetSync(nsIURI* aURL, nsCSSStyleSheet** aSheet) { + nsresult LoadSheetSync(nsIURI* aURL, CSSStyleSheet** aSheet) { return LoadSheetSync(aURL, false, false, aSheet); } @@ -289,7 +289,7 @@ public: nsIPrincipal* aOriginPrincipal, const nsCString& aCharset, nsICSSLoaderObserver* aObserver, - nsCSSStyleSheet** aSheet); + CSSStyleSheet** aSheet); /** * Same as above, to be used when the caller doesn't care about the @@ -385,7 +385,7 @@ private: static PLDHashOperator RemoveEntriesWithURI(URIPrincipalAndCORSModeHashKey* aKey, - nsRefPtr &aSheet, + nsRefPtr& aSheet, void* aUserData); // Note: null aSourcePrincipal indicates that the content policy and @@ -408,24 +408,24 @@ private: const nsAString& aTitle, StyleSheetState& aSheetState, bool *aIsAlternate, - nsCSSStyleSheet** aSheet); + CSSStyleSheet** aSheet); // Pass in either a media string or the nsMediaList from the // CSSParser. Don't pass both. // This method will set the sheet's enabled state based on isAlternate - void PrepareSheet(nsCSSStyleSheet* aSheet, + void PrepareSheet(CSSStyleSheet* aSheet, const nsAString& aTitle, const nsAString& aMediaString, nsMediaList* aMediaList, dom::Element* aScopeElement, bool isAlternate); - nsresult InsertSheetInDoc(nsCSSStyleSheet* aSheet, + nsresult InsertSheetInDoc(CSSStyleSheet* aSheet, nsIContent* aLinkingContent, nsIDocument* aDocument); - nsresult InsertChildSheet(nsCSSStyleSheet* aSheet, - nsCSSStyleSheet* aParentSheet, + nsresult InsertChildSheet(CSSStyleSheet* aSheet, + CSSStyleSheet* aParentSheet, ImportRule* aParentRule); nsresult InternalLoadNonDocumentSheet(nsIURI* aURL, @@ -433,7 +433,7 @@ private: bool aUseSystemPrincipal, nsIPrincipal* aOriginPrincipal, const nsCString& aCharset, - nsCSSStyleSheet** aSheet, + CSSStyleSheet** aSheet, nsICSSLoaderObserver* aObserver, CORSMode aCORSMode = CORS_NONE); @@ -445,7 +445,7 @@ private: // sheet was loaded from (may be null for inline sheets). aElement is the // owning element for this sheet. nsresult PostLoadEvent(nsIURI* aURI, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, nsICSSLoaderObserver* aObserver, bool aWasAlternate, nsIStyleSheetLinkingElement* aElement); @@ -479,7 +479,7 @@ private: LoadDataArray& aDatasToNotify); struct Sheets { - nsRefPtrHashtable + nsRefPtrHashtable mCompleteSheets; nsDataHashtable mLoadingDatas; // weak refs diff --git a/layout/style/Rule.h b/layout/style/Rule.h index 3d1d5b1be1d8..4e7f80b8d442 100644 --- a/layout/style/Rule.h +++ b/layout/style/Rule.h @@ -8,10 +8,10 @@ #ifndef mozilla_css_Rule_h___ #define mozilla_css_Rule_h___ +#include "mozilla/CSSStyleSheet.h" #include "mozilla/MemoryReporting.h" #include "nsIStyleRule.h" #include "nsIDOMCSSRule.h" -#include "nsCSSStyleSheet.h" class nsIStyleSheet; class nsIDocument; @@ -52,7 +52,7 @@ public: // The constants in this list must maintain the following invariants: // If a rule of type N must appear before a rule of type M in stylesheets // then N < M - // Note that nsCSSStyleSheet::RebuildChildList assumes that no other kinds of + // Note that CSSStyleSheet::RebuildChildList assumes that no other kinds of // rules can come between two rules of type IMPORT_RULE. enum { UNKNOWN_RULE = 0, @@ -73,17 +73,17 @@ public: virtual int32_t GetType() const = 0; - nsCSSStyleSheet* GetStyleSheet() const; + CSSStyleSheet* GetStyleSheet() const; nsHTMLCSSStyleSheet* GetHTMLCSSStyleSheet() const; // Return the document the rule lives in, if any nsIDocument* GetDocument() const { - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); return sheet ? sheet->GetDocument() : nullptr; } - virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); + virtual void SetStyleSheet(CSSStyleSheet* aSheet); // This does not need to be virtual, because GroupRule and MediaRule are not // used for inline style. void SetHTMLCSSStyleSheet(nsHTMLCSSStyleSheet* aSheet); @@ -122,7 +122,7 @@ public: void* aData); protected: - // This is either an nsCSSStyleSheet* or a nsHTMLStyleSheet*. The former + // This is either a CSSStyleSheet* or an nsHTMLStyleSheet*. The former // if the low bit is 0, the latter if the low bit is 1. uintptr_t mSheet; GroupRule* mParentRule; diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index ab69b798c126..7849d54c90fe 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -11,10 +11,10 @@ #include "mozilla/css/StyleRule.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/MemoryReporting.h" #include "mozilla/css/GroupRule.h" #include "mozilla/css/Declaration.h" -#include "nsCSSStyleSheet.h" #include "nsIDocument.h" #include "nsIAtom.h" #include "nsString.h" @@ -541,7 +541,7 @@ int32_t nsCSSSelector::CalcWeight() const // StyleRule:selectorText // void -nsCSSSelector::ToString(nsAString& aString, nsCSSStyleSheet* aSheet, +nsCSSSelector::ToString(nsAString& aString, CSSStyleSheet* aSheet, bool aAppend) const { if (!aAppend) @@ -584,7 +584,7 @@ nsCSSSelector::ToString(nsAString& aString, nsCSSStyleSheet* aSheet, void nsCSSSelector::AppendToStringWithoutCombinators - (nsAString& aString, nsCSSStyleSheet* aSheet) const + (nsAString& aString, CSSStyleSheet* aSheet) const { AppendToStringWithoutCombinatorsOrNegations(aString, aSheet, false); @@ -599,7 +599,7 @@ nsCSSSelector::AppendToStringWithoutCombinators void nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations - (nsAString& aString, nsCSSStyleSheet* aSheet, + (nsAString& aString, CSSStyleSheet* aSheet, bool aIsNegated) const { nsAutoString temp; @@ -895,7 +895,7 @@ nsCSSSelectorList::AddSelector(char16_t aOperator) } void -nsCSSSelectorList::ToString(nsAString& aResult, nsCSSStyleSheet* aSheet) +nsCSSSelectorList::ToString(nsAString& aResult, CSSStyleSheet* aSheet) { aResult.Truncate(); nsCSSSelectorList *p = this; @@ -1438,7 +1438,7 @@ StyleRule::DeclarationChanged(Declaration* aDecl, nsRefPtr clone = new StyleRule(*this, aDecl); if (aHandleContainer) { - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (mParentRule) { if (sheet) { sheet->ReplaceRuleInGroup(mParentRule, this, clone); diff --git a/layout/style/StyleRule.h b/layout/style/StyleRule.h index 98e48ebc75b1..9aed50853799 100644 --- a/layout/style/StyleRule.h +++ b/layout/style/StyleRule.h @@ -21,10 +21,13 @@ #include "nsCSSPseudoClasses.h" class nsIAtom; -class nsCSSStyleSheet; struct nsCSSSelectorList; class nsCSSCompressedDataBlock; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla + struct nsAtomList { public: nsAtomList(nsIAtom* aAtom); @@ -154,7 +157,7 @@ public: // Calculate the specificity of this selector (not including its mNext!). int32_t CalcWeight() const; - void ToString(nsAString& aString, nsCSSStyleSheet* aSheet, + void ToString(nsAString& aString, mozilla::CSSStyleSheet* aSheet, bool aAppend = false) const; private: @@ -162,9 +165,9 @@ private: nsCSSSelector* Clone(bool aDeepNext, bool aDeepNegations) const; void AppendToStringWithoutCombinators(nsAString& aString, - nsCSSStyleSheet* aSheet) const; + mozilla::CSSStyleSheet* aSheet) const; void AppendToStringWithoutCombinatorsOrNegations(nsAString& aString, - nsCSSStyleSheet* aSheet, + mozilla::CSSStyleSheet* aSheet, bool aIsNegated) const; // Returns true if this selector can have a namespace specified (which @@ -238,7 +241,7 @@ struct nsCSSSelectorList { /** * Should be used only on the first in the list */ - void ToString(nsAString& aResult, nsCSSStyleSheet* aSheet); + void ToString(nsAString& aResult, mozilla::CSSStyleSheet* aSheet); /** * Do a deep clone. Should be used only on the first in the list. diff --git a/layout/style/moz.build b/layout/style/moz.build index 906a42071a65..287dc05e99d2 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -29,7 +29,6 @@ EXPORTS += [ 'nsCSSPseudoElements.h', 'nsCSSRuleProcessor.h', 'nsCSSScanner.h', - 'nsCSSStyleSheet.h', 'nsCSSValue.h', 'nsDOMCSSAttrDeclaration.h', 'nsDOMCSSDeclaration.h', @@ -59,6 +58,7 @@ EXPORTS += [ ] EXPORTS.mozilla += [ + 'CSSStyleSheet.h', 'CSSVariableDeclarations.h', 'CSSVariableResolver.h', 'CSSVariableValues.h', @@ -88,6 +88,7 @@ UNIFIED_SOURCES += [ 'CounterStyleManager.cpp', 'CSS.cpp', 'CSSRuleList.cpp', + 'CSSStyleSheet.cpp', 'CSSVariableDeclarations.cpp', 'CSSVariableResolver.cpp', 'CSSVariableValues.cpp', @@ -107,7 +108,6 @@ UNIFIED_SOURCES += [ 'nsCSSPseudoElements.cpp', 'nsCSSRules.cpp', 'nsCSSScanner.cpp', - 'nsCSSStyleSheet.cpp', 'nsCSSValue.cpp', 'nsDOMCSSAttrDeclaration.cpp', 'nsDOMCSSDeclaration.cpp', diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index d71a75585b27..f7b90811d397 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -22,7 +22,7 @@ #include "nsCSSRules.h" #include "mozilla/css/NameSpaceRule.h" #include "nsTArray.h" -#include "nsCSSStyleSheet.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Declaration.h" #include "nsStyleConsts.h" #include "nsNetUtil.h" @@ -102,7 +102,7 @@ public: CSSParserImpl(); ~CSSParserImpl(); - nsresult SetStyleSheet(nsCSSStyleSheet* aSheet); + nsresult SetStyleSheet(CSSStyleSheet* aSheet); nsresult SetQuirkMode(bool aQuirkMode); @@ -279,7 +279,7 @@ public: nsIURI* aDocURL, nsIURI* aBaseURL, nsIPrincipal* aDocPrincipal, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, uint32_t aLineNumber, uint32_t aLineOffset); @@ -971,7 +971,7 @@ protected: nsCOMPtr mSheetPrincipal; // The sheet we're parsing into - nsRefPtr mSheet; + nsRefPtr mSheet; // Used for @import rules mozilla::css::Loader* mChildLoader; // not ref counted, it owns us @@ -979,7 +979,7 @@ protected: // Sheet section we're in. This is used to enforce correct ordering of the // various rule types (eg the fact that a @charset rule must come before // anything else). Note that there are checks of similar things in various - // places in nsCSSStyleSheet.cpp (e.g in insertRule, RebuildChildList). + // places in CSSStyleSheet.cpp (e.g in insertRule, RebuildChildList). enum nsCSSSection { eCSSSection_Charset, eCSSSection_Import, @@ -1124,7 +1124,7 @@ CSSParserImpl::~CSSParserImpl() } nsresult -CSSParserImpl::SetStyleSheet(nsCSSStyleSheet* aSheet) +CSSParserImpl::SetStyleSheet(CSSStyleSheet* aSheet) { if (aSheet != mSheet) { // Switch to using the new sheet, if any @@ -2313,7 +2313,7 @@ CSSParserImpl::ParsePropertyWithVariableReferences( nsIURI* aDocURL, nsIURI* aBaseURL, nsIPrincipal* aDocPrincipal, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, uint32_t aLineNumber, uint32_t aLineOffset) { @@ -14505,7 +14505,7 @@ CSSParserImpl::ParseValueWithVariables(CSSVariableDeclarations::Type* aType, static CSSParserImpl* gFreeList = nullptr; nsCSSParser::nsCSSParser(mozilla::css::Loader* aLoader, - nsCSSStyleSheet* aSheet) + CSSStyleSheet* aSheet) { CSSParserImpl *impl = gFreeList; if (impl) { @@ -14551,7 +14551,7 @@ nsCSSParser::Shutdown() // Wrapper methods nsresult -nsCSSParser::SetStyleSheet(nsCSSStyleSheet* aSheet) +nsCSSParser::SetStyleSheet(CSSStyleSheet* aSheet) { return static_cast(mImpl)-> SetStyleSheet(aSheet); @@ -14766,7 +14766,7 @@ nsCSSParser::ParsePropertyWithVariableReferences( nsIURI* aDocURL, nsIURI* aBaseURL, nsIPrincipal* aDocPrincipal, - nsCSSStyleSheet* aSheet, + CSSStyleSheet* aSheet, uint32_t aLineNumber, uint32_t aLineOffset) { diff --git a/layout/style/nsCSSParser.h b/layout/style/nsCSSParser.h index 7f9bf829cdd6..42cd0ff5bdbf 100644 --- a/layout/style/nsCSSParser.h +++ b/layout/style/nsCSSParser.h @@ -16,7 +16,6 @@ #include "nsStringFwd.h" #include "nsTArrayForwardDeclare.h" -class nsCSSStyleSheet; class nsIPrincipal; class nsIURI; struct nsCSSSelectorList; @@ -26,6 +25,7 @@ class nsCSSValue; struct nsRuleData; namespace mozilla { +class CSSStyleSheet; class CSSVariableValues; namespace css { class Rule; @@ -40,7 +40,7 @@ class StyleRule; class MOZ_STACK_CLASS nsCSSParser { public: nsCSSParser(mozilla::css::Loader* aLoader = nullptr, - nsCSSStyleSheet* aSheet = nullptr); + mozilla::CSSStyleSheet* aSheet = nullptr); ~nsCSSParser(); static void Shutdown(); @@ -51,9 +51,9 @@ private: public: // Set a style sheet for the parser to fill in. The style sheet must - // implement the nsCSSStyleSheet interface. Null can be passed in to clear + // implement the CSSStyleSheet interface. Null can be passed in to clear // out an existing stylesheet reference. - nsresult SetStyleSheet(nsCSSStyleSheet* aSheet); + nsresult SetStyleSheet(mozilla::CSSStyleSheet* aSheet); // Set whether or not to emulate Nav quirks nsresult SetQuirkMode(bool aQuirkMode); @@ -260,7 +260,7 @@ public: nsIURI* aDocURL, nsIURI* aBaseURL, nsIPrincipal* aDocPrincipal, - nsCSSStyleSheet* aSheet, + mozilla::CSSStyleSheet* aSheet, uint32_t aLineNumber, uint32_t aLineOffset); diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index fc89b34ac6ed..5d8f9299dd95 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -562,7 +562,7 @@ RuleHash::~RuleHash() uint32_t lineNumber = value->mRule->GetLineNumber(); nsCOMPtr sheet; value->mRule->GetStyleSheet(*getter_AddRefs(sheet)); - nsRefPtr cssSheet = do_QueryObject(sheet); + nsRefPtr cssSheet = do_QueryObject(sheet); value->mSelector->ToString(selectorText, cssSheet); printf(" line %d, %s\n", @@ -3399,12 +3399,12 @@ CascadeRuleEnumFunc(css::Rule* aRule, void* aData) } /* static */ bool -nsCSSRuleProcessor::CascadeSheet(nsCSSStyleSheet* aSheet, CascadeEnumData* aData) +nsCSSRuleProcessor::CascadeSheet(CSSStyleSheet* aSheet, CascadeEnumData* aData) { if (aSheet->IsApplicable() && aSheet->UseForPresentation(aData->mPresContext, aData->mCacheKey) && aSheet->mInner) { - nsCSSStyleSheet* child = aSheet->mInner->mFirstChild; + CSSStyleSheet* child = aSheet->mInner->mFirstChild; while (child) { CascadeSheet(child, aData); child = child->mNext; diff --git a/layout/style/nsCSSRuleProcessor.h b/layout/style/nsCSSRuleProcessor.h index bae55aa9e28c..34abcaba2274 100644 --- a/layout/style/nsCSSRuleProcessor.h +++ b/layout/style/nsCSSRuleProcessor.h @@ -28,9 +28,12 @@ struct TreeMatchContext; class nsCSSKeyframesRule; class nsCSSPageRule; class nsCSSFontFeatureValuesRule; -class nsCSSStyleSheet; class nsCSSCounterStyleRule; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla + /** * The CSS style rule processor provides a mechanism for sibling style * sheets to combine their rule processing in order to allow proper @@ -44,7 +47,7 @@ class nsCSSCounterStyleRule; class nsCSSRuleProcessor: public nsIStyleRuleProcessor { public: - typedef nsTArray > sheet_array_type; + typedef nsTArray> sheet_array_type; // aScopeElement must be non-null iff aSheetType is // nsStyleSet::eScopedDocSheet. @@ -173,7 +176,8 @@ public: }; private: - static bool CascadeSheet(nsCSSStyleSheet* aSheet, CascadeEnumData* aData); + static bool CascadeSheet(mozilla::CSSStyleSheet* aSheet, + CascadeEnumData* aData); RuleCascadeData* GetRuleCascade(nsPresContext* aPresContext); void RefreshRuleCascade(nsPresContext* aPresContext); diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index d4ca8e19c2c9..ffcadc479833 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -9,6 +9,7 @@ #include "nsCSSRules.h" #include "nsCSSValue.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/MemoryReporting.h" #include "mozilla/css/ImportRule.h" #include "mozilla/css/NameSpaceRule.h" @@ -17,7 +18,6 @@ #include "nsIAtom.h" #include "nsCSSProps.h" -#include "nsCSSStyleSheet.h" #include "nsCOMPtr.h" #include "nsIDOMCSSStyleSheet.h" @@ -59,11 +59,11 @@ IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(class_, super_) namespace mozilla { namespace css { -nsCSSStyleSheet* +CSSStyleSheet* Rule::GetStyleSheet() const { if (!(mSheet & 0x1)) { - return reinterpret_cast(mSheet); + return reinterpret_cast(mSheet); } return nullptr; @@ -80,7 +80,7 @@ Rule::GetHTMLCSSStyleSheet() const } /* virtual */ void -Rule::SetStyleSheet(nsCSSStyleSheet* aSheet) +Rule::SetStyleSheet(CSSStyleSheet* aSheet) { // We don't reference count this up reference. The style sheet // will tell us when it's going away or when we're detached from @@ -135,7 +135,7 @@ class GroupRuleRuleList MOZ_FINAL : public dom::CSSRuleList public: GroupRuleRuleList(GroupRule *aGroupRule); - virtual nsCSSStyleSheet* GetParentObject() MOZ_OVERRIDE; + virtual CSSStyleSheet* GetParentObject() MOZ_OVERRIDE; virtual nsIDOMCSSRule* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE; @@ -162,7 +162,7 @@ GroupRuleRuleList::~GroupRuleRuleList() { } -nsCSSStyleSheet* +CSSStyleSheet* GroupRuleRuleList::GetParentObject() { if (!mGroupRule) { @@ -343,7 +343,7 @@ ImportRule::ImportRule(const ImportRule& aCopy) // property of that @import rule, since it is null only if the target // sheet failed security checks. if (aCopy.mChildSheet) { - nsRefPtr sheet = + nsRefPtr sheet = aCopy.mChildSheet->Clone(nullptr, this, nullptr, nullptr); SetSheet(sheet); // SetSheet sets mMedia appropriately @@ -403,7 +403,7 @@ ImportRule::Clone() const } void -ImportRule::SetSheet(nsCSSStyleSheet* aSheet) +ImportRule::SetSheet(CSSStyleSheet* aSheet) { NS_PRECONDITION(aSheet, "null arg"); @@ -494,8 +494,8 @@ ImportRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const // - mURLSpec // // The following members are not measured: - // - mMedia, because it is measured via nsCSSStyleSheet::mMedia - // - mChildSheet, because it is measured via nsCSSStyleSheetInner::mSheets + // - mMedia, because it is measured via CSSStyleSheet::mMedia + // - mChildSheet, because it is measured via CSSStyleSheetInner::mSheets } } // namespace css @@ -547,7 +547,7 @@ IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(GroupRule, Rule) static bool SetStyleSheetReference(Rule* aRule, void* aSheet) { - nsCSSStyleSheet* sheet = (nsCSSStyleSheet*)aSheet; + CSSStyleSheet* sheet = (CSSStyleSheet*)aSheet; aRule->SetStyleSheet(sheet); return true; } @@ -582,7 +582,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(GroupRule) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END /* virtual */ void -GroupRule::SetStyleSheet(nsCSSStyleSheet* aSheet) +GroupRule::SetStyleSheet(CSSStyleSheet* aSheet) { // Don't set the sheet on the kids if it's already the same as the sheet we // already have. This is needed to avoid O(N^2) behavior in group nesting @@ -613,7 +613,7 @@ void GroupRule::AppendStyleRule(Rule* aRule) { mRules.AppendObject(aRule); - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); aRule->SetStyleSheet(sheet); aRule->SetParentRule(this); if (sheet) { @@ -711,7 +711,7 @@ GroupRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList) nsresult GroupRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retval) { - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE); if (aIndex > uint32_t(mRules.Count())) @@ -726,7 +726,7 @@ GroupRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retva nsresult GroupRule::DeleteRule(uint32_t aIndex) { - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE); if (aIndex >= uint32_t(mRules.Count())) @@ -789,7 +789,7 @@ NS_INTERFACE_MAP_BEGIN(MediaRule) NS_INTERFACE_MAP_END_INHERITING(GroupRule) /* virtual */ void -MediaRule::SetStyleSheet(nsCSSStyleSheet* aSheet) +MediaRule::SetStyleSheet(CSSStyleSheet* aSheet) { if (mMedia) { // Set to null so it knows it's leaving one sheet and joining another. @@ -2367,7 +2367,7 @@ nsCSSKeyframeRule::SetKeyText(const nsAString& aKeyText) newSelectors.SwapElements(mKeys); - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (sheet) { sheet->SetModifiedByChildRule(); @@ -2404,7 +2404,7 @@ nsCSSKeyframeRule::ChangeDeclaration(css::Declaration* aDeclaration) mDeclaration = aDeclaration; } - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (sheet) { sheet->SetModifiedByChildRule(); @@ -2543,7 +2543,7 @@ nsCSSKeyframesRule::SetName(const nsAString& aName) mName = aName; - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (sheet) { sheet->SetModifiedByChildRule(); @@ -2578,7 +2578,7 @@ nsCSSKeyframesRule::AppendRule(const nsAString& aRule) AppendStyleRule(rule); - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (sheet) { sheet->SetModifiedByChildRule(); @@ -2626,7 +2626,7 @@ nsCSSKeyframesRule::DeleteRule(const nsAString& aKey) mRules.RemoveObjectAt(index); - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (sheet) { sheet->SetModifiedByChildRule(); @@ -2887,7 +2887,7 @@ nsCSSPageRule::ChangeDeclaration(css::Declaration* aDeclaration) mDeclaration = aDeclaration; } - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (sheet) { sheet->SetModifiedByChildRule(); } @@ -3181,7 +3181,7 @@ nsCSSCounterStyleRule::SetName(const nsAString& aName) mName = name; - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (sheet) { sheet->SetModifiedByChildRule(); if (doc) { @@ -3227,7 +3227,7 @@ nsCSSCounterStyleRule::SetDesc(nsCSSCounterDesc aDescID, const nsCSSValue& aValu mValues[aDescID] = aValue; mGeneration++; - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); if (sheet) { sheet->SetModifiedByChildRule(); if (doc) { @@ -3457,7 +3457,7 @@ nsCSSCounterStyleRule::SetDescriptor(nsCSSCounterDesc aDescID, { nsCSSParser parser; nsCSSValue value; - nsCSSStyleSheet* sheet = GetStyleSheet(); + CSSStyleSheet* sheet = GetStyleSheet(); nsIURI* baseURL = nullptr; nsIPrincipal* principal = nullptr; if (sheet) { diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 9eaff61fb53d..701978e16d45 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -61,7 +61,7 @@ public: #endif // Rule methods - virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); //override GroupRule + virtual void SetStyleSheet(mozilla::CSSStyleSheet* aSheet); //override GroupRule virtual int32_t GetType() const; virtual already_AddRefed Clone() const; virtual nsIDOMCSSRule* GetDOMRule() diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 81a5f4c63a6a..6dd0d0805771 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -8,6 +8,7 @@ #include "nsCSSValue.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/Likely.h" #include "mozilla/MemoryReporting.h" #include "mozilla/css/ImageLoader.h" @@ -18,7 +19,6 @@ #include "nsIDocument.h" #include "nsIPrincipal.h" #include "nsCSSProps.h" -#include "nsCSSStyleSheet.h" #include "nsNetUtil.h" #include "nsPresContext.h" #include "nsStyleUtil.h" diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index 85acbfba04c9..f00af676a1f2 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -26,7 +26,6 @@ #include "gfxFontFamilyList.h" class imgRequestProxy; -class nsCSSStyleSheet; class nsIDocument; class nsIPrincipal; class nsIURI; @@ -34,6 +33,10 @@ class nsPresContext; template class nsPtrHashKey; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla + // Deletes a linked list iteratively to avoid blowing up the stack (bug 456196). #define NS_CSS_DELETE_LIST_MEMBER(type_, ptr_, member_) \ { \ @@ -1456,7 +1459,7 @@ public: nsCOMPtr mBaseURI; nsCOMPtr mSheetURI; nsCOMPtr mSheetPrincipal; - nsCSSStyleSheet* mSheet; + mozilla::CSSStyleSheet* mSheet; uint32_t mLineNumber; uint32_t mLineOffset; diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp index ea32324cac02..2365a71f6b10 100644 --- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -8,7 +8,7 @@ #include "nsDOMCSSDeclaration.h" #include "nsCSSParser.h" -#include "nsCSSStyleSheet.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Rule.h" #include "mozilla/css/Declaration.h" #include "mozilla/dom/CSS2PropertiesBinding.h" @@ -292,7 +292,7 @@ nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule, CSSParsingEnvironment& aCSSParseEnv) { nsIStyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr; - nsRefPtr cssSheet(do_QueryObject(sheet)); + nsRefPtr cssSheet(do_QueryObject(sheet)); if (!cssSheet) { aCSSParseEnv.mPrincipal = nullptr; return; diff --git a/layout/style/nsICSSLoaderObserver.h b/layout/style/nsICSSLoaderObserver.h index 475ca8386d8c..db24314ade9e 100644 --- a/layout/style/nsICSSLoaderObserver.h +++ b/layout/style/nsICSSLoaderObserver.h @@ -14,7 +14,9 @@ { 0x7eb90c74, 0xea0c, 0x4df5, \ {0xa1, 0x5f, 0x95, 0xf0, 0x6a, 0x98, 0xb9, 0x40} } -class nsCSSStyleSheet; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla class nsICSSLoaderObserver : public nsISupports { public: @@ -35,7 +37,8 @@ public: * as CSS, and doesn't indicate anything about the status of any child * sheets of aSheet. */ - NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate, + NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet, + bool aWasAlternate, nsresult aStatus) = 0; }; diff --git a/layout/style/nsIMediaList.h b/layout/style/nsIMediaList.h index fc5b6f50d179..53792f6da947 100644 --- a/layout/style/nsIMediaList.h +++ b/layout/style/nsIMediaList.h @@ -21,10 +21,13 @@ #include "mozilla/ErrorResult.h" class nsPresContext; -class nsCSSStyleSheet; class nsAString; struct nsMediaFeature; +namespace mozilla { +class CSSStyleSheet; +} // namespace mozilla + struct nsMediaExpression { enum Range { eMin, eMax, eEqual }; @@ -173,7 +176,7 @@ public: bool Matches(nsPresContext* aPresContext, nsMediaQueryResultCacheKey* aKey); - nsresult SetStyleSheet(nsCSSStyleSheet* aSheet); + nsresult SetStyleSheet(mozilla::CSSStyleSheet* aSheet); void AppendQuery(nsAutoPtr& aQuery) { // Takes ownership of aQuery mArray.AppendElement(aQuery.forget()); @@ -208,6 +211,6 @@ protected: // not refcounted; sheet will let us know when it goes away // mStyleSheet is the sheet that needs to be dirtied when this medialist // changes - nsCSSStyleSheet* mStyleSheet; + mozilla::CSSStyleSheet* mStyleSheet; }; #endif /* !defined(nsIMediaList_h_) */ diff --git a/layout/style/nsIStyleSheet.h b/layout/style/nsIStyleSheet.h index b61d9d5c80fa..23ccb58fd595 100644 --- a/layout/style/nsIStyleSheet.h +++ b/layout/style/nsIStyleSheet.h @@ -30,7 +30,7 @@ class nsIDocument; * rules. Those style rules can be reached in one of two ways, depending * on which level of the nsStyleSet it is in: * 1) It can be |QueryInterface|d to nsIStyleRuleProcessor - * 2) It can be |QueryInterface|d to nsCSSStyleSheet, with which the + * 2) It can be |QueryInterface|d to CSSStyleSheet, with which the * |nsStyleSet| uses an |nsCSSRuleProcessor| to access the rules. */ class nsIStyleSheet : public nsISupports { diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index 5b815f7e309a..1f8d6e46b250 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -7,6 +7,7 @@ #include "nsLayoutStylesheetCache.h" #include "nsAppDirectoryServiceDefs.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" #include "mozilla/css/Loader.h" @@ -15,7 +16,6 @@ #include "nsIObserverService.h" #include "nsServiceManagerUtils.h" #include "nsIXULRuntime.h" -#include "nsCSSStyleSheet.h" using namespace mozilla; @@ -50,7 +50,7 @@ nsLayoutStylesheetCache::Observe(nsISupports* aSubject, return NS_OK; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::ScrollbarsSheet() { EnsureGlobal(); @@ -71,7 +71,7 @@ nsLayoutStylesheetCache::ScrollbarsSheet() return gStyleCache->mScrollbarsSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::FormsSheet() { EnsureGlobal(); @@ -93,7 +93,7 @@ nsLayoutStylesheetCache::FormsSheet() return gStyleCache->mFormsSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::NumberControlSheet() { EnsureGlobal(); @@ -118,7 +118,7 @@ nsLayoutStylesheetCache::NumberControlSheet() return gStyleCache->mNumberControlSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::UserContentSheet() { EnsureGlobal(); @@ -128,7 +128,7 @@ nsLayoutStylesheetCache::UserContentSheet() return gStyleCache->mUserContentSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::UserChromeSheet() { EnsureGlobal(); @@ -138,7 +138,7 @@ nsLayoutStylesheetCache::UserChromeSheet() return gStyleCache->mUserChromeSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::UASheet() { EnsureGlobal(); @@ -148,7 +148,7 @@ nsLayoutStylesheetCache::UASheet() return gStyleCache->mUASheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::HTMLSheet() { EnsureGlobal(); @@ -158,7 +158,7 @@ nsLayoutStylesheetCache::HTMLSheet() return gStyleCache->mHTMLSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::MinimalXULSheet() { EnsureGlobal(); @@ -168,7 +168,7 @@ nsLayoutStylesheetCache::MinimalXULSheet() return gStyleCache->mMinimalXULSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::XULSheet() { EnsureGlobal(); @@ -178,7 +178,7 @@ nsLayoutStylesheetCache::XULSheet() return gStyleCache->mXULSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::QuirkSheet() { EnsureGlobal(); @@ -188,7 +188,7 @@ nsLayoutStylesheetCache::QuirkSheet() return gStyleCache->mQuirkSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::FullScreenOverrideSheet() { EnsureGlobal(); @@ -198,7 +198,7 @@ nsLayoutStylesheetCache::FullScreenOverrideSheet() return gStyleCache->mFullScreenOverrideSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::SVGSheet() { EnsureGlobal(); @@ -208,7 +208,7 @@ nsLayoutStylesheetCache::SVGSheet() return gStyleCache->mSVGSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::MathMLSheet() { EnsureGlobal(); @@ -227,7 +227,7 @@ nsLayoutStylesheetCache::MathMLSheet() return gStyleCache->mMathMLSheet; } -nsCSSStyleSheet* +CSSStyleSheet* nsLayoutStylesheetCache::CounterStylesSheet() { EnsureGlobal(); @@ -417,7 +417,7 @@ nsLayoutStylesheetCache::InitFromProfile() } void -nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsRefPtr &aSheet) +nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsRefPtr& aSheet) { bool exists = false; aFile->Exists(&exists); @@ -432,7 +432,7 @@ nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsRefPtr void nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, - nsRefPtr &aSheet, + nsRefPtr& aSheet, bool aEnableUnsafeRules) { if (!aURI) { diff --git a/layout/style/nsLayoutStylesheetCache.h b/layout/style/nsLayoutStylesheetCache.h index 3e82dc8a9d64..8b2c1d88586c 100644 --- a/layout/style/nsLayoutStylesheetCache.h +++ b/layout/style/nsLayoutStylesheetCache.h @@ -13,11 +13,11 @@ #include "mozilla/Attributes.h" #include "mozilla/MemoryReporting.h" -class nsCSSStyleSheet; class nsIFile; class nsIURI; namespace mozilla { +class CSSStyleSheet; namespace css { class Loader; } @@ -31,22 +31,22 @@ class nsLayoutStylesheetCache MOZ_FINAL NS_DECL_NSIOBSERVER NS_DECL_NSIMEMORYREPORTER - static nsCSSStyleSheet* ScrollbarsSheet(); - static nsCSSStyleSheet* FormsSheet(); + static mozilla::CSSStyleSheet* ScrollbarsSheet(); + static mozilla::CSSStyleSheet* FormsSheet(); // This function is expected to return nullptr when the dom.forms.number // pref is disabled. - static nsCSSStyleSheet* NumberControlSheet(); - static nsCSSStyleSheet* UserContentSheet(); - static nsCSSStyleSheet* UserChromeSheet(); - static nsCSSStyleSheet* UASheet(); - static nsCSSStyleSheet* HTMLSheet(); - static nsCSSStyleSheet* MinimalXULSheet(); - static nsCSSStyleSheet* XULSheet(); - static nsCSSStyleSheet* QuirkSheet(); - static nsCSSStyleSheet* FullScreenOverrideSheet(); - static nsCSSStyleSheet* SVGSheet(); - static nsCSSStyleSheet* MathMLSheet(); - static nsCSSStyleSheet* CounterStylesSheet(); + static mozilla::CSSStyleSheet* NumberControlSheet(); + static mozilla::CSSStyleSheet* UserContentSheet(); + static mozilla::CSSStyleSheet* UserChromeSheet(); + static mozilla::CSSStyleSheet* UASheet(); + static mozilla::CSSStyleSheet* HTMLSheet(); + static mozilla::CSSStyleSheet* MinimalXULSheet(); + static mozilla::CSSStyleSheet* XULSheet(); + static mozilla::CSSStyleSheet* QuirkSheet(); + static mozilla::CSSStyleSheet* FullScreenOverrideSheet(); + static mozilla::CSSStyleSheet* SVGSheet(); + static mozilla::CSSStyleSheet* MathMLSheet(); + static mozilla::CSSStyleSheet* CounterStylesSheet(); static void Shutdown(); @@ -59,26 +59,27 @@ private: static void EnsureGlobal(); void InitFromProfile(); void InitMemoryReporter(); - static void LoadSheetFile(nsIFile* aFile, nsRefPtr &aSheet); - static void LoadSheet(nsIURI* aURI, nsRefPtr &aSheet, + static void LoadSheetFile(nsIFile* aFile, + nsRefPtr& aSheet); + static void LoadSheet(nsIURI* aURI, nsRefPtr& aSheet, bool aEnableUnsafeRules); static nsLayoutStylesheetCache* gStyleCache; static mozilla::css::Loader* gCSSLoader; - nsRefPtr mScrollbarsSheet; - nsRefPtr mFormsSheet; - nsRefPtr mNumberControlSheet; - nsRefPtr mUserContentSheet; - nsRefPtr mUserChromeSheet; - nsRefPtr mUASheet; - nsRefPtr mHTMLSheet; - nsRefPtr mMinimalXULSheet; - nsRefPtr mXULSheet; - nsRefPtr mQuirkSheet; - nsRefPtr mFullScreenOverrideSheet; - nsRefPtr mSVGSheet; - nsRefPtr mMathMLSheet; - nsRefPtr mCounterStylesSheet; + nsRefPtr mScrollbarsSheet; + nsRefPtr mFormsSheet; + nsRefPtr mNumberControlSheet; + nsRefPtr mUserContentSheet; + nsRefPtr mUserChromeSheet; + nsRefPtr mUASheet; + nsRefPtr mHTMLSheet; + nsRefPtr mMinimalXULSheet; + nsRefPtr mXULSheet; + nsRefPtr mQuirkSheet; + nsRefPtr mFullScreenOverrideSheet; + nsRefPtr mSVGSheet; + nsRefPtr mMathMLSheet; + nsRefPtr mCounterStylesSheet; }; #endif diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 69c2a1459ccd..a4bbf449705e 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -9,12 +9,12 @@ * potentially re-creating) style contexts */ +#include "nsStyleSet.h" + #include "mozilla/ArrayUtils.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/EventStates.h" #include "mozilla/MemoryReporting.h" - -#include "nsStyleSet.h" -#include "nsCSSStyleSheet.h" #include "nsIDocumentInlines.h" #include "nsRuleWalker.h" #include "nsStyleContext.h" @@ -282,7 +282,7 @@ GetScopeDepth(nsINode* aScopeElement, ScopeDepthCache& aCache) struct ScopedSheetOrder { - nsCSSStyleSheet* mSheet; + CSSStyleSheet* mSheet; uint32_t mDepth; uint32_t mOrder; @@ -305,7 +305,7 @@ struct ScopedSheetOrder // before those for descendant scopes, and with sheets for a single // scope in document order. static void -SortStyleSheetsByScope(nsTArray& aSheets) +SortStyleSheetsByScope(nsTArray& aSheets) { uint32_t n = aSheets.Length(); if (n == 1) { @@ -382,11 +382,11 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) uint32_t count = mSheets[eScopedDocSheet].Count(); if (count) { // Gather the scoped style sheets into an array as - // nsCSSStyleSheets, and mark all of their scope elements + // CSSStyleSheets, and mark all of their scope elements // as scoped style roots. - nsTArray sheets(count); + nsTArray sheets(count); for (uint32_t i = 0; i < count; i++) { - nsRefPtr sheet = + nsRefPtr sheet = do_QueryObject(mSheets[eScopedDocSheet].ObjectAt(i)); sheets.AppendElement(sheet); @@ -410,7 +410,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) scope->SetIsScopedStyleRoot(); // Create a rule processor for the scope. - nsTArray< nsRefPtr > sheetsForScope; + nsTArray> sheetsForScope; sheetsForScope.AppendElements(sheets.Elements() + start, end - start); mScopedDocSheetRuleProcessors.AppendElement (new nsCSSRuleProcessor(sheetsForScope, uint8_t(aType), scope)); @@ -428,9 +428,9 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) case eOverrideSheet: { // levels containing CSS stylesheets (apart from eScopedDocSheet) nsCOMArray& sheets = mSheets[aType]; - nsTArray > cssSheets(sheets.Count()); + nsTArray> cssSheets(sheets.Count()); for (int32_t i = 0, i_end = sheets.Count(); i < i_end; ++i) { - nsRefPtr cssSheet = do_QueryObject(sheets[i]); + nsRefPtr cssSheet = do_QueryObject(sheets[i]); NS_ASSERTION(cssSheet, "not a CSS sheet"); cssSheets.AppendElement(cssSheet); } @@ -452,8 +452,8 @@ nsStyleSet::GatherRuleProcessors(sheetType aType) static bool IsScopedStyleSheet(nsIStyleSheet* aSheet) { - nsRefPtr cssSheet = do_QueryObject(aSheet); - NS_ASSERTION(cssSheet, "expected aSheet to be an nsCSSStyleSheet"); + nsRefPtr cssSheet = do_QueryObject(aSheet); + NS_ASSERTION(cssSheet, "expected aSheet to be a CSSStyleSheet"); return cssSheet->GetScopeElement(); } @@ -602,7 +602,7 @@ nsStyleSet::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument) nsresult nsStyleSet::RemoveDocStyleSheet(nsIStyleSheet *aSheet) { - nsRefPtr cssSheet = do_QueryObject(aSheet); + nsRefPtr cssSheet = do_QueryObject(aSheet); bool isScoped = cssSheet && cssSheet->GetScopeElement(); return RemoveStyleSheet(isScoped ? eScopedDocSheet : eDocSheet, aSheet); } @@ -2065,14 +2065,14 @@ nsStyleSet::MediumFeaturesChanged(nsPresContext* aPresContext) return stylesChanged; } -nsCSSStyleSheet::EnsureUniqueInnerResult +CSSStyleSheet::EnsureUniqueInnerResult nsStyleSet::EnsureUniqueInnerOnCSSSheets() { - nsAutoTArray queue; + nsAutoTArray queue; for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) { nsCOMArray &sheets = mSheets[gCSSSheetTypes[i]]; for (uint32_t j = 0, j_end = sheets.Count(); j < j_end; ++j) { - nsCSSStyleSheet *sheet = static_cast(sheets[j]); + CSSStyleSheet* sheet = static_cast(sheets[j]); queue.AppendElement(sheet); } } @@ -2081,16 +2081,16 @@ nsStyleSet::EnsureUniqueInnerOnCSSSheets() mBindingManager->AppendAllSheets(queue); } - nsCSSStyleSheet::EnsureUniqueInnerResult res = - nsCSSStyleSheet::eUniqueInner_AlreadyUnique; + CSSStyleSheet::EnsureUniqueInnerResult res = + CSSStyleSheet::eUniqueInner_AlreadyUnique; while (!queue.IsEmpty()) { uint32_t idx = queue.Length() - 1; - nsCSSStyleSheet *sheet = queue[idx]; + CSSStyleSheet* sheet = queue[idx]; queue.RemoveElementAt(idx); - nsCSSStyleSheet::EnsureUniqueInnerResult sheetRes = + CSSStyleSheet::EnsureUniqueInnerResult sheetRes = sheet->EnsureUniqueInner(); - if (sheetRes == nsCSSStyleSheet::eUniqueInner_ClonedInner) { + if (sheetRes == CSSStyleSheet::eUniqueInner_ClonedInner) { res = sheetRes; } diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index 837831ee1c23..7e984d4b66d9 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -13,10 +13,10 @@ #define nsStyleSet_h_ #include "mozilla/Attributes.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/MemoryReporting.h" #include "nsIStyleRuleProcessor.h" -#include "nsCSSStyleSheet.h" #include "nsBindingManager.h" #include "nsRuleNode.h" #include "nsTArray.h" @@ -338,7 +338,7 @@ class nsStyleSet --mUnusedRuleNodeCount; } - nsCSSStyleSheet::EnsureUniqueInnerResult EnsureUniqueInnerOnCSSSheets(); + mozilla::CSSStyleSheet::EnsureUniqueInnerResult EnsureUniqueInnerOnCSSSheets(); nsIStyleRule* InitialStyleRule(); diff --git a/layout/style/test/ParseCSS.cpp b/layout/style/test/ParseCSS.cpp index 46b2cc1a268c..ea2870ed6453 100644 --- a/layout/style/test/ParseCSS.cpp +++ b/layout/style/test/ParseCSS.cpp @@ -19,8 +19,10 @@ #include "nsNetUtil.h" #include "nsContentCID.h" +#include "mozilla/CSSStyleSheet.h" #include "mozilla/css/Loader.h" -#include "nsCSSStyleSheet.h" + +using namespace mozilla; static already_AddRefed FileToURI(const char *aFilename, nsresult *aRv = 0) @@ -41,7 +43,7 @@ static int ParseCSSFile(nsIURI *aSheetURI) { nsRefPtr = new mozilla::css::Loader(); - nsRefPtr sheet; + nsRefPtr sheet; loader->LoadSheetSync(aSheetURI, getter_AddRefs(sheet)); NS_ASSERTION(sheet, "sheet load failed"); /* This can happen if the file can't be found (e.g. you