summaryrefslogtreecommitdiffstats
path: root/dom/base/nsStyleLinkElement.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/base/nsStyleLinkElement.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/nsStyleLinkElement.h')
-rw-r--r--dom/base/nsStyleLinkElement.h146
1 files changed, 146 insertions, 0 deletions
diff --git a/dom/base/nsStyleLinkElement.h b/dom/base/nsStyleLinkElement.h
new file mode 100644
index 000000000..a41ae5e1d
--- /dev/null
+++ b/dom/base/nsStyleLinkElement.h
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+/*
+ * A base class which implements nsIStyleSheetLinkingElement and can
+ * be subclassed by various content nodes that want to load
+ * stylesheets (<style>, <link>, processing instructions, etc).
+ */
+
+#ifndef nsStyleLinkElement_h___
+#define nsStyleLinkElement_h___
+
+#include "mozilla/Attributes.h"
+#include "mozilla/CORSMode.h"
+#include "mozilla/StyleSheetInlines.h"
+#include "mozilla/net/ReferrerPolicy.h"
+#include "nsCOMPtr.h"
+#include "nsIStyleSheetLinkingElement.h"
+#include "nsTArray.h"
+
+class nsIDocument;
+class nsIURI;
+
+namespace mozilla {
+class CSSStyleSheet;
+namespace dom {
+class ShadowRoot;
+} // namespace dom
+} // namespace mozilla
+
+class nsStyleLinkElement : public nsIStyleSheetLinkingElement
+{
+public:
+ nsStyleLinkElement();
+ virtual ~nsStyleLinkElement();
+
+ NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override = 0;
+
+ mozilla::StyleSheet* GetSheet() const { return mStyleSheet; }
+
+ // nsIStyleSheetLinkingElement
+ NS_IMETHOD SetStyleSheet(mozilla::StyleSheet* aStyleSheet) override;
+ NS_IMETHOD_(mozilla::StyleSheet*) GetStyleSheet() override;
+ NS_IMETHOD InitStyleLinkElement(bool aDontLoadStyle) override;
+ NS_IMETHOD UpdateStyleSheet(nsICSSLoaderObserver* aObserver,
+ bool* aWillNotify,
+ bool* aIsAlternate,
+ bool aForceReload) override;
+ NS_IMETHOD SetEnableUpdates(bool aEnableUpdates) override;
+ NS_IMETHOD GetCharset(nsAString& aCharset) override;
+
+ virtual void OverrideBaseURI(nsIURI* aNewBaseURI) override;
+ virtual void SetLineNumber(uint32_t aLineNumber) override;
+ virtual uint32_t GetLineNumber() override;
+
+ enum RelValue {
+ ePREFETCH = 0x00000001,
+ eDNS_PREFETCH = 0x00000002,
+ eSTYLESHEET = 0x00000004,
+ eNEXT = 0x00000008,
+ eALTERNATE = 0x00000010,
+ eHTMLIMPORT = 0x00000020,
+ ePRECONNECT = 0x00000040
+ };
+
+ // The return value is a bitwise or of 0 or more RelValues.
+ // aPrincipal is used to check if HTML imports is enabled for the
+ // provided principal.
+ static uint32_t ParseLinkTypes(const nsAString& aTypes,
+ nsIPrincipal* aPrincipal);
+
+ static bool IsImportEnabled();
+
+ void UpdateStyleSheetInternal()
+ {
+ UpdateStyleSheetInternal(nullptr, nullptr);
+ }
+protected:
+ /**
+ * @param aOldDocument should be non-null only if we're updating because we
+ * removed the node from the document.
+ * @param aForceUpdate true will force the update even if the URI has not
+ * changed. This should be used in cases when something
+ * about the content that affects the resulting sheet
+ * changed but the URI may not have changed.
+ */
+ nsresult UpdateStyleSheetInternal(nsIDocument *aOldDocument,
+ mozilla::dom::ShadowRoot *aOldShadowRoot,
+ bool aForceUpdate = false);
+
+ void UpdateStyleSheetScopedness(bool aIsNowScoped);
+
+ virtual already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline) = 0;
+ virtual void GetStyleSheetInfo(nsAString& aTitle,
+ nsAString& aType,
+ nsAString& aMedia,
+ bool* aIsScoped,
+ bool* aIsAlternate) = 0;
+
+ virtual mozilla::CORSMode GetCORSMode() const
+ {
+ // Default to no CORS
+ return mozilla::CORS_NONE;
+ }
+
+ virtual mozilla::net::ReferrerPolicy GetLinkReferrerPolicy()
+ {
+ return mozilla::net::RP_Unset;
+ }
+
+ // CC methods
+ void Unlink();
+ void Traverse(nsCycleCollectionTraversalCallback &cb);
+
+private:
+ /**
+ * @param aOldDocument should be non-null only if we're updating because we
+ * removed the node from the document.
+ * @param aOldShadowRoot The ShadowRoot that used to contain the style.
+ * Passed as a parameter because on an update, the node
+ * is removed from the tree before the sheet is removed
+ * from the ShadowRoot.
+ * @param aForceUpdate true will force the update even if the URI has not
+ * changed. This should be used in cases when something
+ * about the content that affects the resulting sheet
+ * changed but the URI may not have changed.
+ */
+ nsresult DoUpdateStyleSheet(nsIDocument* aOldDocument,
+ mozilla::dom::ShadowRoot* aOldShadowRoot,
+ nsICSSLoaderObserver* aObserver,
+ bool* aWillNotify,
+ bool* aIsAlternate,
+ bool aForceUpdate);
+
+ RefPtr<mozilla::StyleSheet> mStyleSheet;
+protected:
+ bool mDontLoadStyle;
+ bool mUpdatesEnabled;
+ uint32_t mLineNumber;
+};
+
+#endif /* nsStyleLinkElement_h___ */
+