Bug 1292432 part 9 - Change WebIDL interface of CSSStyleSheet to StyleSheet. r=heycam

MozReview-Commit-ID: 5AXhsuvvrwe

--HG--
extra : source : 218d4c72938f74f16af22239a99fbdf0e4c621cf
This commit is contained in:
Xidorn Quan 2016-10-14 22:25:38 +11:00
Родитель 541b51df00
Коммит ea2d289c2c
14 изменённых файлов: 52 добавлений и 106 удалений

Просмотреть файл

@ -745,23 +745,14 @@ ShadowRootStyleSheetList::~ShadowRootStyleSheetList()
MOZ_COUNT_DTOR(ShadowRootStyleSheetList);
}
CSSStyleSheet*
StyleSheet*
ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = aIndex < mShadowRoot->mProtoBinding->SheetCount();
if (!aFound) {
return nullptr;
}
// XXXheycam Return null until ServoStyleSheet implements the right
// DOM interfaces.
StyleSheet* sheet = mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
if (sheet->IsServo()) {
NS_ERROR("stylo: can't return ServoStyleSheets to script yet");
return nullptr;
}
return sheet->AsGecko();
return mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
}
uint32_t

Просмотреть файл

@ -202,8 +202,8 @@ public:
return mShadowRoot;
}
virtual uint32_t Length() override;
virtual CSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) override;
uint32_t Length() override;
StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) override;
protected:
virtual ~ShadowRootStyleSheetList();

Просмотреть файл

@ -13,7 +13,7 @@
class nsINode;
namespace mozilla {
class CSSStyleSheet;
class StyleSheet;
namespace dom {
@ -30,8 +30,8 @@ public:
virtual nsINode* GetParentObject() const = 0;
virtual uint32_t Length() = 0;
virtual CSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
CSSStyleSheet* Item(uint32_t aIndex)
virtual StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
StyleSheet* Item(uint32_t aIndex)
{
bool dummy = false;
return IndexedGetter(aIndex, dummy);

Просмотреть файл

@ -592,25 +592,15 @@ nsDOMStyleSheetList::Length()
return mLength;
}
CSSStyleSheet*
StyleSheet*
nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
{
if (!mDocument || aIndex >= (uint32_t)mDocument->GetNumberOfStyleSheets()) {
aFound = false;
return nullptr;
}
aFound = true;
StyleSheet* sheet = mDocument->GetStyleSheetAt(aIndex);
NS_ASSERTION(sheet, "Must have a sheet");
// XXXheycam Return null until ServoStyleSheet implements the right DOM
// interfaces.
if (sheet->IsServo()) {
NS_ERROR("stylo: can't return a ServoStyleSheet to the DOM yet");
return nullptr;
}
return sheet->AsGecko();
return mDocument->GetStyleSheetAt(aIndex);
}
void

Просмотреть файл

@ -306,9 +306,8 @@ public:
return mDocument;
}
virtual uint32_t Length() override;
virtual mozilla::CSSStyleSheet*
IndexedGetter(uint32_t aIndex, bool& aFound) override;
uint32_t Length() override;
mozilla::StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) override;
protected:
virtual ~nsDOMStyleSheetList();

Просмотреть файл

@ -308,7 +308,7 @@ DOMInterfaces = {
},
'CSSStyleSheet': {
'nativeType': 'mozilla::CSSStyleSheet',
'nativeType': 'mozilla::StyleSheet',
'binaryNames': { 'ownerRule': 'DOMOwnerRule' },
},
@ -927,7 +927,8 @@ DOMInterfaces = {
},
'StyleSheet': {
'nativeType': 'mozilla::CSSStyleSheet',
'nativeType': 'mozilla::StyleSheet',
'headerFile': 'mozilla/StyleSheetInlines.h',
},
'SVGAnimatedLengthList': {

Просмотреть файл

@ -98,7 +98,7 @@ inCSSValueSearch::SearchSync()
uint32_t length = sheets->Length();
for (uint32_t i = 0; i < length; ++i) {
RefPtr<CSSStyleSheet> sheet = sheets->Item(i);
RefPtr<StyleSheet> sheet = sheets->Item(i);
SearchStyleSheet(sheet, baseURI);
}

Просмотреть файл

@ -1242,20 +1242,16 @@ CSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb)
}
// QueryInterface implementation for CSSStyleSheet
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSStyleSheet)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CSSStyleSheet)
NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCSSStyleSheet)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, StyleSheet)
if (aIID.Equals(NS_GET_IID(CSSStyleSheet)))
foundInterface = reinterpret_cast<nsISupports*>(this);
else
NS_INTERFACE_MAP_END
NS_INTERFACE_MAP_END_INHERITING(StyleSheet)
NS_IMPL_CYCLE_COLLECTING_ADDREF(CSSStyleSheet)
NS_IMPL_CYCLE_COLLECTING_RELEASE(CSSStyleSheet)
NS_IMPL_ADDREF_INHERITED(CSSStyleSheet, StyleSheet)
NS_IMPL_RELEASE_INHERITED(CSSStyleSheet, StyleSheet)
NS_IMPL_CYCLE_COLLECTION_CLASS(CSSStyleSheet)
@ -1268,18 +1264,15 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSStyleSheet)
tmp->DropRuleCollection();
tmp->UnlinkInner();
tmp->mScopeElement = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CSSStyleSheet)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(StyleSheet)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CSSStyleSheet, StyleSheet)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMedia)
// We do not traverse mNext; our parent will handle that. See
// comments in Unlink for why.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRuleCollection)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScopeElement)
tmp->TraverseInner(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(CSSStyleSheet)
nsresult
CSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor)
@ -2030,11 +2023,4 @@ CSSStyleSheet::ReparseSheet(const nsAString& aInput)
return NS_OK;
}
/* virtual */
JSObject*
CSSStyleSheet::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return CSSStyleSheetBinding::Wrap(aCx, this, aGivenProto);
}
} // namespace mozilla

