diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 261d2c1c374..b832cc0cbdb 100755 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -283,6 +283,7 @@ GK_ATOM(dropBefore, "dropBefore") GK_ATOM(dropOn, "dropOn") GK_ATOM(dt, "dt") GK_ATOM(editable, "editable") +GK_ATOM(editing, "editing") GK_ATOM(editor, "editor") GK_ATOM(editorDisplayList, "EditorDisplay-List") GK_ATOM(element, "element") diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 4c7e8ba33ee..367c344e12e 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -1201,7 +1201,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n // X and Y coords, and a guess at the width and height. The width is the // remaining width we have left to traverse in the cell, which will be the // widest possible value for the text rect, and the row height. - nsRect textRect(cellX, cellRect.y, remainWidth, mRowHeight); + nsRect textRect(cellX, cellRect.y, remainWidth, cellRect.height); // Measure the width of the text. If the width of the text is greater than // the remaining width available, then we just assume that the text has @@ -1215,10 +1215,19 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n nscoord height; fm->GetHeight(height); + nsMargin textMargin; + textContext->GetStyleMargin()->GetMargin(textMargin); + textRect.Deflate(textMargin); + + // Center the text. XXX Obey vertical-align style prop? + if (height < textRect.height) { + textRect.y += (textRect.height - height) / 2; + textRect.height = height; + } + nsMargin bp(0,0,0,0); GetBorderPadding(textContext, bp); - - textRect.height = height + bp.top + bp.bottom; + textRect.height += bp.top + bp.bottom; rc->SetFont(fm); nscoord width; @@ -1880,6 +1889,10 @@ nsTreeBodyFrame::PrefillPropertyArray(PRInt32 aRowIndex, nsTreeColumn* aCol) mScratchArray->AppendElement(nsXULAtoms::odd); else mScratchArray->AppendElement(nsXULAtoms::even); + + nsIContent* baseContent = GetBaseElement(); + if (baseContent && baseContent->HasAttr(kNameSpaceID_None, nsXULAtoms::editing)) + mScratchArray->AppendElement(nsXULAtoms::editing); } if (aCol) { diff --git a/themes/classic/global/mac/tree.css b/themes/classic/global/mac/tree.css index a0c90177c62..6f854d57467 100644 --- a/themes/classic/global/mac/tree.css +++ b/themes/classic/global/mac/tree.css @@ -350,3 +350,24 @@ treechildren[alternatingbackground="true"]::-moz-tree-row(odd, selected, focus) treechildren[alternatingbackground="true"]::-moz-tree-cell-text(odd, selected, focus) { color: HighlightText; } + +/* ::::: editable tree ::::: */ + +treechildren::-moz-tree-row(selected, editing) { + background-color: transparent; +} + +treechildren::-moz-tree-cell-text(selected, editing) { + color: inherit; +} + +.tree-input { + -moz-appearance: none; + border: 1px solid Highlight; + -moz-border-top-colors: Highlight; + -moz-border-bottom-colors: Highlight; + -moz-border-left-colors: Highlight; + -moz-border-right-colors: Highlight; + margin: 0 0 0 -3px; + padding: 1px; +} diff --git a/themes/classic/global/win/tree.css b/themes/classic/global/win/tree.css index 16df06ebb60..6e5fd83bf79 100644 --- a/themes/classic/global/win/tree.css +++ b/themes/classic/global/win/tree.css @@ -380,3 +380,25 @@ treechildren[alternatingbackground="true"]::-moz-tree-row(odd, selected, focus) treechildren[alternatingbackground="true"]::-moz-tree-cell-text(odd, selected, focus) { color: HighlightText; } + +/* ::::: editable tree ::::: */ + +treechildren::-moz-tree-row(selected, editing) { + background-color: transparent; + border: none; +} + +treechildren::-moz-tree-cell-text(selected, editing) { + color: inherit; +} + +.tree-input { + -moz-appearance: none; + border: 1px solid Highlight; + -moz-border-top-colors: Highlight; + -moz-border-bottom-colors: Highlight; + -moz-border-left-colors: Highlight; + -moz-border-right-colors: Highlight; + margin: 0 0 0 -4px; + padding: 1px; +} diff --git a/themes/modern/global/tree.css b/themes/modern/global/tree.css index 71a120dff05..5469c8afc5a 100644 --- a/themes/modern/global/tree.css +++ b/themes/modern/global/tree.css @@ -349,3 +349,24 @@ treechildren.gridlines::-moz-tree-cell { treechildren.gridlines::-moz-tree-row { border: none; } + +/* ::::: editable tree ::::: */ + +treechildren::-moz-tree-row(selected, editing) { + background-color: transparent; +} + +treechildren::-moz-tree-cell-text(selected, editing) { + color: inherit; +} + +.tree-input { + -moz-appearance: none; + border: 1px solid #C7D0D9; + -moz-border-top-colors: #C7D0D9; + -moz-border-bottom-colors: #C7D0D9; + -moz-border-left-colors: #C7D0D9; + -moz-border-right-colors: #C7D0D9; + margin: 0 0 0 -4px; + padding: 1px; +} diff --git a/toolkit/content/widgets/tree.xml b/toolkit/content/widgets/tree.xml index 7424bae8d72..8fb509e7c78 100644 --- a/toolkit/content/widgets/tree.xml +++ b/toolkit/content/widgets/tree.xml @@ -21,7 +21,7 @@ #else return aEvent.ctrlKey; #endif - ]]> + ]]> @@ -29,9 +29,12 @@ - - - + + + + + @@ -103,11 +106,29 @@ onset="if (val) this.setAttribute('enableColumnDrag', 'true'); else this.removeAttribute('enableColumnDrag'); return val;"/> + null + + + + + + -1 + null + + + + @@ -222,7 +243,7 @@ } ]]> - + + + + + + = this.itemCount || !column) + return; + if (column.type != Components.interfaces.nsITreeColumn.TYPE_TEXT || + column.cycler || !this.view.isEditable(row, column)) + return; + + if (this._editingColumn) + this.stopEditing(); + + var input = this.inputField; + input.hidden = false; + + var box = this.treeBoxObject; + var outx = {}, outy = {}, outwidth = {}, outheight = {}; + var coords = box.getCoordsForCellItem(row, column, "text", + outx, outy, outwidth, outheight); + + var style = window.getComputedStyle(input, ""); + var topadj = parseInt(style.borderTopWidth) + parseInt(style.paddingTop); + input.top = outy.value - topadj; + + var left = outx.value; + input.left = left; + input.height = outheight.value + topadj + + parseInt(style.borderBottomWidth) + + parseInt(style.paddingBottom); + + coords = box.getCoordsForCellItem(row, column, "cell", + outx, outy, outwidth, outheight); + input.width = outwidth.value - (left - outx.value); + + input.value = this.view.getCellText(row, column); + var selectText = function selectText() { + input.select(); + input.inputField.focus(); + } + setTimeout(selectText, 0); + + this._editingRow = row; + this._editingColumn = column; + + this.setAttribute("editing", "true"); + ]]> + + + + + + + + + + + - - - + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + + + @@ -86,11 +89,29 @@ onset="if (val) this.setAttribute('enableColumnDrag', 'true'); else this.removeAttribute('enableColumnDrag'); return val;"/> + null + + + + + + -1 + null + + + + @@ -205,7 +226,7 @@ } ]]> - + + + + + + = this.itemCount || !column) + return; + if (column.type != Components.interfaces.nsITreeColumn.TYPE_TEXT || + column.cycler || !this.view.isEditable(row, column)) + return; + + if (this._editingColumn) + this.stopEditing(); + + var input = this.inputField; + input.hidden = false; + + var box = this.treeBoxObject; + var outx = {}, outy = {}, outwidth = {}, outheight = {}; + var coords = box.getCoordsForCellItem(row, column, "text", + outx, outy, outwidth, outheight); + + var style = window.getComputedStyle(input, ""); + var topadj = parseInt(style.borderTopWidth) + parseInt(style.paddingTop); + input.top = outy.value - topadj; + + var left = outx.value; + input.left = left; + input.height = outheight.value + topadj + + parseInt(style.borderBottomWidth) + + parseInt(style.paddingBottom); + + coords = box.getCoordsForCellItem(row, column, "cell", + outx, outy, outwidth, outheight); + input.width = outwidth.value - (left - outx.value); + + input.value = this.view.getCellText(row, column); + var selectText = function selectText() { + input.select(); + input.inputField.focus(); + } + setTimeout(selectText, 0); + + this._editingRow = row; + this._editingColumn = column; + + this.setAttribute("editing", "true"); + ]]> + + + + + + + + + + + - - - + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - +