summaryrefslogtreecommitdiffstats
path: root/browser/components/places/content
diff options
context:
space:
mode:
authorNew Tobin Paradigm <email@mattatobin.com>2018-04-12 17:40:27 -0400
committerGitHub <noreply@github.com>2018-04-12 17:40:27 -0400
commite226e36a6c1792b68ba22a2ae43b8e1e230b5246 (patch)
tree06a4de51ce6c676b27bacbd4f33ce524d40f3838 /browser/components/places/content
parent47354a0f29913df58a6c50fa8b34b1e817a368af (diff)
parentc06b8691e3cc33682fe2b8b614ec36ce0aada079 (diff)
downloadUXP-e226e36a6c1792b68ba22a2ae43b8e1e230b5246.tar
UXP-e226e36a6c1792b68ba22a2ae43b8e1e230b5246.tar.gz
UXP-e226e36a6c1792b68ba22a2ae43b8e1e230b5246.tar.lz
UXP-e226e36a6c1792b68ba22a2ae43b8e1e230b5246.tar.xz
UXP-e226e36a6c1792b68ba22a2ae43b8e1e230b5246.zip
Merge pull request #134 from janekptacijarabaci/places_error_1
Places - fix: throws an error: 0x80004005 (NS_ERROR_FAILURE) [nsIEditor.transactionManager]
Diffstat (limited to 'browser/components/places/content')
-rw-r--r--browser/components/places/content/editBookmarkOverlay.js72
1 files changed, 50 insertions, 22 deletions
diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js
index e26cfb138..d59f5c764 100644
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -57,12 +57,14 @@ var gEditItemOverlay = {
}
}
let focusedElement = aInitInfo.focusedElement;
+ let onPanelReady = aInitInfo.onPanelReady;
return this._paneInfo = { itemId, itemGuid, isItem,
isURI, uri, title,
isBookmark, isFolderShortcut, isParentReadOnly,
bulkTagging, uris,
- visibleRows, postData, isTag, focusedElement };
+ visibleRows, postData, isTag, focusedElement,
+ onPanelReady };
},
get initialized() {
@@ -214,7 +216,8 @@ var gEditItemOverlay = {
let { itemId, isItem, isURI,
isBookmark, bulkTagging, uris,
- visibleRows, focusedElement } = this._setPaneInfo(aInfo);
+ visibleRows, focusedElement,
+ onPanelReady } = this._setPaneInfo(aInfo);
let showOrCollapse =
(rowId, isAppropriateForInput, nameInHiddenRows = null) => {
@@ -286,22 +289,34 @@ var gEditItemOverlay = {
this._observersAdded = true;
}
- // The focusedElement possible values are:
- // * preferred: focus the field that the user touched first the last
- // time the pane was shown (either namePicker or tagsField)
- // * first: focus the first non collapsed textbox
- // Note: since all controls are collapsed by default, we don't get the
- // default XUL dialog behavior, that selects the first control, so we set
- // the focus explicitly.
- let elt;
- if (focusedElement === "preferred") {
- elt = this._element(gPrefService.getCharPref("browser.bookmarks.editDialog.firstEditField"));
- } else if (focusedElement === "first") {
- elt = document.querySelector("textbox:not([collapsed=true])");
- }
- if (elt) {
- elt.focus();
- elt.select();
+ let focusElement = () => {
+ // The focusedElement possible values are:
+ // * preferred: focus the field that the user touched first the last
+ // time the pane was shown (either namePicker or tagsField)
+ // * first: focus the first non collapsed textbox
+ // Note: since all controls are collapsed by default, we don't get the
+ // default XUL dialog behavior, that selects the first control, so we set
+ // the focus explicitly.
+ // Note: If focusedElement === "preferred", this file expects gPrefService
+ // to be defined in the global scope.
+ let elt;
+ if (focusedElement === "preferred") {
+ /* eslint-disable no-undef */
+ elt = this._element(gPrefService.getCharPref("browser.bookmarks.editDialog.firstEditField"));
+ /* eslint-enable no-undef */
+ } else if (focusedElement === "first") {
+ elt = document.querySelector("textbox:not([collapsed=true])");
+ }
+ if (elt) {
+ elt.focus();
+ elt.select();
+ }
+ };
+
+ if (onPanelReady) {
+ onPanelReady(focusElement);
+ } else {
+ focusElement();
}
},
@@ -335,10 +350,23 @@ var gEditItemOverlay = {
if (aElement.value != aValue) {
aElement.value = aValue;
- // Clear the undo stack
- let editor = aElement.editor;
- if (editor)
- editor.transactionManager.clear();
+ // Clear the editor's undo stack
+ let transactionManager;
+ try {
+ transactionManager = aElement.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();
+ }
}
},