summaryrefslogtreecommitdiffstats
path: root/dom/base/nsDocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/nsDocument.cpp')
-rw-r--r--dom/base/nsDocument.cpp127
1 files changed, 14 insertions, 113 deletions
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index d2763eddd..745d170f1 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -570,78 +570,6 @@ struct nsRadioGroupStruct
bool mGroupSuffersFromValueMissing;
};
-
-nsDOMStyleSheetList::nsDOMStyleSheetList(nsIDocument *aDocument)
-{
- mLength = -1;
- // Not reference counted to avoid circular references.
- // The document will tell us when its going away.
- mDocument = aDocument;
- mDocument->AddObserver(this);
-}
-
-nsDOMStyleSheetList::~nsDOMStyleSheetList()
-{
- if (mDocument) {
- mDocument->RemoveObserver(this);
- }
-}
-
-NS_IMPL_ISUPPORTS_INHERITED(nsDOMStyleSheetList, StyleSheetList,
- nsIDocumentObserver,
- nsIMutationObserver)
-
-uint32_t
-nsDOMStyleSheetList::Length()
-{
- if (!mDocument) {
- return 0;
- }
-
- // XXX Find the number and then cache it. We'll use the
- // observer notification to figure out if new ones have
- // been added or removed.
- if (-1 == mLength) {
- mLength = mDocument->GetNumberOfStyleSheets();
- }
- return mLength;
-}
-
-StyleSheet*
-nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
-{
- if (!mDocument || aIndex >= (uint32_t)mDocument->GetNumberOfStyleSheets()) {
- aFound = false;
- return nullptr;
- }
- aFound = true;
- return mDocument->GetStyleSheetAt(aIndex);
-}
-
-void
-nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
-{
- mDocument = nullptr;
-}
-
-void
-nsDOMStyleSheetList::StyleSheetAdded(StyleSheet* aStyleSheet,
- bool aDocumentSheet)
-{
- if (aDocumentSheet && -1 != mLength) {
- mLength++;
- }
-}
-
-void
-nsDOMStyleSheetList::StyleSheetRemoved(StyleSheet* aStyleSheet,
- bool aDocumentSheet)
-{
- if (aDocumentSheet && -1 != mLength) {
- mLength--;
- }
-}
-
// nsOnloadBlocker implementation
NS_IMPL_ISUPPORTS(nsOnloadBlocker, nsIRequest)
@@ -1199,10 +1127,10 @@ nsDOMStyleSheetSetList::EnsureFresh()
// no document, for sure
}
- int32_t count = mDocument->GetNumberOfStyleSheets();
+ size_t count = mDocument->SheetCount();
nsAutoString title;
- for (int32_t index = 0; index < count; index++) {
- StyleSheet* sheet = mDocument->GetStyleSheetAt(index);
+ for (size_t index = 0; index < count; index++) {
+ StyleSheet* sheet = mDocument->SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam ServoStyleSheets don't expose their title yet.
if (sheet->IsServo()) {
@@ -3930,24 +3858,6 @@ nsDocument::AddOnDemandBuiltInUASheet(StyleSheet* aSheet)
NotifyStyleSheetAdded(aSheet, false);
}
-int32_t
-nsDocument::GetNumberOfStyleSheets() const
-{
- return mStyleSheets.Length();
-}
-
-StyleSheet*
-nsDocument::GetStyleSheetAt(int32_t aIndex) const
-{
- return mStyleSheets.SafeElementAt(aIndex, nullptr);
-}
-
-int32_t
-nsDocument::GetIndexOfStyleSheet(const StyleSheet* aSheet) const
-{
- return mStyleSheets.IndexOf(aSheet);
-}
-
void
nsDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
{
@@ -4088,9 +3998,9 @@ nsDocument::UpdateStyleSheets(nsTArray<RefPtr<StyleSheet>>& aOldSheets,
}
void
-nsDocument::InsertStyleSheetAt(StyleSheet* aSheet, int32_t aIndex)
+nsDocument::InsertStyleSheetAt(StyleSheet* aSheet, size_t aIndex)
{
- NS_PRECONDITION(aSheet, "null ptr");
+ MOZ_ASSERT(aSheet);
mStyleSheets.InsertElementAt(aIndex, aSheet);
@@ -5815,15 +5725,6 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetList** aStyleSheets)
return NS_OK;
}
-StyleSheetList*
-nsDocument::StyleSheets()
-{
- if (!mDOMStyleSheets) {
- mDOMStyleSheets = new nsDOMStyleSheetList(this);
- }
- return mDOMStyleSheets;
-}
-
NS_IMETHODIMP
nsDocument::GetMozSelectedStyleSheetSet(nsAString& aSheetSet)
{
@@ -5837,10 +5738,10 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
aSheetSet.Truncate();
// Look through our sheets, find the selected set title
- int32_t count = GetNumberOfStyleSheets();
+ size_t count = SheetCount();
nsAutoString title;
- for (int32_t index = 0; index < count; index++) {
- StyleSheet* sheet = GetStyleSheetAt(index);
+ for (size_t index = 0; index < count; index++) {
+ StyleSheet* sheet = SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam Make this work with ServoStyleSheets.
@@ -5957,10 +5858,10 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
bool aUpdateCSSLoader)
{
BeginUpdate(UPDATE_STYLE);
- int32_t count = GetNumberOfStyleSheets();
+ size_t count = SheetCount();
nsAutoString title;
- for (int32_t index = 0; index < count; index++) {
- StyleSheet* sheet = GetStyleSheetAt(index);
+ for (size_t index = 0; index < count; index++) {
+ StyleSheet* sheet = SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam Make this work with ServoStyleSheets.
@@ -9668,9 +9569,9 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
clonedDoc->mOriginalDocument->mStaticCloneCount++;
- int32_t sheetsCount = GetNumberOfStyleSheets();
- for (int32_t i = 0; i < sheetsCount; ++i) {
- RefPtr<StyleSheet> sheet = GetStyleSheetAt(i);
+ size_t sheetsCount = SheetCount();
+ for (size_t i = 0; i < sheetsCount; ++i) {
+ RefPtr<StyleSheet> sheet = SheetAt(i);
if (sheet) {
if (sheet->IsApplicable()) {
// XXXheycam Need to make ServoStyleSheet cloning work.