mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 01:08:21 +00:00
Bug 738196 - Part b: move StyleSheetList to WebIDL; r=bz
This commit is contained in:
parent
c060291f73
commit
165fd8f857
@ -112,6 +112,7 @@ class GlobalObject;
|
||||
class NodeFilter;
|
||||
class NodeIterator;
|
||||
class ProcessingInstruction;
|
||||
class StyleSheetList;
|
||||
class Touch;
|
||||
class TouchList;
|
||||
class TreeWalker;
|
||||
@ -2169,7 +2170,7 @@ public:
|
||||
WarnOnceAbout(ePrefixedVisibilityAPI);
|
||||
return VisibilityState();
|
||||
}
|
||||
virtual nsIDOMStyleSheetList* StyleSheets() = 0;
|
||||
virtual mozilla::dom::StyleSheetList* StyleSheets() = 0;
|
||||
void GetSelectedStyleSheetSet(nsAString& aSheetSet);
|
||||
virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) = 0;
|
||||
virtual void GetLastStyleSheetSet(nsString& aSheetSet) = 0;
|
||||
|
@ -484,7 +484,7 @@ ShadowRoot::SetApplyAuthorStyles(bool aApplyAuthorStyles)
|
||||
}
|
||||
}
|
||||
|
||||
nsIDOMStyleSheetList*
|
||||
StyleSheetList*
|
||||
ShadowRoot::StyleSheets()
|
||||
{
|
||||
if (!mStyleSheetList) {
|
||||
@ -655,16 +655,14 @@ ShadowRoot::ContentRemoved(nsIDocument* aDocument,
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_1(ShadowRootStyleSheetList, mShadowRoot)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(ShadowRootStyleSheetList, StyleSheetList,
|
||||
mShadowRoot)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(ShadowRootStyleSheetList)
|
||||
NS_INTERFACE_TABLE1(ShadowRootStyleSheetList, nsIDOMStyleSheetList)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(ShadowRootStyleSheetList)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StyleSheetList)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ShadowRootStyleSheetList)
|
||||
NS_INTERFACE_MAP_END_INHERITING(StyleSheetList)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ShadowRootStyleSheetList)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(ShadowRootStyleSheetList)
|
||||
NS_IMPL_ADDREF_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
|
||||
NS_IMPL_RELEASE_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
|
||||
|
||||
ShadowRootStyleSheetList::ShadowRootStyleSheetList(ShadowRoot* aShadowRoot)
|
||||
: mShadowRoot(aShadowRoot)
|
||||
@ -678,37 +676,30 @@ ShadowRootStyleSheetList::~ShadowRootStyleSheetList()
|
||||
}
|
||||
|
||||
nsCSSStyleSheet*
|
||||
ShadowRootStyleSheetList::GetItemAt(uint32_t aIndex)
|
||||
ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
nsTArray<nsRefPtr<nsCSSStyleSheet>>* sheets =
|
||||
mShadowRoot->mProtoBinding->GetStyleSheets();
|
||||
|
||||
if (!sheets) {
|
||||
aFound = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aFound = aIndex < sheets->Length();
|
||||
return sheets->SafeElementAt(aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ShadowRootStyleSheetList::Item(uint32_t aIndex, nsIDOMStyleSheet** aReturn)
|
||||
{
|
||||
NS_IF_ADDREF(*aReturn = GetItemAt(aIndex));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ShadowRootStyleSheetList::GetLength(uint32_t* aLength)
|
||||
uint32_t
|
||||
ShadowRootStyleSheetList::Length()
|
||||
{
|
||||
nsTArray<nsRefPtr<nsCSSStyleSheet> >* sheets =
|
||||
mShadowRoot->mProtoBinding->GetStyleSheets();
|
||||
|
||||
if (sheets) {
|
||||
*aLength = sheets->Length();
|
||||
} else {
|
||||
*aLength = 0;
|
||||
if (!sheets) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return sheets->Length();
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
void RemoveSheet(nsCSSStyleSheet* aSheet);
|
||||
bool ApplyAuthorStyles();
|
||||
void SetApplyAuthorStyles(bool aApplyAuthorStyles);
|
||||
nsIDOMStyleSheetList* StyleSheets();
|
||||
StyleSheetList* StyleSheets();
|
||||
HTMLShadowElement* GetShadowElement() { return mShadowElement; }
|
||||
|
||||
/**
|
||||
@ -176,13 +176,16 @@ public:
|
||||
ShadowRootStyleSheetList(ShadowRoot* aShadowRoot);
|
||||
virtual ~ShadowRootStyleSheetList();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(ShadowRootStyleSheetList)
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
|
||||
|
||||
// nsIDOMStyleSheetList
|
||||
NS_DECL_NSIDOMSTYLESHEETLIST
|
||||
virtual nsINode* GetParentObject() const MOZ_OVERRIDE
|
||||
{
|
||||
return mShadowRoot;
|
||||
}
|
||||
|
||||
virtual nsCSSStyleSheet* GetItemAt(uint32_t aIndex) MOZ_OVERRIDE;
|
||||
virtual uint32_t Length() MOZ_OVERRIDE;
|
||||
virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
nsRefPtr<ShadowRoot> mShadowRoot;
|
||||
|
46
content/base/src/StyleSheetList.cpp
Normal file
46
content/base/src/StyleSheetList.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
|
||||
#include "mozilla/dom/StyleSheetListBinding.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(StyleSheetList)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheetList)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheetList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(StyleSheetList)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(StyleSheetList)
|
||||
|
||||
/* virtual */ JSObject*
|
||||
StyleSheetList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return StyleSheetListBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StyleSheetList::GetLength(uint32_t* aLength)
|
||||
{
|
||||
*aLength = Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StyleSheetList::SlowItem(uint32_t aIndex, nsIDOMStyleSheet** aItem)
|
||||
{
|
||||
NS_IF_ADDREF(*aItem = Item(aIndex));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -7,32 +7,40 @@
|
||||
#define mozilla_dom_StyleSheetList_h
|
||||
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsCSSStyleSheet;
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class StyleSheetList : public nsIDOMStyleSheetList
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
static StyleSheetList* FromSupports(nsISupports* aSupports)
|
||||
StyleSheetList()
|
||||
{
|
||||
nsIDOMStyleSheetList* list = static_cast<nsIDOMStyleSheetList*>(aSupports);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIDOMStyleSheetList> list_qi = do_QueryInterface(aSupports);
|
||||
|
||||
// If this assertion fires the QI implementation for the object in
|
||||
// question doesn't use the nsIDOMStyleSheetList pointer as the
|
||||
// nsISupports pointer. That must be fixed, or we'll crash...
|
||||
MOZ_ASSERT(list_qi == list, "Uh, fix QI!");
|
||||
}
|
||||
#endif
|
||||
return static_cast<StyleSheetList*>(list);
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
virtual ~StyleSheetList() {}
|
||||
|
||||
virtual nsCSSStyleSheet* GetItemAt(uint32_t aIndex) = 0;
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheetList)
|
||||
NS_DECL_NSIDOMSTYLESHEETLIST
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE MOZ_FINAL;
|
||||
|
||||
virtual nsINode* GetParentObject() const = 0;
|
||||
|
||||
virtual uint32_t Length() = 0;
|
||||
virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
|
||||
nsCSSStyleSheet* Item(uint32_t aIndex)
|
||||
{
|
||||
bool dummy = false;
|
||||
return IndexedGetter(aIndex, dummy);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -162,6 +162,7 @@ UNIFIED_SOURCES += [
|
||||
'nsXMLHttpRequest.cpp',
|
||||
'nsXMLNameSpaceMap.cpp',
|
||||
'ShadowRoot.cpp',
|
||||
'StyleSheetList.cpp',
|
||||
'Text.cpp',
|
||||
'ThirdPartyUtil.cpp',
|
||||
'TreeWalker.cpp',
|
||||
|
@ -723,78 +723,50 @@ nsDOMStyleSheetList::~nsDOMStyleSheetList()
|
||||
}
|
||||
}
|
||||
|
||||
DOMCI_DATA(StyleSheetList, nsDOMStyleSheetList)
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsDOMStyleSheetList, StyleSheetList,
|
||||
nsIDocumentObserver,
|
||||
nsIMutationObserver)
|
||||
|
||||
// XXX couldn't we use the GetIIDs method from CSSStyleSheetList here?
|
||||
// QueryInterface implementation for nsDOMStyleSheetList
|
||||
NS_INTERFACE_TABLE_HEAD(nsDOMStyleSheetList)
|
||||
NS_INTERFACE_TABLE3(nsDOMStyleSheetList,
|
||||
nsIDOMStyleSheetList,
|
||||
nsIDocumentObserver,
|
||||
nsIMutationObserver)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StyleSheetList)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMStyleSheetList)
|
||||
NS_IMPL_RELEASE(nsDOMStyleSheetList)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMStyleSheetList::GetLength(uint32_t* aLength)
|
||||
uint32_t
|
||||
nsDOMStyleSheetList::Length()
|
||||
{
|
||||
if (mDocument) {
|
||||
// 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();
|
||||
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();
|
||||
|
||||
#ifdef DEBUG
|
||||
int32_t i;
|
||||
for (i = 0; i < mLength; i++) {
|
||||
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i);
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
|
||||
NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
|
||||
}
|
||||
#endif
|
||||
int32_t i;
|
||||
for (i = 0; i < mLength; i++) {
|
||||
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i);
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
|
||||
NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
|
||||
}
|
||||
*aLength = mLength;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
*aLength = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return mLength;
|
||||
}
|
||||
|
||||
nsCSSStyleSheet*
|
||||
nsDOMStyleSheetList::GetItemAt(uint32_t aIndex)
|
||||
nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
if (!mDocument || aIndex >= (uint32_t)mDocument->GetNumberOfStyleSheets()) {
|
||||
aFound = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aFound = true;
|
||||
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(aIndex);
|
||||
NS_ASSERTION(sheet, "Must have a sheet");
|
||||
|
||||
return static_cast<nsCSSStyleSheet*>(sheet);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMStyleSheetList::Item(uint32_t aIndex, nsIDOMStyleSheet** aReturn)
|
||||
{
|
||||
nsIStyleSheet *sheet = GetItemAt(aIndex);
|
||||
if (!sheet) {
|
||||
*aReturn = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(sheet, aReturn);
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
|
||||
{
|
||||
@ -6092,7 +6064,7 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetList** aStyleSheets)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMStyleSheetList*
|
||||
StyleSheetList*
|
||||
nsDocument::StyleSheets()
|
||||
{
|
||||
if (!mDOMStyleSheets) {
|
||||
|
@ -442,9 +442,7 @@ public:
|
||||
nsDOMStyleSheetList(nsIDocument *aDocument);
|
||||
virtual ~nsDOMStyleSheetList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIDOMSTYLESHEETLIST
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDocumentObserver
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED
|
||||
@ -453,7 +451,13 @@ public:
|
||||
// nsIMutationObserver
|
||||
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
||||
|
||||
virtual nsCSSStyleSheet* GetItemAt(uint32_t aIndex) MOZ_OVERRIDE;
|
||||
virtual nsINode* GetParentObject() const MOZ_OVERRIDE
|
||||
{
|
||||
return mDocument;
|
||||
}
|
||||
|
||||
virtual uint32_t Length() MOZ_OVERRIDE;
|
||||
virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
int32_t mLength;
|
||||
@ -1224,7 +1228,7 @@ public:
|
||||
RegisterElement(JSContext* aCx, const nsAString& aName,
|
||||
const mozilla::dom::ElementRegistrationOptions& aOptions,
|
||||
mozilla::ErrorResult& rv) MOZ_OVERRIDE;
|
||||
virtual nsIDOMStyleSheetList* StyleSheets() MOZ_OVERRIDE;
|
||||
virtual mozilla::dom::StyleSheetList* StyleSheets() MOZ_OVERRIDE;
|
||||
virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) MOZ_OVERRIDE;
|
||||
virtual void GetLastStyleSheetSet(nsString& aSheetSet) MOZ_OVERRIDE;
|
||||
virtual mozilla::dom::DOMStringList* StyleSheetSets() MOZ_OVERRIDE;
|
||||
@ -1429,7 +1433,7 @@ public:
|
||||
nsRefPtr<mozilla::dom::Registry> mRegistry;
|
||||
|
||||
nsRefPtr<mozilla::EventListenerManager> mListenerManager;
|
||||
nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
|
||||
nsRefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
|
||||
nsRefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
|
||||
nsRefPtr<nsScriptLoader> mScriptLoader;
|
||||
nsDocHeaderData* mHeaderData;
|
||||
|
@ -85,7 +85,6 @@
|
||||
|
||||
// CSS related includes
|
||||
#include "nsCSSRules.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIDOMCSSRule.h"
|
||||
#include "nsICSSRuleList.h"
|
||||
#include "nsAutoPtr.h"
|
||||
@ -319,8 +318,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSRuleList, nsCSSRuleListSH,
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(StyleSheetList, nsStyleSheetListSH,
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSStyleSheet, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
@ -948,10 +945,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(StyleSheetList, nsIDOMStyleSheetList)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStyleSheetList)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CSSStyleSheet, nsIDOMCSSStyleSheet)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleSheet)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
@ -3680,18 +3673,6 @@ nsArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
}
|
||||
|
||||
|
||||
// StyleSheetList helper
|
||||
|
||||
nsISupports*
|
||||
nsStyleSheetListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
|
||||
nsWrapperCache **aCache, nsresult *rv)
|
||||
{
|
||||
StyleSheetList* list = StyleSheetList::FromSupports(aNative);
|
||||
nsIDOMStyleSheet* item = list->GetItemAt(aIndex);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
// CSSRuleList scriptable helper
|
||||
|
||||
nsISupports*
|
||||
|
@ -368,30 +368,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// StyleSheetList helper
|
||||
|
||||
class nsStyleSheetListSH : public nsArraySH
|
||||
{
|
||||
protected:
|
||||
nsStyleSheetListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsStyleSheetListSH()
|
||||
{
|
||||
}
|
||||
|
||||
virtual nsISupports* GetItemAt(nsISupports *aNative, uint32_t aIndex,
|
||||
nsWrapperCache **aCache, nsresult *aResult) MOZ_OVERRIDE;
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsStyleSheetListSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// CSSRuleList helper
|
||||
|
||||
class nsCSSRuleListSH : public nsArraySH
|
||||
|
@ -16,7 +16,6 @@ DOMCI_CLASS(CSSImportRule)
|
||||
DOMCI_CLASS(CSSMediaRule)
|
||||
DOMCI_CLASS(CSSNameSpaceRule)
|
||||
DOMCI_CLASS(CSSRuleList)
|
||||
DOMCI_CLASS(StyleSheetList)
|
||||
DOMCI_CLASS(CSSStyleSheet)
|
||||
|
||||
// XUL classes
|
||||
|
@ -1905,7 +1905,6 @@ addExternalIface('Principal', nativeType='nsIPrincipal',
|
||||
headerFile='nsIPrincipal.h', notflattened=True)
|
||||
addExternalIface('StackFrame', nativeType='nsIStackFrame',
|
||||
headerFile='nsIException.h', notflattened=True)
|
||||
addExternalIface('StyleSheetList')
|
||||
addExternalIface('SVGLength')
|
||||
addExternalIface('SVGNumber')
|
||||
addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h',
|
||||
|
@ -17,5 +17,6 @@
|
||||
interface nsIDOMStyleSheetList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long length;
|
||||
[binaryname(SlowItem)]
|
||||
nsIDOMStyleSheet item(in unsigned long index);
|
||||
};
|
||||
|
@ -15,7 +15,6 @@
|
||||
* http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl
|
||||
*/
|
||||
|
||||
interface StyleSheetList;
|
||||
interface WindowProxy;
|
||||
interface nsISupports;
|
||||
interface URI;
|
||||
|
8
dom/webidl/StyleSheetList.webidl
Normal file
8
dom/webidl/StyleSheetList.webidl
Normal file
@ -0,0 +1,8 @@
|
||||
/* 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/. */
|
||||
|
||||
interface StyleSheetList {
|
||||
readonly attribute unsigned long length;
|
||||
getter StyleSheet? item(unsigned long index);
|
||||
};
|
@ -303,6 +303,7 @@ WEBIDL_FILES = [
|
||||
'SourceBufferList.webidl',
|
||||
'StorageType.webidl',
|
||||
'StyleSheet.webidl',
|
||||
'StyleSheetList.webidl',
|
||||
'SVGAElement.webidl',
|
||||
'SVGAltGlyphElement.webidl',
|
||||
'SVGAngle.webidl',
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "inCSSValueSearch.h"
|
||||
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsVoidArray.h"
|
||||
@ -21,6 +23,8 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inCSSValueSearch::inCSSValueSearch()
|
||||
: mResults(nullptr),
|
||||
@ -85,24 +89,18 @@ inCSSValueSearch::SearchSync()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIDocument> idoc = do_QueryInterface(mDocument);
|
||||
if (idoc) {
|
||||
baseURI = idoc->GetBaseURI();
|
||||
}
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(mDocument);
|
||||
MOZ_ASSERT(document);
|
||||
|
||||
nsCOMPtr<nsIDOMStyleSheetList> sheets;
|
||||
nsresult rv = mDocument->GetStyleSheets(getter_AddRefs(sheets));
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
nsCOMPtr<nsIURI> baseURI = document->GetBaseURI();
|
||||
|
||||
uint32_t length;
|
||||
sheets->GetLength(&length);
|
||||
nsRefPtr<dom::StyleSheetList> sheets = document->StyleSheets();
|
||||
MOZ_ASSERT(sheets);
|
||||
|
||||
uint32_t length = sheets->Length();
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsCOMPtr<nsIDOMStyleSheet> sheet;
|
||||
sheets->Item(i, getter_AddRefs(sheet));
|
||||
nsCOMPtr<nsIDOMCSSStyleSheet> cssSheet = do_QueryInterface(sheet);
|
||||
if (cssSheet)
|
||||
SearchStyleSheet(cssSheet, baseURI);
|
||||
nsRefPtr<nsCSSStyleSheet> sheet = sheets->Item(i);
|
||||
SearchStyleSheet(sheet, baseURI);
|
||||
}
|
||||
|
||||
// XXX would be nice to search inline style as well.
|
||||
|
Loading…
x
Reference in New Issue
Block a user