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

Unified Diff: lib/runtime/dart/_js_helper.js

Issue 1099333002: canonicalize const (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/runtime/dart/_internal.js ('k') | lib/runtime/dart/async.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart/_js_helper.js
diff --git a/lib/runtime/dart/_js_helper.js b/lib/runtime/dart/_js_helper.js
index c75071ae22ca7be76848785399128764c0ce4563..4ee8ac054ef28a43383ea24e96c559905d560a85 100644
--- a/lib/runtime/dart/_js_helper.js
+++ b/lib/runtime/dart/_js_helper.js
@@ -439,15 +439,15 @@ var _js_helper;
let newHooks = transformer(hooks);
return newHooks || hooks;
}
- let _baseHooks = new _foreign_helper.JS_CONST('function() {\n function typeNameInChrome(o) {\n var constructor = o.constructor;\n if (constructor) {\n var name = constructor.name;\n if (name) return name;\n }\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n }\n function getUnknownTag(object, tag) {\n // This code really belongs in [getUnknownTagGenericBrowser] but having it\n // here allows [getUnknownTag] to be tested on d8.\n if (/^HTML[A-Z].*Element$/.test(tag)) {\n // Check that it is not a simple JavaScript object.\n var name = Object.prototype.toString.call(object);\n if (name == "[object Object]") return null;\n return "HTMLElement";\n }\n }\n function getUnknownTagGenericBrowser(object, tag) {\n if (self.HTMLElement && object instanceof HTMLElement) return "HTMLElement";\n return getUnknownTag(object, tag);\n }\n function prototypeForTag(tag) {\n if (typeof window == "undefined") return null;\n if (typeof window[tag] == "undefined") return null;\n var constructor = window[tag];\n if (typeof constructor != "function") return null;\n return constructor.prototype;\n }\n function discriminator(tag) { return null; }\n\n var isBrowser = typeof navigator == "object";\n\n return {\n getTag: typeNameInChrome,\n getUnknownTag: isBrowser ? getUnknownTagGenericBrowser : getUnknownTag,\n prototypeForTag: prototypeForTag,\n discriminator: discriminator };\n}');
- let _constructorNameFallback = new _foreign_helper.JS_CONST('function getTagFallback(o) {\n var constructor = o.constructor;\n if (typeof constructor == "function") {\n var name = constructor.name;\n // If the name is a non-empty string, we use that as the type name of this\n // object. There are various cases where that does not work, so we have to\n // detect them and fall through to the toString() based implementation.\n\n if (typeof name == "string" &&\n\n // Sometimes the string is empty. This test also catches minified\n // shadow dom polyfil wrapper for Window on Firefox where the faked\n // constructor name does not \'stick\'. The shortest real DOM object\n // names have three characters (e.g. URL, CSS).\n name.length > 2 &&\n\n // On Firefox we often get "Object" as the constructor name, even for\n // more specialized DOM objects.\n name !== "Object" &&\n\n // This can happen in Opera.\n name !== "Function.prototype") {\n return name;\n }\n }\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n}');
- let _fallbackConstructorHooksTransformerGenerator = new _foreign_helper.JS_CONST('function(getTagFallback) {\n return function(hooks) {\n // If we are not in a browser, assume we are in d8.\n // TODO(sra): Recognize jsshell.\n if (typeof navigator != "object") return hooks;\n\n var ua = navigator.userAgent;\n // TODO(antonm): remove a reference to DumpRenderTree.\n if (ua.indexOf("DumpRenderTree") >= 0) return hooks;\n if (ua.indexOf("Chrome") >= 0) {\n // Confirm constructor name is usable for dispatch.\n function confirm(p) {\n return typeof window == "object" && window[p] && window[p].name == p;\n }\n if (confirm("Window") && confirm("HTMLElement")) return hooks;\n }\n\n hooks.getTag = getTagFallback;\n };\n}');
- let _ieHooksTransformer = new _foreign_helper.JS_CONST('function(hooks) {\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if (userAgent.indexOf("Trident/") == -1) return hooks;\n\n var getTag = hooks.getTag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTransfer": "Clipboard",\n "HTMLDDElement": "HTMLElement",\n "HTMLDTElement": "HTMLElement",\n "HTMLPhraseElement": "HTMLElement",\n "Position": "Geoposition"\n };\n\n function getTagIE(o) {\n var tag = getTag(o);\n var newTag = quickMap[tag];\n if (newTag) return newTag;\n // Patches for types which report themselves as Objects.\n if (tag == "Object") {\n if (window.DataView && (o instanceof window.DataView)) return "DataView";\n }\n return tag;\n }\n\n function prototypeForTagIE(tag) {\n var constructor = window[tag];\n if (constructor == null) return null;\n return constructor.prototype;\n }\n\n hooks.getTag = getTagIE;\n hooks.prototypeForTag = prototypeForTagIE;\n}');
- let _fixDocumentHooksTransformer = new _foreign_helper.JS_CONST('function(hooks) {\n var getTag = hooks.getTag;\n var prototypeForTag = hooks.prototypeForTag;\n function getTagFixed(o) {\n var tag = getTag(o);\n if (tag == "Document") {\n // Some browsers and the polymer polyfill call both HTML and XML documents\n // "Document", so we check for the xmlVersion property, which is the empty\n // string on HTML documents. Since both dart:html classes Document and\n // HtmlDocument share the same type, we must patch the instances and not\n // the prototype.\n if (!!o.xmlVersion) return "!Document";\n return "!HTMLDocument";\n }\n return tag;\n }\n\n function prototypeForTagFixed(tag) {\n if (tag == "Document") return null; // Do not pre-patch Document.\n return prototypeForTag(tag);\n }\n\n hooks.getTag = getTagFixed;\n hooks.prototypeForTag = prototypeForTagFixed;\n}');
- let _firefoxHooksTransformer = new _foreign_helper.JS_CONST('function(hooks) {\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if (userAgent.indexOf("Firefox") == -1) return hooks;\n\n var getTag = hooks.getTag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTransfer": "Clipboard",\n "GeoGeolocation": "Geolocation",\n "Location": "!Location", // Fixes issue 18151\n "WorkerMessageEvent": "MessageEvent",\n "XMLDocument": "!Document"};\n\n function getTagFirefox(o) {\n var tag = getTag(o);\n return quickMap[tag] || tag;\n }\n\n hooks.getTag = getTagFirefox;\n}');
- let _operaHooksTransformer = new _foreign_helper.JS_CONST('function(hooks) { return hooks; }\n');
- let _safariHooksTransformer = new _foreign_helper.JS_CONST('function(hooks) { return hooks; }\n');
- let _dartExperimentalFixupGetTagHooksTransformer = new _foreign_helper.JS_CONST('function(hooks) {\n if (typeof dartExperimentalFixupGetTag != "function") return hooks;\n hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag);\n}');
+ let _baseHooks = dart.const(new _foreign_helper.JS_CONST('function() {\n function typeNameInChrome(o) {\n var constructor = o.constructor;\n if (constructor) {\n var name = constructor.name;\n if (name) return name;\n }\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n }\n function getUnknownTag(object, tag) {\n // This code really belongs in [getUnknownTagGenericBrowser] but having it\n // here allows [getUnknownTag] to be tested on d8.\n if (/^HTML[A-Z].*Element$/.test(tag)) {\n // Check that it is not a simple JavaScript object.\n var name = Object.prototype.toString.call(object);\n if (name == "[object Object]") return null;\n return "HTMLElement";\n }\n }\n function getUnknownTagGenericBrowser(object, tag) {\n if (self.HTMLElement && object instanceof HTMLElement) return "HTMLElement";\n return getUnknownTag(object, tag);\n }\n function prototypeForTag(tag) {\n if (typeof window == "undefined") return null;\n if (typeof window[tag] == "undefined") return null;\n var constructor = window[tag];\n if (typeof constructor != "function") return null;\n return constructor.prototype;\n }\n function discriminator(tag) { return null; }\n\n var isBrowser = typeof navigator == "object";\n\n return {\n getTag: typeNameInChrome,\n getUnknownTag: isBrowser ? getUnknownTagGenericBrowser : getUnknownTag,\n prototypeForTag: prototypeForTag,\n discriminator: discriminator };\n}'));
+ let _constructorNameFallback = dart.const(new _foreign_helper.JS_CONST('function getTagFallback(o) {\n var constructor = o.constructor;\n if (typeof constructor == "function") {\n var name = constructor.name;\n // If the name is a non-empty string, we use that as the type name of this\n // object. There are various cases where that does not work, so we have to\n // detect them and fall through to the toString() based implementation.\n\n if (typeof name == "string" &&\n\n // Sometimes the string is empty. This test also catches minified\n // shadow dom polyfil wrapper for Window on Firefox where the faked\n // constructor name does not \'stick\'. The shortest real DOM object\n // names have three characters (e.g. URL, CSS).\n name.length > 2 &&\n\n // On Firefox we often get "Object" as the constructor name, even for\n // more specialized DOM objects.\n name !== "Object" &&\n\n // This can happen in Opera.\n name !== "Function.prototype") {\n return name;\n }\n }\n var s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1);\n}'));
+ let _fallbackConstructorHooksTransformerGenerator = dart.const(new _foreign_helper.JS_CONST('function(getTagFallback) {\n return function(hooks) {\n // If we are not in a browser, assume we are in d8.\n // TODO(sra): Recognize jsshell.\n if (typeof navigator != "object") return hooks;\n\n var ua = navigator.userAgent;\n // TODO(antonm): remove a reference to DumpRenderTree.\n if (ua.indexOf("DumpRenderTree") >= 0) return hooks;\n if (ua.indexOf("Chrome") >= 0) {\n // Confirm constructor name is usable for dispatch.\n function confirm(p) {\n return typeof window == "object" && window[p] && window[p].name == p;\n }\n if (confirm("Window") && confirm("HTMLElement")) return hooks;\n }\n\n hooks.getTag = getTagFallback;\n };\n}'));
+ let _ieHooksTransformer = dart.const(new _foreign_helper.JS_CONST('function(hooks) {\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if (userAgent.indexOf("Trident/") == -1) return hooks;\n\n var getTag = hooks.getTag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTransfer": "Clipboard",\n "HTMLDDElement": "HTMLElement",\n "HTMLDTElement": "HTMLElement",\n "HTMLPhraseElement": "HTMLElement",\n "Position": "Geoposition"\n };\n\n function getTagIE(o) {\n var tag = getTag(o);\n var newTag = quickMap[tag];\n if (newTag) return newTag;\n // Patches for types which report themselves as Objects.\n if (tag == "Object") {\n if (window.DataView && (o instanceof window.DataView)) return "DataView";\n }\n return tag;\n }\n\n function prototypeForTagIE(tag) {\n var constructor = window[tag];\n if (constructor == null) return null;\n return constructor.prototype;\n }\n\n hooks.getTag = getTagIE;\n hooks.prototypeForTag = prototypeForTagIE;\n}'));
+ let _fixDocumentHooksTransformer = dart.const(new _foreign_helper.JS_CONST('function(hooks) {\n var getTag = hooks.getTag;\n var prototypeForTag = hooks.prototypeForTag;\n function getTagFixed(o) {\n var tag = getTag(o);\n if (tag == "Document") {\n // Some browsers and the polymer polyfill call both HTML and XML documents\n // "Document", so we check for the xmlVersion property, which is the empty\n // string on HTML documents. Since both dart:html classes Document and\n // HtmlDocument share the same type, we must patch the instances and not\n // the prototype.\n if (!!o.xmlVersion) return "!Document";\n return "!HTMLDocument";\n }\n return tag;\n }\n\n function prototypeForTagFixed(tag) {\n if (tag == "Document") return null; // Do not pre-patch Document.\n return prototypeForTag(tag);\n }\n\n hooks.getTag = getTagFixed;\n hooks.prototypeForTag = prototypeForTagFixed;\n}'));
+ let _firefoxHooksTransformer = dart.const(new _foreign_helper.JS_CONST('function(hooks) {\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if (userAgent.indexOf("Firefox") == -1) return hooks;\n\n var getTag = hooks.getTag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTransfer": "Clipboard",\n "GeoGeolocation": "Geolocation",\n "Location": "!Location", // Fixes issue 18151\n "WorkerMessageEvent": "MessageEvent",\n "XMLDocument": "!Document"};\n\n function getTagFirefox(o) {\n var tag = getTag(o);\n return quickMap[tag] || tag;\n }\n\n hooks.getTag = getTagFirefox;\n}'));
+ let _operaHooksTransformer = dart.const(new _foreign_helper.JS_CONST('function(hooks) { return hooks; }\n'));
+ let _safariHooksTransformer = dart.const(new _foreign_helper.JS_CONST('function(hooks) { return hooks; }\n'));
+ let _dartExperimentalFixupGetTagHooksTransformer = dart.const(new _foreign_helper.JS_CONST('function(hooks) {\n if (typeof dartExperimentalFixupGetTag != "function") return hooks;\n hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag);\n}'));
let _nativeRegExp = Symbol('_nativeRegExp');
// Function regExpGetNative: (JSSyntaxRegExp) → dynamic
function regExpGetNative(regexp) {
@@ -1346,7 +1346,7 @@ var _js_helper;
_Patch() {
}
}
- let patch = new _Patch();
+ let patch = dart.const(new _Patch());
class InternalMap extends core.Object {}
// Function requiresPreamble: () → dynamic
function requiresPreamble() {
@@ -1447,10 +1447,10 @@ var _js_helper;
}
get positionalArguments() {
if (this.isGetter)
- return /* Unimplemented const */[];
+ return dart.const([]);
let argumentCount = dart.notNull(this[_arguments][core.$length]) - dart.notNull(this[_namedArgumentNames][core.$length]);
if (argumentCount == 0)
- return /* Unimplemented const */[];
+ return dart.const([]);
let list = [];
for (let index = 0; dart.notNull(index) < dart.notNull(argumentCount); index = dart.notNull(index) + 1) {
list[core.$add](this[_arguments][core.$get](index));
@@ -2045,7 +2045,7 @@ var _js_helper;
});
}
let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argumentCount}${names}`;
- return dart.dsend(func, 'noSuchMethod', createUnmangledInvocationMirror(/* Unimplemented const */new _internal.Symbol("call"), selectorName, JSInvocationMirror.METHOD, arguments$, namedArgumentList));
+ return dart.dsend(func, 'noSuchMethod', createUnmangledInvocationMirror(dart.const(new core.Symbol('call')), selectorName, JSInvocationMirror.METHOD, arguments$, namedArgumentList));
}
static applyFunction(func, positionalArguments, namedArguments) {
return namedArguments == null ? Primitives.applyFunctionWithPositionalArguments(func, positionalArguments) : Primitives.applyFunctionWithNamedArguments(func, positionalArguments, namedArguments);
@@ -3487,7 +3487,7 @@ var _js_helper;
}
// Function getDynamicRuntimeType: () → RuntimeType
function getDynamicRuntimeType() {
- return new DynamicRuntimeType();
+ return dart.const(new DynamicRuntimeType());
}
class VoidRuntimeType extends RuntimeType {
VoidRuntimeType() {
@@ -3502,7 +3502,7 @@ var _js_helper;
}
// Function getVoidRuntimeType: () → RuntimeType
function getVoidRuntimeType() {
- return new VoidRuntimeType();
+ return dart.const(new VoidRuntimeType());
}
// Function functionTypeTestMetaHelper: () → dynamic
function functionTypeTestMetaHelper() {
@@ -3626,7 +3626,7 @@ var _js_helper;
return this[_typeData].named;
}
toRuntimeType() {
- return new DynamicRuntimeType();
+ return dart.const(new DynamicRuntimeType());
}
[_convert](type) {
let result = runtimeTypeToString(type);
« no previous file with comments | « lib/runtime/dart/_internal.js ('k') | lib/runtime/dart/async.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698