Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mullvad Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Mullvad Browser
Commits
17684ebc
Commit
17684ebc
authored
20 years ago
by
timeless%mozdev.org
Browse files
Options
Downloads
Patches
Plain Diff
Bug 179621 Inspector should use Editor's TransactionManager model
patch by ajvincent@gmail.com r=roc sr=roc
parent
a6c47ca2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
extensions/inspector/resources/content/inspector.xml
+119
-29
119 additions, 29 deletions
extensions/inspector/resources/content/inspector.xml
extensions/inspector/resources/content/utils.js
+30
-0
30 additions, 0 deletions
extensions/inspector/resources/content/utils.js
with
149 additions
and
29 deletions
extensions/inspector/resources/content/inspector.xml
+
119
−
29
View file @
17684ebc
...
...
@@ -130,9 +130,13 @@
var enabled;
if (aCommand == "cmdEditUndo")
enabled = this.mCommandPtr >
= 0;
else if (aCommand == "cmdEditRedo")
else if (aCommand == "cmdEditRedo")
{
enabled = this.mCommandPtr+1
< this.mCommandStack.length
;
else
{
if
(!enabled
&&
(this.mCommandPtr
>
-1)) {
var lastCmd = this.mCommandStack[this.mCommandPtr];
enabled = ((lastCmd instanceof nsITransactionManager)
&&
(lastCmd.numberOfRedoItems > 0));
}
} else {
if (this.focusedPanel
&&
this.focusedPanel.viewer) {
enabled = this.focusedPanel.viewer.isCommandEnabled(aCommand);
}
...
...
@@ -178,6 +182,14 @@
]]>
</body>
</method>
<method
name=
"createTransactionManager"
>
<body>
<![CDATA[
var txmgr = Components.classes["@mozilla.org/transactionmanager;1"].createInstance(nsITransactionManager);
txmgr = txmgr.QueryInterface(nsITransactionManager);
return txmgr;
]]>
</body>
</method>
<!-- ////////////// VIEWER-SPECIFIC COMMANDS /////////////////// -->
<method
name=
"setViewerCmdAttribute"
>
...
...
@@ -231,17 +243,37 @@
if (!command)
return;
var noPush = false;
//try {
if (typeof command.txnType == "undefined") {
var noPush = false;
//try {
noPush = command.doCommand();
//} catch (ex) {
// dump("Unable to successfully complete command " + aCommand + "\n");
// return;
//}
if (!noPush) {
this.addCommandToStack(command);
//} catch (ex) {
// dump("Unable to successfully complete command " + aCommand + "\n");
// return;
//}
if (!noPush) {
this.addCommandToStack(command);
}
return;
}
// command.txnType != "undefined"; we have an nsITransaction.
if (command.isTransient) {
// command cannot be undone
command.doTransaction();
return;
}
if (command.txnType == "dialog") {
// transaction executed from dialog box onAcceptDialog event; open dialog.
command.openDialog();
return;
}
// otherwise, command is a standard transaction.
// Pass control to addCommandToStack function; it will handle TxMgr.
this.addCommandToStack(command);
}
]]>
</body>
</method>
...
...
@@ -250,14 +282,20 @@
<body>
<![CDATA[
if (this.mCommandPtr >
= 0) {
var command = this.mCommandStack[this.mCommandPtr];
--this.mCommandPtr;
//try {
command.undoCommand();
/*} catch (ex) {
dump("Unable to successfully undo command.\n");
return;
}*/
if ((command instanceof nsITransactionManager)
&&
(command.numberOfUndoItems > 0)) {
command.undoTransaction();
if (command.numberOfUndoItems == 0) {
--this.mCommandPtr;
}
} else {
--this.mCommandPtr;
//try {
command.undoCommand();
/*} catch (ex) {
dump("Unable to successfully undo command.\n");
return;
}*/
}
this.updateCommand("cmdEditUndo");
this.updateCommand("cmdEditRedo");
...
...
@@ -267,14 +305,27 @@
<method
name=
"redo"
>
<body>
<![CDATA[
if (this.mCommandPtr == -1) {
var command = null;
} else {
command = this.mCommandStack[this.mCommandPtr];
}
if (this.mCommandPtr >
= -1) {
++this.mCommandPtr;
var command = this.mCommandStack[this.mCommandPtr];
try {
command.doCommand();
} catch (ex) {
dump("Unable to successfully redo command.\n");
return;
if (!((command instanceof nsITransactionManager)
&&
(command.numberOfRedoItems > 0))) {
++this.mCommandPtr;
command = this.mCommandStack[this.mCommandPtr];
}
if ((command instanceof nsITransactionManager)
&&
(command.numberOfRedoItems > 0)) {
command.redoTransaction();
} else {
try {
command.doCommand();
} catch (ex) {
dump("Unable to successfully redo command.\n");
return;
}
}
this.updateCommand("cmdEditUndo");
this.updateCommand("cmdEditRedo");
...
...
@@ -285,9 +336,48 @@
<method
name=
"addCommandToStack"
>
<parameter
name=
"command"
/>
<body>
<![CDATA[
// add new command to the stack
++this.mCommandPtr;
this.mCommandStack[this.mCommandPtr] = command;
if (typeof command.txnType == "undefined") {
// original Inspector-compatible command, not nsITransaction.
// add new command to the stack
++this.mCommandPtr;
this.mCommandStack[this.mCommandPtr] = command;
// get rid of stack entries ahead of the command pointer (if there were any);
this.mCommandStack.splice(this.mCommandPtr+1, this.mCommandStack.length - (this.mCommandPtr+1));
this.updateCommand("cmdEditUndo");
this.updateCommand("cmdEditRedo");
return;
}
// command should be treated as a nsITransaction object.
if (this.mCommandPtr + 1 < this.mCommandStack.length) {
var nextCmd = this.mCommandStack[this.mCommandPtr + 1];
if (nextCmd instanceof nsITransactionManager) {
var mgr = nextCmd;
mgr.clear();
// No two Transaction Manager objects are ever adjacent to each other.
// We simply use the Transaction Manager immediately following, and clear all transactions from it.
// This gives us a fresh Transaction Manager.
}
}
var currentCmd = this.mCommandStack[this.mCommandPtr];
if (currentCmd instanceof nsITransactionManager) {
mgr = currentCmd;
}
// we need a Transaction Manager, even if we create one.
if (typeof mgr == "undefined") {
mgr = this.createTransactionManager();
}
mgr.doTransaction(command);
if (currentCmd != mgr) {
// insert Transaction Manager into stack
++this.mCommandPtr;
this.mCommandStack[this.mCommandPtr] = mgr;
}
// get rid of stack entries ahead of the command pointer (if there were any);
this.mCommandStack.splice(this.mCommandPtr + 1, this.mCommandStack.length - (this.mCommandPtr + 1));
...
...
This diff is collapsed.
Click to expand it.
extensions/inspector/resources/content/utils.js
+
30
−
0
View file @
17684ebc
...
...
@@ -49,6 +49,7 @@
const
kInspectorNSURI
=
"
http://www.mozilla.org/inspector#
"
;
const
kXULNSURI
=
"
http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul
"
;
const
kHTMLNSURI
=
"
http://www.w3.org/1999/xhtml
"
;
const
nsITransactionManager
=
Components
.
interfaces
.
nsITransactionManager
;
var
InsUtil
=
{
/******************************************************************************
...
...
@@ -145,3 +146,32 @@ function nodeTypeToText (nodeType)
return
nodeType
;
}
// Functions for converting Inspector-style command constructors to nsITransaction constructors
function
ConvertCommandToTxn
(
constructor
)
{
constructor
.
prototype
.
doTransaction
=
constructor
.
prototype
.
doCommand
;
constructor
.
prototype
.
undoTransaction
=
constructor
.
prototype
.
undoCommand
;
constructor
.
prototype
.
redoTransaction
=
constructor
.
prototype
.
doCommand
;
constructor
.
prototype
.
merge
=
ConvertCommandToTxn
.
txnMerge
;
constructor
.
prototype
.
QueryInterface
=
ConvertCommandToTxn
.
txnQueryInterface
;
if
(
arguments
.
length
>
1
)
{
constructor
.
prototype
.
txnType
=
arguments
[
1
];
}
else
{
constructor
.
prototype
.
txnType
=
"
standard
"
;
}
if
(
arguments
.
length
>
2
)
{
constructor
.
prototype
.
isTransient
=
arguments
[
2
];
}
else
{
constructor
.
prototype
.
isTransient
=
false
;
}
}
ConvertCommandToTxn
.
txnQueryInterface
=
function
(
theUID
,
theResult
)
{
if
(
theUID
==
Components
.
interfaces
.
nsITransaction
||
theUID
==
Components
.
interfaces
.
nsISupports
)
{
return
this
;
}
return
null
;
}
ConvertCommandToTxn
.
txnMerge
=
function
()
{
return
false
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment