Bug 1422524: Inline nsAttrValue::Type. r?xidorn
MozReview-Commit-ID: I2uTeremrsS
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -28,16 +28,17 @@
#include "nsPresContext.h"
#include "mozilla/CORSMode.h"
#include "mozilla/Attributes.h"
#include "nsIScrollableFrame.h"
#include "mozilla/dom/Attr.h"
#include "nsISMILAttr.h"
#include "mozilla/dom/DOMRect.h"
#include "nsAttrValue.h"
+#include "nsAttrValueInlines.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/DOMTokenListSupportedTokens.h"
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/dom/ElementBinding.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PointerEventHandler.h"
#include "mozilla/UniquePtr.h"
--- a/dom/base/nsAttrValue.cpp
+++ b/dom/base/nsAttrValue.cpp
@@ -181,35 +181,16 @@ nsAttrValue::Init()
/* static */
void
nsAttrValue::Shutdown()
{
delete sEnumTableArray;
sEnumTableArray = nullptr;
}
-nsAttrValue::ValueType
-nsAttrValue::Type() const
-{
- switch (BaseType()) {
- case eIntegerBase:
- {
- return static_cast<ValueType>(mBits & NS_ATTRVALUE_INTEGERTYPE_MASK);
- }
- case eOtherBase:
- {
- return GetMiscContainer()->mType;
- }
- default:
- {
- return static_cast<ValueType>(static_cast<uint16_t>(BaseType()));
- }
- }
-}
-
void
nsAttrValue::Reset()
{
switch(BaseType()) {
case eStringBase:
{
nsStringBuffer* str = static_cast<nsStringBuffer*>(GetPtr());
if (str) {
--- a/dom/base/nsAttrValue.h
+++ b/dom/base/nsAttrValue.h
@@ -127,17 +127,17 @@ public:
explicit nsAttrValue(const nsIntMargin& aValue);
~nsAttrValue();
inline const nsAttrValue& operator=(const nsAttrValue& aOther);
static nsresult Init();
static void Shutdown();
- ValueType Type() const;
+ inline ValueType Type() const;
// Returns true when this value is self-contained and does not depend on
// the state of its associated element.
// Returns false when this value depends on the state of its associated
// element and may be invalid if that state has been changed by changes to
// that element state outside of attribute setting.
inline bool StoresOwnData() const;
void Reset();
@@ -499,23 +499,16 @@ private:
inline const nsAttrValue&
nsAttrValue::operator=(const nsAttrValue& aOther)
{
SetTo(aOther);
return *this;
}
-inline nsAtom*
-nsAttrValue::GetAtomValue() const
-{
- NS_PRECONDITION(Type() == eAtom, "wrong type");
- return reinterpret_cast<nsAtom*>(GetPtr());
-}
-
inline nsAttrValue::ValueBaseType
nsAttrValue::BaseType() const
{
return static_cast<ValueBaseType>(mBits & NS_ATTRVALUE_BASETYPE_MASK);
}
inline void*
nsAttrValue::GetPtr() const
@@ -526,35 +519,9 @@ nsAttrValue::GetPtr() const
}
inline bool
nsAttrValue::IsEmptyString() const
{
return !mBits;
}
-inline void
-nsAttrValue::ToString(mozilla::dom::DOMString& aResult) const
-{
- switch (Type()) {
- case eString:
- {
- nsStringBuffer* str = static_cast<nsStringBuffer*>(GetPtr());
- if (str) {
- aResult.SetStringBuffer(str, str->StorageSize()/sizeof(char16_t) - 1);
- }
- // else aResult is already empty
- return;
- }
- case eAtom:
- {
- nsAtom *atom = static_cast<nsAtom*>(GetPtr());
- aResult.SetOwnedAtom(atom, mozilla::dom::DOMString::eNullNotExpected);
- break;
- }
- default:
- {
- ToString(aResult.AsAString());
- }
- }
-}
-
#endif
--- a/dom/base/nsAttrValueInlines.h
+++ b/dom/base/nsAttrValueInlines.h
@@ -231,9 +231,61 @@ nsAttrValue::GetIntInternal() const
"getting integer from non-integer");
// Make sure we get a signed value.
// Lets hope the optimizer optimizes this into a shift. Unfortunatly signed
// bitshift right is implementaion dependant.
return static_cast<int32_t>(mBits & ~NS_ATTRVALUE_INTEGERTYPE_MASK) /
NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER;
}
+inline nsAttrValue::ValueType
+nsAttrValue::Type() const
+{
+ switch (BaseType()) {
+ case eIntegerBase:
+ {
+ return static_cast<ValueType>(mBits & NS_ATTRVALUE_INTEGERTYPE_MASK);
+ }
+ case eOtherBase:
+ {
+ return GetMiscContainer()->mType;
+ }
+ default:
+ {
+ return static_cast<ValueType>(static_cast<uint16_t>(BaseType()));
+ }
+ }
+}
+
+inline nsAtom*
+nsAttrValue::GetAtomValue() const
+{
+ NS_PRECONDITION(Type() == eAtom, "wrong type");
+ return reinterpret_cast<nsAtom*>(GetPtr());
+}
+
+inline void
+nsAttrValue::ToString(mozilla::dom::DOMString& aResult) const
+{
+ switch (Type()) {
+ case eString:
+ {
+ nsStringBuffer* str = static_cast<nsStringBuffer*>(GetPtr());
+ if (str) {
+ aResult.SetStringBuffer(str, str->StorageSize()/sizeof(char16_t) - 1);
+ }
+ // else aResult is already empty
+ return;
+ }
+ case eAtom:
+ {
+ nsAtom *atom = static_cast<nsAtom*>(GetPtr());
+ aResult.SetOwnedAtom(atom, mozilla::dom::DOMString::eNullNotExpected);
+ break;
+ }
+ default:
+ {
+ ToString(aResult.AsAString());
+ }
+ }
+}
+
#endif