зеркало из https://github.com/mozilla/pjs.git
Fix for bug 43417. r=pinkerton.
This commit is contained in:
Родитель
a2fccb3141
Коммит
911f34cf7f
|
@ -2989,12 +2989,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ nsXULTreeElement::nsXULTreeElement(nsIDOMXULElement* aOuter)
|
|||
mSelectedItems = children;
|
||||
|
||||
mCurrentItem = nsnull;
|
||||
mSelectionStart = nsnull;
|
||||
}
|
||||
|
||||
nsXULTreeElement::~nsXULTreeElement()
|
||||
|
@ -160,6 +161,7 @@ nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem)
|
|||
AddItemToSelectionInternal(aTreeItem);
|
||||
|
||||
SetCurrentItem(aTreeItem);
|
||||
mSelectionStart = nsnull;
|
||||
|
||||
FireOnSelectHandler();
|
||||
|
||||
|
@ -170,6 +172,7 @@ NS_IMETHODIMP
|
|||
nsXULTreeElement::ClearItemSelection()
|
||||
{
|
||||
ClearItemSelectionInternal();
|
||||
mSelectionStart = nsnull;
|
||||
FireOnSelectHandler();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -262,8 +265,10 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
|
|||
|
||||
nsCOMPtr<nsIDOMXULElement> startItem;
|
||||
if (aStartItem == nsnull) {
|
||||
// Continue the ranged selection based off the current item.
|
||||
startItem = mCurrentItem;
|
||||
// Continue the ranged selection based off the first item selected
|
||||
if (!mSelectionStart)
|
||||
mSelectionStart = mCurrentItem;
|
||||
startItem = mSelectionStart;
|
||||
}
|
||||
else startItem = aStartItem;
|
||||
|
||||
|
@ -287,11 +292,10 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
|
|||
treebox->GetIndexOfItem(startItem, &startIndex);
|
||||
treebox->GetIndexOfItem(aEndItem, &endIndex);
|
||||
|
||||
PRBool didSwap = (endIndex < startIndex);
|
||||
nsCOMPtr<nsIDOMElement> currentItem;
|
||||
// If it's a backward selection, swap the starting and
|
||||
// ending items so we always iterate forward
|
||||
if (didSwap) {
|
||||
if (endIndex < startIndex) {
|
||||
currentItem = do_QueryInterface(aEndItem);
|
||||
aEndItem = startItem;
|
||||
startItem = do_QueryInterface(currentItem);
|
||||
|
@ -315,11 +319,6 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
|
|||
currentItem = nextItem;
|
||||
}
|
||||
|
||||
// We want the focused item to end up being the last one the user clicked
|
||||
if (didSwap)
|
||||
SetCurrentItem(startItem);
|
||||
else
|
||||
SetCurrentItem(aEndItem);
|
||||
FireOnSelectHandler();
|
||||
|
||||
return NS_OK;
|
||||
|
@ -328,8 +327,6 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
|
|||
NS_IMETHODIMP
|
||||
nsXULTreeElement::SelectAll()
|
||||
{
|
||||
nsIDOMXULElement* oldItem = mCurrentItem;
|
||||
|
||||
PRInt32 childCount;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mOuter);
|
||||
content->ChildCount(childCount);
|
||||
|
@ -361,9 +358,6 @@ nsXULTreeElement::SelectAll()
|
|||
// Select the whole range.
|
||||
SelectItemRange(startContent, endContent);
|
||||
|
||||
// We shouldn't move the active item.
|
||||
mCurrentItem = oldItem;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
|||
protected:
|
||||
nsRDFDOMNodeList* mSelectedItems;
|
||||
nsIDOMXULElement* mCurrentItem;
|
||||
nsIDOMXULElement* mSelectionStart;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ function refreshServerList()
|
|||
for (var i=0; i< oldSelectedIds.length; i++) {
|
||||
var element = document.getElementById(oldSelectedIds[i]);
|
||||
if (element)
|
||||
element.setAttribute("selected", "true");
|
||||
serverList.selectItem(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2989,12 +2989,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ nsXULTreeElement::nsXULTreeElement(nsIDOMXULElement* aOuter)
|
|||
mSelectedItems = children;
|
||||
|
||||
mCurrentItem = nsnull;
|
||||
mSelectionStart = nsnull;
|
||||
}
|
||||
|
||||
nsXULTreeElement::~nsXULTreeElement()
|
||||
|
@ -160,6 +161,7 @@ nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem)
|
|||
AddItemToSelectionInternal(aTreeItem);
|
||||
|
||||
SetCurrentItem(aTreeItem);
|
||||
mSelectionStart = nsnull;
|
||||
|
||||
FireOnSelectHandler();
|
||||
|
||||
|
@ -170,6 +172,7 @@ NS_IMETHODIMP
|
|||
nsXULTreeElement::ClearItemSelection()
|
||||
{
|
||||
ClearItemSelectionInternal();
|
||||
mSelectionStart = nsnull;
|
||||
FireOnSelectHandler();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -262,8 +265,10 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
|
|||
|
||||
nsCOMPtr<nsIDOMXULElement> startItem;
|
||||
if (aStartItem == nsnull) {
|
||||
// Continue the ranged selection based off the current item.
|
||||
startItem = mCurrentItem;
|
||||
// Continue the ranged selection based off the first item selected
|
||||
if (!mSelectionStart)
|
||||
mSelectionStart = mCurrentItem;
|
||||
startItem = mSelectionStart;
|
||||
}
|
||||
else startItem = aStartItem;
|
||||
|
||||
|
@ -287,11 +292,10 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
|
|||
treebox->GetIndexOfItem(startItem, &startIndex);
|
||||
treebox->GetIndexOfItem(aEndItem, &endIndex);
|
||||
|
||||
PRBool didSwap = (endIndex < startIndex);
|
||||
nsCOMPtr<nsIDOMElement> currentItem;
|
||||
// If it's a backward selection, swap the starting and
|
||||
// ending items so we always iterate forward
|
||||
if (didSwap) {
|
||||
if (endIndex < startIndex) {
|
||||
currentItem = do_QueryInterface(aEndItem);
|
||||
aEndItem = startItem;
|
||||
startItem = do_QueryInterface(currentItem);
|
||||
|
@ -315,11 +319,6 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
|
|||
currentItem = nextItem;
|
||||
}
|
||||
|
||||
// We want the focused item to end up being the last one the user clicked
|
||||
if (didSwap)
|
||||
SetCurrentItem(startItem);
|
||||
else
|
||||
SetCurrentItem(aEndItem);
|
||||
FireOnSelectHandler();
|
||||
|
||||
return NS_OK;
|
||||
|
@ -328,8 +327,6 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
|
|||
NS_IMETHODIMP
|
||||
nsXULTreeElement::SelectAll()
|
||||
{
|
||||
nsIDOMXULElement* oldItem = mCurrentItem;
|
||||
|
||||
PRInt32 childCount;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mOuter);
|
||||
content->ChildCount(childCount);
|
||||
|
@ -361,9 +358,6 @@ nsXULTreeElement::SelectAll()
|
|||
// Select the whole range.
|
||||
SelectItemRange(startContent, endContent);
|
||||
|
||||
// We shouldn't move the active item.
|
||||
mCurrentItem = oldItem;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
|||
protected:
|
||||
nsRDFDOMNodeList* mSelectedItems;
|
||||
nsIDOMXULElement* mCurrentItem;
|
||||
nsIDOMXULElement* mSelectionStart;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -441,7 +441,7 @@ function selectDroppedItems(treeRoot, containerID, targetID)
|
|||
|
||||
if (id == containerID)
|
||||
{
|
||||
node.setAttribute("selected", "true");
|
||||
treeRoot.selectItem(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -584,7 +584,7 @@ function selectItems(treeRoot, containerID, targetID)
|
|||
|
||||
if (id == containerID)
|
||||
{
|
||||
node.setAttribute("selected", "true");
|
||||
treeRoot.selectItem(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,15 +280,49 @@
|
|||
<binding id="treerows">
|
||||
<content flex="1"/>
|
||||
<handlers>
|
||||
<handler type="click" shift="false" control="false"
|
||||
value="if (event.target.localName == 'treecell')
|
||||
parentNode.selectItem(event.target.parentNode.parentNode);"/>
|
||||
<handler type="click" shift="false" control="true"
|
||||
value="if (event.target.localName == 'treecell')
|
||||
parentNode.toggleItemSelection(event.target.parentNode.parentNode);"/>
|
||||
<handler type="click" shift="true" control="false"
|
||||
value="if (event.target.localName == 'treecell')
|
||||
parentNode.selectItemRange(null, event.target.parentNode.parentNode);"/>
|
||||
<!-- If there is no modifier key, we select on mousedown, not
|
||||
click, so that drags work correctly. -->
|
||||
<handler type="mousedown" shift="false" control="false">
|
||||
<![CDATA[
|
||||
if (event.target.localName == 'treecell') {
|
||||
var isSelected = event.target.parentNode.parentNode.getAttribute("selected");
|
||||
if (!isSelected) {
|
||||
parentNode.selectItem(event.target.parentNode.parentNode);
|
||||
}
|
||||
parentNode.currentItem = event.target.parentNode.parentNode;
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<!-- On a click (up+down on the same item), deselect everything
|
||||
except this item. -->
|
||||
<handler type="click" shift="false" control="false">
|
||||
<![CDATA[
|
||||
if (event.target.localName == 'treecell') {
|
||||
parentNode.clearItemSelection();
|
||||
parentNode.selectItem(event.target.parentNode.parentNode);
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<handler type="click" shift="false" control="true">
|
||||
<![CDATA[
|
||||
if (event.target.localName == 'treecell') {
|
||||
parentNode.toggleItemSelection(event.target.parentNode.parentNode);
|
||||
parentNode.currentItem = event.target.parentNode.parentNode;
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<handler type="click" shift="true" control="false">
|
||||
<![CDATA[
|
||||
if (event.target.localName == 'treecell') {
|
||||
parentNode.selectItemRange(null, event.target.parentNode.parentNode);
|
||||
parentNode.currentItem = event.target.parentNode.parentNode;
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<handler type="click" shift="false" control="false" clickcount="2">
|
||||
<![CDATA[
|
||||
if (event.target.localName == 'treecell') {
|
||||
|
|
Загрузка…
Ссылка в новой задаче