gecko-dev/layout/style/nsHTMLStyleSheet.h
Nathan Froyd 01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00

168 lines
5.1 KiB
C++

/* -*- 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/. */
/*
* style sheet and style rule processor representing data from presentational
* HTML attributes
*/
#ifndef nsHTMLStyleSheet_h_
#define nsHTMLStyleSheet_h_
#include "nsAutoPtr.h"
#include "nsColor.h"
#include "nsCOMPtr.h"
#include "nsIStyleRule.h"
#include "nsIStyleRuleProcessor.h"
#include "PLDHashTable.h"
#include "mozilla/Attributes.h"
#include "mozilla/MemoryReporting.h"
#include "nsString.h"
class nsIDocument;
class nsMappedAttributes;
class nsHTMLStyleSheet final : public nsIStyleRuleProcessor
{
public:
explicit nsHTMLStyleSheet(nsIDocument* aDocument);
void SetOwningDocument(nsIDocument* aDocument);
NS_DECL_ISUPPORTS
// nsIStyleRuleProcessor API
virtual void RulesMatching(ElementRuleProcessorData* aData) override;
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) override;
virtual void RulesMatching(AnonBoxRuleProcessorData* aData) override;
#ifdef MOZ_XUL
virtual void RulesMatching(XULTreeRuleProcessorData* aData) override;
#endif
virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) override;
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
virtual nsRestyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
mozilla::RestyleHintData& aRestyleHintDataResult) override;
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) override;
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE override;
size_t DOMSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
void Reset();
nsresult SetLinkColor(nscolor aColor);
nsresult SetActiveLinkColor(nscolor aColor);
nsresult SetVisitedLinkColor(nscolor aColor);
// Mapped Attribute management methods
already_AddRefed<nsMappedAttributes>
UniqueMappedAttributes(nsMappedAttributes* aMapped);
void DropMappedAttributes(nsMappedAttributes* aMapped);
nsIStyleRule* LangRuleFor(const nsString& aLanguage);
private:
nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy) = delete;
nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy) = delete;
~nsHTMLStyleSheet() {}
class HTMLColorRule;
friend class HTMLColorRule;
class HTMLColorRule final : public nsIStyleRule {
private:
~HTMLColorRule() {}
public:
HTMLColorRule() {}
NS_DECL_ISUPPORTS
// nsIStyleRule interface
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
nscolor mColor;
};
// Implementation of SetLink/VisitedLink/ActiveLinkColor
nsresult ImplLinkColorSetter(RefPtr<HTMLColorRule>& aRule, nscolor aColor);
class GenericTableRule;
friend class GenericTableRule;
class GenericTableRule : public nsIStyleRule {
protected:
virtual ~GenericTableRule() {}
public:
GenericTableRule() {}
NS_DECL_ISUPPORTS
// nsIStyleRule interface
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override = 0;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
};
// this rule handles <th> inheritance
class TableTHRule;
friend class TableTHRule;
class TableTHRule final : public GenericTableRule {
public:
TableTHRule() {}
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
};
// Rule to handle quirk table colors
class TableQuirkColorRule final : public GenericTableRule {
public:
TableQuirkColorRule() {}
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
};
public: // for mLangRuleTable structures only
// Rule to handle xml:lang attributes, of which we have exactly one
// per language string, maintained in mLangRuleTable.
// We also create one extra rule for the "x-math" language string, used on
// <math> elements.
class LangRule final : public nsIStyleRule {
private:
~LangRule() {}
public:
explicit LangRule(const nsSubstring& aLang) : mLang(aLang) {}
NS_DECL_ISUPPORTS
// nsIStyleRule interface
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
nsString mLang;
};
private:
nsIDocument* mDocument;
RefPtr<HTMLColorRule> mLinkRule;
RefPtr<HTMLColorRule> mVisitedRule;
RefPtr<HTMLColorRule> mActiveRule;
RefPtr<TableQuirkColorRule> mTableQuirkColorRule;
RefPtr<TableTHRule> mTableTHRule;
PLDHashTable mMappedAttrTable;
PLDHashTable mLangRuleTable;
};
#endif /* !defined(nsHTMLStyleSheet_h_) */