Bug 1260651 part.35 Move PorpItem and TypeInState from global namespace to mozilla namespace r=mccr8

Moving PropItem and TypeInState into mozilla namespace. I.e., these names are:
PropItem -> mozilla::PropItem
TypeInState -> mozilla::TypeInState

Although, there might be better names for them.  They are too general names.

MozReview-Commit-ID: By9CX1KlAaU
This commit is contained in:
Masayuki Nakano 2016-07-08 11:51:46 +09:00
parent 26f08a9046
commit 4b7aede741
4 changed files with 108 additions and 96 deletions

View File

@ -23,11 +23,12 @@
class nsIAtom;
class nsIDOMDocument;
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
using namespace dom;
/********************************************************************
* XPCOM cruft
* mozilla::TypeInState
*******************************************************************/
NS_IMPL_CYCLE_COLLECTION(TypeInState, mLastSelectionContainer)
@ -38,15 +39,9 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TypeInState)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
/********************************************************************
* public methods
*******************************************************************/
TypeInState::TypeInState() :
mSetArray()
,mClearedArray()
,mRelativeFontSize(0)
,mLastSelectionOffset(0)
TypeInState::TypeInState()
: mRelativeFontSize(0)
, mLastSelectionOffset(0)
{
Reset();
}
@ -72,7 +67,10 @@ TypeInState::UpdateSelState(Selection* aSelection)
}
NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsISelection *aSelection, int16_t)
NS_IMETHODIMP
TypeInState::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
nsISelection* aSelection,
int16_t aReason)
{
// XXX: Selection currently generates bogus selection changed notifications
// XXX: (bug 140303). It can notify us when the selection hasn't actually
@ -119,7 +117,8 @@ NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsISelection
return NS_OK;
}
void TypeInState::Reset()
void
TypeInState::Reset()
{
for(uint32_t i = 0, n = mClearedArray.Length(); i < n; i++) {
delete mClearedArray[i];
@ -133,7 +132,8 @@ void TypeInState::Reset()
void
TypeInState::SetProp(nsIAtom* aProp, const nsAString& aAttr,
TypeInState::SetProp(nsIAtom* aProp,
const nsAString& aAttr,
const nsAString& aValue)
{
// special case for big/small, these nest
@ -169,7 +169,8 @@ TypeInState::ClearAllProps()
}
void
TypeInState::ClearProp(nsIAtom* aProp, const nsAString& aAttr)
TypeInState::ClearProp(nsIAtom* aProp,
const nsAString& aAttr)
{
// if it's already cleared we are done
if (IsPropCleared(aProp, aAttr)) {
@ -187,9 +188,9 @@ TypeInState::ClearProp(nsIAtom* aProp, const nsAString& aAttr)
}
/***************************************************************************
* TakeClearProperty: hands back next property item on the clear list.
* caller assumes ownership of PropItem and must delete it.
/**
* TakeClearProperty() hands back next property item on the clear list.
* Caller assumes ownership of PropItem and must delete it.
*/
PropItem*
TypeInState::TakeClearProperty()
@ -205,9 +206,9 @@ TypeInState::TakeClearProperty()
return propItem;
}
/***************************************************************************
* TakeSetProperty: hands back next poroperty item on the set list.
* caller assumes ownership of PropItem and must delete it.
/**
* TakeSetProperty() hands back next poroperty item on the set list.
* Caller assumes ownership of PropItem and must delete it.
*/
PropItem*
TypeInState::TakeSetProperty()
@ -222,9 +223,10 @@ TypeInState::TakeSetProperty()
return propItem;
}
//**************************************************************************
// TakeRelativeFontSize: hands back relative font value, which is then
// cleared out.
/**
* TakeRelativeFontSize() hands back relative font value, which is then
* cleared out.
*/
int32_t
TypeInState::TakeRelativeFontSize()
{
@ -234,17 +236,19 @@ TypeInState::TakeRelativeFontSize()
}
void
TypeInState::GetTypingState(bool &isSet, bool &theSetting, nsIAtom *aProp)
TypeInState::GetTypingState(bool& isSet,
bool& theSetting,
nsIAtom* aProp)
{
GetTypingState(isSet, theSetting, aProp, EmptyString(), nullptr);
}
void
TypeInState::GetTypingState(bool &isSet,
bool &theSetting,
nsIAtom *aProp,
const nsString &aAttr,
nsString *aValue)
TypeInState::GetTypingState(bool& isSet,
bool& theSetting,
nsIAtom* aProp,
const nsString& aAttr,
nsString* aValue)
{
if (IsPropSet(aProp, aAttr, aValue))
{
@ -262,14 +266,9 @@ TypeInState::GetTypingState(bool &isSet,
}
}
/********************************************************************
* protected methods
*******************************************************************/
void
TypeInState::RemovePropFromSetList(nsIAtom* aProp, const nsAString& aAttr)
TypeInState::RemovePropFromSetList(nsIAtom* aProp,
const nsAString& aAttr)
{
int32_t index;
if (!aProp)
@ -290,7 +289,8 @@ TypeInState::RemovePropFromSetList(nsIAtom* aProp, const nsAString& aAttr)
void
TypeInState::RemovePropFromClearedList(nsIAtom* aProp, const nsAString& aAttr)
TypeInState::RemovePropFromClearedList(nsIAtom* aProp,
const nsAString& aAttr)
{
int32_t index;
if (FindPropInList(aProp, aAttr, nullptr, mClearedArray, index))
@ -301,19 +301,21 @@ TypeInState::RemovePropFromClearedList(nsIAtom* aProp, const nsAString& aAttr)
}
bool TypeInState::IsPropSet(nsIAtom *aProp,
const nsAString& aAttr,
nsAString* outValue)
bool
TypeInState::IsPropSet(nsIAtom* aProp,
const nsAString& aAttr,
nsAString* outValue)
{
int32_t i;
return IsPropSet(aProp, aAttr, outValue, i);
}
bool TypeInState::IsPropSet(nsIAtom* aProp,
const nsAString& aAttr,
nsAString* outValue,
int32_t& outIndex)
bool
TypeInState::IsPropSet(nsIAtom* aProp,
const nsAString& aAttr,
nsAString* outValue,
int32_t& outIndex)
{
// linear search. list should be short.
uint32_t i, count = mSetArray.Length();
@ -332,17 +334,19 @@ bool TypeInState::IsPropSet(nsIAtom* aProp,
}
bool TypeInState::IsPropCleared(nsIAtom* aProp,
const nsAString& aAttr)
bool
TypeInState::IsPropCleared(nsIAtom* aProp,
const nsAString& aAttr)
{
int32_t i;
return IsPropCleared(aProp, aAttr, i);
}
bool TypeInState::IsPropCleared(nsIAtom* aProp,
const nsAString& aAttr,
int32_t& outIndex)
bool
TypeInState::IsPropCleared(nsIAtom* aProp,
const nsAString& aAttr,
int32_t& outIndex)
{
if (FindPropInList(aProp, aAttr, nullptr, mClearedArray, outIndex))
return true;
@ -355,11 +359,12 @@ bool TypeInState::IsPropCleared(nsIAtom* aProp,
return false;
}
bool TypeInState::FindPropInList(nsIAtom *aProp,
const nsAString &aAttr,
nsAString *outValue,
nsTArray<PropItem*> &aList,
int32_t &outIndex)
bool
TypeInState::FindPropInList(nsIAtom* aProp,
const nsAString& aAttr,
nsAString* outValue,
nsTArray<PropItem*>& aList,
int32_t& outIndex)
{
// linear search. list should be short.
uint32_t i, count = aList.Length();
@ -377,24 +382,22 @@ bool TypeInState::FindPropInList(nsIAtom *aProp,
return false;
}
/********************************************************************
* PropItem: helper struct for TypeInState
* mozilla::PropItem: helper struct for mozilla::TypeInState
*******************************************************************/
PropItem::PropItem() :
tag(nullptr)
,attr()
,value()
PropItem::PropItem()
: tag(nullptr)
{
MOZ_COUNT_CTOR(PropItem);
}
PropItem::PropItem(nsIAtom *aTag, const nsAString &aAttr, const nsAString &aValue) :
tag(aTag)
,attr(aAttr)
,value(aValue)
PropItem::PropItem(nsIAtom* aTag,
const nsAString& aAttr,
const nsAString &aValue)
: tag(aTag)
, attr(aAttr)
, value(aValue)
{
MOZ_COUNT_CTOR(PropItem);
}
@ -403,3 +406,5 @@ PropItem::~PropItem()
{
MOZ_COUNT_DTOR(PropItem);
}
} // namespace mozilla

View File

@ -3,8 +3,8 @@
* 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 TypeInState_h__
#define TypeInState_h__
#ifndef TypeInState_h
#define TypeInState_h
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
@ -19,36 +19,37 @@
#undef SetProp
#endif
class nsHTMLEditRules;
class nsIAtom;
class nsIDOMNode;
namespace mozilla {
namespace dom {
class Selection;
} // namespace dom
} // namespace mozilla
struct PropItem
{
nsIAtom *tag;
nsIAtom* tag;
nsString attr;
nsString value;
PropItem();
PropItem(nsIAtom *aTag, const nsAString &aAttr, const nsAString &aValue);
PropItem(nsIAtom* aTag, const nsAString& aAttr, const nsAString& aValue);
~PropItem();
};
class TypeInState : public nsISelectionListener
class TypeInState final : public nsISelectionListener
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(TypeInState)
TypeInState();
void Reset();
nsresult UpdateSelState(mozilla::dom::Selection* aSelection);
nsresult UpdateSelState(dom::Selection* aSelection);
// nsISelectionListener
NS_DECL_NSISELECTIONLISTENER
@ -58,26 +59,31 @@ public:
void ClearAllProps();
void ClearProp(nsIAtom* aProp, const nsAString& aAttr);
//**************************************************************************
// TakeClearProperty: hands back next property item on the clear list.
// caller assumes ownership of PropItem and must delete it.
/**
* TakeClearProperty() hands back next property item on the clear list.
* Caller assumes ownership of PropItem and must delete it.
*/
PropItem* TakeClearProperty();
//**************************************************************************
// TakeSetProperty: hands back next property item on the set list.
// caller assumes ownership of PropItem and must delete it.
/**
* TakeSetProperty() hands back next property item on the set list.
* Caller assumes ownership of PropItem and must delete it.
*/
PropItem* TakeSetProperty();
//**************************************************************************
// TakeRelativeFontSize: hands back relative font value, which is then
// cleared out.
/**
* TakeRelativeFontSize() hands back relative font value, which is then
* cleared out.
*/
int32_t TakeRelativeFontSize();
void GetTypingState(bool &isSet, bool &theSetting, nsIAtom *aProp);
void GetTypingState(bool &isSet, bool &theSetting, nsIAtom *aProp,
const nsString &aAttr, nsString* outValue);
void GetTypingState(bool& isSet, bool& theSetting, nsIAtom* aProp);
void GetTypingState(bool& isSet, bool& theSetting, nsIAtom* aProp,
const nsString& aAttr, nsString* outValue);
static bool FindPropInList(nsIAtom *aProp, const nsAString &aAttr, nsAString *outValue, nsTArray<PropItem*> &aList, int32_t &outIndex);
static bool FindPropInList(nsIAtom* aProp, const nsAString& aAttr,
nsAString* outValue, nsTArray<PropItem*>& aList,
int32_t& outIndex);
protected:
virtual ~TypeInState();
@ -85,7 +91,8 @@ protected:
void RemovePropFromSetList(nsIAtom* aProp, const nsAString& aAttr);
void RemovePropFromClearedList(nsIAtom* aProp, const nsAString& aAttr);
bool IsPropSet(nsIAtom* aProp, const nsAString& aAttr, nsAString* outValue);
bool IsPropSet(nsIAtom* aProp, const nsAString& aAttr, nsAString* outValue, int32_t& outIndex);
bool IsPropSet(nsIAtom* aProp, const nsAString& aAttr, nsAString* outValue,
int32_t& outIndex);
bool IsPropCleared(nsIAtom* aProp, const nsAString& aAttr);
bool IsPropCleared(nsIAtom* aProp, const nsAString& aAttr, int32_t& outIndex);
@ -98,7 +105,7 @@ protected:
friend class nsHTMLEditRules;
};
} // namespace mozilla
#endif // TypeInState_h__
#endif // #ifndef TypeInState_h

View File

@ -37,7 +37,7 @@ class Selection;
} // namespace dom
} // namespace mozilla
struct StyleCache : public PropItem
struct StyleCache : public mozilla::PropItem
{
bool mPresent;

View File

@ -46,15 +46,15 @@ class nsDocumentFragment;
class nsIDOMKeyEvent;
class nsITransferable;
class nsIClipboard;
class TypeInState;
class nsIContentFilter;
class nsILinkHandler;
class nsTableWrapperFrame;
class nsIDOMRange;
class nsRange;
struct PropItem;
namespace mozilla {
class TypeInState;
struct PropItem;
template<class T> class OwningNonNull;
namespace dom {
class BlobImpl;
@ -784,7 +784,7 @@ protected:
nsTArray<OwningNonNull<nsIContentFilter>> mContentFilters;
RefPtr<TypeInState> mTypeInState;
RefPtr<mozilla::TypeInState> mTypeInState;
bool mCRInParagraphCreatesParagraph;
@ -802,7 +802,7 @@ protected:
nsTArray<mozilla::StyleSheetHandle::RefPtr> mStyleSheets;
// an array for holding default style settings
nsTArray<PropItem*> mDefaultStyles;
nsTArray<mozilla::PropItem*> mDefaultStyles;
protected: