зеркало из https://github.com/mozilla/pjs.git
Bug 331547: Get rid of nsGenericElement::WillAddOrRemove
This commit is contained in:
Родитель
1d8ffada26
Коммит
294e954db4
|
@ -2285,9 +2285,6 @@ nsGenericElement::InsertChildAt(nsIContent* aKid,
|
|||
{
|
||||
NS_PRECONDITION(aKid, "null ptr");
|
||||
|
||||
nsresult rv = WillAddOrRemoveChild(aKid, aIndex, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return doInsertChildAt(aKid, aIndex, aNotify, this, GetCurrentDoc(),
|
||||
mAttrsAndChildren);
|
||||
}
|
||||
|
@ -2376,9 +2373,6 @@ nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
|||
{
|
||||
nsCOMPtr<nsIContent> oldKid = GetChildAt(aIndex);
|
||||
if (oldKid) {
|
||||
nsresult rv = WillAddOrRemoveChild(oldKid, aIndex, PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return doRemoveChildAt(aIndex, aNotify, oldKid, this, GetCurrentDoc(),
|
||||
mAttrsAndChildren);
|
||||
}
|
||||
|
@ -3237,14 +3231,6 @@ nsGenericElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) co
|
|||
NS_ConvertUTF16toUTF8(aStr));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::WillAddOrRemoveChild(nsIContent* /*aKid*/,
|
||||
PRUint32 /*aIndex*/,
|
||||
PRBool /*aRemove*/)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::CopyInnerTo(nsGenericElement* aDst, PRBool aDeep) const
|
||||
{
|
||||
|
|
|
@ -907,22 +907,6 @@ protected:
|
|||
*/
|
||||
virtual const nsAttrName* InternalGetExistingAttrNameFromQName(const nsAString& aStr) const;
|
||||
|
||||
/**
|
||||
* Will be called when InsertChildAt, AppendChildTo or RemoveChildAt is used,
|
||||
* before anything else is done.
|
||||
* The processing of the calling method will be cancelled if this method
|
||||
* does not succeed.
|
||||
* @param aKid the content object which will be added or removed. Never null.
|
||||
* @param aIndex the same index which is used as a parameter with InsertChildAt;
|
||||
* aIndex gets value from GetChildCount() when AppendChildTo is
|
||||
* called. When a child will be removed, this is the index of
|
||||
* the aKid.
|
||||
* @param aRemove PR_TRUE, if a child object is being removed.
|
||||
*/
|
||||
virtual nsresult WillAddOrRemoveChild(nsIContent* aKid,
|
||||
PRUint32 aIndex,
|
||||
PRBool aRemove);
|
||||
|
||||
PRBool HasDOMSlots() const
|
||||
{
|
||||
return !(mFlagsOrSlots & GENERIC_ELEMENT_DOESNT_HAVE_DOMSLOTS);
|
||||
|
|
|
@ -75,9 +75,10 @@ public:
|
|||
NS_DECL_NSIDOMHTMLOPTGROUPELEMENT
|
||||
|
||||
// nsGenericElement
|
||||
virtual nsresult WillAddOrRemoveChild(nsIContent* aKid,
|
||||
PRUint32 aIndex,
|
||||
PRBool aRemove);
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
|
||||
// nsIContent
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
|
@ -197,21 +198,35 @@ nsHTMLOptGroupElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLOptGroupElement::WillAddOrRemoveChild(nsIContent* aKid,
|
||||
PRUint32 aIndex,
|
||||
PRBool aRemove)
|
||||
nsHTMLOptGroupElement::InsertChildAt(nsIContent* aKid,
|
||||
PRUint32 aIndex,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
GetSelect(getter_AddRefs(sel));
|
||||
if (sel) {
|
||||
if (aRemove) {
|
||||
sel->WillRemoveOptions(this, aIndex);
|
||||
} else {
|
||||
sel->WillAddOptions(aKid, this, aIndex);
|
||||
}
|
||||
sel->WillAddOptions(aKid, this, aIndex);
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::WillAddOrRemoveChild(aKid, aIndex, aRemove);
|
||||
return nsGenericHTMLElement::InsertChildAt(aKid, aIndex, aNotify);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLOptGroupElement::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
||||
{
|
||||
return nsHTMLOptGroupElement::InsertChildAt(aKid, GetChildCount(), aNotify);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLOptGroupElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
GetSelect(getter_AddRefs(sel));
|
||||
if (sel) {
|
||||
sel->WillRemoveOptions(this, aIndex);
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::RemoveChildAt(aIndex, aNotify);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
|
|
@ -1850,16 +1850,18 @@ nsXULElement::EnsureContentsGenerated(void) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULElement::WillAddOrRemoveChild(nsIContent* aKid,
|
||||
PRUint32 aIndex,
|
||||
PRBool aRemove)
|
||||
// No need to implement AppendChildTo. The default implementation will call
|
||||
// GetChildCount which will call EnsureContentsGenerated
|
||||
nsresult
|
||||
nsXULElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
// nsXULElement has its own RemoveChildAt, so no need to do
|
||||
// anything here when removing a child.
|
||||
return aRemove ? NS_OK : EnsureContentsGenerated();
|
||||
nsresult rv = EnsureContentsGenerated();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return nsGenericElement::InsertChildAt(aKid, aIndex, aNotify);
|
||||
}
|
||||
|
||||
|
||||
/// XXX GetID must be defined here because we have proto attrs.
|
||||
nsIAtom*
|
||||
nsXULElement::GetID() const
|
||||
|
|
|
@ -472,6 +472,8 @@ public:
|
|||
nsIEventListenerManager** aRes) {
|
||||
return GetListenerManager(aCreateIfNotFound, aRes);
|
||||
}
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
|
||||
// nsIContent
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
|
@ -571,10 +573,6 @@ protected:
|
|||
// Implementation methods
|
||||
nsresult EnsureContentsGenerated(void) const;
|
||||
|
||||
virtual nsresult WillAddOrRemoveChild(nsIContent* aKid,
|
||||
PRUint32 aIndex,
|
||||
PRBool aRemove);
|
||||
|
||||
nsresult ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsAString& attrName);
|
||||
|
||||
static nsresult
|
||||
|
|
Загрузка…
Ссылка в новой задаче