Bug 1425769 - Base class for ShadowRoot and Document to manage style state

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 07:42:07 -04:00 committed by Roy Tam
commit b8260c664a
16 changed files with 250 additions and 296 deletions

View file

@ -34,6 +34,7 @@
#include "prclist.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/CORSMode.h"
#include "mozilla/dom/StyleScope.h"
#include "mozilla/LinkedList.h"
#include "mozilla/StyleBackendType.h"
#include "mozilla/StyleSheet.h"
@ -196,7 +197,8 @@ class nsContentList;
// Document interface. This is implemented by all document objects in
// Gecko.
class nsIDocument : public nsINode
class nsIDocument : public nsINode,
public mozilla::dom::StyleScope
{
typedef mozilla::dom::GlobalObject GlobalObject;
@ -1069,40 +1071,24 @@ public:
*/
virtual void EnsureOnDemandBuiltInUASheet(mozilla::StyleSheet* aSheet) = 0;
/**
* Get the number of (document) stylesheets
*
* @return the number of stylesheets
* @throws no exceptions
*/
virtual int32_t GetNumberOfStyleSheets() const = 0;
nsINode& AsNode() final
{
return *this;
}
/**
* Get a particular stylesheet
* @param aIndex the index the stylesheet lives at. This is zero-based
* @return the stylesheet at aIndex. Null if aIndex is out of range.
* @throws no exceptions
*/
virtual mozilla::StyleSheet* GetStyleSheetAt(int32_t aIndex) const = 0;
mozilla::dom::StyleSheetList* StyleSheets()
{
return &StyleScope::EnsureDOMStyleSheets();
}
/**
* Insert a sheet at a particular spot in the stylesheet list (zero-based)
* @param aSheet the sheet to insert
* @param aIndex the index to insert at. This index will be
* adjusted for the "special" sheets.
* @param aIndex the index to insert at.
* @throws no exceptions
*/
virtual void InsertStyleSheetAt(mozilla::StyleSheet* aSheet,
int32_t aIndex) = 0;
/**
* Get the index of a particular stylesheet. This will _always_
* consider the "special" sheets as part of the sheet list.
* @param aSheet the sheet to get the index of
* @return aIndex the index of the sheet in the full list
*/
virtual int32_t GetIndexOfStyleSheet(
const mozilla::StyleSheet* aSheet) const = 0;
size_t aIndex) = 0;
/**
* Replace the stylesheets in aOldSheets with the stylesheets in
@ -1159,7 +1145,7 @@ public:
*/
template<typename T>
size_t FindDocStyleSheetInsertionPoint(const nsTArray<T>& aDocSheets,
mozilla::StyleSheet* aSheet);
const mozilla::StyleSheet& aSheet);
/**
* Get this document's CSSLoader. This is guaranteed to not return null.
@ -2699,7 +2685,6 @@ public:
return mVisibilityState;
}
#endif
virtual mozilla::dom::StyleSheetList* StyleSheets() = 0;
void GetSelectedStyleSheetSet(nsAString& aSheetSet);
virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) = 0;
virtual void GetLastStyleSheetSet(nsString& aSheetSet) = 0;