[WIP] Cleaning up changes to Blockly core

This commit is contained in:
Evan W. Patton
2016-10-12 19:31:48 -04:00
parent 4e398b7057
commit 64a6f7b547
5 changed files with 12 additions and 31 deletions

View File

@@ -118,32 +118,20 @@ Blockly.Mutator.prototype.createEditor_ = function() {
var quarkXml = null;
}
var workspaceOptions = {
horizontalLayout: false,
languageTree: quarkXml,
parentWorkspace: this.block_.workspace,
pathToMedia: this.block_.workspace.options.pathToMedia,
RTL: this.block_.RTL,
hasCategories: false,
toolboxPosition: this.block_.RTL ? Blockly.TOOLBOX_AT_RIGHT :
Blockly.TOOLBOX_AT_LEFT,
horizontalLayout: false,
getMetrics: this.getFlyoutMetrics_.bind(this),
setMetrics: null
};
this.workspace_ = new Blockly.WorkspaceSvg(workspaceOptions);
this.workspace_.isMutator = true;
//this.flyout_ = new Blockly.Flyout();
//this.flyout_.autoClose = false;
//this.svgDialog_.appendChild(this.flyout_.createDom());
this.svgDialog_.appendChild(
this.workspace_.createDom('blocklyMutatorBackground'));
//when mutator bubble is clicked, do not close mutator
Blockly.bindEvent_(this.svgDialog_, 'mousedown', this.svgDialog_,
function(e) {
e.preventDefault();
e.stopPropagation();
});
this.workspace_.createDom('blocklyMutatorBackground'));
return this.svgDialog_;
};
@@ -177,12 +165,7 @@ Blockly.Mutator.prototype.updateEditable = function() {
*/
Blockly.Mutator.prototype.resizeBubble_ = function() {
var doubleBorderWidth = 2 * Blockly.Bubble.BORDER_WIDTH;
try {
var workspaceSize = this.workspace_.getCanvas().getBBox();
} catch (e) {
// Firefox has trouble with hidden elements (Bug 528969).
return;
}
var workspaceSize = this.workspace_.getCanvas().getBBox();
var width;
if (this.block_.RTL) {
width = -workspaceSize.x;

View File

@@ -125,6 +125,7 @@ Blockly.ScrollbarPair.prototype.resize = function() {
this.oldHostMetrics_.absoluteTop != hostMetrics.absoluteTop) {
this.corner_.setAttribute('y', this.hScroll.position_.y);
}
// Cache the current metrics to potentially short-cut the next resize event.
this.oldHostMetrics_ = hostMetrics;
};

View File

@@ -117,8 +117,6 @@ Blockly.Workspace.SCAN_ANGLE = 3;
* @param {!Blockly.Block} block Block to remove.
*/
Blockly.Workspace.prototype.addTopBlock = function(block) {
if (block.workspace == Blockly.mainWorkspace) //Do not reset arrangements for the flyout
this.resetArrangements();
this.topBlocks_.push(block);
if (this.isFlyout) {
// This is for the (unlikely) case where you have a variable in a block in
@@ -138,8 +136,6 @@ Blockly.Workspace.prototype.addTopBlock = function(block) {
* @param {!Blockly.Block} block Block to remove.
*/
Blockly.Workspace.prototype.removeTopBlock = function(block) {
if (block.workspace == Blockly.mainWorkspace) //Do not reset arrangements for the flyout
this.resetArrangements();
var found = false;
for (var child, i = 0; child = this.topBlocks_[i]; i++) {
if (child == block) {
@@ -160,7 +156,6 @@ Blockly.Workspace.prototype.removeTopBlock = function(block) {
* @return {!Array.<!Blockly.Block>} The top-level block objects.
*/
Blockly.Workspace.prototype.getTopBlocks = function(ordered) {
var start = new Date().getTime(); //*** lyn instrumentation
// Copy the topBlocks_ list.
var blocks = [].concat(this.topBlocks_);
if (ordered && blocks.length > 1) {
@@ -174,10 +169,6 @@ Blockly.Workspace.prototype.getTopBlocks = function(ordered) {
return (aXY.y + offset * aXY.x) - (bXY.y + offset * bXY.x);
});
}
var stop = new Date().getTime(); //*** lyn instrumentation
var timeDiff = stop - start; //*** lyn instrumentation
Blockly.Instrument.stats.getTopBlocksCalls++;
Blockly.Instrument.stats.getTopBlocksTime += timeDiff;
return blocks;
};

View File

@@ -947,7 +947,13 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) {
var expandOption = {enabled: hasCollapsedBlocks};
expandOption.text = Blockly.Msg.EXPAND_ALL;
expandOption.callback = function() {
toggleOption(false);
Blockly.Instrument.initializeStats('expandAllCollapsedBlocks');
Blockly.Instrument.timer(
function() { toggleOption(false); },
function(result, timeDiff) {
Blockly.Instrument.stats.totalTime = timeDiff;
Blockly.Instrument.displayStats('expandAllCollapsedBlocks');
});
};
menuOptions.push(expandOption);
}

View File

@@ -156,7 +156,7 @@ Blockly.Xml.blockToDom = function(block) {
var nextBlock = block.getNextBlock();
if (nextBlock) {
var container = goog.dom.createDom('next', null,
Blockly.Xml.blockToDom(nextBlock));
Blockly.Xml.blockToDom(nextBlock));
element.appendChild(container);
}
var shadow = block.nextConnection && block.nextConnection.getShadowDom();