Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Infinite canvas #3623

Merged
merged 9 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion lib/ace/css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
position: absolute;
box-sizing: border-box;
min-width: 100%;
contain: style size layout;
}

.ace_dragging .ace_scroller:before{
Expand All @@ -49,7 +50,6 @@
overflow : hidden;
width: auto;
top: 0;
bottom: 0;
left: 0;
cursor: default;
z-index: 4;
Expand All @@ -70,6 +70,10 @@
}

.ace_gutter-cell {
position: absolute;
top: 0;
left: 0;
right: 0;
padding-left: 19px;
padding-right: 6px;
background-repeat: no-repeat;
Expand All @@ -95,6 +99,7 @@
}

.ace_scrollbar {
contain: strict;
position: absolute;
right: 0;
bottom: 0;
Expand Down Expand Up @@ -188,10 +193,34 @@
width: auto;
text-align: right;
pointer-events: auto;
height: 1000000px;
contain: style size layout;
}

.ace_text-layer {
font: inherit !important;
position: absolute;
height: 1000000px;
width: 1000000px;
contain: style size layout;
}

.ace_text-layer > .ace_line, .ace_text-layer > .ace_line_group {
contain: style size layout;
position: absolute;
top: 0;
left: 0;
right: 0;
}

@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 1.5dppx) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we only get hw acceleration on retina screens?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, do we need to enable it on mac even if screen is not retina?

.ace_text-layer, .ace_gutter-layer, .ace_content {
contain: strict;
will-change: transform;
}
.ace_gutter {
will-change: transform;
}
}

.ace_cjk {
Expand Down
1 change: 0 additions & 1 deletion lib/ace/edit_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@ EditSession.$uid = 0;
}
}
if (!dontSelect && this.$undoSelect) {
// console.log(deltas.selectionBefore + "uuu")
if (deltas.selectionBefore)
this.selection.fromJSON(deltas.selectionBefore);
else
Expand Down
15 changes: 8 additions & 7 deletions lib/ace/keyboard/vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -4458,8 +4458,10 @@ dom.importCssString(".normal-mode .ace_cursor{\
cm.openDialog(template, onClose, { bottom: true, value: options.value,
onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp,
selectValueOnOpen: false, onClose: function() {
cm.state.vim.status = "";
cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR);
if (cm.state.vim) {
cm.state.vim.status = "";
cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR);
}
}});
}
else {
Expand Down Expand Up @@ -6110,7 +6112,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
var getVim = Vim.maybeInitVimState_;
exports.handler = {
$id: "ace/keyboard/vim",
drawCursor: function(style, pixelPos, config, sel, session) {
drawCursor: function(element, pixelPos, config, sel, session) {
var vim = this.state.vim || {};
var w = config.characterWidth;
var h = config.lineHeight;
Expand All @@ -6127,10 +6129,9 @@ dom.importCssString(".normal-mode .ace_cursor{\
h = h / 2;
top += h;
}
style.left = left + "px";
style.top = top + "px";
style.width = w + "px";
style.height = h + "px";
dom.translate(element, left, top);
dom.setStyle(element.style, "width", w + "px");
dom.setStyle(element.style, "height", h + "px");
},
handleKeyboard: function(data, hashId, key, keyCode, e) {
var editor = data.editor;
Expand Down
1 change: 1 addition & 0 deletions lib/ace/keyboard/vim_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

if (typeof process !== "undefined") {
require("amd-loader");
require("../test/mockdom");
}

define(function(require, exports, module) {
Expand Down
47 changes: 23 additions & 24 deletions lib/ace/layer/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ define(function(require, exports, module) {
"use strict";

var dom = require("../lib/dom");
var isIE8;

var Cursor = function(parentEl) {
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_cursor-layer";
parentEl.appendChild(this.element);

if (isIE8 === undefined)
isIE8 = !("opacity" in this.element.style);

this.isVisible = false;
this.isBlinking = true;
this.blinkInterval = 1000;
Expand All @@ -50,24 +46,17 @@ var Cursor = function(parentEl) {
this.cursors = [];
this.cursor = this.addCursor();
dom.addCssClass(this.element, "ace_hidden-cursors");
this.$updateCursors = (isIE8
? this.$updateVisibility
: this.$updateOpacity).bind(this);
this.$updateCursors = this.$updateOpacity.bind(this);
};

(function() {

this.$updateVisibility = function(val) {
var cursors = this.cursors;
for (var i = cursors.length; i--; )
cursors[i].style.visibility = val ? "" : "hidden";
};
this.$updateOpacity = function(val) {
var cursors = this.cursors;
for (var i = cursors.length; i--; )
cursors[i].style.opacity = val ? "" : "0";
dom.setStyle(cursors[i].style, "opacity", val ? "" : "0");
};

this.$startCssAnimation = function() {
var cursors = this.cursors;
for (var i = cursors.length; i--; )
Expand Down Expand Up @@ -106,11 +95,10 @@ var Cursor = function(parentEl) {
};

this.setSmoothBlinking = function(smoothBlinking) {
if (smoothBlinking != this.smoothBlinking && !isIE8) {
if (smoothBlinking != this.smoothBlinking) {
this.smoothBlinking = smoothBlinking;
dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
this.$updateCursors(true);
this.$updateCursors = (this.$updateOpacity).bind(this);
this.restartTimer();
}
};
Expand Down Expand Up @@ -148,15 +136,17 @@ var Cursor = function(parentEl) {
clearInterval(this.intervalId);
clearTimeout(this.timeoutId);
this.$stopCssAnimation();

if (this.smoothBlinking) {
dom.removeCssClass(this.element, "ace_smooth-blinking");
}

update(true);

if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
if (!this.isBlinking || !this.blinkInterval || !this.isVisible) {
this.$stopCssAnimation();
return;
}

if (this.smoothBlinking) {
setTimeout(function(){
Expand Down Expand Up @@ -198,6 +188,10 @@ var Cursor = function(parentEl) {
return {left : cursorLeft, top : cursorTop};
};

this.isCursorInView = function(pixelPos, config) {
return pixelPos.top >= 0 && pixelPos.top < config.maxHeight;
};

this.update = function(config) {
this.config = config;

Expand All @@ -215,15 +209,20 @@ var Cursor = function(parentEl) {
continue;
}

var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
var element = this.cursors[cursorIndex++] || this.addCursor();
var style = element.style;

if (!this.drawCursor) {
style.left = pixelPos.left + "px";
style.top = pixelPos.top + "px";
style.width = config.characterWidth + "px";
style.height = config.lineHeight + "px";
if (!this.isCursorInView(pixelPos, config)) {
dom.setStyle(style, "display", "none");
} else {
dom.setStyle(style, "display", "block");
dom.translate(element, pixelPos.left, pixelPos.top);
dom.setStyle(style, "width", Math.round(config.characterWidth) + "px");
dom.setStyle(style, "height", config.lineHeight + "px");
}
} else {
this.drawCursor(style, pixelPos, config, selections[i], this.session);
this.drawCursor(element, pixelPos, config, selections[i], this.session);
}
}
while (this.cursors.length > cursorIndex)
Expand Down
Loading