Fixing Bug 454632 - Resizing tree widget always re-scrolls to current index. r=enndeakin,sr=bz. Patch by Stephen Lau <steve@grommit.com>.

This commit is contained in:
Nick Kreeger 2009-01-13 10:50:26 -08:00
Родитель 9e4c216172
Коммит 77cbc0d00a
3 изменённых файлов: 20 добавлений и 9 удалений

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

@ -459,6 +459,7 @@ GK_ATOM(isindex, "isindex")
GK_ATOM(ismap, "ismap") GK_ATOM(ismap, "ismap")
GK_ATOM(kbd, "kbd") GK_ATOM(kbd, "kbd")
GK_ATOM(noautofocus, "noautofocus") GK_ATOM(noautofocus, "noautofocus")
GK_ATOM(keepcurrentinview, "keepcurrentinview")
GK_ATOM(key, "key") GK_ATOM(key, "key")
GK_ATOM(keycode, "keycode") GK_ATOM(keycode, "keycode")
GK_ATOM(keydown, "keydown") GK_ATOM(keydown, "keydown")

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

@ -451,15 +451,20 @@ nsTreeBodyFrame::ReflowFinished()
if (mTopRowIndex > lastPageTopRow) if (mTopRowIndex > lastPageTopRow)
ScrollToRowInternal(parts, lastPageTopRow); ScrollToRowInternal(parts, lastPageTopRow);
// make sure that the current selected item is still nsIContent *treeContent = GetBaseElement();
// visible after the tree changes size. if (treeContent->AttrValueIs(kNameSpaceID_None,
nsCOMPtr<nsITreeSelection> sel; nsGkAtoms::keepcurrentinview,
mView->GetSelection(getter_AddRefs(sel)); nsGkAtoms::_true, eCaseMatters)) {
if (sel) { // make sure that the current selected item is still
PRInt32 currentIndex; // visible after the tree changes size.
sel->GetCurrentIndex(&currentIndex); nsCOMPtr<nsITreeSelection> sel;
if (currentIndex != -1) mView->GetSelection(getter_AddRefs(sel));
EnsureRowIsVisibleInternal(parts, currentIndex); if (sel) {
PRInt32 currentIndex;
sel->GetCurrentIndex(&currentIndex);
if (currentIndex != -1)
EnsureRowIsVisibleInternal(parts, currentIndex);
}
} }
if (!FullScrollbarsUpdate(PR_FALSE)) { if (!FullScrollbarsUpdate(PR_FALSE)) {

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

@ -105,6 +105,11 @@
true true
#endif #endif
</field> </field>
<property name="keepCurrentInView"
onget="return (this.getAttribute('keepcurrentinview') == 'true');"
onset="if (val) this.setAttribute('keepcurrentinview', 'true');
else this.removeAttribute('keepcurrentinview'); return val;"/>
<property name="enableColumnDrag" <property name="enableColumnDrag"
onget="return this.hasAttribute('enableColumnDrag');" onget="return this.hasAttribute('enableColumnDrag');"
onset="if (val) this.setAttribute('enableColumnDrag', 'true'); onset="if (val) this.setAttribute('enableColumnDrag', 'true');