104401 - eliminate mOuter aggregate from nsXULElement, r=waterson, sr=hyatt

This commit is contained in:
hewitt%netscape.com 2002-01-12 01:20:29 +00:00
Родитель 6bb61e9651
Коммит 55a509e710
47 изменённых файлов: 683 добавлений и 924 удалений

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

@ -51,7 +51,6 @@
class nsIDocument; class nsIDocument;
class nsIScrollableView; class nsIScrollableView;
class nsIPresShell; class nsIPresShell;
class nsITreeFrame;
class nsIFrameSelection; class nsIFrameSelection;
class nsIDocShell; class nsIDocShell;
class nsIDocShellTreeNode; class nsIDocShellTreeNode;

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

@ -54,7 +54,6 @@ CPPSRCS = \
nsXULAttributes.cpp \ nsXULAttributes.cpp \
nsXULElement.cpp \ nsXULElement.cpp \
nsXULPopupListener.cpp \ nsXULPopupListener.cpp \
nsXULTreeElement.cpp \
$(NULL) $(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib. # we don't want the shared lib, but we want to force the creation of a static lib.

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

@ -51,7 +51,6 @@ CPP_OBJS= \
.\$(OBJDIR)\nsXULAttributes.obj \ .\$(OBJDIR)\nsXULAttributes.obj \
.\$(OBJDIR)\nsXULElement.obj \ .\$(OBJDIR)\nsXULElement.obj \
.\$(OBJDIR)\nsXULPopupListener.obj \ .\$(OBJDIR)\nsXULPopupListener.obj \
.\$(OBJDIR)\nsXULTreeElement.obj \
$(NULL) $(NULL)
LINCS= \ LINCS= \

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

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

@ -77,6 +77,7 @@
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
#include "nsIDOMXULCommandDispatcher.h" #include "nsIDOMXULCommandDispatcher.h"
#include "nsIDOMXULElement.h" #include "nsIDOMXULElement.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIEventListenerManager.h" #include "nsIEventListenerManager.h"
#include "nsIEventStateManager.h" #include "nsIEventStateManager.h"
@ -117,7 +118,6 @@
#include "nsXPIDLString.h" #include "nsXPIDLString.h"
#include "nsXULAttributes.h" #include "nsXULAttributes.h"
#include "nsXULControllers.h" #include "nsXULControllers.h"
#include "nsXULTreeElement.h"
#include "nsIBoxObject.h" #include "nsIBoxObject.h"
#include "nsPIBoxObject.h" #include "nsPIBoxObject.h"
#include "nsXULDocument.h" #include "nsXULDocument.h"
@ -649,8 +649,6 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*result = nsnull; *result = nsnull;
nsresult rv;
if (iid.Equals(NS_GET_IID(nsIStyledContent)) || if (iid.Equals(NS_GET_IID(nsIStyledContent)) ||
iid.Equals(NS_GET_IID(nsIContent)) || iid.Equals(NS_GET_IID(nsIContent)) ||
iid.Equals(NS_GET_IID(nsISupports))) { iid.Equals(NS_GET_IID(nsISupports))) {
@ -679,46 +677,13 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result)
else if (iid.Equals(NS_GET_IID(nsIChromeEventHandler))) { else if (iid.Equals(NS_GET_IID(nsIChromeEventHandler))) {
*result = NS_STATIC_CAST(nsIChromeEventHandler*, this); *result = NS_STATIC_CAST(nsIChromeEventHandler*, this);
} }
else if ((iid.Equals(NS_GET_IID(nsIDOMXULTreeElement)) ||
iid.Equals(NS_GET_IID(nsIXULTreeContent))) &&
(NodeInfo()->NamespaceEquals(kNameSpaceID_XUL))){
nsCOMPtr<nsIAtom> tag;
PRInt32 dummy;
nsIXBLService *xblService = GetXBLService();
xblService->ResolveTag(NS_STATIC_CAST(nsIStyledContent*, this), &dummy, getter_AddRefs(tag));
if (tag == nsXULAtoms::tree) {
// We delegate XULTreeElement APIs to an aggregate object
if (! InnerXULElement()) {
rv = EnsureSlots();
if (NS_FAILED(rv)) return rv;
if ((mSlots->mInnerXULElement = new nsXULTreeElement(this)) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
}
return InnerXULElement()->QueryInterface(iid, result);
}
else
return NS_NOINTERFACE;
}
else if (iid.Equals(NS_GET_IID(nsIDOM3Node))) { else if (iid.Equals(NS_GET_IID(nsIDOM3Node))) {
*result = new nsNode3Tearoff(this); *result = new nsNode3Tearoff(this);
NS_ENSURE_TRUE(*result, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(*result, NS_ERROR_OUT_OF_MEMORY);
} }
else if (iid.Equals(NS_GET_IID(nsIClassInfo))) { else if (iid.Equals(NS_GET_IID(nsIClassInfo))) {
nsISupports *inst = nsnull; nsISupports *inst = nsContentUtils::
nsCOMPtr<nsIAtom> tag;
PRInt32 dummy;
nsIXBLService *xblService = GetXBLService();
xblService->ResolveTag(NS_STATIC_CAST(nsIStyledContent*, this), &dummy, getter_AddRefs(tag));
if (tag == nsXULAtoms::tree) {
inst = nsContentUtils::
GetClassInfoInstance(eDOMClassInfo_XULTreeElement_id);
} else {
inst = nsContentUtils::
GetClassInfoInstance(eDOMClassInfo_XULElement_id); GetClassInfoInstance(eDOMClassInfo_XULElement_id);
}
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
@ -2394,7 +2359,7 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
// the possibility exists that some of the items in the removed subtree // the possibility exists that some of the items in the removed subtree
// are selected (and therefore need to be deselected). We need to account for this. // are selected (and therefore need to be deselected). We need to account for this.
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
nsCOMPtr<nsIDOMXULTreeElement> treeElement; nsCOMPtr<nsIDOMXULMultiSelectControlElement> controlElement;
nsCOMPtr<nsITreeBoxObject> treeBox; nsCOMPtr<nsITreeBoxObject> treeBox;
PRBool fireSelectionHandler = PR_FALSE; PRBool fireSelectionHandler = PR_FALSE;
@ -2404,50 +2369,40 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
oldKid->GetTag(*getter_AddRefs(tag)); oldKid->GetTag(*getter_AddRefs(tag));
if (tag && (tag == nsXULAtoms::treechildren || tag == nsXULAtoms::treeitem || if (tag && (tag == nsXULAtoms::treechildren || tag == nsXULAtoms::treeitem ||
tag == nsXULAtoms::treecell)) { tag == nsXULAtoms::treecell || tag == nsXULAtoms::listitem)) {
// This is the nasty case. We have (potentially) a slew of selected items // This is the nasty case. We have (potentially) a slew of selected items
// and cells going away. // and cells going away.
// First, retrieve the tree. // First, retrieve the tree.
// Check first whether this element IS the tree // Check first whether this element IS the tree
treeElement = do_QueryInterface((nsIDOMXULElement*)this); controlElement = do_QueryInterface((nsIDOMXULElement*)this);
// If it's not, look at our parent // If it's not, look at our parent
if (!treeElement) if (!controlElement)
rv = GetParentTree(getter_AddRefs(treeElement)); rv = GetParentTree(getter_AddRefs(controlElement));
if (treeElement) { if (controlElement) {
nsCOMPtr<nsIDOMNodeList> itemList;
treeElement->GetSelectedItems(getter_AddRefs(itemList));
nsCOMPtr<nsIDOMNode> parentKid = do_QueryInterface(oldKid); nsCOMPtr<nsIDOMNode> parentKid = do_QueryInterface(oldKid);
if (itemList) { // Iterate over all of the items and find out if they are contained inside
// Iterate over all of the items and find out if they are contained inside // the removed subtree.
// the removed subtree. PRInt32 length;
PRUint32 length; controlElement->GetSelectedCount(&length);
itemList->GetLength(&length); for (PRInt32 i = 0; i < length; i++) {
for (PRUint32 i = 0; i < length; i++) { nsCOMPtr<nsIDOMXULSelectControlItemElement> node;
nsCOMPtr<nsIDOMNode> node; controlElement->GetSelectedItem(i, getter_AddRefs(node));
itemList->Item(i, getter_AddRefs(node)); if (IsAncestor(parentKid, node)) {
if (IsAncestor(parentKid, node)) { controlElement->RemoveItemFromSelection(node);
nsCOMPtr<nsIContent> content = do_QueryInterface(node); length--;
content->UnsetAttr(kNameSpaceID_None, nsXULAtoms::selected, PR_FALSE); i--;
nsCOMPtr<nsIXULTreeContent> tree = do_QueryInterface(treeElement); fireSelectionHandler = PR_TRUE;
nsCOMPtr<nsIDOMXULElement> domxulnode = do_QueryInterface(node);
if (tree && domxulnode)
tree->CheckSelection(domxulnode);
length--;
i--;
fireSelectionHandler = PR_TRUE;
}
} }
} }
nsCOMPtr<nsIDOMXULElement> curItem; nsCOMPtr<nsIDOMXULSelectControlItemElement> curItem;
treeElement->GetCurrentItem(getter_AddRefs(curItem)); controlElement->GetCurrentItem(getter_AddRefs(curItem));
nsCOMPtr<nsIDOMNode> curNode = do_QueryInterface(curItem); nsCOMPtr<nsIDOMNode> curNode = do_QueryInterface(curItem);
if (IsAncestor(parentKid, curNode)) { if (IsAncestor(parentKid, curNode)) {
// Current item going away // Current item going away
nsCOMPtr<nsIBoxObject> box; nsCOMPtr<nsIBoxObject> box;
treeElement->GetBoxObject(getter_AddRefs(box)); controlElement->GetBoxObject(getter_AddRefs(box));
treeBox = do_QueryInterface(box); treeBox = do_QueryInterface(box);
if (treeBox) { if (treeBox) {
nsCOMPtr<nsIDOMElement> domElem = do_QueryInterface(parentKid); nsCOMPtr<nsIDOMElement> domElem = do_QueryInterface(parentKid);
@ -2471,7 +2426,7 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
} }
if (newCurrentIndex == -2) if (newCurrentIndex == -2)
treeElement->SetCurrentItem(nsnull); controlElement->SetCurrentItem(nsnull);
else if (newCurrentIndex > -1) { else if (newCurrentIndex > -1) {
// Make sure the index is still valid // Make sure the index is still valid
PRInt32 treeRows; PRInt32 treeRows;
@ -2481,19 +2436,23 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
nsCOMPtr<nsIDOMElement> newCurrentItem; nsCOMPtr<nsIDOMElement> newCurrentItem;
treeBox->GetItemAtIndex(newCurrentIndex, getter_AddRefs(newCurrentItem)); treeBox->GetItemAtIndex(newCurrentIndex, getter_AddRefs(newCurrentItem));
if (newCurrentItem) { if (newCurrentItem) {
nsCOMPtr<nsIDOMXULElement> xulCurItem = do_QueryInterface(newCurrentItem); nsCOMPtr<nsIDOMXULSelectControlItemElement> xulCurItem = do_QueryInterface(newCurrentItem);
if (xulCurItem) if (xulCurItem)
treeElement->SetCurrentItem(xulCurItem); controlElement->SetCurrentItem(xulCurItem);
} }
} else { } else {
treeElement->SetCurrentItem(nsnull); controlElement->SetCurrentItem(nsnull);
} }
} }
if (fireSelectionHandler) { if (fireSelectionHandler) {
nsCOMPtr<nsIXULTreeContent> tree = do_QueryInterface(treeElement); nsCOMPtr<nsIDOMDocumentEvent> doc(do_QueryInterface(mDocument));
if (tree) { nsCOMPtr<nsIDOMEvent> event;
tree->FireOnSelectHandler(); doc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (event) {
event->InitEvent(NS_LITERAL_STRING("select"), PR_FALSE, PR_TRUE);
PRBool noDefault;
DispatchEvent(event, &noDefault);
} }
} }
@ -2626,31 +2585,6 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo,
// XXX Some kind of special document update might need to happen here. // XXX Some kind of special document update might need to happen here.
} }
// Need to check for the SELECTED attribute
// being set. If we're a <treeitem>, <treerow>, or <treecell>, the act of
// setting these attributes forces us to update our selected arrays.
nsCOMPtr<nsIAtom> tag;
GetTag(*getter_AddRefs(tag));
if (mDocument && aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
// See if we're a treeitem atom.
nsCOMPtr<nsIRDFNodeList> nodeList;
if (tag && (tag == nsXULAtoms::treeitem) &&
aNodeInfo->Equals(nsXULAtoms::selected)) {
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> nodes;
treeElement->GetSelectedItems(getter_AddRefs(nodes));
nodeList = do_QueryInterface(nodes);
}
}
if (nodeList) {
// Append this node to the list.
nodeList->AppendNode(this);
}
}
// XXX need to check if they're changing an event handler: if so, then we need // XXX need to check if they're changing an event handler: if so, then we need
// to unhook the old one. // to unhook the old one.
@ -2902,39 +2836,17 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID,
// XXXwaterson if aNotify == PR_TRUE, do we want to call // XXXwaterson if aNotify == PR_TRUE, do we want to call
// nsIDocument::BeginUpdate() now? // nsIDocument::BeginUpdate() now?
if (aNameSpaceID == kNameSpaceID_None) { if (aNameSpaceID == kNameSpaceID_None) {
if (aName == nsXULAtoms::selected) { if (mDocument) {
// Need to check for the SELECTED attribute if (aName == nsXULAtoms::clazz) {
// being unset. If we're a <treeitem>, <treerow>, or <treecell>, the act of // If CLASS is being unset, delete our class list.
// unsetting these attributes forces us to update our selected arrays. Attributes()->UpdateClassList(nsAutoString());
nsCOMPtr<nsIAtom> tag; } else if (aName == nsXULAtoms::style) {
GetTag(*getter_AddRefs(tag)); nsCOMPtr <nsIURI> docURL;
mDocument->GetBaseURL(*getter_AddRefs(docURL));
// See if we're a treeitem atom. Attributes()->UpdateStyleRule(docURL, nsAutoString());
if (tag && (tag == nsXULAtoms::treeitem)) { // XXX Some kind of special document update might need to happen here.
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> nodes;
treeElement->GetSelectedItems(getter_AddRefs(nodes));
nsCOMPtr<nsIRDFNodeList> nodeList(do_QueryInterface(nodes));
if (nodeList) {
// Remove this node from the list.
nodeList->RemoveNode(this);
}
}
}
} else if (mDocument) {
if (aName == nsXULAtoms::clazz) {
// If CLASS is being unset, delete our class list.
Attributes()->UpdateClassList(nsAutoString());
} else if (aName == nsXULAtoms::style) {
nsCOMPtr <nsIURI> docURL;
mDocument->GetBaseURL(*getter_AddRefs(docURL));
Attributes()->UpdateStyleRule(docURL, nsAutoString());
// XXX Some kind of special document update might need to happen here.
}
} }
}
} }
// XXX Know how to remove POPUP event listeners when an attribute is unset? // XXX Know how to remove POPUP event listeners when an attribute is unset?
@ -3385,7 +3297,7 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
parent = mParent; parent = mParent;
} }
if (retarget || (parent != mParent)) { if (!retarget || (parent != mParent)) {
if (!*aDOMEvent) { if (!*aDOMEvent) {
// We haven't made a DOMEvent yet. Force making one now. // We haven't made a DOMEvent yet. Force making one now.
nsCOMPtr<nsIEventListenerManager> listenerManager; nsCOMPtr<nsIEventListenerManager> listenerManager;
@ -4402,15 +4314,15 @@ nsXULElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXULElement::GetParentTree(nsIDOMXULTreeElement** aTreeElement) nsXULElement::GetParentTree(nsIDOMXULMultiSelectControlElement** aTreeElement)
{ {
nsCOMPtr<nsIContent> current; nsCOMPtr<nsIContent> current;
GetParent(*getter_AddRefs(current)); GetParent(*getter_AddRefs(current));
while (current) { while (current) {
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
current->GetTag(*getter_AddRefs(tag)); current->GetTag(*getter_AddRefs(tag));
if (tag && (tag == nsXULAtoms::tree)) { if (tag && (tag == nsXULAtoms::tree || tag == nsXULAtoms::listbox)) {
nsCOMPtr<nsIDOMXULTreeElement> element = do_QueryInterface(current); nsCOMPtr<nsIDOMXULMultiSelectControlElement> element = do_QueryInterface(current);
*aTreeElement = element; *aTreeElement = element;
NS_IF_ADDREF(*aTreeElement); NS_IF_ADDREF(*aTreeElement);
return NS_OK; return NS_OK;
@ -4819,8 +4731,7 @@ nsresult nsXULElement::MakeHeavyweight()
nsXULElement::Slots::Slots(nsXULElement* aElement) nsXULElement::Slots::Slots(nsXULElement* aElement)
: mAttributes(nsnull), : mAttributes(nsnull),
mLazyState(0), mLazyState(0)
mInnerXULElement(nsnull)
{ {
MOZ_COUNT_CTOR(nsXULElement::Slots); MOZ_COUNT_CTOR(nsXULElement::Slots);
} }
@ -4831,9 +4742,6 @@ nsXULElement::Slots::~Slots()
MOZ_COUNT_DTOR(nsXULElement::Slots); MOZ_COUNT_DTOR(nsXULElement::Slots);
NS_IF_RELEASE(mAttributes); NS_IF_RELEASE(mAttributes);
// Delete the aggregated interface, if one exists.
delete mInnerXULElement;
} }

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

@ -57,7 +57,7 @@
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDOMEventReceiver.h" #include "nsIDOMEventReceiver.h"
#include "nsIDOMXULElement.h" #include "nsIDOMXULElement.h"
#include "nsIDOMXULTreeElement.h" #include "nsIDOMXULMultSelectCntrlEl.h"
#include "nsIEventListenerManager.h" #include "nsIEventListenerManager.h"
#include "nsINameSpace.h" #include "nsINameSpace.h"
#include "nsINameSpaceManager.h" #include "nsINameSpaceManager.h"
@ -309,42 +309,6 @@ public:
nsString mValue; nsString mValue;
}; };
////////////////////////////////////////////////////////////////////////
/**
This class serves as a base for aggregates that will implement a
per-element XUL API.
*/
class nsXULAggregateElement : public nsISupports
{
protected:
nsIDOMXULElement* mOuter;
nsXULAggregateElement(nsIDOMXULElement* aOuter) : mOuter(aOuter) {}
public:
virtual ~nsXULAggregateElement() {};
// nsISupports interface. Subclasses should use the
// NS_DECL/IMPL_ISUPPORTS_INHERITED macros to implement the
// nsISupports interface.
NS_IMETHOD_(nsrefcnt) AddRef() {
return mOuter->AddRef();
}
NS_IMETHOD_(nsrefcnt) Release() {
return mOuter->Release();
}
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult) {
return mOuter->QueryInterface(aIID, aResult);
}
};
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/** /**
@ -528,7 +492,7 @@ protected:
static PRBool IsAncestor(nsIDOMNode* aParentNode, nsIDOMNode* aChildNode); static PRBool IsAncestor(nsIDOMNode* aParentNode, nsIDOMNode* aChildNode);
// Helper routine that crawls a parent chain looking for a tree element. // Helper routine that crawls a parent chain looking for a tree element.
NS_IMETHOD GetParentTree(nsIDOMXULTreeElement** aTreeElement); NS_IMETHOD GetParentTree(nsIDOMXULMultiSelectControlElement** aTreeElement);
nsresult AddPopupListener(nsIAtom* aName); nsresult AddPopupListener(nsIAtom* aName);
@ -567,12 +531,6 @@ protected:
* RDF; see nsIXULContent and nsRDFGenericBuilder. * RDF; see nsIXULContent and nsRDFGenericBuilder.
*/ */
PRInt32 mLazyState; PRInt32 mLazyState;
/**
* An unreferenced bare pointer to an aggregate that can
* implement element-specific APIs.
*/
nsXULAggregateElement* mInnerXULElement;
}; };
friend struct Slots; friend struct Slots;
@ -630,7 +588,6 @@ protected:
nsINodeInfo* NodeInfo() const { return mSlots ? mSlots->mNodeInfo : mPrototype->mNodeInfo; } nsINodeInfo* NodeInfo() const { return mSlots ? mSlots->mNodeInfo : mPrototype->mNodeInfo; }
nsIControllers* Controllers() const { return mSlots ? mSlots->mControllers.get() : nsnull; } nsIControllers* Controllers() const { return mSlots ? mSlots->mControllers.get() : nsnull; }
nsXULAttributes* Attributes() const { return mSlots ? mSlots->mAttributes : nsnull; } nsXULAttributes* Attributes() const { return mSlots ? mSlots->mAttributes : nsnull; }
nsXULAggregateElement* InnerXULElement() const { return mSlots ? mSlots->mInnerXULElement : nsnull; }
static nsIXBLService *gXBLService; static nsIXBLService *gXBLService;
}; };

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

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

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

@ -733,7 +733,7 @@
</FILE> </FILE>
<FILE> <FILE>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULTreeElement.idl</PATH> <PATH>nsIDOMXULMultSelectCntrlEl.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT> <PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND> <FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS> <FILEFLAGS></FILEFLAGS>
@ -834,7 +834,7 @@
</FILEREF> </FILEREF>
<FILEREF> <FILEREF>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULTreeElement.idl</PATH> <PATH>nsIDOMXULMultSelectCntrlEl.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT> <PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF> </FILEREF>
<FILEREF> <FILEREF>
@ -1574,7 +1574,7 @@
</FILE> </FILE>
<FILE> <FILE>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULTreeElement.idl</PATH> <PATH>nsIDOMXULMultSelectCntrlEl.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT> <PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND> <FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS> <FILEFLAGS></FILEFLAGS>
@ -1675,7 +1675,7 @@
</FILEREF> </FILEREF>
<FILEREF> <FILEREF>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULTreeElement.idl</PATH> <PATH>nsIDOMXULMultSelectCntrlEl.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT> <PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF> </FILEREF>
<FILEREF> <FILEREF>
@ -1764,7 +1764,7 @@
<FILEREF> <FILEREF>
<TARGETNAME>headers</TARGETNAME> <TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>nsIDOMXULTreeElement.idl</PATH> <PATH>nsIDOMXULMultSelectCntrlEl.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT> <PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF> </FILEREF>
<FILEREF> <FILEREF>

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

@ -1,4 +1,3 @@
nsIDOMXULCommandDispatcher.idl nsIDOMXULCommandDispatcher.idl
nsIDOMXULDocument.idl nsIDOMXULDocument.idl
nsIDOMXULElement.idl nsIDOMXULElement.idl
nsIDOMXULTreeElement.idl

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

@ -40,11 +40,11 @@ XPIDLSRCS = \
nsIDOMXULImageElement.idl \ nsIDOMXULImageElement.idl \
nsIDOMXULLabelElement.idl \ nsIDOMXULLabelElement.idl \
nsIDOMXULLabeledControlEl.idl \ nsIDOMXULLabeledControlEl.idl \
nsIDOMXULMenuListElement.idl \ nsIDOMXULMenuListElement.idl \
nsIDOMXULPopupElement.idl \ nsIDOMXULPopupElement.idl \
nsIDOMXULSelectCntrlEl.idl \ nsIDOMXULSelectCntrlEl.idl \
nsIDOMXULSelectCntrlItemEl.idl \ nsIDOMXULSelectCntrlItemEl.idl \
nsIDOMXULTreeElement.idl \ nsIDOMXULMultSelectCntrlEl.idl \
$(NULL) $(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

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

@ -40,7 +40,7 @@ XPIDLSRCS = \
.\nsIDOMXULPopupElement.idl \ .\nsIDOMXULPopupElement.idl \
.\nsIDOMXULSelectCntrlEl.idl \ .\nsIDOMXULSelectCntrlEl.idl \
.\nsIDOMXULSelectCntrlItemEl.idl \ .\nsIDOMXULSelectCntrlItemEl.idl \
.\nsIDOMXULTreeElement.idl \ .\nsIDOMXULMultSelectCntrlEl.idl \
$(NULL) $(NULL)
include <$(DEPTH)\config\rules.mak> include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,67 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* David Hyatt <hyatt@netscape.com> (original author)
* Joe Hewitt <hewitt@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMXULSelectCntrlEl.idl"
[scriptable, uuid(7F435623-BA16-4c44-B4B0-0990946D3D7C)]
interface nsIDOMXULMultiSelectControlElement : nsIDOMXULSelectControlElement
{
attribute DOMString selType;
attribute nsIDOMXULSelectControlItemElement currentItem;
readonly attribute nsIDOMNodeList selectedItems;
void addItemToSelection(in nsIDOMXULSelectControlItemElement item);
void removeItemFromSelection(in nsIDOMXULSelectControlItemElement item);
void toggleItemSelection(in nsIDOMXULSelectControlItemElement item);
void selectItem(in nsIDOMXULSelectControlItemElement item);
void selectItemRange(in nsIDOMXULSelectControlItemElement startItem, in nsIDOMXULSelectControlItemElement item);
void selectAll();
void invertSelection();
void clearSelection();
// XXX - temporary, pending implementation of scriptable,
// mutable nsIDOMNodeList for selectedItems
readonly attribute long selectedCount;
nsIDOMXULSelectControlItemElement getSelectedItem(in long index);
};

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

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

@ -172,7 +172,6 @@ enum nsDOMClassInfoID {
// XUL classes // XUL classes
eDOMClassInfo_XULDocument_id, eDOMClassInfo_XULDocument_id,
eDOMClassInfo_XULElement_id, eDOMClassInfo_XULElement_id,
eDOMClassInfo_XULTreeElement_id,
eDOMClassInfo_XULCommandDispatcher_id, eDOMClassInfo_XULCommandDispatcher_id,
eDOMClassInfo_XULNodeList_id, eDOMClassInfo_XULNodeList_id,
eDOMClassInfo_XULNamedNodeMap_id, eDOMClassInfo_XULNamedNodeMap_id,

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

@ -253,7 +253,6 @@
#include "nsIDOMTreeWalker.h" #include "nsIDOMTreeWalker.h"
#include "nsIDOMXULDocument.h" #include "nsIDOMXULDocument.h"
#include "nsIDOMXULElement.h" #include "nsIDOMXULElement.h"
#include "nsIDOMXULTreeElement.h"
#include "nsIDOMXULCommandDispatcher.h" #include "nsIDOMXULCommandDispatcher.h"
#include "nsIDOMCrypto.h" #include "nsIDOMCrypto.h"
#include "nsIDOMCRMFObject.h" #include "nsIDOMCRMFObject.h"
@ -659,8 +658,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
nsIXPCScriptable::WANT_ENUMERATE) nsIXPCScriptable::WANT_ENUMERATE)
NS_DEFINE_CLASSINFO_DATA(XULElement, nsElementSH, NS_DEFINE_CLASSINFO_DATA(XULElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS) ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(XULTreeElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH, NS_DEFINE_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS) DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(XULNodeList, NodeList, nsArraySH, NS_DEFINE_CLASSINFO_DATA_WITH_NAME(XULNodeList, NodeList, nsArraySH,
@ -1709,12 +1706,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(XULTreeElement, nsIDOMXULTreeElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULTreeElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(XULCommandDispatcher, nsIDOMXULCommandDispatcher) DOM_CLASSINFO_MAP_BEGIN(XULCommandDispatcher, nsIDOMXULCommandDispatcher)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandDispatcher) DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandDispatcher)
DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_END

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

@ -29,7 +29,7 @@
function BookmarkProperties() function BookmarkProperties()
{ {
var tree = document.getElementById('bookmarksTree'); var tree = document.getElementById('bookmarksTree');
var select_list = tree.getElementsByAttribute("selected", "true"); var select_list = tree.selectedItems;
if (select_list.length >= 1) { if (select_list.length >= 1) {
@ -172,17 +172,8 @@ function OpenEditNode()
saveNode = gEditNode; saveNode = gEditNode;
// unselect all nodes! // unselect all nodes!
var select_list = document.getElementsByAttribute("selected", "true"); var tree = document.getElementById('bookmarksTree');
dump("# of Nodes selected: " + select_list.length + "\n\n"); tree.clearSelection();
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (node)
{
dump("Unselecting node "+node.getAttribute("Name") + "\n");
node.removeAttribute("selected");
}
}
// XXX for now, just remove the child from the parent // XXX for now, just remove the child from the parent
// optimally, we'd like to not remove the child-parent relationship // optimally, we'd like to not remove the child-parent relationship
@ -379,7 +370,7 @@ function fillContextMenu(name)
var rdf = isupports.QueryInterface(Components.interfaces.nsIRDFService); var rdf = isupports.QueryInterface(Components.interfaces.nsIRDFService);
if (!rdf) return(false); if (!rdf) return(false);
var select_list = treeNode.getElementsByAttribute("selected", "true"); var select_list = treeNode.selectedItems;
if (select_list.length < 1) return(false); if (select_list.length < 1) return(false);
dump("# of Nodes selected: " + select_list.length + "\n\n"); dump("# of Nodes selected: " + select_list.length + "\n\n");
@ -491,7 +482,7 @@ function doContextCmd(cmdName)
cmdResource = cmdResource.QueryInterface(Components.interfaces.nsIRDFResource); cmdResource = cmdResource.QueryInterface(Components.interfaces.nsIRDFResource);
if (!cmdResource) return(false); if (!cmdResource) return(false);
var select_list = treeNode.getElementsByAttribute("selected", "true"); var select_list = treeNode.selectedItems;
if (select_list.length < 1) return(false); if (select_list.length < 1) return(false);
dump("# of Nodes selected: " + select_list.length + "\n\n"); dump("# of Nodes selected: " + select_list.length + "\n\n");

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

@ -1,544 +0,0 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Ben Goodger
*/
/*
Script for the file properties window
*/
function FileProperties()
{
var tree = document.getElementById('fileTree');
if (tree.selectedItems.length >= 1) {
// don't bother showing properties on bookmark separators
var type = tree.selectedItems[0].getAttribute('type');
if (type != "http://home.netscape.com/NC-rdf#BookmarkSeparator") {
var props = window.open("chrome://communicator/content/bookmarks/bm-props.xul",
"BookmarkProperties", "chrome,menubar,resizable");
props.BookmarkURL = tree.selectedItems[0].getAttribute("id");
}
} else {
dump("nothing selected!\n");
}
}
function OpenSearch(tabName)
{
window.openDialog("resource:/res/samples/search.xul", "SearchWindow", "dialog=no,close,chrome,resizable", tabName);
}
function OpenURL(event, node)
{
// clear any single-click/edit timeouts
if (timerID != null)
{
gEditNode = null;
clearTimeout(timerID);
timerID = null;
}
if (node.getAttribute('container') == "true")
{
return(false);
}
var url = node.getAttribute('id');
// Ignore "NC:" urls.
if (url.substring(0, 3) == "NC:")
{
return(false);
}
try
{
// add support for IE favorites under Win32, and NetPositive URLs under BeOS
if (url.indexOf("file://") == 0)
{
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var fileSys = rdf.GetDataSource("rdf:files");
if (fileSys)
{
var src = rdf.GetResource(url, true);
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true);
var target = fileSys.GetTarget(src, prop, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target) url = target;
}
}
}
}
catch(ex)
{
}
if(top.isEditor != undefined) {
if(top.editorShell) {
var ext = getFileExtension(url);
// look at the extension of the file to see what should be done
// with it. Note that this is a typically windowsey approach. will
// rdf:files hold a reference to the actual file type? (Mac?)
switch(ext) {
// XXX Crude, but it will do for now.
case "gif":
case "jpeg":
case "jpg":
case "png":
// just insert the image
EditorAutoInsertImage(url);
break;
case "htm":
case "html":
case "xul":
toEditor(url);
break;
case "js":
EditorInsertJSFile(url);
break;
case "css":
EditorInsertCSSFile(url);
break;
default:
// load the file in the editor
dump("Editor Message: Weirdo File Format\n");
toEditor(url);
break;
}
}
} else {
window.open(url,'bookmarks');
}
dump("OpenURL(" + url + ")\n");
return(true);
}
// returns the extension of a specified file URL
function getFileExtension(url)
{
return url.substring(url.lastIndexOf(".")+1,url.length).toLowerCase();
}
var htmlInput = null;
var saveNode = null;
var newValue = "";
var timerID = null;
var gEditNode = null;
function DoSingleClick(event, node)
{
var type = node.parentNode.parentNode.getAttribute('type');
var selected = node.parentNode.parentNode.getAttribute('selected');
if (gEditNode == node) {
// Only start an inline edit if it is the second consecutive click
// on the same node that is not already editing or a separator.
if (!htmlInput &&
type != "http://home.netscape.com/NC-rdf#BookmarkSeparator") {
// Edit node if we don't get a double-click in less than 1/2 second
timerID = setTimeout("OpenEditNode()", 500);
}
} else {
if (htmlInput) {
// Clicked during an edit
// Save the changes and move on
CloseEditNode(true);
}
gEditNode = node;
}
return false;
}
function OpenEditNode()
{
dump("OpenEditNode entered.\n");
// clear any single-click/edit timeouts
if (timerID != null)
{
clearTimeout(timerID);
timerID = null;
}
// XXX uncomment the following line to replace the whole input row we do this
// (and, therefore, only allow editing on the name column) until we can
// arbitrarily change the content model (bugs prevent this at the moment)
gEditNode = gEditNode.parentNode;
var name = gEditNode.parentNode.getAttribute("Name");
dump("Single click on '" + name + "'\n");
var theParent = gEditNode.parentNode;
dump("Parent node is a " + theParent.nodeName + "\n\n");
saveNode = gEditNode;
// unselect all nodes!
var select_list = document.getElementsByAttribute("selected", "true");
dump("# of Nodes selected: " + select_list.length + "\n\n");
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (node)
{
dump("Unselecting node "+node.getAttribute("Name") + "\n");
node.removeAttribute("selected");
}
}
// XXX for now, just remove the child from the parent
// optimally, we'd like to not remove the child-parent relationship
// and instead just set a "display: none;" attribute on the child node
// gEditNode.setAttribute("style", "display: none;");
// dump("gEditNode hidden.\n");
theParent.removeChild(gEditNode);
gEditNode = null;
dump("gEditNode removed.\n");
// create the html:input node
htmlInput = document.createElementNS("http://www.w3.org/1999/xhtml", "html:input");
htmlInput.setAttribute("value", name);
htmlInput.setAttribute("onkeypress", "return EditNodeKeyPress(event)");
theParent.appendChild(htmlInput);
dump("html:input node added.\n");
htmlInput.focus();
dump("OpenEditNode done.\n");
return(true);
}
function CloseEditNode(saveChangeFlag)
{
dump("CloseEditNode entered.\n");
if (htmlInput)
{
if (saveChangeFlag)
{
newValue = htmlInput.value;
}
dump(" Got html input: "+newValue+" \n");
var theParent = htmlInput.parentNode;
theParent.removeChild(htmlInput);
theParent.appendChild(saveNode);
dump(" child node appended.\n");
if (saveNode && saveChangeFlag)
{
var RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
var Bookmarks = RDF.GetDataSource("rdf:bookmarks");
dump("Got bookmarks datasource.\n");
// XXX once we support multi-column editing, get the property
// from the column in the content model
var propertyName = "http://home.netscape.com/NC-rdf#Name";
var propertyNode = RDF.GetResource(propertyName, true);
dump(" replacing value of property '" + propertyName + "'\n");
// get the URI
var theNode = saveNode;
var bookmarkURL = "";
while(true)
{
var tag = theNode.nodeName;
if (tag == "treeitem")
{
bookmarkURL = theNode.getAttribute("id");
break;
}
theNode = theNode.parentNode;
}
dump(" uri is '" + bookmarkURL + "'\n");
if (bookmarkURL == "") return(false);
var bookmarkNode = RDF.GetResource(bookmarkURL, true);
dump(" newValue = '" + newValue + "'\n");
newValue = (newValue != "") ? RDF.GetLiteral(newValue) : null;
var oldValue = Bookmarks.GetTarget(bookmarkNode, propertyNode, true);
if (oldValue)
{
oldValue = oldValue.QueryInterface(Components.interfaces.nsIRDFLiteral);
dump(" oldValue = '" + oldValue + "'\n");
}
if (oldValue != newValue)
{
if (oldValue && !newValue)
{
Bookmarks.Unassert(bookmarkNode, propertyNode, oldValue);
dump(" Unassert used.\n");
}
else if (!oldValue && newValue)
{
Bookmarks.Assert(bookmarkNode, propertyNode, newValue, true);
dump(" Assert used.\n");
}
else if (oldValue && newValue)
{
Bookmarks.Change(bookmarkNode, propertyNode, oldValue, newValue);
dump(" Change used.\n");
}
dump("re-writing bookmarks.html\n");
var remote = Bookmarks.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
remote.Flush();
}
newValue = "";
saveNode = null;
}
else dump("saveNode was null?\n");
htmlInput = null;
}
else dump("htmlInput was null?\n");
dump("CloseEditNode done.\n");
}
function EditNodeKeyPress(event)
{
if (event.keyCode == 27)
{
CloseEditNode(false);
return(false);
}
else if (event.keyCode == 13 || event.keyCode == 10)
{
CloseEditNode(true);
return(false);
}
return(true);
}
function doSort(sortColName)
{
var node = document.getElementById(sortColName);
// determine column resource to sort on
var sortResource = node.getAttribute('resource');
if (!node) return(false);
var sortDirection="ascending";
var isSortActive = node.getAttribute('sortActive');
if (isSortActive == "true") {
var currentDirection = node.getAttribute('sortDirection');
if (currentDirection == "ascending")
sortDirection = "descending";
else if (currentDirection == "descending")
sortDirection = "natural";
else
sortDirection = "ascending";
}
// get RDF Core service
var rdfCore = XPAppCoresManager.Find("RDFCore");
if (!rdfCore) {
rdfCore = new RDFCore();
if (!rdfCore) {
return(false);
}
rdfCore.Init("RDFCore");
// XPAppCoresManager.Add(rdfCore);
}
// sort!!!
rdfCore.doSort(node, sortResource, sortDirection);
return(false);
}
function fillContextMenu(name,node)
{
if (!name) return(false);
var popupNode = document.getElementById(name);
if (!popupNode) return(false);
var url = GetFileURL(node);
var ext = getFileExtension(url);
// remove the menu node (which tosses all of its kids);
// do this in case any old command nodes are hanging around
var menuNode = popupNode.childNodes[0];
popupNode.removeChild(menuNode);
// create a new menu node
menuNode = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menu");
popupNode.appendChild(menuNode);
dump("mwa");
if(ext == "gif")
{
// note: deleted all the doContextCmd stuff from bookmarks.
menuItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
menuItem.setAttribute("label","Insert Image");
// menuItem.setAttribute("onaction","AutoInsertImage(\'" + url + "\')");
parent.appendChild(menuItem);
}
return(true);
}
function isImageFile(parent,url)
{
}
function GetFileURL(node)
{
var url = node.getAttribute('id');
// Ignore "NC:" urls.
if (url.substring(0, 3) == "NC:")
{
return(false);
}
try
{
// add support for IE favorites under Win32, and NetPositive URLs under BeOS
if (url.indexOf("file://") == 0)
{
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var fileSys = rdf.GetDataSource("rdf:files");
if (fileSys)
{
var src = rdf.GetResource(url, true);
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true);
var target = fileSys.GetTarget(src, prop, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target) url = target;
}
}
}
}
catch(ex)
{
}
return url;
}
function doContextCmd(cmdName)
{
dump("doContextCmd start: cmd='" + cmdName + "'\n");
var treeNode = document.getElementById("bookmarksTree");
if (!treeNode) return(false);
var db = treeNode.database;
if (!db) return(false);
var compositeDB = db.QueryInterface(Components.interfaces.nsIRDFDataSource);
if (!compositeDB) return(false);
var isupports = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
if (!isupports) return(false);
var rdf = isupports.QueryInterface(Components.interfaces.nsIRDFService);
if (!rdf) return(false);
// need a resource for the command
var cmdResource = rdf.GetResource(cmdName);
if (!cmdResource) return(false);
cmdResource = cmdResource.QueryInterface(Components.interfaces.nsIRDFResource);
if (!cmdResource) return(false);
var select_list = treeNode.getElementsByAttribute("selected", "true");
if (select_list.length < 1) return(false);
dump("# of Nodes selected: " + select_list.length + "\n\n");
// set up selection nsISupportsArray
var selectionInstance = Components.classes["@mozilla.org/supports-array;1"].createInstance();
var selectionArray = selectionInstance.QueryInterface(Components.interfaces.nsISupportsArray);
// set up arguments nsISupportsArray
var argumentsInstance = Components.classes["@mozilla.org/supports-array;1"].createInstance();
var argumentsArray = argumentsInstance.QueryInterface(Components.interfaces.nsISupportsArray);
// get argument (parent)
var parentArc = rdf.GetResource("http://home.netscape.com/NC-rdf#parent");
if (!parentArc) return(false);
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (!node) break;
var uri = node.getAttribute("ref");
if ((uri) || (uri == ""))
{
uri = node.getAttribute("id");
}
if (!uri) return(false);
var rdfNode = rdf.GetResource(uri);
if (!rdfNode) break;
// add node into selection array
selectionArray.AppendElement(rdfNode);
// get the parent's URI
var parentURI="";
var theParent = node;
while (theParent)
{
theParent = theParent.parentNode;
parentURI = theParent.getAttribute("ref");
if ((!parentURI) || (parentURI == ""))
{
parentURI = theParent.getAttribute("id");
}
if (parentURI != "") break;
}
if (parentURI == "") return(false);
var parentNode = rdf.GetResource(parentURI, true);
if (!parentNode) return(false);
// add parent arc and node into arguments array
argumentsArray.AppendElement(parentArc);
argumentsArray.AppendElement(parentNode);
}
// do the command
compositeDB.DoCommand( selectionArray, cmdResource, argumentsArray );
dump("doContextCmd ends.\n\n");
return(true);
}

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

@ -72,7 +72,7 @@ function onChangeCSSAttribute()
function ClearCSSInputWidgets() function ClearCSSInputWidgets()
{ {
gDialog.AddCSSAttributeTree.clearItemSelection(); gDialog.AddCSSAttributeTree.clearSelection();
gDialog.AddCSSAttributeNameInput.value =""; gDialog.AddCSSAttributeNameInput.value ="";
gDialog.AddCSSAttributeValueInput.value = ""; gDialog.AddCSSAttributeValueInput.value = "";
gDialog.AddCSSAttributeNameInput.inputField.focus(); gDialog.AddCSSAttributeNameInput.inputField.focus();

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

@ -153,7 +153,7 @@ function onChangeHTMLAttribute()
function ClearHTMLInputWidgets() function ClearHTMLInputWidgets()
{ {
gDialog.AddHTMLAttributeTree.clearItemSelection(); gDialog.AddHTMLAttributeTree.clearSelection();
gDialog.AddHTMLAttributeNameInput.value =""; gDialog.AddHTMLAttributeNameInput.value ="";
gDialog.AddHTMLAttributeValueInput.value = ""; gDialog.AddHTMLAttributeValueInput.value = "";
gDialog.AddHTMLAttributeNameInput.inputField.focus(); gDialog.AddHTMLAttributeNameInput.inputField.focus();

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

@ -244,7 +244,7 @@ function GetAndSelectExistingAttributeValue( attName, treeChildrenId )
// Attribute doesn't exist in tree, so remove selection // Attribute doesn't exist in tree, so remove selection
gDoOnSelectTree = false; gDoOnSelectTree = false;
try { try {
treeChildren.parentNode.clearItemSelection(); treeChildren.parentNode.clearSelection();
} catch (e) {} } catch (e) {}
gDoOnSelectTree = true; gDoOnSelectTree = true;

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

@ -413,7 +413,7 @@ function ClearTreelist(tree)
{ {
if (tree) if (tree)
{ {
tree.clearItemSelection(); tree.clearSelection();
// Skip over the first <treecolgroup> child // Skip over the first <treecolgroup> child
if (tree.firstChild) if (tree.firstChild)
{ {
@ -462,7 +462,7 @@ function RemoveSelectedTreelistItem(tree)
var treeItem = tree.selectedItems[0]; var treeItem = tree.selectedItems[0];
if (treeItem) if (treeItem)
{ {
tree.clearItemSelection(); tree.cleaclearSelection
var parent = treeItem.parentNode; var parent = treeItem.parentNode;
if (parent) if (parent)
{ {

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

@ -125,7 +125,7 @@
sortResource="http://www.mozilla.org/rdf/chrome#name" sortResource="http://www.mozilla.org/rdf/chrome#name"
preftype="localizedstring" prefstring="general.useragent.contentlocale" preftype="localizedstring" prefstring="general.useragent.contentlocale"
prefvalue="" prefattribute="prefvalue" wsm_attributes="prefvalue" prefvalue="" prefattribute="prefvalue" wsm_attributes="prefvalue"
multiple="false" onselect="SelectContentPack();" seltype="false" onselect="SelectContentPack();"
sortDirection="ascending"> sortDirection="ascending">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>

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

@ -1663,9 +1663,18 @@ function setCurrentObject (obj)
/* Unselect currently selected users. */ /* Unselect currently selected users. */
userList = document.getElementById("user-list"); userList = document.getElementById("user-list");
<<<<<<< static.js
if (userList)
/* Remove curently selection items before this tree gets rerooted,
* because it seems to remember the selections for eternity if not. */
userList.clearSelection ();
else
dd ("setCurrentObject: could not find element with ID='user-list'");
=======
/* Remove curently selection items before this tree gets rerooted, /* Remove curently selection items before this tree gets rerooted,
* because it seems to remember the selections for eternity if not. */ * because it seems to remember the selections for eternity if not. */
userList.clearItemSelection (); userList.clearItemSelection ();
>>>>>>> 1.31
if (obj.TYPE == "IRCChannel") if (obj.TYPE == "IRCChannel")
client.rdf.setTreeRoot ("user-list", obj.getGraphResource()); client.rdf.setTreeRoot ("user-list", obj.getGraphResource());

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

@ -45,7 +45,7 @@
<spacer style="width: 7px;"/> <spacer style="width: 7px;"/>
<vbox> <vbox>
<label value="&treehead.schemaname.label;"/> <label value="&treehead.schemaname.label;"/>
<tree multiple="true" id="schematree" <tree seltype="multiple" id="schematree"
style="height: 250px;" onclick="ViewEntries();"> style="height: 250px;" onclick="ViewEntries();">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>
@ -60,7 +60,7 @@
<spacer style="width: 7px;"/> <spacer style="width: 7px;"/>
<vbox> <vbox>
<label id="entrytext" value2="&treehead.entries.label;" value3="&treehead.entries1.label;"/> <label id="entrytext" value2="&treehead.entries.label;" value3="&treehead.entries1.label;"/>
<tree multiple="true" id="entrytree" class="inset" <tree seltype="multiple" id="entrytree" class="inset"
style="height: 113px;" orient="vertical" onclick="ViewSynonyms();"> style="height: 113px;" orient="vertical" onclick="ViewSynonyms();">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>
@ -69,7 +69,7 @@
</tree> </tree>
<spacer style="height: 7px;"/> <spacer style="height: 7px;"/>
<label id="synonymtext" value2="&treehead.synonyms.label;" value3="&treehead.synonymsoff.label;" value4="&treehead.synonyms1.label;"/> <label id="synonymtext" value2="&treehead.synonyms.label;" value3="&treehead.synonymsoff.label;" value4="&treehead.synonyms1.label;"/>
<tree multiple="true" id="synonymtree" <tree seltype="multiple" id="synonymtree"
style="height: 113px;" orient="vertical" onclick="SynonymSelected();"> style="height: 113px;" orient="vertical" onclick="SynonymSelected();">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>

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

@ -93,7 +93,7 @@ Contributor(s):
<!-- Address bucket --> <!-- Address bucket -->
<vbox id="bucketBox"> <vbox id="bucketBox">
<tree id="addressBucket" flex="1" multiple="true" <tree id="addressBucket" flex="1" seltype="multiple"
ondragover="DragOverBucketPane(event);" ondragover="DragOverBucketPane(event);"
ondragdrop="DropOnBucketPane(event);" ondragdrop="DropOnBucketPane(event);"
onselect="DialogBucketPaneSelectionChanged();"> onselect="DialogBucketPaneSelectionChanged();">

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

@ -132,7 +132,7 @@ function refreshServerList()
{ {
// save selection // save selection
var oldSelectedIds = new Array; var oldSelectedIds = new Array;
serverList.clearItemSelection(); serverList.clearSelection();
var selectedItems = serverList.selectedItems; var selectedItems = serverList.selectedItems;
for (var i=0; i< selectedItems.length; i++) for (var i=0; i< selectedItems.length; i++)
oldSelectedIds[i] = selectedItems[0].id; oldSelectedIds[i] = selectedItems[0].id;

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

@ -96,7 +96,7 @@ Rights Reserved.
<tree flex="1" <tree flex="1"
id="subscribetree" id="subscribetree"
datasources="rdf:null" datasources="rdf:null"
multiple="true" seltype="multiple"
onclick="SubscribeOnClick(event);"> onclick="SubscribeOnClick(event);">
<template> <template>
<rule> <rule>

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

@ -234,7 +234,7 @@ function refreshFilterList() {
if (selectedItems && selectedItems.length >0) if (selectedItems && selectedItems.length >0)
selection = tree.selectedItems[0].id; selection = tree.selectedItems[0].id;
tree.clearItemSelection(); tree.clearSelection();
tree.setAttribute("ref", tree.getAttribute("ref")); tree.setAttribute("ref", tree.getAttribute("ref"));
if (selection) { if (selection) {

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

@ -55,7 +55,7 @@
<description>&HTMLdomaintitle.label;</description> <description>&HTMLdomaintitle.label;</description>
<hbox flex="1"> <hbox flex="1">
<tree id="html_domains" flex="1" <tree id="html_domains" flex="1"
datasources="rdf:null" multiple="true" datasources="rdf:null" seltype="multiple"
onkeypress="if (event.keyCode == 8 || event.keyCode == 46) RemoveDomains(htmlobj);"> onkeypress="if (event.keyCode == 8 || event.keyCode == 46) RemoveDomains(htmlobj);">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>
@ -76,7 +76,7 @@
<description>&PlainTexttitle.label;</description> <description>&PlainTexttitle.label;</description>
<hbox flex="1"> <hbox flex="1">
<tree id="plaintext_domains" flex="1" <tree id="plaintext_domains" flex="1"
datasources="rdf:null" multiple="true" datasources="rdf:null" seltype="multiple"
onkeypress="if (event.keyCode == 8 || event.keyCode == 46) RemoveDomains(plainobj);"> onkeypress="if (event.keyCode == 8 || event.keyCode == 46) RemoveDomains(plainobj);">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>

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

@ -34,7 +34,7 @@
<vbox id="CACerts"> <vbox id="CACerts">
<description>&certmgr.cas;</description> <description>&certmgr.cas;</description>
<separator class="thin"/> <separator class="thin"/>
<outliner id="ca-outliner" multiple="true" enableColumnDrag="true" <outliner id="ca-outliner" seltype="multiple" enableColumnDrag="true"
onselect="ca_enableButtons()" flex="1"> onselect="ca_enableButtons()" flex="1">
<outlinercols> <outlinercols>
<outlinercol id="certcol" label="&certmgr.certname;" primary="true" <outlinercol id="certcol" label="&certmgr.certname;" primary="true"

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

@ -34,7 +34,7 @@
<vbox id="myCerts"> <vbox id="myCerts">
<description>&certmgr.mine;</description> <description>&certmgr.mine;</description>
<separator class="thin"/> <separator class="thin"/>
<outliner id="user-outliner" multiple="true" enableColumnDrag="true" <outliner id="user-outliner" seltype="multiple" enableColumnDrag="true"
onselect="mine_enableButtons()" flex="1"> onselect="mine_enableButtons()" flex="1">
<outlinercols> <outlinercols>
<outlinercol id="certcol" label="&certmgr.certname;" primary="true" <outlinercol id="certcol" label="&certmgr.certname;" primary="true"

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

@ -47,7 +47,7 @@
<vbox id="othersCerts"> <vbox id="othersCerts">
<description>&certmgr.others;</description> <description>&certmgr.others;</description>
<separator class="thin"/> <separator class="thin"/>
<outliner id="email-outliner" multiple="true" <outliner id="email-outliner" seltype="multiple"
onselect="email_enableButtons()" flex="1"> onselect="email_enableButtons()" flex="1">
<outlinercols> <outlinercols>
<outlinercol id="certcol" label="&certmgr.certname;" primary="true" <outlinercol id="certcol" label="&certmgr.certname;" primary="true"

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

@ -34,7 +34,7 @@
<vbox id="webCerts"> <vbox id="webCerts">
<description>&certmgr.websites;</description> <description>&certmgr.websites;</description>
<separator class="thin"/> <separator class="thin"/>
<outliner id="server-outliner" multiple="true" enableColumnDrag="true" <outliner id="server-outliner" seltype="multiple" enableColumnDrag="true"
onselect="websites_enableButtons()" flex="1"> onselect="websites_enableButtons()" flex="1">
<outlinercols> <outlinercols>
<outlinercol id="certcol" label="&certmgr.certname;" primary="true" <outlinercol id="certcol" label="&certmgr.certname;" primary="true"

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

@ -47,7 +47,7 @@
<description value="&validation.crlmanager.label;"/> <description value="&validation.crlmanager.label;"/>
<separator class="thin"/> <separator class="thin"/>
<tree id="crltree" style="height: 10em;" <tree id="crltree" style="height: 10em;"
multiple="false" onclick="EnableCrlActions()" flex="1"> seltype="multiple" onclick="EnableCrlActions()" flex="1">
<treecolgroup> <treecolgroup>
<treecol flex="3" width="0"/> <treecol flex="3" width="0"/>
<splitter class="tree-splitter"/> <splitter class="tree-splitter"/>

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

@ -50,7 +50,7 @@
<rows> <rows>
<row> <row>
<hbox flex="1"> <!-- List of devices --> <hbox flex="1"> <!-- List of devices -->
<tree id="device_tree" rows="12" multiple="false" <tree id="device_tree" rows="12" seltype="false"
onselect="enableButtons();" onselect="enableButtons();"
flex="1" style="min-width:15em"> flex="1" style="min-width:15em">
<treecolgroup> <treecolgroup>
@ -67,7 +67,7 @@
</tree> </tree>
</hbox> <!-- / List of devices --> </hbox> <!-- / List of devices -->
<hbox flex="1"> <!-- Device status --> <hbox flex="1"> <!-- Device status -->
<tree id="info_tree" rows="12" multiple="false" <tree id="info_tree" rows="12" seltype="false"
class="list" flex="1" style="min-width:10em"> class="list" flex="1" style="min-width:10em">
<treecolgroup> <treecolgroup>
<treecol flex="5"/> <treecol flex="5"/>

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

@ -124,7 +124,7 @@
<tree id="downloadView" ref="NC:DownloadsRoot" <tree id="downloadView" ref="NC:DownloadsRoot"
datasources="rdf:downloads" datasources="rdf:downloads"
multiple="true" flags="dont-test-empty" seltype="multiple" flags="dont-test-empty"
ondragover="nsDragAndDrop.dragOver(event, downloadView);" ondragover="nsDragAndDrop.dragOver(event, downloadView);"
ondraggesture="nsDragAndDrop.startDrag(event, downloadView);" ondraggesture="nsDragAndDrop.startDrag(event, downloadView);"
ondragdrop="nsDragAndDrop.drop(event, downloadView);" ondragdrop="nsDragAndDrop.drop(event, downloadView);"

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

@ -139,7 +139,7 @@ function SelectAvailableCharset()
var active_charsets = document.getElementById('active_charsets'); var active_charsets = document.getElementById('active_charsets');
if (active_charsets.selectedItems.length > 0) if (active_charsets.selectedItems.length > 0)
active_charsets.clearItemSelection(); active_charsets.clearSelection();
update_buttons(); update_buttons();
} //SelectAvailableCharset } //SelectAvailableCharset
@ -152,7 +152,7 @@ function SelectActiveCharset()
var available_charsets = document.getElementById('available_charsets'); var available_charsets = document.getElementById('available_charsets');
if (available_charsets.selectedItems.length > 0) if (available_charsets.selectedItems.length > 0)
available_charsets.clearItemSelection(); available_charsets.clearSelection();
update_buttons(); update_buttons();
} //SelectActiveCharset } //SelectActiveCharset
@ -227,7 +227,7 @@ function AddAvailableCharset()
}//for }//for
available_charsets.clearItemSelection(); available_charsets.clearSelection();
enable_save(); enable_save();
} //AddAvailableCharset } //AddAvailableCharset
@ -262,7 +262,7 @@ function RemoveActiveCharset()
if (nextNode) { if (nextNode) {
tree.selectItem(nextNode) tree.selectItem(nextNode)
} else { } else {
//tree.clearItemSelection(); //tree.clearSelection();
} }
enable_save(); enable_save();

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

@ -47,7 +47,7 @@
<tree id="available_charsets" flex="1" <tree id="available_charsets" flex="1"
onselect="SelectAvailableCharset();" onselect="SelectAvailableCharset();"
ondblclick="AddAvailableCharset();" ondblclick="AddAvailableCharset();"
datasources="rdf:null" multiple="true"> datasources="rdf:null" seltype="multiple">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>
</treecolgroup> </treecolgroup>
@ -66,7 +66,7 @@
onselect="SelectActiveCharset();" onselect="SelectActiveCharset();"
ondblclick="RemoveActiveCharset();" ondblclick="RemoveActiveCharset();"
datasources="rdf:null" datasources="rdf:null"
indent="false" multiple="true"> indent="false" seltype="multiple">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>
</treecolgroup> </treecolgroup>

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

@ -39,7 +39,7 @@
<description>&languages.customize.available.label;</description> <description>&languages.customize.available.label;</description>
<tree id="available_languages" flex="1" <tree id="available_languages" flex="1"
datasources="rdf:null" multiple="true" ondblclick="HandleDoubleClick(event.target)"> datasources="rdf:null" seltype="multiple" ondblclick="HandleDoubleClick(event.target)">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>
</treecolgroup> </treecolgroup>

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

@ -386,7 +386,7 @@ function AddAvailableLanguage()
}//if }//if
} }
available_languages.clearItemSelection(); available_languages.clearSelection();
return true; return true;
} //AddAvailableLanguage } //AddAvailableLanguage
@ -433,7 +433,7 @@ function RemoveActiveLanguage()
if (nextNode) { if (nextNode) {
active_languages.selectItem(nextNode) active_languages.selectItem(nextNode)
} else { } else {
//active_languages.clearItemSelection(); //active_languages.clearSelection();
} }
UpdateSavePrefString(); UpdateSavePrefString();

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

@ -52,7 +52,7 @@
<hbox flex="1"> <hbox flex="1">
<tree id="active_languages" flex="1" style="width: 0px; height: 0px;" <tree id="active_languages" flex="1" style="width: 0px; height: 0px;"
preftype="localizedstring" prefstring="intl.accept_languages" prefvalue="" prefattribute="prefvalue" wsm_attributes="prefvalue" preftype="localizedstring" prefstring="intl.accept_languages" prefvalue="" prefattribute="prefvalue" wsm_attributes="prefvalue"
datasources="rdf:null" multiple="true" onselect="SelectLanguage();"> datasources="rdf:null" seltype="multiple" onselect="SelectLanguage();">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>
</treecolgroup> </treecolgroup>

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

@ -76,7 +76,7 @@
</row> </row>
<separator class="thin"/> <separator class="thin"/>
<row flex="1"> <row flex="1">
<tree id="disabledDomains" multiple="true" onkeyup="treeHandleEvent(event)" style="height: 0px; width: 0px;" flex="1"> <tree id="disabledDomains" seltype="multiple" onkeyup="treeHandleEvent(event)" style="height: 0px; width: 0px;" flex="1">
<treecolgroup> <treecolgroup>
<treecol flex="1"/> <treecol flex="1"/>
</treecolgroup> </treecolgroup>

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

@ -46,7 +46,7 @@
<hbox flex="1"> <hbox flex="1">
<vbox flex="1"> <vbox flex="1">
<tree multiple="true" flex="1" id="allengines" ref="NC:SearchEngineRoot" datasources="rdf:internetsearch"> <tree seltype="multiple" flex="1" id="allengines" ref="NC:SearchEngineRoot" datasources="rdf:internetsearch">
<template> <template>
<treechildren> <treechildren>
<treeitem uri="..." loading="rdf:http://home.netscape.com/NC-rdf#loading"> <treeitem uri="..." loading="rdf:http://home.netscape.com/NC-rdf#loading">
@ -105,7 +105,7 @@
<separator class="thin"/> <separator class="thin"/>
<hbox flex="1"> <hbox flex="1">
<tree multiple="true" flex="1" id="engineList" style="height: 0px;" <tree seltype="multiple" flex="1" id="engineList" style="height: 0px;"
datasources="rdf:internetsearch" onselect="doMoveDirectionEnabling()"> datasources="rdf:internetsearch" onselect="doMoveDirectionEnabling()">
<template> <template>
<treechildren> <treechildren>

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

@ -222,7 +222,7 @@ function ClickOnOtherPanels(event)
// Remove the selection in the "current" panels list // Remove the selection in the "current" panels list
var current_panels = document.getElementById('current-panels'); var current_panels = document.getElementById('current-panels');
current_panels.clearItemSelection(); current_panels.clearSelection();
enable_buttons_for_current_panels(); enable_buttons_for_current_panels();
if (treeitem.getAttribute('container') == 'true') { if (treeitem.getAttribute('container') == 'true') {
@ -275,7 +275,7 @@ function add_datasource_to_other_panels(link) {
function SelectChangeForCurrentPanels() { function SelectChangeForCurrentPanels() {
// Remove the selection in the available panels list // Remove the selection in the available panels list
var all_panels = document.getElementById('other-panels'); var all_panels = document.getElementById('other-panels');
all_panels.clearItemSelection(); all_panels.clearSelection();
enable_buttons_for_current_panels(); enable_buttons_for_current_panels();
enable_buttons_for_other_panels(); enable_buttons_for_other_panels();
@ -370,7 +370,7 @@ function AddPanel()
// Remove the selection in the other list. // Remove the selection in the other list.
// Selection will move to "current" list. // Selection will move to "current" list.
var all_panels = document.getElementById('other-panels'); var all_panels = document.getElementById('other-panels');
all_panels.clearItemSelection(); all_panels.clearSelection();
enable_buttons_for_current_panels(); enable_buttons_for_current_panels();
enable_buttons_for_other_panels(); enable_buttons_for_other_panels();

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

@ -52,7 +52,7 @@
<tree id="other-panels" flex="1" <tree id="other-panels" flex="1"
datasources="rdf:null" datasources="rdf:null"
containment="http://home.netscape.com/NC-rdf#panel-list" containment="http://home.netscape.com/NC-rdf#panel-list"
indent="true" multiple="true" indent="true" seltype="multiple"
onselect="SelectChangeForOtherPanels(event, event.target.parentNode.parentNode)" onselect="SelectChangeForOtherPanels(event, event.target.parentNode.parentNode)"
onclick="if (event.detail == 2) { AddPanel(); }" onclick="if (event.detail == 2) { AddPanel(); }"
> >
@ -116,7 +116,7 @@
<label value="&sidebar.customize.current.label;" <label value="&sidebar.customize.current.label;"
crop="right"/> crop="right"/>
<tree id="current-panels" onclick="SelectChangeForCurrentPanels();" <tree id="current-panels" onclick="SelectChangeForCurrentPanels();"
datasources="rdf:null" flex="1" multiple="true"> datasources="rdf:null" flex="1" seltype="multiple">
<template> <template>
<rule> <rule>
<conditions> <conditions>

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

@ -15,28 +15,387 @@
extends="chrome://global/content/bindings/tree.xml#tree-base"> extends="chrome://global/content/bindings/tree.xml#tree-base">
<content> <content>
<children> <children>
<xul:treecolgroup> <xul:treecolgroup>
<xul:treecol flex="1"/> <xul:treecol flex="1"/>
</xul:treecolgroup> </xul:treecolgroup>
</children> </children>
<xul:treerows class="tree-container-treerows" inherits="dragover,dragdroptree"> <xul:treerows class="tree-container-treerows" inherits="dragover,dragdroptree">
<children includes="treehead|treechildren"/> <children includes="treehead|treechildren"/>
</xul:treerows> </xul:treerows>
</content> </content>
<implementation>
<property name="selectedIndex" <implementation implements="nsIDOMXULMultiSelectControlElement">
onget="return (this.selectedItems.length > 0 ? this.getIndexOfItem(this.selectedItems[0]) : -1)" <field name="_isUpSelection">0</field>
onset="if(val>=0){var item=this.getItemAtIndex(val); if(item) this.selectItem(item);} else this.clearItemSelection();" <field name="_isDownSelection">0</field>
/> <field name="_suppressOnSelect">false</field>
<field name="_selectionStart">null</field>
<field name="_currentItem">null</field>
<field name="_selectTimeout">null</field>
<constructor>
<![CDATA[
var els = this.getElementsByAttribute("selected", "true");
this.selectedItems = [];
for (var i = 0; i < els.length; ++i)
this.selectedItems.push(els[i]);
]]>
</constructor>
<!-- ///////////////// public tree members ///////////////// -->
<property name="treeBoxObject" <property name="treeBoxObject"
onget="return this.boxObject.QueryInterface(Components.interfaces.nsITreeBoxObject);" onget="return this.boxObject.QueryInterface(Components.interfaces.nsITreeBoxObject);"
readonly="true"/> readonly="true"/>
<field name="isUpSelection">
0 <method name="timedSelect">
</field> <parameter name="item"/>
<field name="isDownSelection"> <parameter name="timeout"/>
0 <body>
</field> <![CDATA[
var suppress = this._suppressOnSelect;
if (timeout != -1)
this._suppressOnSelect = true;
this.selectItem(item);
this._suppressOnSelect = suppress;
if (timeout != -1) {
if (this._selectTimeout)
window.clearTimeout(this._selectTimeout);
this._selectTimeout = window.setTimeout(this._selectTimeoutHandler, timeout, this);
}
]]>
</body>
</method>
<!-- ///////////////// private tree members ///////////////// -->
<method name="_fireOnSelect">
<body>
<![CDATA[
if (!this._suppressOnSelect && this.getAttribute("suppressonselect") != "true") {
var event = document.createEvent("Events");
event.initEvent("select", false, true);
this.dispatchEvent(event);
}
]]>
</body>
</method>
<method name="_selectTimeoutHandler">
<parameter name="me"/>
<body>
<![CDATA[
me._fireOnSelect();
this._selectTimeout = null;
]]>
</body>
</method>
<!-- ///////////////// nsIDOMXULSelectControlElement ///////////////// -->
<property name="selType"
onget="return this.getAttribute('seltype')"
onset="this.setAttribute('seltype', val); return val;"/>
<property name="selectedIndex">
<getter><![CDATA[
return this.selectedItems.length > 0 ? this.getIndexOfItem(this.selectedItems[0]) : -1;
]]></getter>
<setter><![CDATA[
if (val >= 0)
this.selectItem(this.getItemAtIndex(val));
else
this.clearSelection();
]]></setter>
</property>
<property name="selectedItem">
<getter><![CDATA[
return this.selectedItems.length > 0 ? this.selectedItems[0] : null;
]]></getter>
<setter><![CDATA[
this.selectItem(item);
]]></setter>
</property>
<property name="value">
<getter>
<![CDATA[
if (this.selectedItems.length > 0)
return this.selectedItem.value;
else
return null;
]]>
</getter>
<setter>
<![CDATA[
var kids = this.getElementsByAttribute("value", val);
if (kids && kids.length)
this.selectItem(kids[0]);
return val;
]]>
</setter>
</property>
<method name="appendItem">
<parameter name="label"/>
<parameter name="value"/>
<body>
<![CDATA[
var kiddies = this.getElementsByTagName("treechildren")[0];
var item = null;
if (kiddies) {
var XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
item = document.createElementNS(XULNS, "treeitem");
var row = document.createElementNS(XULNS, "treerow");
var cell = document.createElementNS(XULNS, "treecell");
item.setAttribute("label", label);
item.setAttribute("value", value);
kiddies.appendChild(item);
}
return item;
]]>
</body>
</method>
<method name="insertItemAt">
<parameter name="index"/>
<parameter name="label"/>
<parameter name="value"/>
<body>
<![CDATA[
var kiddies = this.getElementsByTagName("treechildren")[0];
var item = null;
if (kiddies) {
var XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
item = document.createElementNS(XULNS, "treeitem");
item.setAttribute("label", label);
item.setAttribute("value", value);
var before = kiddies.childNodes[index];
if (before)
kiddies.insertBefore(item, before);
else
kiddies.appendChild(item);
}
return item;
]]>
</body>
</method>
<method name="removeItemAt">
<parameter name="index"/>
<body>
<![CDATA[
var kiddies = this.getElementsByTagName("treechildren")[0];
var remove = null;
if (kiddies) {
remove = kiddies.childNodes[index];
if (remove)
kiddies.removeChild(remove);
}
return remove;
]]>
</body>
</method>
<!-- ///////////////// nsIDOMXULSelectMultipleControlElement ///////////////// -->
<property name="currentItem" onget="return this._currentItem;">
<setter>
<![CDATA[
if (this._currentItem)
this._currentItem.current = false;
this._currentItem = val;
if (val)
val.current = true;
return val;
]]>
</setter>
</property>
<property name="selectedCount" onget="return this.selectedItems.length;"/>
<method name="getSelectedItem">
<parameter name="index"/>
<body>
<![CDATA[
return index < this.selectedItems.length ? this.selectedItems[index] : null;
]]>
</body>
</method>
<method name="addItemToSelection">
<parameter name="item"/>
<body>
<![CDATA[
if (item.selected)
return;
this.selectedItems.push(item);
item.selected = true;
this._fireOnSelect();
]]>
</body>
</method>
<method name="removeItemFromSelection">
<parameter name="item"/>
<body>
<![CDATA[
if (!item.selected)
return;
for (var i = 0; i < this.selectedItems.length; ++i) {
if (this.selectedItems[i] == item) {
this.selectedItems.splice(i, 1);
item.selected = false;
break;
}
}
this._fireOnSelect();
]]>
</body>
</method>
<method name="toggleItemSelection">
<parameter name="item"/>
<body>
<![CDATA[
if (item.selected)
this.removeItemFromSelection(item);
else
this.addItemToSelection(item);
]]>
</body>
</method>
<method name="selectItem">
<parameter name="item"/>
<body>
<![CDATA[
if (!item)
return;
if (this.selectedItems.length == 1 && this.selectedItems[0] == item)
return;
this._selectionStart = null;
var suppress = this._suppressOnSelect;
this._suppressOnSelect = true;
this.clearSelection();
this.addItemToSelection(item);
this.currentItem = item;
this._suppressOnSelect = suppress;
this._fireOnSelect();
]]>
</body>
</method>
<method name="selectItemRange">
<parameter name="startItem"/>
<parameter name="endItem"/>
<body>
<![CDATA[
if (this.selType != "multiple")
return;
if (!startItem)
startItem = this._selectionStart ? this._selectionStart : this.currentItem;
if (!startItem)
startItem = endItem;
var suppressSelect = this._suppressOnSelect;
this._suppressOnSelect = true;
this.clearSelection();
this._selectionStart = startItem;
var currentItem;
var startIndex = this.getIndexOfItem(startItem);
var endIndex = this.getIndexOfItem(endItem);
if (endIndex < startIndex) {
currentItem = endItem;
endItem = startItem;
startItem = currentItem;
} else {
currentItem = startItem;
}
while (currentItem) {
if (currentItem.localName == "treeitem")
this.addItemToSelection(currentItem);
if (currentItem == endItem)
break;
currentItem = this.getNextItem(currentItem, 1);
}
this._suppressOnSelect = suppressSelect;
this._fireOnSelect();
]]>
</body>
</method>
<method name="selectAll">
<body>
<![CDATA[
var suppress = this._suppressOnSelect;
this._suppressOnSelect = true;
var item = this.getItemAtIndex(0);
while (item) {
this.addItemToSelection(item);
item = this.getNextItem(item, 1);
}
this._suppressOnSelect = suppress;
this._fireOnSelect();
]]>
</body>
</method>
<method name="invertSelection">
<body>
<![CDATA[
var suppress = this._suppressOnSelect;
this._suppressOnSelect = true;
var item = this.getItemAtIndex(0);
while (item) {
if (item.selected)
this.removeItemFromSelection(item);
else
this.addItemToSelection(item);
item = this.getNextItem(item, 1);
}
this._suppressOnSelect = suppress;
this._fireOnSelect();
]]>
</body>
</method>
<method name="clearSelection">
<body>
<![CDATA[
for (var i = this.selectedItems.length-1; i >= 0; --i)
this.selectedItems[i].selected = false;
this.selectedItems.splice(0, this.selectedItems.length);
this._selectionStart = null;
this._fireOnSelect();
]]>
</body>
</method>
<!-- ///////////////// nsITreeBoxObject ///////////////// -->
<method name="getNextItem"> <method name="getNextItem">
<parameter name="startItem"/> <parameter name="startItem"/>
<parameter name="delta"/> <parameter name="delta"/>
@ -97,17 +456,18 @@
</body> </body>
</method> </method>
</implementation> </implementation>
<handlers> <handlers>
<handler event="keypress" keycode="vk_enter"> <handler event="keypress" keycode="vk_enter">
<![CDATA[ <![CDATA[
if (event.target != this || selectedItems.length != 1) if (event.target != this || this.selectedItems.length != 1)
return; return;
this.selectedItems[0].toggleOpenState(); this.selectedItems[0].toggleOpenState();
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="vk_return"> <handler event="keypress" keycode="vk_return">
<![CDATA[ <![CDATA[
if (event.target != this || selectedItems.length != 1) if (event.target != this || this.selectedItems.length != 1)
return; return;
this.selectedItems[0].toggleOpenState(); this.selectedItems[0].toggleOpenState();
]]> ]]>
@ -137,8 +497,8 @@
<![CDATA[ <![CDATA[
if (event.target != this || this.selectedItems.length < 1) if (event.target != this || this.selectedItems.length < 1)
return; return;
this.isUpSelection=0; this._isUpSelection=0;
this.isDownSelection=0; this._isDownSelection=0;
var n = this.getPreviousItem(this.selectedItems[this.selectedItems.length-1], 1); var n = this.getPreviousItem(this.selectedItems[this.selectedItems.length-1], 1);
if (n) { if (n) {
this.ensureIndexIsVisible(this.getIndexOfItem(n)); this.ensureIndexIsVisible(this.getIndexOfItem(n));
@ -156,8 +516,8 @@
n = this.getItemAtIndex(0); n = this.getItemAtIndex(0);
} }
else { else {
this.isUpSelection=0; this._isUpSelection=0;
this.isDownSelection=0; this._isDownSelection=0;
n = this.getNextItem(this.selectedItems[this.selectedItems.length-1], 1); n = this.getNextItem(this.selectedItems[this.selectedItems.length-1], 1);
} }
@ -170,20 +530,20 @@
<handler event="keypress" modifiers="shift" keycode="vk_up"> <handler event="keypress" modifiers="shift" keycode="vk_up">
<![CDATA[ <![CDATA[
var l=this.selectedItems.length; var l=this.selectedItems.length;
if (event.target != this || l < 1 || this.getAttribute("multiple") != "true") if (event.target != this || l < 1 || this.selType != "multiple")
return; return;
var n = this.getPreviousItem(this.selectedItems[l-1], 1); var n = this.getPreviousItem(this.selectedItems[l-1], 1);
if (n) { if (n) {
this.ensureElementIsVisible(n); this.ensureElementIsVisible(n);
if ( this.isDownSelection) { if ( this._isDownSelection) {
if ( l > 1 ) if ( l > 1 )
this.removeItemFromSelection(this.selectedItems[l-1]); this.removeItemFromSelection(this.selectedItems[l-1]);
if ( l <= 2 ) if ( l <= 2 )
this.isDownSelection=0; this._isDownSelection=0;
} }
else { else {
this.addItemToSelection(n); this.addItemToSelection(n);
this.isUpSelection=1; this._isUpSelection=1;
} }
} }
]]> ]]>
@ -191,20 +551,20 @@
<handler event="keypress" modifiers="shift" keycode="vk_down"> <handler event="keypress" modifiers="shift" keycode="vk_down">
<![CDATA[ <![CDATA[
var l=this.selectedItems.length; var l=this.selectedItems.length;
if (event.target != this || l < 1 || this.getAttribute("multiple") != "true") if (event.target != this || l < 1 || this.selType != "multiple")
return; return;
var n = this.getNextItem(this.selectedItems[l-1], 1); var n = this.getNextItem(this.selectedItems[l-1], 1);
if (n) { if (n) {
this.ensureElementIsVisible(n); this.ensureElementIsVisible(n);
if ( this.isUpSelection) { if ( this._isUpSelection) {
if ( l > 1 ) if ( l > 1 )
this.removeItemFromSelection(this.selectedItems[l-1]); this.removeItemFromSelection(this.selectedItems[l-1]);
if ( l <= 2 ) if ( l <= 2 )
this.isUpSelection=0; this._isUpSelection=0;
} }
else { else {
this.addItemToSelection(n); this.addItemToSelection(n);
this.isDownSelection=1; this._isDownSelection=1;
} }
} }
]]> ]]>
@ -214,8 +574,8 @@
var l = this.selectedItems.length; var l = this.selectedItems.length;
if (event.target != this || l < 1) if (event.target != this || l < 1)
return; return;
this.isUpSelection=0; this._isUpSelection=0;
this.isDownSelection=0; this._isDownSelection=0;
var i = this.getIndexOfFirstVisibleRow(); var i = this.getIndexOfFirstVisibleRow();
if ( i == 0 ) if ( i == 0 )
var n=this.getItemAtIndex(0); var n=this.getItemAtIndex(0);
@ -237,8 +597,8 @@
var l = this.selectedItems.length; var l = this.selectedItems.length;
if (event.target != this || l < 1) if (event.target != this || l < 1)
return; return;
this.isUpSelection=0; this._isUpSelection=0;
this.isDownSelection=0; this._isDownSelection=0;
var i = this.getIndexOfFirstVisibleRow(); var i = this.getIndexOfFirstVisibleRow();
var v = this.getNumberOfVisibleRows(); var v = this.getNumberOfVisibleRows();
var count = this.getRowCount(); var count = this.getRowCount();
@ -261,8 +621,8 @@
<![CDATA[ <![CDATA[
if (event.target != this || this.selectedItems.length < 1) if (event.target != this || this.selectedItems.length < 1)
return; return;
this.isUpSelection=0; this._isUpSelection=0;
this.isDownSelection=0; this._isDownSelection=0;
this.scrollToIndex(0); this.scrollToIndex(0);
this.selectItem(this.getItemAtIndex(0)); this.selectItem(this.getItemAtIndex(0));
]]> ]]>
@ -271,8 +631,8 @@
<![CDATA[ <![CDATA[
if (event.target != this || this.selectedItems.length < 1) if (event.target != this || this.selectedItems.length < 1)
return; return;
this.isUpSelection=0; this._isUpSelection=0;
this.isDownSelection=0; this._isDownSelection=0;
var count = this.getRowCount(); var count = this.getRowCount();
this.ensureIndexIsVisible(count-1); this.ensureIndexIsVisible(count-1);
this.selectItem(this.getItemAtIndex(count-1)); this.selectItem(this.getItemAtIndex(count-1));
@ -284,6 +644,7 @@
<binding id="treerows" <binding id="treerows"
extends="chrome://global/content/bindings/tree.xml#tree-base"> extends="chrome://global/content/bindings/tree.xml#tree-base">
<content outer="true"/> <content outer="true"/>
<implementation> <implementation>
<constructor> <constructor>
this.addEventListener("DOMMouseScroll", this._handleMouseScroll, true); this.addEventListener("DOMMouseScroll", this._handleMouseScroll, true);
@ -307,6 +668,21 @@
}) })
]]> ]]>
</field> </field>
<method name="_getMouseTargetItem">
<parameter name="event"/>
<body>
<![CDATA[
var p = event.originalTarget;
while (p) {
if (p.localName == "treeitem")
return p;
p = p.parentNode;
}
return null;
]]>
</body>
</method>
</implementation> </implementation>
<handlers> <handlers>
@ -314,16 +690,13 @@
click, so that drags work correctly. --> click, so that drags work correctly. -->
<handler event="mousedown"> <handler event="mousedown">
<![CDATA[ <![CDATA[
var lt = event.originalTarget.localName; var targetItem = this._getMouseTargetItem(event);
var target = (lt == 'treecell' || lt == 'treerow') ? lt : null; if (targetItem && !event.ctrlKey && !event.shiftKey && !event.metaKey) {
if (target && !event.ctrlKey && !event.shiftKey && !event.metaKey) { if (!targetItem.selected)
var parent = lt == 'treecell' ? event.target.parentNode.parentNode : event.target.parentNode; parentNode.selectItem(targetItem);
var isSelected = parent.getAttribute("selected");
if (!isSelected) { parentNode.currentItem = targetItem;
parentNode.selectItem(parent); }
}
parentNode.currentItem = parent;
}
]]> ]]>
</handler> </handler>
@ -331,41 +704,41 @@
except this item. --> except this item. -->
<handler event="click"> <handler event="click">
<![CDATA[ <![CDATA[
if (event.button != 0) return; if (event.button != 0) return;
var t = event.originalTarget; var targetItem = this._getMouseTargetItem(event);
if (t.localName == 'treecell') { if (targetItem) {
if (event.ctrlKey || event.metaKey) { if (event.ctrlKey || event.metaKey) {
parentNode.toggleItemSelection(t.parentNode.parentNode); parentNode.toggleItemSelection(targetItem);
parentNode.currentItem = t.parentNode.parentNode; parentNode.currentItem = targetItem;
} }
else if (event.shiftKey) { else if (event.shiftKey) {
parentNode.selectItemRange(null, t.parentNode.parentNode); parentNode.selectItemRange(null, targetItem);
parentNode.currentItem = t.parentNode.parentNode; parentNode.currentItem = targetItem;
} }
else { else {
/* We want to deselect all the selected items except what was /* We want to deselect all the selected items except what was
clicked, UNLESS it was a right-click. We have to do this clicked, UNLESS it was a right-click. We have to do this
in click rather than mousedown so that you can drag a in click rather than mousedown so that you can drag a
selected group of items */ selected group of items */
var selectedItems = parentNode.selectedItems; var selectedItems = parentNode.selectedItems;
var didSuppressSelect = false; var didSuppressSelect = false;
var i = 0; var i = 0;
while (i < selectedItems.length) { while (i < selectedItems.length) {
if (selectedItems[i] != t.parentNode.parentNode) { if (selectedItems[i] != targetItem) {
if (!didSuppressSelect) { if (!didSuppressSelect) {
parentNode.suppressOnSelect = true; parentNode._suppressOnSelect = true;
didSuppressSelect = true; didSuppressSelect = true;
} }
parentNode.removeItemFromSelection(selectedItems[i]); parentNode.removeItemFromSelection(selectedItems[i]);
} }
else else
i++; i++;
} }
if (didSuppressSelect) if (didSuppressSelect)
parentNode.suppressOnSelect = false; parentNode._suppressOnSelect = false;
} }
} }
]]> ]]>
</handler> </handler>
@ -395,8 +768,52 @@
</binding> </binding>
<binding id="treeitem" <binding id="treeitem"
extends="chrome://global/content/bindings/tree.xml#tree-base"> extends="chrome://global/content/bindings/general.xml#basetext">
<implementation> <resources>
<stylesheet src="chrome://global/content/bindings/tree.css"/>
<stylesheet src="chrome://global/skin/tree.css"/>
</resources>
<implementation implements="nsIDOMXULSelectControlItemElement">
<property name="current" onget="return this.getAttribute('current') == 'true';">
<setter><![CDATA[
if (val)
this.setAttribute("current", "true");
else
this.removeAttribute("current");
return val;
]]></setter>
</property>
<!-- ///////////////// nsIDOMXULSelectControlItemElement ///////////////// -->
<property name="value" onget="return this.getAttribute('value');"
onset="this.setAttribute('value', val); return val;"/>
<property name="selected" onget="return this.getAttribute('selected') == 'true';">
<setter><![CDATA[
if (val)
this.setAttribute("selected", "true");
else
this.removeAttribute("selected");
return val;
]]></setter>
</property>
<property name="control">
<getter><![CDATA[
var parent = this.parentNode;
while (parent) {
if (parent.localName == "tree")
return parent;
parent = parent.parentNode;
}
return null;
]]></getter>
</property>
<!-- ///////////////// public treeitem members ///////////////// -->
<method name="toggleOpenState"> <method name="toggleOpenState">
<body> <body>
<![CDATA[ <![CDATA[
@ -557,37 +974,5 @@
</content> </content>
</binding> </binding>
<binding id="listbox" extends="xul:tree">
<content>
<xul:cols>
<xul:col flex="1"/>
</xul:cols>
<xul:treerows>
<xul:treerows>
<children includes="listhead"/>
<xul:treechildren>
<children/>
</xul:treechildren>
</xul:treerows>
</xul:treerows>
</content>
</binding>
<binding id="listhead" extends="xul:treehead">
<content>
<xul:treerow>
<xul:treecell inherits="label" class="listcell-header"/>
</xul:treerow>
</content>
</binding>
<binding id="listitem" extends="xul:treeitem">
<content>
<xul:treerow>
<xul:treecell inherits="label" class="listcell-text"/>
</xul:treerow>
</content>
</binding>
</bindings> </bindings>