gecko-dev/dom/base/nsStyleLinkElement.h

140 строки
5.0 KiB
C
Исходник Обычный вид История

/* -*- 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
2012-05-21 15:12:37 +04:00
* 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/CSSStyleSheet.h"
#include "nsCOMPtr.h"
#include "nsIStyleSheetLinkingElement.h"
#include "nsTArray.h"
class nsIDocument;
class nsIURI;
namespace mozilla {
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::CSSStyleSheet* GetSheet() const { return mStyleSheet; }
// nsIStyleSheetLinkingElement
NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) override;
NS_IMETHOD_(mozilla::CSSStyleSheet*) 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;
}
// 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);
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 08:24:48 +03:00
RefPtr<mozilla::CSSStyleSheet> mStyleSheet;
protected:
bool mDontLoadStyle;
bool mUpdatesEnabled;
uint32_t mLineNumber;
};
#endif /* nsStyleLinkElement_h___ */