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: */
|
2014-04-12 12:15:59 +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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_StyleSheetList_h
|
|
|
|
#define mozilla_dom_StyleSheetList_h
|
|
|
|
|
2018-04-13 21:04:47 +03:00
|
|
|
#include "nsContentUtils.h"
|
2017-12-21 01:29:21 +03:00
|
|
|
#include "mozilla/dom/DocumentOrShadowRoot.h"
|
2018-01-11 11:17:56 +03:00
|
|
|
#include "nsStubMutationObserver.h"
|
2014-04-12 12:18:54 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2014-04-12 12:15:59 +04:00
|
|
|
|
2014-04-12 12:18:54 +04:00
|
|
|
class nsINode;
|
2014-04-12 12:15:59 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2016-10-14 14:25:38 +03:00
|
|
|
class StyleSheet;
|
2014-06-20 14:32:49 +04:00
|
|
|
|
2014-04-12 12:15:59 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2018-01-11 11:17:56 +03:00
|
|
|
class StyleSheetList final : public nsStubMutationObserver,
|
2017-12-18 00:29:10 +03:00
|
|
|
public nsWrapperCache {
|
2014-04-12 12:15:59 +04:00
|
|
|
public:
|
2014-04-12 12:18:54 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2018-01-11 11:17:56 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheetList)
|
2014-04-12 12:18:54 +04:00
|
|
|
|
2017-12-18 00:29:10 +03:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
|
|
|
|
2017-12-21 01:29:21 +03:00
|
|
|
explicit StyleSheetList(DocumentOrShadowRoot& aScope);
|
2017-12-18 00:29:10 +03:00
|
|
|
|
2018-02-09 08:22:43 +03:00
|
|
|
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
|
2014-04-12 12:18:54 +04:00
|
|
|
|
2017-12-18 00:29:10 +03:00
|
|
|
nsINode* GetParentObject() const {
|
2017-12-21 01:29:21 +03:00
|
|
|
return mDocumentOrShadowRoot ? &mDocumentOrShadowRoot->AsNode() : nullptr;
|
2017-12-18 00:29:10 +03:00
|
|
|
}
|
2014-04-12 12:18:54 +04:00
|
|
|
|
2017-12-18 00:29:10 +03:00
|
|
|
uint32_t Length() const {
|
2017-12-21 01:29:21 +03:00
|
|
|
return mDocumentOrShadowRoot ? mDocumentOrShadowRoot->SheetCount() : 0;
|
2017-12-18 00:29:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) const {
|
2017-12-21 01:29:21 +03:00
|
|
|
if (!mDocumentOrShadowRoot) {
|
2017-12-18 00:29:10 +03:00
|
|
|
aFound = false;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-12-21 01:29:21 +03:00
|
|
|
StyleSheet* sheet = mDocumentOrShadowRoot->SheetAt(aIndex);
|
2017-12-18 00:29:10 +03:00
|
|
|
aFound = !!sheet;
|
|
|
|
return sheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
StyleSheet* Item(uint32_t aIndex) const {
|
2014-04-12 12:18:54 +04:00
|
|
|
bool dummy = false;
|
|
|
|
return IndexedGetter(aIndex, dummy);
|
|
|
|
}
|
2014-06-25 06:09:15 +04:00
|
|
|
|
|
|
|
protected:
|
2017-12-18 00:29:10 +03:00
|
|
|
virtual ~StyleSheetList();
|
|
|
|
|
2017-12-21 01:29:21 +03:00
|
|
|
DocumentOrShadowRoot*
|
|
|
|
mDocumentOrShadowRoot; // Weak, cleared on "NodeWillBeDestroyed".
|
2014-04-12 12:15:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_StyleSheetList_h
|