Address comments from CL 125123002 and additional cleanup.

R=kasperl@google.com

Review URL: https://codereview.chromium.org//126003002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31660 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
ahe@google.com 2014-01-09 15:04:41 +00:00
parent 4789392a5b
commit 795de8c481
12 changed files with 117 additions and 39940 deletions

1
site/try/README Normal file
View file

@ -0,0 +1 @@
See https://code.google.com/p/dart/wiki/TryDart.

View file

@ -1,3 +1,10 @@
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# App Engine configuration, see:
# https://developers.google.com/appengine/docs/python/config/appconfig
application: try-dart-lang
version: 5
runtime: python27

View file

@ -1,4 +1,9 @@
#!/bin/bash
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Script to create AppCache manifest.
echo CACHE MANIFEST

View file

@ -1,3 +1,15 @@
#!/bin/bash
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Deploy step for try.dartlang.org. Usage:
#
# bash deploy.sh OLD NEW
#
# Where OLD and NEW are unique prefixes, for example, a short git commit hash.
# OLD is the existing prefix that should be replaced by NEW.
old=$1
new=$2
echo git checkout-index -a -f --prefix=$new/

View file

@ -1,3 +1,7 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of trydart.themes;
/// Black Pastel theme extracted from

View file

@ -27,19 +27,25 @@ function onMessageReceived(event) {
window.addEventListener("message", onMessageReceived, false);
(function () {
function postScrollHeight() {
window.parent.postMessage(["scrollHeight", document.documentElement.scrollHeight], "*");
}
function postScrollHeight() {
window.parent.postMessage(
["scrollHeight", document.documentElement.scrollHeight], "*");
}
var observer = new (window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver)(function(mutations) {
postScrollHeight()
window.setTimeout(postScrollHeight, 500);
});
var mutationObserverConstructor =
window.MutationObserver ||
window.WebKitMutationObserver ||
window.MozMutationObserver;
observer.observe(
document.body,
{ attributes: true,
childList: true,
characterData: true,
subtree: true });
var observer = new mutationObserverConstructor(function(mutations) {
postScrollHeight()
window.setTimeout(postScrollHeight, 500);
});
observer.observe(
document.body,
{ attributes: true,
childList: true,
characterData: true,
subtree: true });
})();

View file

@ -9,8 +9,13 @@ import 'dart:html';
import 'dart:isolate';
import 'dart:uri';
import '../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart' show StringScanner, EOF_TOKEN;
import '../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart' as scanner;
import '../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart'
show
StringScanner,
EOF_TOKEN;
import '../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart'
as scanner;
import 'decoration.dart';
import 'themes.dart';
@ -31,7 +36,8 @@ bool alwaysRunInWorker = window.localStorage['alwaysRunInWorker'] == 'true';
bool verboseCompiler = window.localStorage['verboseCompiler'] == 'true';
bool minified = window.localStorage['minified'] == 'true';
bool onlyAnalyze = window.localStorage['onlyAnalyze'] == 'true';
String codeFont = ((x) => x == null ? '' : x)(window.localStorage['codeFont']);
final String rawCodeFont = window.localStorage['codeFont'];
String codeFont = rawCodeFont == null ? '' : rawCodeFont;
String currentSample = window.localStorage['currentSample'];
Theme currentTheme = Theme.named(window.localStorage['theme']);
bool applyingSettings = false;
@ -58,6 +64,7 @@ onKeyUp(KeyboardEvent e) {
bool isMalformedInput = false;
String currentSource = "";
// TODO(ahe): This method should be cleaned up. It is too large.
onMutation(List<MutationRecord> mutations, MutationObserver observer) {
scheduleCompilation();
@ -74,53 +81,53 @@ onMutation(List<MutationRecord> mutations, MutationObserver observer) {
String type = record.type;
switch (type) {
case 'characterData':
case 'characterData':
bool hasSelection = false;
int offset = selection.anchorOffset;
if (selection.isCollapsed && selection.anchorNode == record.target) {
hasSelection = true;
}
var parent = record.target.parentNode;
if (parent != inputPre) {
inlineChildren(parent);
}
if (hasSelection) {
selection.collapse(record.target, offset);
}
break;
bool hasSelection = false;
int offset = selection.anchorOffset;
if (selection.isCollapsed && selection.anchorNode == record.target) {
hasSelection = true;
}
var parent = record.target.parentNode;
if (parent != inputPre) {
inlineChildren(parent);
}
if (hasSelection) {
selection.collapse(record.target, offset);
}
break;
default:
if (!record.addedNodes.isEmpty) {
for (var node in record.addedNodes) {
default:
if (!record.addedNodes.isEmpty) {
for (var node in record.addedNodes) {
if (node.nodeType != Node.ELEMENT_NODE) continue;
if (node.nodeType != Node.ELEMENT_NODE) continue;
if (node is BRElement) {
if (selection.anchorNode != node) {
node.replaceWith(new Text('\n'));
}
} else {
var parent = node.parentNode;
if (parent == null) continue;
var nodes = new List.from(node.nodes);
var style = node.getComputedStyle();
if (style.display != 'inline') {
var previous = node.previousNode;
if (previous is Text) {
previous.appendData('\n');
} else {
parent.insertBefore(new Text('\n'), node);
if (node is BRElement) {
if (selection.anchorNode != node) {
node.replaceWith(new Text('\n'));
}
} else {
var parent = node.parentNode;
if (parent == null) continue;
var nodes = new List.from(node.nodes);
var style = node.getComputedStyle();
if (style.display != 'inline') {
var previous = node.previousNode;
if (previous is Text) {
previous.appendData('\n');
} else {
parent.insertBefore(new Text('\n'), node);
}
}
for (Node child in nodes) {
child.remove();
parent.insertBefore(child, node);
}
node.remove();
}
for (Node child in nodes) {
child.remove();
parent.insertBefore(child, node);
}
node.remove();
}
}
}
}
}
mutations = observer.takeRecords();
@ -137,10 +144,12 @@ onMutation(List<MutationRecord> mutations, MutationObserver observer) {
int anchorOffset = 0;
bool hasSelection = false;
Node anchorNode = selection.anchorNode;
// TODO(ahe): Try to share walk4 methods.
void walk4(Node node) {
// TODO(ahe): Use TreeWalker when that is exposed.
// function textNodesUnder(root){
// var n, a=[], walk=document.createTreeWalker(root,NodeFilter.SHOW_TEXT,null,false);
// var n, a=[], walk=document.createTreeWalker(
// root,NodeFilter.SHOW_TEXT,null,false);
// while(n=walk.nextNode()) a.push(n);
// return a;
// }
@ -155,7 +164,7 @@ onMutation(List<MutationRecord> mutations, MutationObserver observer) {
}
var child = node.$dom_firstChild;
while(child != null) {
while (child != null) {
walk4(child);
if (hasSelection) return;
child = child.nextNode;
@ -271,7 +280,8 @@ addDiagnostic(String kind, String message, int begin, int end) {
}
observer.takeRecords();
observer.observe(inputPre, childList: true, characterData: true, subtree: true);
observer.observe(
inputPre, childList: true, characterData: true, subtree: true);
}
void inlineChildren(Element element) {
@ -363,15 +373,15 @@ class CompilationProcess {
String kind = message is String ? message : message[0];
var data = (message is List && message.length == 2) ? message[1] : null;
switch (kind) {
case 'done': return onDone(data);
case 'url': return onUrl(data);
case 'code': return onCode(data);
case 'diagnostic': return onDiagnostic(data);
case 'crash': return onCrash(data);
case 'failed': return onFail(data);
case 'dart:html': return onDartHtml(data);
default:
throw ['Unknown message kind', message];
case 'done': return onDone(data);
case 'url': return onUrl(data);
case 'code': return onCode(data);
case 'diagnostic': return onDiagnostic(data);
case 'crash': return onCrash(data);
case 'failed': return onFail(data);
case 'dart:html': return onDartHtml(data);
default:
throw ['Unknown message kind', message];
}
}
@ -895,6 +905,7 @@ void openSettings(MouseEvent event) {
..appendText(' $text');
}
// TODO(ahe): Build abstraction for flags/options.
fieldSet.append(
buildCheckBox(
'Always run in Worker thread.', alwaysRunInWorker,

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,7 @@
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
CACHE MANIFEST
# Version 5

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

View file

@ -1,5 +0,0 @@
$ git pull --ff-only
$ git checkout-index -a -f --prefix=8bbcef7/
$ rm -rf 12775d4
$ sh 8bbcef7/dart/web_editor/create_manifest.sh > live.appcache
$ sed -e 's/12775d4/8bbcef7/' -i.12775d4 index.html