mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Fix for 42806. r=waterson
This commit is contained in:
parent
569653202b
commit
8072ceb8f8
@ -2282,6 +2282,9 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileE
|
||||
nsresult rv;
|
||||
|
||||
if (aDocument != mDocument) {
|
||||
|
||||
mListenerManager = nsnull;
|
||||
|
||||
nsCOMPtr<nsIXULDocument> rdfDoc;
|
||||
if (mDocument) {
|
||||
// Release the named reference to the script object so it can
|
||||
@ -3066,6 +3069,12 @@ nsXULElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotif
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
nsCOMPtr<nsIDOMXULElement> current;
|
||||
treeElement->GetCurrentItem(getter_AddRefs(current));
|
||||
nsCOMPtr<nsIContent> currentContent(do_QueryInterface(current));
|
||||
nsIContent* us = NS_STATIC_CAST(nsIStyledContent*, this);
|
||||
if (currentContent.get() == us)
|
||||
treeElement->SetCurrentItem(nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,10 +426,14 @@ nsXULTreeElement::GetCurrentItem(nsIDOMXULElement** aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::SetCurrentItem(nsIDOMXULElement* aCurrentItem)
|
||||
{
|
||||
NS_IF_RELEASE(mCurrentItem);
|
||||
mCurrentItem = aCurrentItem;
|
||||
NS_IF_ADDREF(aCurrentItem);
|
||||
nsCOMPtr<nsIContent> current = do_QueryInterface(mCurrentItem);
|
||||
current->SetAttribute(kNameSpaceID_None, kCurrentAtom, NS_ConvertASCIItoUCS2("true"), PR_TRUE);
|
||||
if (current)
|
||||
current->SetAttribute(kNameSpaceID_None, kCurrentAtom, NS_ConvertASCIItoUCS2("true"), PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -73,15 +73,9 @@ public:
|
||||
protected:
|
||||
// Helpers
|
||||
void ClearItemSelectionInternal();
|
||||
void ClearCellSelectionInternal();
|
||||
void AddItemToSelectionInternal(nsIDOMXULElement* aTreeItem);
|
||||
void RemoveItemFromSelectionInternal(nsIDOMXULElement* aTreeItem);
|
||||
void AddCellToSelectionInternal(nsIDOMXULElement* aTreeCell);
|
||||
void RemoveCellFromSelectionInternal(nsIDOMXULElement* aTreeCell);
|
||||
|
||||
void SetCurrentItem(nsIDOMXULElement* aElement);
|
||||
void SetCurrentCell(nsIDOMXULElement* aCell);
|
||||
|
||||
|
||||
static nsresult IndexOfContent(nsIContent *aRoot, nsIContent *aContent,
|
||||
PRBool aDescendIntoRows,
|
||||
PRBool aParentIsOpen,
|
||||
|
@ -3,7 +3,7 @@ interface XULTreeElement : XULElement {
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */
|
||||
readonly attribute NodeList selectedItems;
|
||||
|
||||
readonly attribute XULElement currentItem;
|
||||
attribute XULElement currentItem;
|
||||
|
||||
void selectItem(in XULElement treeItem);
|
||||
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems)=0;
|
||||
|
||||
NS_IMETHOD GetCurrentItem(nsIDOMXULElement** aCurrentItem)=0;
|
||||
NS_IMETHOD SetCurrentItem(nsIDOMXULElement* aCurrentItem)=0;
|
||||
|
||||
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem)=0;
|
||||
|
||||
@ -65,6 +66,7 @@ public:
|
||||
#define NS_DECL_IDOMXULTREEELEMENT \
|
||||
NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems); \
|
||||
NS_IMETHOD GetCurrentItem(nsIDOMXULElement** aCurrentItem); \
|
||||
NS_IMETHOD SetCurrentItem(nsIDOMXULElement* aCurrentItem); \
|
||||
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem); \
|
||||
NS_IMETHOD ClearItemSelection(); \
|
||||
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem); \
|
||||
@ -79,6 +81,7 @@ public:
|
||||
#define NS_FORWARD_IDOMXULTREEELEMENT(_to) \
|
||||
NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems) { return _to GetSelectedItems(aSelectedItems); } \
|
||||
NS_IMETHOD GetCurrentItem(nsIDOMXULElement** aCurrentItem) { return _to GetCurrentItem(aCurrentItem); } \
|
||||
NS_IMETHOD SetCurrentItem(nsIDOMXULElement* aCurrentItem) { return _to SetCurrentItem(aCurrentItem); } \
|
||||
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem) { return _to SelectItem(aTreeItem); } \
|
||||
NS_IMETHOD ClearItemSelection() { return _to ClearItemSelection(); } \
|
||||
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem) { return _to AddItemToSelection(aTreeItem); } \
|
||||
|
@ -133,7 +133,23 @@ SetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
case XULTREEELEMENT_CURRENTITEM:
|
||||
{
|
||||
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTREEELEMENT_CURRENTITEM, PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIDOMXULElement* prop;
|
||||
if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop,
|
||||
kIXULElementIID, NS_ConvertASCIItoUCS2("XULElement"),
|
||||
cx, *vp)) {
|
||||
rv = NS_ERROR_DOM_NOT_OBJECT_ERR;
|
||||
break;
|
||||
}
|
||||
|
||||
rv = a->SetCurrentItem(prop);
|
||||
NS_IF_RELEASE(prop);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp);
|
||||
}
|
||||
@ -552,7 +568,7 @@ JSClass XULTreeElementClass = {
|
||||
static JSPropertySpec XULTreeElementProperties[] =
|
||||
{
|
||||
{"selectedItems", XULTREEELEMENT_SELECTEDITEMS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"currentItem", XULTREEELEMENT_CURRENTITEM, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"currentItem", XULTREEELEMENT_CURRENTITEM, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@ interface XULTreeElement : XULElement {
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */
|
||||
readonly attribute NodeList selectedItems;
|
||||
|
||||
readonly attribute XULElement currentItem;
|
||||
attribute XULElement currentItem;
|
||||
|
||||
void selectItem(in XULElement treeItem);
|
||||
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems)=0;
|
||||
|
||||
NS_IMETHOD GetCurrentItem(nsIDOMXULElement** aCurrentItem)=0;
|
||||
NS_IMETHOD SetCurrentItem(nsIDOMXULElement* aCurrentItem)=0;
|
||||
|
||||
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem)=0;
|
||||
|
||||
@ -65,6 +66,7 @@ public:
|
||||
#define NS_DECL_IDOMXULTREEELEMENT \
|
||||
NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems); \
|
||||
NS_IMETHOD GetCurrentItem(nsIDOMXULElement** aCurrentItem); \
|
||||
NS_IMETHOD SetCurrentItem(nsIDOMXULElement* aCurrentItem); \
|
||||
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem); \
|
||||
NS_IMETHOD ClearItemSelection(); \
|
||||
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem); \
|
||||
@ -79,6 +81,7 @@ public:
|
||||
#define NS_FORWARD_IDOMXULTREEELEMENT(_to) \
|
||||
NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems) { return _to GetSelectedItems(aSelectedItems); } \
|
||||
NS_IMETHOD GetCurrentItem(nsIDOMXULElement** aCurrentItem) { return _to GetCurrentItem(aCurrentItem); } \
|
||||
NS_IMETHOD SetCurrentItem(nsIDOMXULElement* aCurrentItem) { return _to SetCurrentItem(aCurrentItem); } \
|
||||
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem) { return _to SelectItem(aTreeItem); } \
|
||||
NS_IMETHOD ClearItemSelection() { return _to ClearItemSelection(); } \
|
||||
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem) { return _to AddItemToSelection(aTreeItem); } \
|
||||
|
@ -133,7 +133,23 @@ SetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
case XULTREEELEMENT_CURRENTITEM:
|
||||
{
|
||||
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTREEELEMENT_CURRENTITEM, PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIDOMXULElement* prop;
|
||||
if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop,
|
||||
kIXULElementIID, NS_ConvertASCIItoUCS2("XULElement"),
|
||||
cx, *vp)) {
|
||||
rv = NS_ERROR_DOM_NOT_OBJECT_ERR;
|
||||
break;
|
||||
}
|
||||
|
||||
rv = a->SetCurrentItem(prop);
|
||||
NS_IF_RELEASE(prop);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp);
|
||||
}
|
||||
@ -552,7 +568,7 @@ JSClass XULTreeElementClass = {
|
||||
static JSPropertySpec XULTreeElementProperties[] =
|
||||
{
|
||||
{"selectedItems", XULTREEELEMENT_SELECTEDITEMS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"currentItem", XULTREEELEMENT_CURRENTITEM, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"currentItem", XULTREEELEMENT_CURRENTITEM, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -2282,6 +2282,9 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileE
|
||||
nsresult rv;
|
||||
|
||||
if (aDocument != mDocument) {
|
||||
|
||||
mListenerManager = nsnull;
|
||||
|
||||
nsCOMPtr<nsIXULDocument> rdfDoc;
|
||||
if (mDocument) {
|
||||
// Release the named reference to the script object so it can
|
||||
@ -3066,6 +3069,12 @@ nsXULElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotif
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
nsCOMPtr<nsIDOMXULElement> current;
|
||||
treeElement->GetCurrentItem(getter_AddRefs(current));
|
||||
nsCOMPtr<nsIContent> currentContent(do_QueryInterface(current));
|
||||
nsIContent* us = NS_STATIC_CAST(nsIStyledContent*, this);
|
||||
if (currentContent.get() == us)
|
||||
treeElement->SetCurrentItem(nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,10 +426,14 @@ nsXULTreeElement::GetCurrentItem(nsIDOMXULElement** aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::SetCurrentItem(nsIDOMXULElement* aCurrentItem)
|
||||
{
|
||||
NS_IF_RELEASE(mCurrentItem);
|
||||
mCurrentItem = aCurrentItem;
|
||||
NS_IF_ADDREF(aCurrentItem);
|
||||
nsCOMPtr<nsIContent> current = do_QueryInterface(mCurrentItem);
|
||||
current->SetAttribute(kNameSpaceID_None, kCurrentAtom, NS_ConvertASCIItoUCS2("true"), PR_TRUE);
|
||||
if (current)
|
||||
current->SetAttribute(kNameSpaceID_None, kCurrentAtom, NS_ConvertASCIItoUCS2("true"), PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -73,15 +73,9 @@ public:
|
||||
protected:
|
||||
// Helpers
|
||||
void ClearItemSelectionInternal();
|
||||
void ClearCellSelectionInternal();
|
||||
void AddItemToSelectionInternal(nsIDOMXULElement* aTreeItem);
|
||||
void RemoveItemFromSelectionInternal(nsIDOMXULElement* aTreeItem);
|
||||
void AddCellToSelectionInternal(nsIDOMXULElement* aTreeCell);
|
||||
void RemoveCellFromSelectionInternal(nsIDOMXULElement* aTreeCell);
|
||||
|
||||
void SetCurrentItem(nsIDOMXULElement* aElement);
|
||||
void SetCurrentCell(nsIDOMXULElement* aCell);
|
||||
|
||||
|
||||
static nsresult IndexOfContent(nsIContent *aRoot, nsIContent *aContent,
|
||||
PRBool aDescendIntoRows,
|
||||
PRBool aParentIsOpen,
|
||||
|
Loading…
Reference in New Issue
Block a user