2004-08-04 03:27:28 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:cindent:tabstop=2:expandtab:shiftwidth=2:
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2006-03-25 05:47:31 +00:00
|
|
|
/* representation of a CSS style sheet */
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
#ifndef mozilla_CSSStyleSheet_h
|
|
|
|
#define mozilla_CSSStyleSheet_h
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2011-11-21 06:21:16 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2015-06-15 19:34:23 +00:00
|
|
|
#include "mozilla/IncrementalClearCOMRuleArray.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2016-02-26 01:51:01 +00:00
|
|
|
#include "mozilla/StyleSheet.h"
|
2016-02-26 01:51:01 +00:00
|
|
|
#include "mozilla/StyleSheetInfo.h"
|
2016-02-24 07:01:11 +00:00
|
|
|
#include "mozilla/css/SheetParsingMode.h"
|
2013-01-08 23:25:47 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2015-12-21 15:52:45 +00:00
|
|
|
#include "mozilla/dom/CSSStyleSheetBinding.h"
|
2011-11-21 06:21:16 +00:00
|
|
|
|
2004-08-04 03:27:28 +00:00
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2005-02-18 19:18:37 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2004-08-04 03:27:28 +00:00
|
|
|
#include "nsIDOMCSSStyleSheet.h"
|
|
|
|
#include "nsICSSLoaderObserver.h"
|
2014-05-09 15:23:14 +00:00
|
|
|
#include "nsTArrayForwardDeclare.h"
|
2011-10-28 07:35:45 +00:00
|
|
|
#include "nsString.h"
|
2012-08-28 17:10:08 +00:00
|
|
|
#include "mozilla/CORSMode.h"
|
2012-10-08 02:39:08 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-03-17 14:42:09 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2014-11-18 13:46:47 +00:00
|
|
|
#include "mozilla/net/ReferrerPolicy.h"
|
2015-08-13 03:19:11 +00:00
|
|
|
#include "mozilla/dom/SRIMetadata.h"
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
class CSSRuleListImpl;
|
2010-05-11 20:41:47 +00:00
|
|
|
class nsCSSRuleProcessor;
|
|
|
|
class nsIPrincipal;
|
2004-08-04 03:27:28 +00:00
|
|
|
class nsIURI;
|
2005-03-30 00:36:57 +00:00
|
|
|
class nsMediaList;
|
2008-07-26 16:14:48 +00:00
|
|
|
class nsMediaQueryResultCacheKey;
|
2016-02-24 07:01:11 +00:00
|
|
|
class nsStyleSet;
|
2010-04-10 20:10:12 +00:00
|
|
|
class nsPresContext;
|
2014-06-20 10:32:49 +00:00
|
|
|
class nsXMLNameSpaceMap;
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
namespace mozilla {
|
2014-06-20 10:32:49 +00:00
|
|
|
struct ChildSheetListBuilder;
|
|
|
|
class CSSStyleSheet;
|
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
namespace css {
|
2011-04-08 01:23:46 +00:00
|
|
|
class Rule;
|
2010-08-08 05:28:33 +00:00
|
|
|
class GroupRule;
|
2011-03-17 17:41:52 +00:00
|
|
|
class ImportRule;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace css
|
2014-06-10 02:11:00 +00:00
|
|
|
namespace dom {
|
|
|
|
class CSSRuleList;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
2011-03-17 17:41:52 +00:00
|
|
|
|
2015-12-21 15:52:45 +00:00
|
|
|
// -------------------------------
|
2004-08-04 03:27:28 +00:00
|
|
|
// CSS Style Sheet Inner Data Container
|
|
|
|
//
|
|
|
|
|
2016-02-26 01:51:01 +00:00
|
|
|
class CSSStyleSheetInner : public StyleSheetInfo
|
2014-06-20 10:32:49 +00:00
|
|
|
{
|
2004-08-04 03:27:28 +00:00
|
|
|
public:
|
2014-06-20 10:32:49 +00:00
|
|
|
friend class mozilla::CSSStyleSheet;
|
|
|
|
friend class ::nsCSSRuleProcessor;
|
2014-11-18 13:46:47 +00:00
|
|
|
|
2010-01-07 13:51:16 +00:00
|
|
|
private:
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheetInner(CSSStyleSheet* aPrimarySheet,
|
2014-11-18 13:46:47 +00:00
|
|
|
CORSMode aCORSMode,
|
2015-08-13 03:19:11 +00:00
|
|
|
ReferrerPolicy aReferrerPolicy,
|
|
|
|
const dom::SRIMetadata& aIntegrity);
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheetInner(CSSStyleSheetInner& aCopy,
|
|
|
|
CSSStyleSheet* aPrimarySheet);
|
|
|
|
~CSSStyleSheetInner();
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheetInner* CloneFor(CSSStyleSheet* aPrimarySheet);
|
|
|
|
void AddSheet(CSSStyleSheet* aSheet);
|
|
|
|
void RemoveSheet(CSSStyleSheet* aSheet);
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2008-10-15 20:24:45 +00:00
|
|
|
void RebuildNameSpaces();
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2008-10-15 20:23:21 +00:00
|
|
|
// Create a new namespace map
|
|
|
|
nsresult CreateNamespaceMap();
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2016-02-02 15:36:30 +00:00
|
|
|
AutoTArray<CSSStyleSheet*, 8> mSheets;
|
2015-06-15 19:34:23 +00:00
|
|
|
IncrementalClearCOMRuleArray mOrderedRules;
|
2005-02-19 00:10:38 +00:00
|
|
|
nsAutoPtr<nsXMLNameSpaceMap> mNameSpaceMap;
|
2008-09-09 18:08:11 +00:00
|
|
|
// 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.
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<CSSStyleSheet> mFirstChild;
|
2004-08-04 03:27:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------
|
|
|
|
// CSS Style Sheet
|
|
|
|
//
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
// CID for the CSSStyleSheet class
|
2015-11-17 06:04:09 +00:00
|
|
|
// 7985c7ac-9ddc-444d-9899-0c86ec122f54
|
2010-05-11 20:41:47 +00:00
|
|
|
#define NS_CSS_STYLE_SHEET_IMPL_CID \
|
2015-11-17 06:04:09 +00:00
|
|
|
{ 0x7985c7ac, 0x9ddc, 0x444d, \
|
|
|
|
{ 0x98, 0x99, 0x0c, 0x86, 0xec, 0x12, 0x2f, 0x54 } }
|
2010-05-11 20:41:47 +00:00
|
|
|
|
|
|
|
|
2015-11-17 06:04:09 +00:00
|
|
|
class CSSStyleSheet final : public nsIDOMCSSStyleSheet,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsICSSLoaderObserver,
|
2016-02-26 01:51:01 +00:00
|
|
|
public nsWrapperCache,
|
|
|
|
public StyleSheet
|
2004-08-04 03:27:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-11-18 13:46:47 +00:00
|
|
|
typedef net::ReferrerPolicy ReferrerPolicy;
|
|
|
|
CSSStyleSheet(CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy);
|
2015-08-13 03:19:11 +00:00
|
|
|
CSSStyleSheet(CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy,
|
|
|
|
const dom::SRIMetadata& aIntegrity);
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2012-10-08 02:39:08 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2014-06-20 10:32:49 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(CSSStyleSheet,
|
2015-11-17 06:04:09 +00:00
|
|
|
nsIDOMCSSStyleSheet)
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2010-05-11 20:41:47 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_SHEET_IMPL_CID)
|
|
|
|
|
2015-11-17 06:04:09 +00:00
|
|
|
nsIURI* GetSheetURI() const;
|
|
|
|
nsIURI* GetBaseURI() const;
|
|
|
|
void GetTitle(nsString& aTitle) const;
|
|
|
|
void GetType(nsString& aType) const;
|
|
|
|
bool HasRules() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the sheet is applicable. A sheet that is not applicable
|
|
|
|
* should never be inserted into a style set. A sheet may not be
|
|
|
|
* applicable for a variety of reasons including being disabled and
|
|
|
|
* being incomplete.
|
|
|
|
*/
|
|
|
|
bool IsApplicable() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the stylesheet to be enabled. This may or may not make it
|
|
|
|
* applicable. Note that this WILL inform the sheet's document of
|
|
|
|
* its new applicable state if the state changes but WILL NOT call
|
|
|
|
* BeginUpdate() or EndUpdate() on the document -- calling those is
|
|
|
|
* the caller's responsibility. This allows use of SetEnabled when
|
|
|
|
* batched updates are desired. If you want updates handled for
|
|
|
|
* you, see nsIDOMStyleSheet::SetDisabled().
|
|
|
|
*/
|
|
|
|
void SetEnabled(bool aEnabled);
|
|
|
|
|
|
|
|
// style sheet owner info
|
|
|
|
CSSStyleSheet* GetParentSheet() const; // may be null
|
|
|
|
nsIDocument* GetOwningDocument() const; // may be null
|
|
|
|
void SetOwningDocument(nsIDocument* aDocument);
|
2010-12-20 16:21:59 +00:00
|
|
|
|
2011-08-24 20:44:35 +00:00
|
|
|
// Find the ID of the owner inner window.
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t FindOwningWindowInnerID() const;
|
2004-08-04 03:27:28 +00:00
|
|
|
#ifdef DEBUG
|
2015-11-17 06:04:09 +00:00
|
|
|
void List(FILE* out = stdout, int32_t aIndent = 0) const;
|
2004-08-04 03:27:28 +00:00
|
|
|
#endif
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
void AppendStyleSheet(CSSStyleSheet* aSheet);
|
2010-05-11 20:59:25 +00:00
|
|
|
|
|
|
|
// XXX do these belong here or are they generic?
|
2014-06-20 10:32:49 +00:00
|
|
|
void AppendStyleRule(css::Rule* aRule);
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t StyleRuleCount() const;
|
2014-06-20 10:32:49 +00:00
|
|
|
css::Rule* GetStyleRuleAt(int32_t aIndex) const;
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
nsresult DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex);
|
|
|
|
nsresult InsertRuleIntoGroup(const nsAString& aRule, css::GroupRule* aGroup, uint32_t aIndex, uint32_t* _retval);
|
2010-05-11 20:59:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SetURIs must be called on all sheets before parsing into them.
|
|
|
|
* SetURIs may only be called while the sheet is 1) incomplete and 2)
|
|
|
|
* has no rules in it
|
|
|
|
*/
|
2010-05-11 20:41:48 +00:00
|
|
|
void SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, nsIURI* aBaseURI);
|
2010-05-11 20:59:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SetPrincipal should be called on all sheets before parsing into them.
|
|
|
|
* This can only be called once with a non-null principal. Calling this with
|
|
|
|
* a null pointer is allowed and is treated as a no-op.
|
|
|
|
*/
|
2010-05-11 20:41:48 +00:00
|
|
|
void SetPrincipal(nsIPrincipal* aPrincipal);
|
2010-05-11 20:59:25 +00:00
|
|
|
|
|
|
|
// Principal() never returns a null pointer.
|
2010-05-18 04:00:39 +00:00
|
|
|
nsIPrincipal* Principal() const { return mInner->mPrincipal; }
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2010-05-11 20:41:47 +00:00
|
|
|
void SetTitle(const nsAString& aTitle) { mTitle = aTitle; }
|
2010-05-11 20:41:48 +00:00
|
|
|
void SetMedia(nsMediaList* aMedia);
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
void SetOwnerRule(css::ImportRule* aOwnerRule) { mOwnerRule = aOwnerRule; /* Not ref counted */ }
|
|
|
|
css::ImportRule* GetOwnerRule() const { return mOwnerRule; }
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2010-05-18 04:00:39 +00:00
|
|
|
nsXMLNameSpaceMap* GetNameSpaceMap() const { return mInner->mNameSpaceMap; }
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
already_AddRefed<CSSStyleSheet> Clone(CSSStyleSheet* aCloneParent,
|
|
|
|
css::ImportRule* aCloneOwnerRule,
|
|
|
|
nsIDocument* aCloneDocument,
|
|
|
|
nsINode* aCloneOwningNode) const;
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsModified() const { return mDirty; }
|
2011-04-12 06:18:43 +00:00
|
|
|
|
|
|
|
void SetModifiedByChildRule() {
|
|
|
|
NS_ASSERTION(mDirty,
|
|
|
|
"sheet must be marked dirty before handing out child rules");
|
|
|
|
DidDirty();
|
|
|
|
}
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2010-05-11 20:41:48 +00:00
|
|
|
nsresult AddRuleProcessor(nsCSSRuleProcessor* aProcessor);
|
|
|
|
nsresult DropRuleProcessor(nsCSSRuleProcessor* aProcessor);
|
2010-05-11 20:59:25 +00:00
|
|
|
|
2015-06-26 03:49:58 +00:00
|
|
|
void AddStyleSet(nsStyleSet* aStyleSet);
|
|
|
|
void DropStyleSet(nsStyleSet* aStyleSet);
|
|
|
|
|
2010-05-11 20:59:25 +00:00
|
|
|
/**
|
|
|
|
* Like the DOM insertRule() method, but doesn't do any security checks
|
|
|
|
*/
|
2010-05-11 20:41:48 +00:00
|
|
|
nsresult InsertRuleInternal(const nsAString& aRule,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aIndex, uint32_t* aReturn);
|
2010-05-11 20:59:25 +00:00
|
|
|
|
|
|
|
/* Get the URI this sheet was originally loaded from, if any. Can
|
|
|
|
return null */
|
2015-11-06 01:10:15 +00:00
|
|
|
nsIURI* GetOriginalURI() const { return mInner->mOriginalSheetURI; }
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2016-03-26 06:02:30 +00:00
|
|
|
// Whether the sheet is for an inline <style> element.
|
|
|
|
bool IsInline() const { return mInner->IsInline(); }
|
|
|
|
|
2004-08-04 03:27:28 +00:00
|
|
|
// nsICSSLoaderObserver interface
|
2016-02-24 07:01:12 +00:00
|
|
|
NS_IMETHOD StyleSheetLoaded(StyleSheetHandle aSheet, bool aWasAlternate,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsresult aStatus) override;
|
2009-12-31 15:56:33 +00:00
|
|
|
|
2015-06-26 03:49:58 +00:00
|
|
|
void EnsureUniqueInner();
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2013-11-11 07:59:58 +00:00
|
|
|
// Append all of this sheet's child sheets to aArray.
|
2014-06-20 10:32:49 +00:00
|
|
|
void AppendAllChildSheets(nsTArray<CSSStyleSheet*>& aArray);
|
2009-12-31 15:56:33 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool UseForPresentation(nsPresContext* aPresContext,
|
2008-07-26 16:14:48 +00:00
|
|
|
nsMediaQueryResultCacheKey& aKey) const;
|
|
|
|
|
2015-09-18 05:27:00 +00:00
|
|
|
nsresult ReparseSheet(const nsAString& aInput);
|
2012-06-03 16:54:38 +00:00
|
|
|
|
2015-06-26 03:52:47 +00:00
|
|
|
void SetInRuleProcessorCache() { mInRuleProcessorCache = true; }
|
|
|
|
|
2004-08-04 03:27:28 +00:00
|
|
|
// nsIDOMStyleSheet interface
|
|
|
|
NS_DECL_NSIDOMSTYLESHEET
|
|
|
|
|
|
|
|
// nsIDOMCSSStyleSheet interface
|
|
|
|
NS_DECL_NSIDOMCSSSTYLESHEET
|
|
|
|
|
2009-05-26 19:40:49 +00:00
|
|
|
// Function used as a callback to rebuild our inner's child sheet
|
|
|
|
// list after we clone a unique inner for ourselves.
|
2014-06-20 10:32:49 +00:00
|
|
|
static bool RebuildChildList(css::Rule* aRule, void* aBuilder);
|
2009-05-26 19:40:49 +00:00
|
|
|
|
2015-11-17 06:04:09 +00:00
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2012-08-28 17:10:08 +00:00
|
|
|
// Get this style sheet's CORS mode
|
2014-06-20 10:32:49 +00:00
|
|
|
CORSMode GetCORSMode() const { return mInner->mCORSMode; }
|
2012-08-28 17:10:08 +00:00
|
|
|
|
2014-11-18 13:46:47 +00:00
|
|
|
// Get this style sheet's Referrer Policy
|
|
|
|
ReferrerPolicy GetReferrerPolicy() const { return mInner->mReferrerPolicy; }
|
|
|
|
|
2015-08-13 03:19:11 +00:00
|
|
|
// Get this style sheet's integrity metadata
|
2016-02-24 07:01:12 +00:00
|
|
|
void GetIntegrity(dom::SRIMetadata& aResult) const { aResult = mInner->mIntegrity; }
|
2015-08-13 03:19:11 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
dom::Element* GetScopeElement() const { return mScopeElement; }
|
|
|
|
void SetScopeElement(dom::Element* aScopeElement)
|
2013-01-08 23:25:47 +00:00
|
|
|
{
|
|
|
|
mScopeElement = aScopeElement;
|
|
|
|
}
|
|
|
|
|
2013-03-17 14:42:59 +00:00
|
|
|
// WebIDL StyleSheet API
|
2015-11-17 06:04:09 +00:00
|
|
|
// Our CSSStyleSheet::GetType is a const method, so it ends up
|
2013-03-17 14:42:59 +00:00
|
|
|
// ambiguous with with the XPCOM version. Just disambiguate.
|
|
|
|
void GetType(nsString& aType) {
|
2014-06-20 10:32:49 +00:00
|
|
|
const_cast<const CSSStyleSheet*>(this)->GetType(aType);
|
2013-03-17 14:42:59 +00:00
|
|
|
}
|
|
|
|
// Our XPCOM GetHref is fine for WebIDL
|
|
|
|
nsINode* GetOwnerNode() const { return mOwningNode; }
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* GetParentStyleSheet() const { return mParent; }
|
2015-11-17 06:04:09 +00:00
|
|
|
// Our CSSStyleSheet::GetTitle is a const method, so it ends up
|
2013-03-17 14:42:59 +00:00
|
|
|
// ambiguous with with the XPCOM version. Just disambiguate.
|
|
|
|
void GetTitle(nsString& aTitle) {
|
2014-06-20 10:32:49 +00:00
|
|
|
const_cast<const CSSStyleSheet*>(this)->GetTitle(aTitle);
|
2013-03-17 14:42:59 +00:00
|
|
|
}
|
2013-11-11 08:03:17 +00:00
|
|
|
nsMediaList* Media();
|
2013-03-17 14:42:59 +00:00
|
|
|
bool Disabled() const { return mDisabled; }
|
|
|
|
// The XPCOM SetDisabled is fine for WebIDL
|
|
|
|
|
|
|
|
// WebIDL CSSStyleSheet API
|
|
|
|
// Can't be inline because we can't include ImportRule here. And can't be
|
|
|
|
// called GetOwnerRule because that would be ambiguous with the ImportRule
|
|
|
|
// version.
|
|
|
|
nsIDOMCSSRule* GetDOMOwnerRule() const;
|
2014-06-20 10:32:49 +00:00
|
|
|
dom::CSSRuleList* GetCssRules(ErrorResult& aRv);
|
2013-03-17 14:42:59 +00:00
|
|
|
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
|
2014-06-20 10:32:49 +00:00
|
|
|
ErrorResult& aRv) {
|
2013-03-17 14:42:59 +00:00
|
|
|
uint32_t retval;
|
|
|
|
aRv = InsertRule(aRule, aIndex, &retval);
|
|
|
|
return retval;
|
|
|
|
}
|
2014-06-20 10:32:49 +00:00
|
|
|
void DeleteRule(uint32_t aIndex, ErrorResult& aRv) {
|
2013-03-17 14:42:59 +00:00
|
|
|
aRv = DeleteRule(aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
// WebIDL miscellaneous bits
|
2014-06-20 10:32:49 +00:00
|
|
|
dom::ParentObject GetParentObject() const {
|
2013-03-17 14:42:59 +00:00
|
|
|
if (mOwningNode) {
|
2014-06-20 10:32:49 +00:00
|
|
|
return dom::ParentObject(mOwningNode);
|
2013-03-17 14:42:59 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 06:04:09 +00:00
|
|
|
return dom::ParentObject(static_cast<nsIDOMCSSStyleSheet*>(mParent), mParent);
|
2013-03-17 14:42:59 +00:00
|
|
|
}
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-03-17 14:42:59 +00:00
|
|
|
|
2015-11-09 07:57:17 +00:00
|
|
|
// Changes to sheets should be inside of a WillDirty-DidDirty pair.
|
|
|
|
// However, the calls do not need to be matched; it's ok to call
|
|
|
|
// WillDirty and then make no change and skip the DidDirty call.
|
|
|
|
void WillDirty();
|
|
|
|
void DidDirty();
|
|
|
|
|
2015-12-21 15:52:45 +00:00
|
|
|
mozilla::dom::CSSStyleSheetParsingMode ParsingMode();
|
|
|
|
|
2004-08-04 03:27:28 +00:00
|
|
|
private:
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet(const CSSStyleSheet& aCopy,
|
|
|
|
CSSStyleSheet* aParentToUse,
|
|
|
|
css::ImportRule* aOwnerRuleToUse,
|
|
|
|
nsIDocument* aDocumentToUse,
|
|
|
|
nsINode* aOwningNodeToUse);
|
2010-05-11 20:41:47 +00:00
|
|
|
|
2015-01-06 23:35:02 +00:00
|
|
|
CSSStyleSheet(const CSSStyleSheet& aCopy) = delete;
|
|
|
|
CSSStyleSheet& operator=(const CSSStyleSheet& aCopy) = delete;
|
2004-08-04 03:27:28 +00:00
|
|
|
|
|
|
|
protected:
|
2014-06-20 10:32:49 +00:00
|
|
|
virtual ~CSSStyleSheet();
|
2004-08-04 03:27:28 +00:00
|
|
|
|
|
|
|
void ClearRuleCascades();
|
|
|
|
|
2007-07-03 18:45:39 +00:00
|
|
|
// Return success if the subject principal subsumes the principal of our
|
|
|
|
// inner, error otherwise. This will also succeed if the subject has
|
2012-08-28 17:10:09 +00:00
|
|
|
// UniversalXPConnect or if access is allowed by CORS. In the latter case,
|
|
|
|
// it will set the principal of the inner to the subject principal.
|
|
|
|
nsresult SubjectSubsumesInnerPrincipal();
|
2007-07-03 18:45:39 +00:00
|
|
|
|
2008-10-15 20:23:21 +00:00
|
|
|
// Add the namespace mapping from this @namespace rule to our namespace map
|
2014-06-20 10:32:49 +00:00
|
|
|
nsresult RegisterNamespaceRule(css::Rule* aRule);
|
2008-10-15 20:23:21 +00:00
|
|
|
|
2012-10-08 02:39:08 +00:00
|
|
|
// Drop our reference to mRuleCollection
|
|
|
|
void DropRuleCollection();
|
|
|
|
|
|
|
|
// Drop our reference to mMedia
|
|
|
|
void DropMedia();
|
|
|
|
|
|
|
|
// Unlink our inner, if needed, for cycle collection
|
|
|
|
void UnlinkInner();
|
|
|
|
// Traverse our inner, if needed, for cycle collection
|
|
|
|
void TraverseInner(nsCycleCollectionTraversalCallback &);
|
|
|
|
|
2004-08-04 03:27:28 +00:00
|
|
|
protected:
|
|
|
|
nsString mTitle;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsMediaList> mMedia;
|
|
|
|
RefPtr<CSSStyleSheet> mNext;
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* mParent; // weak ref
|
|
|
|
css::ImportRule* mOwnerRule; // weak ref
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<CSSRuleListImpl> mRuleCollection;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDirty; // has been modified
|
2015-06-26 03:52:47 +00:00
|
|
|
bool mInRuleProcessorCache;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<dom::Element> mScopeElement;
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheetInner* mInner;
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2016-02-02 15:36:30 +00:00
|
|
|
AutoTArray<nsCSSRuleProcessor*, 8>* mRuleProcessors;
|
2015-06-26 03:49:58 +00:00
|
|
|
nsTArray<nsStyleSet*> mStyleSets;
|
2004-08-04 03:27:28 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
friend class ::nsMediaList;
|
|
|
|
friend class ::nsCSSRuleProcessor;
|
2016-03-01 22:38:13 +00:00
|
|
|
friend class mozilla::StyleSheet;
|
2014-06-20 10:32:49 +00:00
|
|
|
friend struct mozilla::ChildSheetListBuilder;
|
2004-08-04 03:27:28 +00:00
|
|
|
};
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(CSSStyleSheet, NS_CSS_STYLE_SHEET_IMPL_CID)
|
|
|
|
|
|
|
|
} // namespace mozilla
|
2010-05-11 20:41:47 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
#endif /* !defined(mozilla_CSSStyleSheet_h) */
|