Bug 811449 part 3. Eliminate nsGenericElement as a separate class.

This commit is contained in:
Boris Zbarsky 2012-11-14 14:10:07 -08:00
Родитель f156bedf33
Коммит 19333a472b
10 изменённых файлов: 78 добавлений и 75 удалений

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

@ -115,6 +115,15 @@ namespace mozilla {
namespace dom {
class Link;
class Element;
} // namespace dom
} // namespace mozilla
typedef mozilla::dom::Element nsGenericElement;
namespace mozilla {
namespace dom {
// IID for the dom::Element interface
#define NS_ELEMENT_IID \
@ -128,7 +137,11 @@ public:
Element(already_AddRefed<nsINodeInfo> aNodeInfo) :
FragmentOrElement(aNodeInfo),
mState(NS_EVENT_STATE_MOZ_READONLY)
{}
{
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::ELEMENT_NODE,
"Bad NodeType in aNodeInfo");
SetIsElement();
}
#endif // MOZILLA_INTERNAL_API
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ELEMENT_IID)
@ -203,7 +216,7 @@ public:
/**
* Get the inline style rule, if any, for this element.
*/
virtual css::StyleRule* GetInlineStyleRule() = 0;
virtual css::StyleRule* GetInlineStyleRule();
/**
* Set the inline style rule for this element. This will send an appropriate
@ -211,13 +224,13 @@ public:
*/
virtual nsresult SetInlineStyleRule(css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify) = 0;
bool aNotify);
/**
* Get the SMIL override style rule for this element. If the rule hasn't been
* created, this method simply returns null.
*/
virtual css::StyleRule* GetSMILOverrideStyleRule() = 0;
virtual css::StyleRule* GetSMILOverrideStyleRule();
/**
* Set the SMIL override style rule for this element. If aNotify is true, this
@ -225,7 +238,7 @@ public:
* will be noticed.
*/
virtual nsresult SetSMILOverrideStyleRule(css::StyleRule* aStyleRule,
bool aNotify) = 0;
bool aNotify);
/**
* Returns a new nsISMILAttr that allows the caller to animate the given
@ -233,7 +246,10 @@ public:
*
* The CALLER OWNS the result and is responsible for deleting it.
*/
virtual nsISMILAttr* GetAnimatedAttr(int32_t aNamespaceID, nsIAtom* aName) = 0;
virtual nsISMILAttr* GetAnimatedAttr(int32_t aNamespaceID, nsIAtom* aName)
{
return nullptr;
}
/**
* Get the SMIL override style for this element. This is a style declaration
@ -243,12 +259,12 @@ public:
* Note: This method is analogous to the 'GetStyle' method in
* nsGenericHTMLElement and nsStyledElement.
*/
virtual nsICSSDeclaration* GetSMILOverrideStyle() = 0;
virtual nsICSSDeclaration* GetSMILOverrideStyle();
/**
* Returns if the element is labelable as per HTML specification.
*/
virtual bool IsLabelable() const = 0;
virtual bool IsLabelable() const;
/**
* Is the attribute named stored in the mapped attributes?
@ -257,7 +273,7 @@ public:
* returns true here even though it stores nothing in the mapped
* attributes.
*/
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const = 0;
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
/**
* Get a hint that tells the style system what to do when
@ -266,14 +282,14 @@ public:
* mapped into style data via any type of style rule.
*/
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
int32_t aModType) const = 0;
int32_t aModType) const;
/**
* Returns an atom holding the name of the "class" attribute on this
* content node (if applicable). Returns null if there is no
* "class" attribute for this type of content node.
*/
virtual nsIAtom *GetClassAttributeName() const = 0;
virtual nsIAtom *GetClassAttributeName() const;
inline mozilla::directionality::Directionality GetDirectionality() const {
if (HasFlag(NODE_HAS_DIRECTION_RTL)) {
@ -388,21 +404,8 @@ private:
}
nsEventStates mState;
};
NS_DEFINE_STATIC_IID_ACCESSOR(Element, NS_ELEMENT_IID)
} // namespace dom
} // namespace mozilla
/**
* A generic base class for DOM elements, implementing many nsIContent,
* nsIDOMNode and nsIDOMElement methods.
*/
class nsGenericElement : public mozilla::dom::Element
{
public:
nsGenericElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual void UpdateEditableState(bool aNotify);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
@ -410,7 +413,6 @@ public:
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
virtual nsIAtom *GetClassAttributeName() const;
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const;
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
@ -481,18 +483,8 @@ public:
virtual uint32_t GetAttrCount() const;
virtual bool IsNodeOfType(uint32_t aFlags) const;
virtual nsISMILAttr* GetAnimatedAttr(int32_t /*aNamespaceID*/, nsIAtom* /*aName*/)
{
return nullptr;
}
virtual nsICSSDeclaration* GetSMILOverrideStyle();
virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule();
virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule,
bool aNotify);
virtual bool IsLabelable() const;
#ifdef DEBUG
virtual void List(FILE* out, int32_t aIndent) const
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const
{
List(out, aIndent, EmptyCString());
}
@ -501,14 +493,6 @@ public:
void ListAttributes(FILE* out) const;
#endif
virtual mozilla::css::StyleRule* GetInlineStyleRule();
virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
const nsAString* aSerialized,
bool aNotify);
NS_IMETHOD_(bool)
IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
int32_t aModType) const;
/*
* Attribute Mapping Helpers
*/
@ -1099,6 +1083,11 @@ private:
nsIScrollableFrame* GetScrollFrame(nsIFrame **aStyledFrame = nullptr);
};
NS_DEFINE_STATIC_IID_ACCESSOR(Element, NS_ELEMENT_IID)
} // namespace dom
} // namespace mozilla
inline mozilla::dom::Element* nsINode::AsElement()
{
MOZ_ASSERT(IsElement());

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

@ -46,7 +46,6 @@ class nsIURI;
class nsNodeSupportsWeakRefTearoff;
class nsNodeWeakReference;
class nsXPCClassInfo;
class nsGenericElement;
namespace mozilla {
namespace dom {
@ -1079,8 +1078,8 @@ public:
SetTextContentInternal(aTextContent, aError);
}
nsGenericElement* QuerySelector(const nsAString& aSelector,
mozilla::ErrorResult& aResult);
mozilla::dom::Element* QuerySelector(const nsAString& aSelector,
mozilla::ErrorResult& aResult);
already_AddRefed<nsINodeList> QuerySelectorAll(const nsAString& aSelector,
mozilla::ErrorResult& aResult);
@ -1421,7 +1420,7 @@ public:
aNodeName = NodeName();
}
void GetBaseURI(nsAString& aBaseURI) const;
nsGenericElement* GetParentElement() const;
mozilla::dom::Element* GetParentElement() const;
bool HasChildNodes() const
{
return HasChildren();

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

@ -276,7 +276,7 @@ public:
}
virtual nsIContent* Item(uint32_t aIndex);
virtual nsGenericElement* GetElementAt(uint32_t index);
virtual mozilla::dom::Element* GetElementAt(uint32_t index);
virtual JSObject* NamedItem(JSContext* cx, const nsAString& name,
mozilla::ErrorResult& error);
virtual void GetSupportedNames(nsTArray<nsString>& aNames);

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

@ -12,8 +12,12 @@
#include "nsIDOMDOMSettableTokenList.h"
#include "nsDOMTokenList.h"
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
class nsGenericElement;
class nsIAtom;
// nsISupports must be on the primary inheritance chain
@ -27,7 +31,7 @@ public:
NS_FORWARD_NSIDOMDOMTOKENLIST(nsDOMTokenList::);
nsDOMSettableTokenList(nsGenericElement* aElement, nsIAtom* aAttrAtom);
nsDOMSettableTokenList(mozilla::dom::Element* aElement, nsIAtom* aAttrAtom);
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);

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

