mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-02 21:37:32 +09:00
[PALEMOON] Places - fix: throws an error: 0x80004005 (NS_ERROR_FAILURE) [nsIEditor.transactionManager]
Issue #133 Tag https://github.com/MoonchildProductions/UXP/pull/134
This commit is contained in:
parent
7754d12175
commit
bd50a27250
2 changed files with 50 additions and 16 deletions
|
|
@ -189,11 +189,24 @@ var StarUI = {
|
|||
this._itemId = aItemId !== undefined ? aItemId : this._itemId;
|
||||
this.beginBatch();
|
||||
|
||||
this.panel.openPopup(aAnchorElement, aPosition);
|
||||
|
||||
let onPanelReady = fn => {
|
||||
let target = this.panel;
|
||||
if (target.parentNode) {
|
||||
// By targeting the panel's parent and using a capturing listener, we
|
||||
// can have our listener called before others waiting for the panel to
|
||||
// be shown (which probably expect the panel to be fully initialized)
|
||||
target = target.parentNode;
|
||||
}
|
||||
target.addEventListener("popupshown", function(event) {
|
||||
fn();
|
||||
}, {"capture": true, "once": true});
|
||||
};
|
||||
gEditItemOverlay.initPanel(this._itemId,
|
||||
{ hiddenRows: ["description", "location",
|
||||
{ onPanelReady,
|
||||
hiddenRows: ["description", "location",
|
||||
"loadInSidebar", "keyword"] });
|
||||
|
||||
this.panel.openPopup(aAnchorElement, aPosition);
|
||||
},
|
||||
|
||||
panelShown:
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ var gEditItemOverlay = {
|
|||
_itemType: -1,
|
||||
_readOnly: false,
|
||||
_hiddenRows: [],
|
||||
_onPanelReady: false,
|
||||
_observersAdded: false,
|
||||
_staticFoldersListBuilt: false,
|
||||
_initialized: false,
|
||||
|
|
@ -50,6 +51,7 @@ var gEditItemOverlay = {
|
|||
this._readOnly = aInfo && aInfo.forceReadOnly;
|
||||
this._titleOverride = aInfo && aInfo.titleOverride ? aInfo.titleOverride
|
||||
: "";
|
||||
this._onPanelReady = aInfo && aInfo.onPanelReady;
|
||||
},
|
||||
|
||||
_showHideRows: function EIO__showHideRows() {
|
||||
|
|
@ -219,7 +221,15 @@ var gEditItemOverlay = {
|
|||
this._observersAdded = true;
|
||||
}
|
||||
|
||||
this._initialized = true;
|
||||
let focusElement = () => {
|
||||
this._initialized = true;
|
||||
};
|
||||
|
||||
if (this._onPanelReady) {
|
||||
this._onPanelReady(focusElement);
|
||||
} else {
|
||||
focusElement();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -243,11 +253,7 @@ var gEditItemOverlay = {
|
|||
|
||||
if (field.value != aValue) {
|
||||
field.value = aValue;
|
||||
|
||||
// clear the undo stack
|
||||
var editor = field.editor;
|
||||
if (editor)
|
||||
editor.transactionManager.clear();
|
||||
this._editorTransactionManagerClear(field);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -352,6 +358,26 @@ var gEditItemOverlay = {
|
|||
return document.getElementById("editBMPanel_" + aID);
|
||||
},
|
||||
|
||||
_editorTransactionManagerClear: function EIO__editorTransactionManagerClear(aItem) {
|
||||
// Clear the editor's undo stack
|
||||
let transactionManager;
|
||||
try {
|
||||
transactionManager = aItem.editor.transactionManager;
|
||||
} catch (e) {
|
||||
// When retrieving the transaction manager, editor may be null resulting
|
||||
// in a TypeError. Additionally, the transaction manager may not
|
||||
// exist yet, which causes access to it to throw NS_ERROR_FAILURE.
|
||||
// In either event, the transaction manager doesn't exist it, so we
|
||||
// don't need to worry about clearing it.
|
||||
if (!(e instanceof TypeError) && e.result != Cr.NS_ERROR_FAILURE) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (transactionManager) {
|
||||
transactionManager.clear();
|
||||
}
|
||||
},
|
||||
|
||||
_getItemStaticTitle: function EIO__getItemStaticTitle() {
|
||||
if (this._titleOverride)
|
||||
return this._titleOverride;
|
||||
|
|
@ -370,11 +396,7 @@ var gEditItemOverlay = {
|
|||
var namePicker = this._element("namePicker");
|
||||
namePicker.value = this._getItemStaticTitle();
|
||||
namePicker.readOnly = this._readOnly;
|
||||
|
||||
// clear the undo stack
|
||||
var editor = namePicker.editor;
|
||||
if (editor)
|
||||
editor.transactionManager.clear();
|
||||
this._editorTransactionManagerClear(namePicker);
|
||||
},
|
||||
|
||||
uninitPanel: function EIO_uninitPanel(aHideCollapsibleElements) {
|
||||
|
|
@ -963,8 +985,7 @@ var gEditItemOverlay = {
|
|||
var namePicker = this._element("namePicker");
|
||||
if (namePicker.value != aValue) {
|
||||
namePicker.value = aValue;
|
||||
// clear undo stack
|
||||
namePicker.editor.transactionManager.clear();
|
||||
this._editorTransactionManagerClear(namePicker);
|
||||
}
|
||||
break;
|
||||
case "uri":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue