Bug 692807 - Update the code from Orion upstream; r=rcampbell

This commit is contained in:
Mihai Sucan 2011-10-12 15:52:45 +03:00
parent 53f13e6750
commit 37a4f7641b
7 changed files with 2495 additions and 1278 deletions

View File

@ -6,4 +6,5 @@ browser.jar:
content/browser/csshtmltree.xhtml (styleinspector/csshtmltree.xhtml)
content/browser/orion.js (sourceeditor/orion/orion.js)
content/browser/orion.css (sourceeditor/orion/orion.css)
content/browser/orion-mozilla.css (sourceeditor/orion/mozilla.css)

View File

@ -8,8 +8,8 @@ The Orion editor web site: http://www.eclipse.org/orion
To upgrade Orion to a newer version see the UPGRADE file.
Orion version: git clone from 2011-07-06 (after the 0.2 release)
commit hash b19bc0b0f4e2843823bb1b8c8b4a64395c59e617
Orion version: git clone from 2011-10-07
commit hash eedba6403b6dff4536bc0469d31126c3485deb56
# License

View File

@ -0,0 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
.rulerLines {
background: -moz-Dialog;
color: -moz-DialogText;
min-width: 1.4em;
padding-left: 4px;
padding-right: 4px;
}

View File

@ -8,53 +8,75 @@
}
.viewContent {
}.ruler_annotation {
background-color: #e1ebfb;
width: 16px;
}
.ruler_annotation_todo {
}
.ruler_annotation_todo_overview {
background-color: lightgreen;
border: 1px solid green;
}
.ruler_annotation_breakpoint {
}
.ruler_annotation_breakpoint_overview {
background-color: lightblue;
border: 1px solid blue;
}
.ruler_lines {
background-color: #e1ebfb;
border-right: 1px solid #b1badf;
text-align: right;
}
.ruler_overview {
background-color: #e1ebfb;
}
.ruler_lines_even {
background-color: #e1ebfb;
}
.ruler_lines_odd {
}/* Styles for rulers */
.ruler {
background-color: white;
}
.ruler.annotations {
border-right: 1px solid lightgray;
width: 16px;
}
.ruler.folding {
border-right: 1px solid lightgray;
width: 14px;
}
.ruler.lines {
border-right: 1px solid lightgray;
text-align: right;
}
.ruler.overview {
width: 14px;
}
.token_comment {
/* Styles for the line number ruler */
.rulerLines {
background-color: white;
}
.rulerLines.even
.rulerLines.odd {
}
/* Styles for the ruler tooltips */
.rulerTooltip {
font-family: monospace;
font-size: 10pt;
background-color: InfoBackground;
color: InfoText;
padding: 2px;
border-radius: 4px;
border: 1px solid black;
z-index: 100;
position: absolute;
overflow: hidden;
white-space: pre;
}
.rulerTooltip em {
font-style: normal;
font-weight: bold;
}.token_singleline_comment {
color: green;
}
.token_javadoc {
.token_multiline_comment {
color: green;
}
.token_doc_comment {
color: #00008F;
}
.token_doc_html_markup {
color: #7F7F9F;
}
.token_doc_tag {
color: #7F9FBF;
}
.token_task_tag {
color: #7F9FBF;
}
.token_string {
color: blue;
}
@ -74,20 +96,24 @@
}
.token_space {
background-image: url('/examples/textview/images/white_space.png');
/* images/white_space.png */
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
background-repeat: no-repeat;
background-position: center center;
}
.token_tab {
background-image: url('/examples/textview/images/white_tab.png');
/* images/white_tab.png */
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
background-repeat: no-repeat;
background-position: left center;
}
.line_caret {
background-color: #EAF2FE;
}/* Styling for html syntax highlighting */
}
/* Styling for html syntax highlighting */
.entity-name-tag {
color: #3f7f7f;
}
@ -112,4 +138,4 @@
.invalid {
color: red;
font-weight: bold;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,8 @@ const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
* SourceEditor.THEMES to Orion CSS files.
*/
const ORION_THEMES = {
textmate: "chrome://browser/content/orion.css",
textmate: ["chrome://browser/content/orion.css",
"chrome://browser/content/orion-mozilla.css"],
};
/**
@ -196,9 +197,9 @@ SourceEditor.prototype = {
});
if (config.showLineNumbers) {
this._lines_ruler = new textview.LineNumberRuler("left",
{styleClass: "ruler_lines", style: {minWidth: "1.4em"}},
{styleClass: "ruler_lines_even"}, {styleClass: "ruler_lines_even"});
this._lines_ruler = new textview.LineNumberRuler(null, "left",
{styleClass: "rulerLines"}, {styleClass: "rulerLine odd"},
{styleClass: "rulerLine even"});
this._view.addRuler(this._lines_ruler);
}
@ -390,7 +391,7 @@ SourceEditor.prototype = {
let model = this._model;
let lineIndex = model.getLineAtOffset(selection.start);
let lineText = model.getLine(lineIndex);
let lineText = model.getLine(lineIndex, true);
let lineStart = model.getLineStart(lineIndex);
let index = 0;
let lineOffset = selection.start - lineStart;

View File

@ -145,35 +145,10 @@ function editorLoaded()
is(editor.getCaretOffset(), 8, "caret moved to the left");
EventUtils.synthesizeKey("a", {accelKey: true}, testWin);
is(editor.getSelectedText(), "code-ed.aitor",
"select all worked");
EventUtils.synthesizeKey("x", {accelKey: true}, testWin);
ok(!editor.getText(), "cut works");
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
is(editor.getText(), "code-ed.aitorcode-ed.aitor", "paste works");
editor.setText("foo");
EventUtils.synthesizeKey("a", {accelKey: true}, testWin);
EventUtils.synthesizeKey("c", {accelKey: true}, testWin);
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
is(editor.getText(), "foofoo", "ctrl-a, c, v, v works");
is(editor.getCaretOffset(), 6, "caret location is correct");
EventUtils.synthesizeKey(".", {}, testWin);
EventUtils.synthesizeKey("VK_TAB", {}, testWin);
is(editor.getText(), "foofoo. ", "Tab works");
is(editor.getText(), "code-ed.. aitor", "Tab works");
is(editor.getCaretOffset(), 14, "caret location is correct");
@ -276,24 +251,8 @@ function editorLoaded()
is(event.removedCharCount, 0, "event.removedCharCount is correct");
is(event.addedCharCount, 1, "event.addedCharCount is correct");
let chars = editor.getText().length;
event = null;
EventUtils.synthesizeKey("a", {accelKey: true}, testWin);
EventUtils.synthesizeKey("c", {accelKey: true}, testWin);
editor.setCaretOffset(chars);
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
ok(event, "the TextChanged event fired after paste");
is(event.start, chars, "event.start is correct");
is(event.removedCharCount, 0, "event.removedCharCount is correct");
is(event.addedCharCount, chars, "event.addedCharCount is correct");
editor.setText("line1\nline2\nline3");
chars = editor.getText().length;
let chars = editor.getText().length;
event = null;
editor.setText("a\nline4\nline5", chars);
@ -303,6 +262,7 @@ function editorLoaded()
is(event.removedCharCount, 0, "event.removedCharCount is correct");
is(event.addedCharCount, 13, "event.addedCharCount is correct");
event = null;
editor.setText("line3b\nline4b\nfoo", 12, 24);
ok(event, "the TextChanged event fired after setText() again");
@ -312,8 +272,11 @@ function editorLoaded()
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, eventHandler);
// Done.
testClipboardEvents();
}
function testEnd()
{
editor.destroy();
ok(!editor.parentElement && !editor.editorElement, "destroy() works");
@ -361,3 +324,75 @@ function testReturnKey()
"return maintains indentation (again)");
}
function testClipboardEvents()
{
editor.setText("foobar");
let doCut = function() {
EventUtils.synthesizeKey("a", {accelKey: true}, testWin);
is(editor.getSelectedText(), "foobar", "select all worked");
EventUtils.synthesizeKey("x", {accelKey: true}, testWin);
};
let onCut = function() {
ok(!editor.getText(), "cut works");
editor.setText("test--");
editor.setCaretOffset(5);
editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste1);
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
};
let onPaste1 = function() {
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste1);
is(editor.getText(), "test-foobar-", "paste works");
executeSoon(waitForClipboard.bind(this, "test", doCopy, onCopy, testEnd));
};
let doCopy = function() {
editor.setSelection(0, 4);
EventUtils.synthesizeKey("c", {accelKey: true}, testWin);
};
let onCopy = function() {
editor.setSelection(5, 11);
editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste2);
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
};
let pasteTextChanges = 0;
let removedCharCount = 0;
let addedCharCount = 0;
let onPaste2 = function(aEvent) {
pasteTextChanges++;
ok(aEvent && (pasteTextChanges == 1 || pasteTextChanges == 2),
"event TEXT_CHANGED fired " + pasteTextChanges + " time(s)");
is(aEvent.start, 5, "event.start is correct");
if (aEvent.removedCharCount) {
removedCharCount = aEvent.removedCharCount;
}
if (aEvent.addedCharCount) {
addedCharCount = aEvent.addedCharCount;
}
if (pasteTextChanges == 2 || addedCharCount && removedCharCount) {
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste2);
executeSoon(checkPaste2Result);
}
};
let checkPaste2Result = function() {
is(removedCharCount, 6, "event.removedCharCount is correct");
is(addedCharCount, 4, "event.addedCharCount is correct");
is(editor.getText(), "test-test-", "paste works after copy");
testEnd();
};
waitForClipboard("foobar", doCut, onCut, testEnd);
}