@ -16,29 +16,35 @@
namespace mozilla {
class ErrorResult;
}
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
class nsAttrValue;
class nsGenericElement;
class nsIAtom;
// nsISupports must be on the primary inheritance chain
// because nsDOMSettableTokenList is traversed by nsGenericElement.
// because nsDOMSettableTokenList is traversed by Element.
class nsDOMTokenList : public nsIDOMDOMTokenList,
public nsWrapperCache
{
typedef mozilla::dom::Element Element;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTokenList)
NS_DECL_NSIDOMDOMTOKENLIST
nsDOMTokenList(nsGenericElement* aElement, nsIAtom* aAttrAtom);
nsDOMTokenList(Element* aElement, nsIAtom* aAttrAtom);
void DropReference();
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
nsGenericElement* GetParentObject()
Element* GetParentObject()
{
return mElement;
}
@ -67,7 +73,7 @@ protected:
void RemoveInternal(const nsAttrValue* aAttr, const nsAString& aToken);
inline const nsAttrValue* GetParsedAttr();
nsGenericElement* mElement;
Element* mElement;
nsCOMPtr<nsIAtom> mAttrAtom;
};

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

@ -693,15 +693,6 @@ nsGenericElement::GetClientRects(ErrorResult& aError)
//----------------------------------------------------------------------
nsGenericElement::nsGenericElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: Element(aNodeInfo)
{
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::ELEMENT_NODE,
"Bad NodeType in aNodeInfo");
SetIsElement();
}
void
nsGenericElement::GetAttribute(const nsAString& aName, nsString& aReturn)
{

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

@ -68,7 +68,7 @@ protected:
virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
const nsAString& aValue, nsAttrValue& aResult);
friend class nsGenericElement;
friend class mozilla::dom::Element;
/**
* Create the style struct from the style attr. Used when an element is

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

@ -11,11 +11,14 @@
struct JSContext;
struct JSObject;
class nsGenericElement;
class nsINode;
namespace mozilla {
class ErrorResult;
}
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
// IID for the nsIHTMLCollection interface
#define NS_IHTMLCOLLECTION_IID \
@ -44,14 +47,14 @@ public:
GetLength(&length);
return length;
}
virtual nsGenericElement* GetElementAt(uint32_t index) = 0;
nsGenericElement* Item(uint32_t index)
virtual mozilla::dom::Element* GetElementAt(uint32_t index) = 0;
mozilla::dom::Element* Item(uint32_t index)
{
return GetElementAt(index);
}
nsGenericElement* IndexedGetter(uint32_t index, bool& aFound)
mozilla::dom::Element* IndexedGetter(uint32_t index, bool& aFound)
{
nsGenericElement* item = Item(index);
mozilla::dom::Element* item = Item(index);
aFound = !!item;
return item;
}

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

@ -31,6 +31,7 @@ namespace dom {
class HTMLPropertiesCollection;
class PropertyNodeList;
class Element;
class PropertyStringList : public nsDOMStringList
{
@ -61,7 +62,7 @@ public:
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
bool *triedToWrap);
virtual nsGenericElement* GetElementAt(uint32_t aIndex);
virtual Element* GetElementAt(uint32_t aIndex);
NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aResult);
void SetDocument(nsIDocument* aDocument);

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

@ -49,7 +49,8 @@ enum nsDOMClassInfoID {
#undef DOMCI_CASTABLE_INTERFACE
#define DOMCI_CASTABLE_INTERFACES(_extra) \
DOMCI_CASTABLE_INTERFACE(nsINode, nsINode, 0, _extra) \
DOMCI_CASTABLE_INTERFACE(nsGenericElement, nsGenericElement, 1, _extra) \
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::Element, mozilla::dom::Element,\
1, _extra) \
DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 5, _extra) \
DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsGenericHTMLElement, 6, \
_extra) \
@ -59,9 +60,18 @@ DOMCI_CASTABLE_INTERFACE(nsSVGStylableElement, nsIContent, 9, _extra)
// Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
// have been declared.
#define DOMCI_CASTABLE_NODECL_INTERFACE(_interface, _u1, _u2, _u3) /* Nothing */
#define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2, _u3) class _interface;
DOMCI_CASTABLE_INTERFACES(unused)
#undef DOMCI_CASTABLE_INTERFACE
#undef DOMCI_CASTABLE_NODECL_INTERFACE
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
#define DOMCI_CASTABLE_NODECL_INTERFACE DOMCI_CASTABLE_INTERFACE
#ifdef _IMPL_NS_LAYOUT