summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 07:39:08 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 07:39:08 -0400
commit0f5b789157547128694bd41061f2e9631bc1061f (patch)
tree490f97520ce8f7f957f2ab1c3fd0e6aa9662c5cf
parentf605c68f1369935026e38ad2f535608f06d50d73 (diff)
downloadUXP-0f5b789157547128694bd41061f2e9631bc1061f.tar
UXP-0f5b789157547128694bd41061f2e9631bc1061f.tar.gz
UXP-0f5b789157547128694bd41061f2e9631bc1061f.tar.lz
UXP-0f5b789157547128694bd41061f2e9631bc1061f.tar.xz
UXP-0f5b789157547128694bd41061f2e9631bc1061f.zip
Bug 1348481 - Part 1b: Generalize FindDocStyleSheetInsertionPoint so it doesn't require an array of RefPtrs
Tag #1375
-rw-r--r--dom/base/nsIDocument.h6
-rw-r--r--dom/base/nsIDocumentInlines.h13
2 files changed, 10 insertions, 9 deletions
diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h
index 297a207fc..5ccb18f78 100644
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -1153,11 +1153,13 @@ public:
* sheets for this document, returns the index that aSheet should
* be inserted at to maintain document ordering.
*
+ * Type T has to cast to StyleSheet*.
+ *
* Defined in nsIDocumentInlines.h.
*/
template<typename T>
- size_t FindDocStyleSheetInsertionPoint(const nsTArray<RefPtr<T>>& aDocSheets,
- T* aSheet);
+ size_t FindDocStyleSheetInsertionPoint(const nsTArray<T>& aDocSheets,
+ mozilla::StyleSheet* aSheet);
/**
* Get this document's CSSLoader. This is guaranteed to not return null.
diff --git a/dom/base/nsIDocumentInlines.h b/dom/base/nsIDocumentInlines.h
index 4ba21dfe6..708a1ae91 100644
--- a/dom/base/nsIDocumentInlines.h
+++ b/dom/base/nsIDocumentInlines.h
@@ -19,8 +19,8 @@ nsIDocument::GetBodyElement()
template<typename T>
size_t
nsIDocument::FindDocStyleSheetInsertionPoint(
- const nsTArray<RefPtr<T>>& aDocSheets,
- T* aSheet)
+ const nsTArray<T>& aDocSheets,
+ mozilla::StyleSheet* aSheet)
{
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
@@ -30,13 +30,12 @@ nsIDocument::FindDocStyleSheetInsertionPoint(
int32_t count = aDocSheets.Length();
int32_t index;
for (index = 0; index < count; index++) {
- T* sheet = aDocSheets[index];
+ mozilla::StyleSheet* sheet = static_cast<mozilla::StyleSheet*>(
+ aDocSheets[index]);
int32_t sheetDocIndex = GetIndexOfStyleSheet(sheet);
if (sheetDocIndex > newDocIndex)
break;
- mozilla::StyleSheet* sheetHandle = sheet;
-
// If the sheet is not owned by the document it can be an author
// sheet registered at nsStyleSheetService or an additional author
// sheet on the document, which means the new
@@ -44,11 +43,11 @@ nsIDocument::FindDocStyleSheetInsertionPoint(
if (sheetDocIndex < 0) {
if (sheetService) {
auto& authorSheets = *sheetService->AuthorStyleSheets();
- if (authorSheets.IndexOf(sheetHandle) != authorSheets.NoIndex) {
+ if (authorSheets.IndexOf(sheet) != authorSheets.NoIndex) {
break;
}
}
- if (sheetHandle == GetFirstAdditionalAuthorSheet()) {
+ if (sheet == GetFirstAdditionalAuthorSheet()) {
break;
}
}