Просмотреть файл

@ -25,7 +25,6 @@
#include "nsString.h"
#include "mozilla/CORSMode.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "mozilla/net/ReferrerPolicy.h"
#include "mozilla/dom/SRIMetadata.h"
@ -101,7 +100,6 @@ struct CSSStyleSheetInner : public StyleSheetInfo
class CSSStyleSheet final : public StyleSheet
, public nsICSSLoaderObserver
, public nsWrapperCache
{
public:
typedef net::ReferrerPolicy ReferrerPolicy;
@ -111,9 +109,8 @@ public:
CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy,
const dom::SRIMetadata& aIntegrity);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(CSSStyleSheet,
nsIDOMCSSStyleSheet)
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CSSStyleSheet, StyleSheet)
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_SHEET_IMPL_CID)
@ -217,9 +214,6 @@ public:
// version.
nsIDOMCSSRule* GetDOMOwnerRule() const final;
// WebIDL miscellaneous bits
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void WillDirty();
void DidDirty();

Просмотреть файл

@ -23,14 +23,6 @@ ServoStyleSheet::~ServoStyleSheet()
DropSheet();
}
NS_INTERFACE_MAP_BEGIN(ServoStyleSheet)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(ServoStyleSheet)
NS_IMPL_RELEASE(ServoStyleSheet)
bool
ServoStyleSheet::HasRules() const
{

Просмотреть файл

@ -27,8 +27,6 @@ public:
net::ReferrerPolicy aReferrerPolicy,
const dom::SRIMetadata& aIntegrity);
NS_DECL_ISUPPORTS
bool HasRules() const;
void SetOwningDocument(nsIDocument* aDocument);
@ -63,7 +61,7 @@ public:
void DidDirty() {}
protected:
~ServoStyleSheet();
virtual ~ServoStyleSheet();
// Internal methods which do not have security check and completeness check.
dom::CSSRuleList* GetCssRulesInternal(ErrorResult& aRv);

Просмотреть файл

@ -37,6 +37,18 @@ StyleSheet::StyleSheet(const StyleSheet& aCopy,
{
}
// QueryInterface implementation for StyleSheet
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheet)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(StyleSheet)
NS_IMPL_CYCLE_COLLECTING_RELEASE(StyleSheet)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(StyleSheet)
mozilla::dom::CSSStyleSheetParsingMode
StyleSheet::ParsingModeDOM()
{
@ -306,4 +318,12 @@ StyleSheet::AreRulesAvailable(nsIPrincipal& aSubjectPrincipal,
return true;
}
// nsWrapperCache
JSObject*
StyleSheet::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return CSSStyleSheetBinding::Wrap(aCx, this, aGivenProto);
}
} // namespace mozilla

Просмотреть файл

@ -15,6 +15,7 @@
#include "mozilla/ServoUtils.h"
#include "nsIDOMCSSStyleSheet.h"
#include "nsWrapperCache.h"
class nsIDocument;
class nsINode;
@ -36,14 +37,19 @@ class SRIMetadata;
* Superclass for data common to CSSStyleSheet and ServoStyleSheet.
*/
class StyleSheet : public nsIDOMCSSStyleSheet
, public nsWrapperCache
{
protected:
StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMode);
StyleSheet(const StyleSheet& aCopy,
nsIDocument* aDocumentToUse,
nsINode* aOwningNodeToUse);
virtual ~StyleSheet() {}
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheet)
void SetOwningNode(nsINode* aOwningNode)
{
mOwningNode = aOwningNode;
@ -63,9 +69,6 @@ public:
MOZ_DECL_STYLO_METHODS(CSSStyleSheet, ServoStyleSheet)
inline MozExternalRefCountType AddRef();
inline MozExternalRefCountType Release();
// Whether the sheet is for an inline <style> element.
inline bool IsInline() const;
@ -143,6 +146,7 @@ public:
// WebIDL miscellaneous bits
inline dom::ParentObject GetParentObject() const;
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
// nsIDOMStyleSheet interface
NS_IMETHOD GetType(nsAString& aType) final;

Просмотреть файл

@ -33,18 +33,6 @@ StyleSheet::SheetInfo() const
return *AsGecko()->mInner;
}
MozExternalRefCountType
StyleSheet::AddRef()
{
MOZ_STYLO_FORWARD(AddRef, ())
}
MozExternalRefCountType
StyleSheet::Release()
{
MOZ_STYLO_FORWARD(Release, ())
}
bool
StyleSheet::IsInline() const
{
@ -182,23 +170,6 @@ StyleSheet::List(FILE* aOut, int32_t aIndex) const
void StyleSheet::WillDirty() { MOZ_STYLO_FORWARD(WillDirty, ()) }
void StyleSheet::DidDirty() { MOZ_STYLO_FORWARD(DidDirty, ()) }
inline void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
RefPtr<StyleSheet>& aField,
const char* aName,
uint32_t aFlags = 0)
{
if (aField && aField->IsGecko()) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, aName);
aCallback.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, aField->AsGecko()));
}
}
inline void
ImplCycleCollectionUnlink(RefPtr<StyleSheet>& aField)
{
aField = nullptr;
}
}