Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tools/dom/src/html_native_DOMImplementation.dart

Issue 284113004: Check for Dartium 35 string indicating that an eval call occurs on the console. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: ptal Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of html; 5 part of html;
6 6
7 class _ConsoleVariables { 7 class _ConsoleVariables {
8 Map<String, Object> _data = new Map<String, Object>(); 8 Map<String, Object> _data = new Map<String, Object>();
9 9
10 /** 10 /**
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 map[stripMemberName(localVariables[i])] = localVariables[i+1]; 139 map[stripMemberName(localVariables[i])] = localVariables[i+1];
140 } 140 }
141 return map; 141 return map;
142 } 142 }
143 143
144 static _ConsoleVariables _consoleTempVariables = new _ConsoleVariables(); 144 static _ConsoleVariables _consoleTempVariables = new _ConsoleVariables();
145 145
146 /** 146 /**
147 * Header passed in from the Dartium Developer Tools when an expression is 147 * Header passed in from the Dartium Developer Tools when an expression is
148 * evaluated in the console as opposed to the watch window or another context 148 * evaluated in the console as opposed to the watch window or another context
149 * that does not expect REPL support. 149 * that does not expect REPL support in Dartium 34.
150 */ 150 */
151 static const _CONSOLE_API_SUPPORT_HEADER = 151 static const _CONSOLE_API_SUPPORT_HEADER_34 =
152 'with ((console && console._commandLineAPI) || { __proto__: null }) {\n'; 152 'with ((console && console._commandLineAPI) || { __proto__: null }) {\n';
153 /**
154 * Header passed in from the Dartium Developer Tools when an expression is
155 * evaluated in the console as opposed to the watch window or another context
156 * that does not expect REPL support in Dartium 35.
157 */
158 static const _CONSOLE_API_SUPPORT_HEADER_35 =
159 'with (__commandLineAPI || { __proto__: null }) {\n';
160
161
153 static bool expectsConsoleApi(String expression) { 162 static bool expectsConsoleApi(String expression) {
154 return expression.indexOf(_CONSOLE_API_SUPPORT_HEADER) == 0;; 163 return expression.indexOf(_CONSOLE_API_SUPPORT_HEADER_34) == 0 ||
164 expression.indexOf(_CONSOLE_API_SUPPORT_HEADER_35) == 0;
155 } 165 }
156 166
157 /** 167 /**
158 * Takes an [expression] and a list of [local] variable and returns an 168 * Takes an [expression] and a list of [local] variable and returns an
159 * expression for a closure with a body matching the original expression 169 * expression for a closure with a body matching the original expression
160 * where locals are passed in as arguments. Returns a list containing the 170 * where locals are passed in as arguments. Returns a list containing the
161 * String expression for the closure and the list of arguments that should 171 * String expression for the closure and the list of arguments that should
162 * be passed to it. The expression should then be evaluated using 172 * be passed to it. The expression should then be evaluated using
163 * Dart_EvaluateExpr which will generate a closure that should be invoked 173 * Dart_EvaluateExpr which will generate a closure that should be invoked
164 * with the list of arguments passed to this method. 174 * with the list of arguments passed to this method.
165 * 175 *
166 * For example: 176 * For example:
167 * <code> 177 * <code>
168 * _consoleTempVariables = {'a' : someValue, 'b': someOtherValue} 178 * _consoleTempVariables = {'a' : someValue, 'b': someOtherValue}
169 * wrapExpressionAsClosure("${_CONSOLE_API_SUPPORT_HEADER}foo + bar + a", 179 * wrapExpressionAsClosure("${_CONSOLE_API_SUPPORT_HEADER35}foo + bar + a",
170 * ["bar", 40, "foo", 2]) 180 * ["bar", 40, "foo", 2])
171 * </code> 181 * </code>
172 * will return: 182 * will return:
173 * <code> 183 * <code>
174 * ["""(final $consoleVariables, final bar, final foo, final a, final b) => 184 * ["""(final $consoleVariables, final bar, final foo, final a, final b) =>
175 * (foo + bar + a 185 * (foo + bar + a
176 * )""", 186 * )""",
177 * [_consoleTempVariables, 40, 2, someValue, someOtherValue]] 187 * [_consoleTempVariables, 40, 2, someValue, someOtherValue]]
178 * </code> 188 * </code>
179 */ 189 */
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 _scheduleImmediateHelper._schedule(callback); 609 _scheduleImmediateHelper._schedule(callback);
600 }; 610 };
601 611
602 get _pureIsolateScheduleImmediateClosure => ((void callback()) => 612 get _pureIsolateScheduleImmediateClosure => ((void callback()) =>
603 throw new UnimplementedError("scheduleMicrotask in background isolates " 613 throw new UnimplementedError("scheduleMicrotask in background isolates "
604 "are not supported in the browser")); 614 "are not supported in the browser"));
605 615
606 void _initializeCustomElement(Element e) { 616 void _initializeCustomElement(Element e) {
607 _Utils.initializeCustomElement(e); 617 _Utils.initializeCustomElement(e);
608 } 618 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698