2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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/. */
|
1999-02-23 22:18:12 +03:00
|
|
|
#ifndef nsIStyleSheetLinkingElement_h__
|
|
|
|
#define nsIStyleSheetLinkingElement_h__
|
|
|
|
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
2018-04-24 13:50:35 +03:00
|
|
|
#include "mozilla/Result.h"
|
1999-02-23 22:18:12 +03:00
|
|
|
|
2003-01-06 17:55:13 +03:00
|
|
|
class nsICSSLoaderObserver;
|
2006-12-18 06:59:46 +03:00
|
|
|
class nsIURI;
|
2001-05-19 06:59:15 +04:00
|
|
|
|
1999-02-23 22:18:12 +03:00
|
|
|
#define NS_ISTYLESHEETLINKINGELEMENT_IID \
|
2015-08-18 01:19:21 +03:00
|
|
|
{ 0xa8b79f3b, 0x9d18, 0x4f9c, \
|
|
|
|
{ 0xb1, 0xaa, 0x8c, 0x9b, 0x1b, 0xaa, 0xac, 0xad } }
|
1999-02-23 22:18:12 +03:00
|
|
|
|
|
|
|
class nsIStyleSheetLinkingElement : public nsISupports {
|
|
|
|
public:
|
2018-04-24 13:50:35 +03:00
|
|
|
enum class ForceUpdate
|
|
|
|
{
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class IsAlternate
|
|
|
|
{
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
2018-04-24 15:56:02 +03:00
|
|
|
enum class Completed
|
2018-04-24 13:50:35 +03:00
|
|
|
{
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Update
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
bool mWillNotify;
|
|
|
|
bool mIsAlternate;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Update()
|
|
|
|
: mWillNotify(false)
|
|
|
|
, mIsAlternate(false)
|
2018-04-24 15:56:02 +03:00
|
|
|
{ }
|
2018-04-24 13:50:35 +03:00
|
|
|
|
2018-04-24 15:56:02 +03:00
|
|
|
Update(Completed aCompleted, IsAlternate aIsAlternate)
|
|
|
|
: mWillNotify(aCompleted == Completed::No)
|
2018-04-24 13:50:35 +03:00
|
|
|
, mIsAlternate(aIsAlternate == IsAlternate::Yes)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool WillNotify() const
|
|
|
|
{
|
|
|
|
return mWillNotify;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShouldBlock() const
|
|
|
|
{
|
|
|
|
if (!mWillNotify) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return !mIsAlternate;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLESHEETLINKINGELEMENT_IID)
|
2000-09-09 09:46:14 +04:00
|
|
|
|
1999-02-23 22:18:12 +03:00
|
|
|
/**
|
|
|
|
* Used to make the association between a style sheet and
|
|
|
|
* the element that linked it to the document.
|
|
|
|
*
|
|
|
|
* @param aStyleSheet the style sheet associated with this
|
|
|
|
* element.
|
|
|
|
*/
|
2018-02-02 16:21:32 +03:00
|
|
|
virtual void SetStyleSheet(mozilla::StyleSheet* aStyleSheet) = 0;
|
1999-02-23 22:18:12 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to obtain the style sheet linked in by this element.
|
|
|
|
*
|
2014-07-02 14:53:40 +04:00
|
|
|
* @return the style sheet associated with this element.
|
1999-02-23 22:18:12 +03:00
|
|
|
*/
|
2018-02-02 16:21:32 +03:00
|
|
|
virtual mozilla::StyleSheet* GetStyleSheet() = 0;
|
2001-05-19 06:59:15 +04:00
|
|
|
|
|
|
|
/**
|
2007-04-21 02:59:18 +04:00
|
|
|
* Initialize the stylesheet linking element. If aDontLoadStyle is
|
|
|
|
* true the element will ignore the first modification to the
|
|
|
|
* element that would cause a stylesheet to be loaded. Subsequent
|
|
|
|
* modifications to the element will not be ignored.
|
2001-05-19 06:59:15 +04:00
|
|
|
*/
|
2018-02-02 16:21:32 +03:00
|
|
|
virtual void InitStyleLinkElement(bool aDontLoadStyle) = 0;
|
2001-05-19 06:59:15 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells this element to update the stylesheet.
|
|
|
|
*
|
2003-01-06 17:55:13 +03:00
|
|
|
* @param aObserver observer to notify once the stylesheet is loaded.
|
2007-04-21 02:59:18 +04:00
|
|
|
* This will be passed to the CSSLoader
|
2014-08-29 04:20:27 +04:00
|
|
|
* @param aForceUpdate whether we wand to force the update, flushing the
|
|
|
|
* cached version if any.
|
2001-05-19 06:59:15 +04:00
|
|
|
*/
|
2018-04-24 13:50:35 +03:00
|
|
|
virtual mozilla::Result<Update, nsresult>
|
|
|
|
UpdateStyleSheet(nsICSSLoaderObserver* aObserver,
|
|
|
|
ForceUpdate = ForceUpdate::No) = 0;
|
2001-05-19 06:59:15 +04:00
|
|
|
|
|
|
|
/**
|
2005-11-26 00:57:13 +03:00
|
|
|
* Tells this element whether to update the stylesheet when the
|
2001-05-19 06:59:15 +04:00
|
|
|
* element's properties change.
|
|
|
|
*
|
|
|
|
* @param aEnableUpdates update on changes or not.
|
|
|
|
*/
|
2018-02-02 16:21:32 +03:00
|
|
|
virtual void SetEnableUpdates(bool aEnableUpdates) = 0;
|
2001-10-25 04:34:20 +04:00
|
|
|
|
|
|
|
/**
|
2018-02-02 16:21:32 +03:00
|
|
|
* Gets the charset that the element claims the style sheet is in.
|
|
|
|
* Can return empty string to indicate that we have no charset
|
|
|
|
* information.
|
2001-10-25 04:34:20 +04:00
|
|
|
*
|
|
|
|
* @param aCharset the charset
|
|
|
|
*/
|
2018-02-02 16:21:32 +03:00
|
|
|
virtual void GetCharset(nsAString& aCharset) = 0;
|
2004-09-09 21:32:35 +04:00
|
|
|
|
2006-12-18 06:59:46 +03:00
|
|
|
/**
|
|
|
|
* Tells this element to use a different base URI. This is used for
|
|
|
|
* proper loading of xml-stylesheet processing instructions in XUL overlays
|
|
|
|
* and is only currently used by nsXMLStylesheetPI.
|
|
|
|
*
|
2012-07-30 18:20:58 +04:00
|
|
|
* @param aNewBaseURI the new base URI, nullptr to use the default base URI.
|
2006-12-18 06:59:46 +03:00
|
|
|
*/
|
|
|
|
virtual void OverrideBaseURI(nsIURI* aNewBaseURI) = 0;
|
|
|
|
|
2004-09-09 21:32:35 +04:00
|
|
|
// This doesn't entirely belong here since they only make sense for
|
|
|
|
// some types of linking elements, but it's a better place than
|
|
|
|
// anywhere else.
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void SetLineNumber(uint32_t aLineNumber) = 0;
|
2015-08-18 01:19:21 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the line number, as previously set by SetLineNumber.
|
|
|
|
*
|
|
|
|
* @return the line number of this element; or 1 if no line number
|
|
|
|
* was set
|
|
|
|
*/
|
|
|
|
virtual uint32_t GetLineNumber() = 0;
|
1999-02-23 22:18:12 +03:00
|
|
|
};
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleSheetLinkingElement,
|
|
|
|
NS_ISTYLESHEETLINKINGELEMENT_IID)
|
|
|
|
|
1999-02-23 22:18:12 +03:00
|
|
|
#endif // nsILinkingElement_h__
|