зеркало из https://github.com/mozilla/gecko-dev.git
Bug 882573 patch 4: Make nsHTMLStyleSheet and nsHTMLCSSStyleSheet stop implementing nsIStyleSheet. r=heycam
Note that this removes the Reset method and the mURL and mDocument members (and arguments to set them) from nsHTMLCSSStyleSheet. On the other hand, from nsHTMLStyleSheet it only removes mURL (and equivalent arguments), and nsHTMLStyleSheet keeps the SetOwningDocument method that was previously part of nsIStyleSheet (but no longer virtual).
This commit is contained in:
Родитель
f753ac02c0
Коммит
d8bcb54fbd
|
@ -1478,8 +1478,6 @@ nsDocument::~nsDocument()
|
|||
if (mAttrStyleSheet) {
|
||||
mAttrStyleSheet->SetOwningDocument(nullptr);
|
||||
}
|
||||
if (mStyleAttrStyleSheet)
|
||||
mStyleAttrStyleSheet->SetOwningDocument(nullptr);
|
||||
|
||||
if (mListenerManager) {
|
||||
mListenerManager->Disconnect();
|
||||
|
@ -2234,25 +2232,16 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
|||
|
||||
// Now reset our inline style and attribute sheets.
|
||||
if (mAttrStyleSheet) {
|
||||
mAttrStyleSheet->Reset(aURI);
|
||||
mAttrStyleSheet->Reset();
|
||||
mAttrStyleSheet->SetOwningDocument(this);
|
||||
} else {
|
||||
mAttrStyleSheet = new nsHTMLStyleSheet(aURI, this);
|
||||
mAttrStyleSheet = new nsHTMLStyleSheet(this);
|
||||
}
|
||||
|
||||
// Don't use AddStyleSheet, since it'll put the sheet into style
|
||||
// sets in the document level, which is not desirable here.
|
||||
mAttrStyleSheet->SetOwningDocument(this);
|
||||
|
||||
if (mStyleAttrStyleSheet) {
|
||||
mStyleAttrStyleSheet->Reset(aURI);
|
||||
} else {
|
||||
mStyleAttrStyleSheet = new nsHTMLCSSStyleSheet(aURI, this);
|
||||
if (!mStyleAttrStyleSheet) {
|
||||
mStyleAttrStyleSheet = new nsHTMLCSSStyleSheet();
|
||||
}
|
||||
|
||||
// The loop over style sets below will handle putting this sheet
|
||||
// into style sets as needed.
|
||||
mStyleAttrStyleSheet->SetOwningDocument(this);
|
||||
|
||||
// Now set up our style sets
|
||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||
if (shell) {
|
||||
|
|
|
@ -39,12 +39,8 @@ ClearAttrCache(const nsAString& aKey, MiscContainer*& aValue, void*)
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet(nsIURI* aURL, nsIDocument* aDocument)
|
||||
: mURL(aURL)
|
||||
, mDocument(aDocument) // not refcounted!
|
||||
nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet()
|
||||
{
|
||||
MOZ_ASSERT(aURL);
|
||||
MOZ_ASSERT(aDocument);
|
||||
mCachedStyleAttrs.Init();
|
||||
}
|
||||
|
||||
|
@ -55,9 +51,7 @@ nsHTMLCSSStyleSheet::~nsHTMLCSSStyleSheet()
|
|||
mCachedStyleAttrs.Enumerate(ClearAttrCache, nullptr);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsHTMLCSSStyleSheet,
|
||||
nsIStyleSheet,
|
||||
nsIStyleRuleProcessor)
|
||||
NS_IMPL_ISUPPORTS1(nsHTMLCSSStyleSheet, nsIStyleRuleProcessor)
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLCSSStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
|
||||
|
@ -175,98 +169,3 @@ nsHTMLCSSStyleSheet::LookupStyleAttr(const nsAString& aSerialized)
|
|||
{
|
||||
return mCachedStyleAttrs.Get(aSerialized);
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLCSSStyleSheet::Reset(nsIURI* aURL)
|
||||
{
|
||||
mURL = aURL;
|
||||
}
|
||||
|
||||
/* virtual */ nsIURI*
|
||||
nsHTMLCSSStyleSheet::GetSheetURI() const
|
||||
{
|
||||
return mURL;
|
||||
}
|
||||
|
||||
/* virtual */ nsIURI*
|
||||
nsHTMLCSSStyleSheet::GetBaseURI() const
|
||||
{
|
||||
return mURL;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLCSSStyleSheet::GetTitle(nsString& aTitle) const
|
||||
{
|
||||
aTitle.AssignLiteral("Internal HTML/CSS Style Sheet");
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLCSSStyleSheet::GetType(nsString& aType) const
|
||||
{
|
||||
aType.AssignLiteral("text/html");
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsHTMLCSSStyleSheet::HasRules() const
|
||||
{
|
||||
// Say we always have rules, since we don't know.
|
||||
return true;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsHTMLCSSStyleSheet::IsApplicable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLCSSStyleSheet::SetEnabled(bool aEnabled)
|
||||
{ // these can't be disabled
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsHTMLCSSStyleSheet::IsComplete() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLCSSStyleSheet::SetComplete()
|
||||
{
|
||||
}
|
||||
|
||||
// style sheet owner info
|
||||
/* virtual */ nsIStyleSheet*
|
||||
nsHTMLCSSStyleSheet::GetParentSheet() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* virtual */ nsIDocument*
|
||||
nsHTMLCSSStyleSheet::GetOwningDocument() const
|
||||
{
|
||||
return mDocument;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLCSSStyleSheet::SetOwningDocument(nsIDocument* aDocument)
|
||||
{
|
||||
mDocument = aDocument;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* virtual */ void
|
||||
nsHTMLCSSStyleSheet::List(FILE* out, int32_t aIndent) const
|
||||
{
|
||||
// Indent
|
||||
for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
fputs("HTML CSS Style Sheet: ", out);
|
||||
nsAutoCString urlSpec;
|
||||
mURL->GetSpec(urlSpec);
|
||||
if (!urlSpec.IsEmpty()) {
|
||||
fputs(urlSpec.get(), out);
|
||||
}
|
||||
fputs("\n", out);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,34 +19,14 @@
|
|||
|
||||
struct MiscContainer;
|
||||
|
||||
class nsHTMLCSSStyleSheet MOZ_FINAL : public nsIStyleSheet,
|
||||
public nsIStyleRuleProcessor
|
||||
class nsHTMLCSSStyleSheet MOZ_FINAL : public nsIStyleRuleProcessor
|
||||
{
|
||||
public:
|
||||
nsHTMLCSSStyleSheet(nsIURI* aURL, nsIDocument* aDocument);
|
||||
nsHTMLCSSStyleSheet();
|
||||
~nsHTMLCSSStyleSheet();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
void Reset(nsIURI* aURL);
|
||||
|
||||
// nsIStyleSheet
|
||||
virtual nsIURI* GetSheetURI() const MOZ_OVERRIDE;
|
||||
virtual nsIURI* GetBaseURI() const MOZ_OVERRIDE;
|
||||
virtual void GetTitle(nsString& aTitle) const MOZ_OVERRIDE;
|
||||
virtual void GetType(nsString& aType) const MOZ_OVERRIDE;
|
||||
virtual bool HasRules() const MOZ_OVERRIDE;
|
||||
virtual bool IsApplicable() const MOZ_OVERRIDE;
|
||||
virtual void SetEnabled(bool aEnabled) MOZ_OVERRIDE;
|
||||
virtual bool IsComplete() const MOZ_OVERRIDE;
|
||||
virtual void SetComplete() MOZ_OVERRIDE;
|
||||
virtual nsIStyleSheet* GetParentSheet() const MOZ_OVERRIDE; // will be null
|
||||
virtual nsIDocument* GetOwningDocument() const MOZ_OVERRIDE;
|
||||
virtual void SetOwningDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
||||
#endif
|
||||
|
||||
// nsIStyleRuleProcessor
|
||||
virtual void RulesMatching(ElementRuleProcessorData* aData) MOZ_OVERRIDE;
|
||||
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) MOZ_OVERRIDE;
|
||||
|
@ -73,15 +53,7 @@ private:
|
|||
nsHTMLCSSStyleSheet& operator=(const nsHTMLCSSStyleSheet& aCopy) MOZ_DELETE;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mURL;
|
||||
nsIDocument* mDocument;
|
||||
nsDataHashtable<nsStringHashKey, MiscContainer*> mCachedStyleAttrs;
|
||||
};
|
||||
|
||||
inline nsISupports*
|
||||
ToSupports(nsHTMLCSSStyleSheet* aPointer)
|
||||
{
|
||||
return static_cast<nsIStyleSheet*>(aPointer);
|
||||
}
|
||||
|
||||
#endif /* !defined(nsHTMLCSSStyleSheet_h_) */
|
||||
|
|
|
@ -227,13 +227,11 @@ static PLDHashTableOps LangRuleTable_Ops = {
|
|||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
nsHTMLStyleSheet::nsHTMLStyleSheet(nsIURI* aURL, nsIDocument* aDocument)
|
||||
: mURL(aURL)
|
||||
, mDocument(aDocument)
|
||||
nsHTMLStyleSheet::nsHTMLStyleSheet(nsIDocument* aDocument)
|
||||
: mDocument(aDocument)
|
||||
, mTableQuirkColorRule(new TableQuirkColorRule())
|
||||
, mTableTHRule(new TableTHRule())
|
||||
{
|
||||
MOZ_ASSERT(aURL);
|
||||
MOZ_ASSERT(aDocument);
|
||||
mMappedAttrTable.ops = nullptr;
|
||||
mLangRuleTable.ops = nullptr;
|
||||
|
@ -247,7 +245,7 @@ nsHTMLStyleSheet::~nsHTMLStyleSheet()
|
|||
PL_DHashTableFinish(&mMappedAttrTable);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsHTMLStyleSheet, nsIStyleSheet, nsIStyleRuleProcessor)
|
||||
NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet, nsIStyleRuleProcessor)
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
|
||||
|
@ -402,82 +400,15 @@ nsHTMLStyleSheet::RulesMatching(XULTreeRuleProcessorData* aData)
|
|||
}
|
||||
#endif
|
||||
|
||||
// nsIStyleSheet api
|
||||
/* virtual */ nsIURI*
|
||||
nsHTMLStyleSheet::GetSheetURI() const
|
||||
{
|
||||
return mURL;
|
||||
}
|
||||
|
||||
/* virtual */ nsIURI*
|
||||
nsHTMLStyleSheet::GetBaseURI() const
|
||||
{
|
||||
return mURL;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLStyleSheet::GetTitle(nsString& aTitle) const
|
||||
{
|
||||
aTitle.Truncate();
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLStyleSheet::GetType(nsString& aType) const
|
||||
{
|
||||
aType.AssignLiteral("text/html");
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsHTMLStyleSheet::HasRules() const
|
||||
{
|
||||
return true; // We have rules at all reasonable times
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsHTMLStyleSheet::IsApplicable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLStyleSheet::SetEnabled(bool aEnabled)
|
||||
{ // these can't be disabled
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
nsHTMLStyleSheet::IsComplete() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsHTMLStyleSheet::SetComplete()
|
||||
{
|
||||
}
|
||||
|
||||
/* virtual */ nsIStyleSheet*
|
||||
nsHTMLStyleSheet::GetParentSheet() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* virtual */ nsIDocument*
|
||||
nsHTMLStyleSheet::GetOwningDocument() const
|
||||
{
|
||||
return mDocument;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
void
|
||||
nsHTMLStyleSheet::SetOwningDocument(nsIDocument* aDocument)
|
||||
{
|
||||
mDocument = aDocument; // not refcounted
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLStyleSheet::Reset(nsIURI* aURL)
|
||||
nsHTMLStyleSheet::Reset()
|
||||
{
|
||||
mURL = aURL;
|
||||
|
||||
mLinkRule = nullptr;
|
||||
mVisitedRule = nullptr;
|
||||
mActiveRule = nullptr;
|
||||
|
@ -594,23 +525,6 @@ nsHTMLStyleSheet::LangRuleFor(const nsString& aLanguage)
|
|||
return entry->mRule;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* virtual */ void
|
||||
nsHTMLStyleSheet::List(FILE* out, int32_t aIndent) const
|
||||
{
|
||||
// Indent
|
||||
for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
fputs("HTML Style Sheet: ", out);
|
||||
nsAutoCString urlSpec;
|
||||
mURL->GetSpec(urlSpec);
|
||||
if (!urlSpec.IsEmpty()) {
|
||||
fputs(urlSpec.get(), out);
|
||||
}
|
||||
fputs("\n", out);
|
||||
}
|
||||
#endif
|
||||
|
||||
static size_t
|
||||
SizeOfAttributesEntryExcludingThis(PLDHashEntryHdr* aEntry,
|
||||
nsMallocSizeOfFun aMallocSizeOf,
|
||||
|
|
|
@ -24,31 +24,15 @@
|
|||
|
||||
class nsMappedAttributes;
|
||||
|
||||
class nsHTMLStyleSheet MOZ_FINAL : public nsIStyleSheet,
|
||||
public nsIStyleRuleProcessor
|
||||
class nsHTMLStyleSheet MOZ_FINAL : public nsIStyleRuleProcessor
|
||||
{
|
||||
public:
|
||||
nsHTMLStyleSheet(nsIURI* aURL, nsIDocument* aDocument);
|
||||
nsHTMLStyleSheet(nsIDocument* aDocument);
|
||||
|
||||
void SetOwningDocument(nsIDocument* aDocument);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIStyleSheet api
|
||||
virtual nsIURI* GetSheetURI() const MOZ_OVERRIDE;
|
||||
virtual nsIURI* GetBaseURI() const MOZ_OVERRIDE;
|
||||
virtual void GetTitle(nsString& aTitle) const MOZ_OVERRIDE;
|
||||
virtual void GetType(nsString& aType) const MOZ_OVERRIDE;
|
||||
virtual bool HasRules() const MOZ_OVERRIDE;
|
||||
virtual bool IsApplicable() const MOZ_OVERRIDE;
|
||||
virtual void SetEnabled(bool aEnabled) MOZ_OVERRIDE;
|
||||
virtual bool IsComplete() const MOZ_OVERRIDE;
|
||||
virtual void SetComplete() MOZ_OVERRIDE;
|
||||
virtual nsIStyleSheet* GetParentSheet() const MOZ_OVERRIDE; // will be null
|
||||
virtual nsIDocument* GetOwningDocument() const MOZ_OVERRIDE;
|
||||
virtual void SetOwningDocument(nsIDocument* aDocumemt) MOZ_OVERRIDE;
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
||||
#endif
|
||||
|
||||
// nsIStyleRuleProcessor API
|
||||
virtual void RulesMatching(ElementRuleProcessorData* aData) MOZ_OVERRIDE;
|
||||
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) MOZ_OVERRIDE;
|
||||
|
@ -67,7 +51,7 @@ public:
|
|||
const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;
|
||||
size_t DOMSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
||||
|
||||
void Reset(nsIURI* aURL);
|
||||
void Reset();
|
||||
nsresult SetLinkColor(nscolor aColor);
|
||||
nsresult SetActiveLinkColor(nscolor aColor);
|
||||
nsresult SetVisitedLinkColor(nscolor aColor);
|
||||
|
@ -159,7 +143,6 @@ public: // for mLangRuleTable structures only
|
|||
};
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIURI> mURL;
|
||||
nsIDocument* mDocument;
|
||||
nsRefPtr<HTMLColorRule> mLinkRule;
|
||||
nsRefPtr<HTMLColorRule> mVisitedRule;
|
||||
|
|
Загрузка…
Ссылка в новой задаче