diff --git a/javascript/atoms/BUILD.bazel b/javascript/atoms/BUILD.bazel index 02b961abf2fd7..204267689b419 100644 --- a/javascript/atoms/BUILD.bazel +++ b/javascript/atoms/BUILD.bazel @@ -40,11 +40,11 @@ closure_js_library( ":dom", ":errors", ":events", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom:tagname", - "@io_bazel_rules_closure//closure/library/math:coordinate", - "@io_bazel_rules_closure//closure/library/math:vec2", - "@io_bazel_rules_closure//closure/library/style", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom:tagname", + "//third_party/closure/goog/math:coordinate", + "//third_party/closure/goog/math:vec2", + "//third_party/closure/goog/style", ], ) @@ -63,8 +63,8 @@ closure_js_library( "JSC_USE_OF_GOOG_PROVIDE", ], deps = [ - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/color:names", + "//third_party/closure/goog/array", + "//third_party/closure/goog/color:names", ], ) @@ -91,15 +91,15 @@ closure_js_library( ":events", ":locators", ":useragent", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom", - "@io_bazel_rules_closure//closure/library/dom:selection", - "@io_bazel_rules_closure//closure/library/dom:tagname", - "@io_bazel_rules_closure//closure/library/math:coordinate", - "@io_bazel_rules_closure//closure/library/structs:map", - "@io_bazel_rules_closure//closure/library/structs:set", - "@io_bazel_rules_closure//closure/library/useragent", - "@io_bazel_rules_closure//closure/library/useragent:product", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:selection", + "//third_party/closure/goog/dom:tagname", + "//third_party/closure/goog/math:coordinate", + "//third_party/closure/goog/structs:map", + "//third_party/closure/goog/structs:set", + "//third_party/closure/goog/useragent", + "//third_party/closure/goog/useragent:product", ], ) @@ -115,10 +115,10 @@ closure_js_library( deps = [ ":errors", ":useragent", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom", - "@io_bazel_rules_closure//closure/library/dom:nodetype", - "@io_bazel_rules_closure//closure/library/dom:tagname", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:nodetype", + "//third_party/closure/goog/dom:tagname", ], ) @@ -139,16 +139,16 @@ closure_js_library( ":domcore", ":json", ":useragent", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom", - "@io_bazel_rules_closure//closure/library/dom:nodetype", - "@io_bazel_rules_closure//closure/library/dom:tagname", - "@io_bazel_rules_closure//closure/library/math", - "@io_bazel_rules_closure//closure/library/math:coordinate", - "@io_bazel_rules_closure//closure/library/math:rect", - "@io_bazel_rules_closure//closure/library/string", - "@io_bazel_rules_closure//closure/library/style", - "@io_bazel_rules_closure//closure/library/useragent", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:nodetype", + "//third_party/closure/goog/dom:tagname", + "//third_party/closure/goog/math", + "//third_party/closure/goog/math:coordinate", + "//third_party/closure/goog/math:rect", + "//third_party/closure/goog/string", + "//third_party/closure/goog/style", + "//third_party/closure/goog/useragent", ], ) @@ -183,12 +183,12 @@ closure_js_library( ":errors", ":json", ":useragent", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom", - "@io_bazel_rules_closure//closure/library/events:browserevent", - "@io_bazel_rules_closure//closure/library/style", - "@io_bazel_rules_closure//closure/library/useragent", - "@io_bazel_rules_closure//closure/library/useragent:product", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/events:browserevent", + "//third_party/closure/goog/style", + "//third_party/closure/goog/useragent", + "//third_party/closure/goog/useragent:product", ], ) @@ -209,8 +209,8 @@ closure_js_library( ":dom", ":errors", ":locators", - "@io_bazel_rules_closure//closure/library/dom", - "@io_bazel_rules_closure//closure/library/dom:tagname", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:tagname", ], ) @@ -228,7 +228,7 @@ closure_js_library( ":errors", ":json", ":useragent", - "@io_bazel_rules_closure//closure/library/useragent:all_js", + "//third_party/closure/goog/useragent:all_js", ], ) @@ -250,10 +250,10 @@ closure_js_library( ":bot", ":errors", ":json", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom:nodetype", - "@io_bazel_rules_closure//closure/library/object", - "@io_bazel_rules_closure//closure/library/useragent", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom:nodetype", + "//third_party/closure/goog/object", + "//third_party/closure/goog/useragent", ], ) @@ -265,8 +265,8 @@ closure_js_library( ], deps = [ ":useragent", - "@io_bazel_rules_closure//closure/library/json", - "@io_bazel_rules_closure//closure/library/useragent", + "//third_party/closure/goog/json", + "//third_party/closure/goog/useragent", ], ) @@ -290,13 +290,13 @@ closure_js_library( ":errors", ":json", ":useragent", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom", - "@io_bazel_rules_closure//closure/library/dom:nodetype", - "@io_bazel_rules_closure//closure/library/math:rect", - "@io_bazel_rules_closure//closure/library/string", - "@io_bazel_rules_closure//closure/library/useragent", - "@io_bazel_rules_closure//closure/library/useragent:product", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:nodetype", + "//third_party/closure/goog/math:rect", + "//third_party/closure/goog/string", + "//third_party/closure/goog/useragent", + "//third_party/closure/goog/useragent:product", ], ) @@ -309,10 +309,10 @@ closure_js_library( "JSC_USE_OF_GOOG_PROVIDE", ], deps = [ - "@io_bazel_rules_closure//closure/library/string", - "@io_bazel_rules_closure//closure/library/useragent", - "@io_bazel_rules_closure//closure/library/useragent:product", - "@io_bazel_rules_closure//closure/library/useragent:product_isversion", + "//third_party/closure/goog/string", + "//third_party/closure/goog/useragent", + "//third_party/closure/goog/useragent:product", + "//third_party/closure/goog/useragent:product_isversion", ], ) @@ -347,9 +347,9 @@ closure_js_library( ":bot", ":errors", ":useragent", - "@io_bazel_rules_closure//closure/library/dom:nodetype", - "@io_bazel_rules_closure//closure/library/string", - "@io_bazel_rules_closure//closure/library/useragent", + "//third_party/closure/goog/dom:nodetype", + "//third_party/closure/goog/string", + "//third_party/closure/goog/useragent", ], ) diff --git a/javascript/atoms/fragments/BUILD.bazel b/javascript/atoms/fragments/BUILD.bazel index cf18aed671e80..2bbe6e6678fc2 100644 --- a/javascript/atoms/fragments/BUILD.bazel +++ b/javascript/atoms/fragments/BUILD.bazel @@ -108,7 +108,7 @@ closure_fragment( "//javascript/chrome-driver:__pkg__", ], deps = [ - "@io_bazel_rules_closure//closure/library/style", + "//third_party/closure/goog/style", ], ) diff --git a/javascript/atoms/test/test_bootstrap.js b/javascript/atoms/test/test_bootstrap.js index 84186cec89325..955116c00fd7d 100644 --- a/javascript/atoms/test/test_bootstrap.js +++ b/javascript/atoms/test/test_bootstrap.js @@ -58,14 +58,14 @@ // All the files to load. Files are specified in the order they must be // loaded, NOT alphabetical order. var files = [ - '../../../third_party/closure/goog/base.js', + '/filez/_main/third_party/closure/goog/base.js', 'deps.js' ]; if (location.pathname.lastIndexOf('/filez/_main/javascript/', 0) === 0) { directoryPath = ''; files = [ - '/filez/com_google_javascript_closure_library/closure/goog/base.js', + '/filez/_main/third_party/closure/goog/base.js', '/filez/_main/javascript/atoms/deps.js', ]; } diff --git a/javascript/chrome-driver/BUILD.bazel b/javascript/chrome-driver/BUILD.bazel index f06b66c43718b..9622666958f4a 100644 --- a/javascript/chrome-driver/BUILD.bazel +++ b/javascript/chrome-driver/BUILD.bazel @@ -15,11 +15,11 @@ closure_js_library( deps = [ "//javascript/atoms:dom", "//javascript/atoms:locators", - "@io_bazel_rules_closure//closure/library/dom", - "@io_bazel_rules_closure//closure/library/math:coordinate", - "@io_bazel_rules_closure//closure/library/math:rect", - "@io_bazel_rules_closure//closure/library/math:size", - "@io_bazel_rules_closure//closure/library/style", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/math:coordinate", + "//third_party/closure/goog/math:rect", + "//third_party/closure/goog/math:size", + "//third_party/closure/goog/style", ], ) @@ -29,7 +29,7 @@ closure_fragment( function = "goog.style.getPageOffset", module = "goog.style", deps = [ - "@io_bazel_rules_closure//closure/library/style", + "//third_party/closure/goog/style", ], ) diff --git a/javascript/chrome-driver/test/test_bootstrap.js b/javascript/chrome-driver/test/test_bootstrap.js index 389c04a2b048a..54a3342ff8a85 100644 --- a/javascript/chrome-driver/test/test_bootstrap.js +++ b/javascript/chrome-driver/test/test_bootstrap.js @@ -63,7 +63,7 @@ if (location.pathname.lastIndexOf('/filez/_main/javascript/', 0) === 0) { directoryPath = ''; files = [ - '/filez/com_google_javascript_closure_library/closure/goog/base.js', + '/filez/_main/third_party/closure/goog/base.js', '/filez/_main/javascript/chrome-driver/deps.js', ]; } diff --git a/javascript/ie-driver/BUILD.bazel b/javascript/ie-driver/BUILD.bazel index ada49881dc71b..d1640d8cd439d 100644 --- a/javascript/ie-driver/BUILD.bazel +++ b/javascript/ie-driver/BUILD.bazel @@ -23,8 +23,8 @@ closure_js_library( "//javascript/atoms:errors", "//javascript/atoms:locators", "//javascript/atoms:useragent", - "@io_bazel_rules_closure//closure/library/math:coordinate", - "@io_bazel_rules_closure//closure/library/style", + "//third_party/closure/goog/math:coordinate", + "//third_party/closure/goog/style", ], ) diff --git a/javascript/private/closure_js_deps.bzl b/javascript/private/closure_js_deps.bzl index 292cd5e405038..c406a064022dc 100644 --- a/javascript/private/closure_js_deps.bzl +++ b/javascript/private/closure_js_deps.bzl @@ -98,8 +98,7 @@ def closure_js_deps(name, deps = [], testonly = None, **kwargs): $(location //javascript/private:closure_make_deps) \\ --closure-path $$(pwd)/external/com_google_javascript_closure_library/closure \\ --no-validate \\ - $$FILES | \\ - sed 's|../../../javascript/|../../../_main/javascript/|g' \\ + $$FILES \\ > $@ """, tools = ["//javascript/private:closure_make_deps"], diff --git a/javascript/private/test_suite.bzl b/javascript/private/test_suite.bzl index d8453c0368d1a..edf4b4395e92f 100644 --- a/javascript/private/test_suite.bzl +++ b/javascript/private/test_suite.bzl @@ -3,7 +3,11 @@ load("//java:defs.bzl", "selenium_test") def closure_test_suite(name, data = [], browsers = None): data = data + [ - "@com_google_javascript_closure_library//:com_google_javascript_closure_library", + "//third_party/closure/goog:base", + "//third_party/closure/goog:css", + "//third_party/closure/goog:deps", + "//third_party/closure/goog:library", + "//third_party/closure/goog/testing", ] selenium_test( diff --git a/javascript/webdriver/atoms/BUILD.bazel b/javascript/webdriver/atoms/BUILD.bazel index b47514b00e39d..ba739cb1f5b99 100644 --- a/javascript/webdriver/atoms/BUILD.bazel +++ b/javascript/webdriver/atoms/BUILD.bazel @@ -37,11 +37,11 @@ closure_js_library( "//javascript/atoms:domcore", "//javascript/atoms:html5", "//javascript/webdriver:key", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom", - "@io_bazel_rules_closure//closure/library/dom:tagname", - "@io_bazel_rules_closure//closure/library/math:coordinate", - "@io_bazel_rules_closure//closure/library/style", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:tagname", + "//third_party/closure/goog/math:coordinate", + "//third_party/closure/goog/style", ], ) @@ -55,8 +55,8 @@ closure_js_library( visibility = ["//visibility:private"], deps = [ "//javascript/atoms:domcore", - "@io_bazel_rules_closure//closure/library/array", - "@io_bazel_rules_closure//closure/library/dom:tagname", + "//third_party/closure/goog/array", + "//third_party/closure/goog/dom:tagname", ], ) diff --git a/javascript/webdriver/atoms/inject/BUILD.bazel b/javascript/webdriver/atoms/inject/BUILD.bazel index f74069ab3d655..da7e4cdf44e79 100644 --- a/javascript/webdriver/atoms/inject/BUILD.bazel +++ b/javascript/webdriver/atoms/inject/BUILD.bazel @@ -38,7 +38,7 @@ closure_js_library( "//javascript/atoms:action", "//javascript/atoms:inject", "//javascript/webdriver/atoms:atoms-lib", - "@io_bazel_rules_closure//closure/library/json", + "//third_party/closure/goog/json", ], ) @@ -68,7 +68,7 @@ closure_js_library( "//javascript/atoms:inject", "//javascript/atoms:useragent", "//javascript/webdriver/atoms:atoms-lib", - "@io_bazel_rules_closure//closure/library/json", + "//third_party/closure/goog/json", ], ) @@ -97,7 +97,7 @@ closure_js_library( ":execute-script", "//javascript/atoms:inject", "//javascript/atoms:locators", - "@io_bazel_rules_closure//closure/library/json", + "//third_party/closure/goog/json", ], ) diff --git a/javascript/webdriver/test/test_bootstrap.js b/javascript/webdriver/test/test_bootstrap.js index eaadf8c52e5d8..fbef8cdd01b4d 100644 --- a/javascript/webdriver/test/test_bootstrap.js +++ b/javascript/webdriver/test/test_bootstrap.js @@ -65,7 +65,7 @@ || location.pathname.lastIndexOf('/common/generated/javascript/', 0) === 0) { directoryPath = ''; files = [ - '/filez/com_google_javascript_closure_library/closure/goog/base.js', + '/filez/_main/third_party/closure/goog/base.js', '/filez/_main/javascript/atoms/deps.js', '/filez/_main/javascript/webdriver/deps.js', ]; diff --git a/third_party/closure/goog/BUILD.bazel b/third_party/closure/goog/BUILD.bazel index c7b787bece6bd..bbf10cde2dc17 100644 --- a/third_party/closure/goog/BUILD.bazel +++ b/third_party/closure/goog/BUILD.bazel @@ -1,12 +1,126 @@ -# Only present to allow us to provide the filegroup to the test webserver +# DO NOT EDIT -- bazel run //third_party/closure/goog:regenerate -- "$PWD" -filegroup( +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_css_library", "closure_js_library") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +closure_js_library( + name = "library", + exports = [ + "//third_party/closure/goog/array:all_js", + "//third_party/closure/goog/asserts:all_js", + "//third_party/closure/goog/async:all_js", + "//third_party/closure/goog/color:all_js", + "//third_party/closure/goog/debug:divconsole", + "//third_party/closure/goog/debug:error", + "//third_party/closure/goog/debug:logger", + "//third_party/closure/goog/debug:logrecord", + "//third_party/closure/goog/disposable:all_js", + "//third_party/closure/goog/dom:all_js", + "//third_party/closure/goog/events", + "//third_party/closure/goog/events:browserevent", + "//third_party/closure/goog/events:eventtype", + "//third_party/closure/goog/events:keycodes", + "//third_party/closure/goog/fs:all_js", + "//third_party/closure/goog/functions:all_js", + "//third_party/closure/goog/fx:all_js", + "//third_party/closure/goog/html:all_js", + "//third_party/closure/goog/i18n:all_js", + "//third_party/closure/goog/iter:all_js", + "//third_party/closure/goog/json:all_js", + "//third_party/closure/goog/labs/useragent:all_js", + "//third_party/closure/goog/log:all_js", + "//third_party/closure/goog/math:all_js", + "//third_party/closure/goog/mochikit/async:all_js", + "//third_party/closure/goog/net:xmlhttp", + "//third_party/closure/goog/object:all_js", + "//third_party/closure/goog/positioning:all_js", + "//third_party/closure/goog/promise:all_js", + "//third_party/closure/goog/reflect:all_js", + "//third_party/closure/goog/string:all_js", + "//third_party/closure/goog/structs:all_js", + "//third_party/closure/goog/style:all_js", + "//third_party/closure/goog/timer:all_js", + "//third_party/closure/goog/ui:component", + "//third_party/closure/goog/ui/editor:defaulttoolbar", + "//third_party/closure/goog/uri:all_js", + "//third_party/closure/goog/useragent:all_js", + "//third_party/closure/goog/window:all_js", + ], +) + +closure_js_library( + name = "testing", + testonly = True, + exports = [ + "//third_party/closure/goog/testing:asserts", + "//third_party/closure/goog/testing:expectedfailures", + "//third_party/closure/goog/testing:jsunit", + "//third_party/closure/goog/testing:jsunitexception", + "//third_party/closure/goog/testing:mockclock", + "//third_party/closure/goog/testing:mockcontrol", + "//third_party/closure/goog/testing:performancetable", + "//third_party/closure/goog/testing:performancetimer", + "//third_party/closure/goog/testing:propertyreplacer", + "//third_party/closure/goog/testing:recordfunction", + "//third_party/closure/goog/testing:stacktrace", + "//third_party/closure/goog/testing:strictmock", + "//third_party/closure/goog/testing:testcase", + ], +) + +closure_js_library( name = "goog", - srcs = glob([ - "**/*.js", - ]), - visibility = [ - "//dotnet/test:__subpackages__", - "//java/test/org/openqa/selenium/environment:__pkg__", + srcs = ["goog.js"], + lenient = True, + no_closure_library = True, +) + +closure_js_library( + name = "test_module", + testonly = True, + srcs = ["test_module.js"], + lenient = True, + deps = ["//third_party/closure/goog:test_module_dep"], +) + +closure_js_library( + name = "test_module_dep", + testonly = True, + srcs = ["test_module_dep.js"], + lenient = True, +) + +filegroup( + name = "base", + srcs = [ + "base.js", + "transitionalforwarddeclarations.js", + ], +) + +closure_js_library( + name = "deps", + srcs = ["deps.js"], + lenient = True, +) + +closure_js_library( + name = "transpile", + srcs = ["transpile.js"], + lenient = True, +) + +closure_css_library( + name = "css", + srcs = [ + "css/colormenubutton.css", + "css/colorpalette.css", + "css/editortoolbar.css", + "css/palette.css", + "css/toolbar.css", + "demos/css/demo.css", ], ) diff --git a/third_party/closure/goog/a11y/aria/BUILD.bazel b/third_party/closure/goog/a11y/aria/BUILD.bazel new file mode 100644 index 0000000000000..d2c084acd532c --- /dev/null +++ b/third_party/closure/goog/a11y/aria/BUILD.bazel @@ -0,0 +1,72 @@ +# DO NOT EDIT -- bazel run //third_party/closure/goog:regenerate -- "$PWD" + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +closure_js_library( + name = "all_js", + exports = [ + ":announcer", + ":aria", + ":attributes", + ":datatables", + ":roles", + ], +) + +closure_js_library( + name = "announcer", + srcs = ["announcer.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/a11y/aria", + "//third_party/closure/goog/a11y/aria:attributes", + "//third_party/closure/goog/disposable", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:tagname", + "//third_party/closure/goog/object", + "//third_party/closure/goog/timer", + ], +) + +closure_js_library( + name = "aria", + srcs = ["aria.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/a11y/aria:attributes", + "//third_party/closure/goog/a11y/aria:datatables", + "//third_party/closure/goog/a11y/aria:roles", + "//third_party/closure/goog/array", + "//third_party/closure/goog/asserts", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:tagname", + "//third_party/closure/goog/object", + "//third_party/closure/goog/string", + ], +) + +closure_js_library( + name = "attributes", + srcs = ["attributes.js"], + lenient = True, +) + +closure_js_library( + name = "datatables", + srcs = ["datatables.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/a11y/aria:attributes", + "//third_party/closure/goog/object", + ], +) + +closure_js_library( + name = "roles", + srcs = ["roles.js"], + lenient = True, +) diff --git a/third_party/closure/goog/a11y/aria/aria.js b/third_party/closure/goog/a11y/aria/aria.js index 0df45f98f21fc..e6bab22b5115e 100644 --- a/third_party/closure/goog/a11y/aria/aria.js +++ b/third_party/closure/goog/a11y/aria/aria.js @@ -18,7 +18,6 @@ * states as defined by W3C ARIA standard: http://www.w3.org/TR/wai-aria/ * All modern browsers have some form of ARIA support, so no browser checks are * performed when adding ARIA to components. - * */ goog.provide('goog.a11y.aria'); @@ -304,16 +303,15 @@ goog.a11y.aria.assertRoleIsSetInternalUtil = function(element, allowedRoles) { */ goog.a11y.aria.getStateBoolean = function(element, stateName) { var attr = - /** @type {string|boolean} */ ( - element.getAttribute( - goog.a11y.aria.getAriaAttributeName_(stateName))); + /** @type {string|boolean|null} */ (element.getAttribute( + goog.a11y.aria.getAriaAttributeName_(stateName))); goog.asserts.assert( - goog.isBoolean(attr) || attr == null || attr == 'true' || + typeof attr === 'boolean' || attr == null || attr == 'true' || attr == 'false'); if (attr == null) { return attr; } - return goog.isBoolean(attr) ? attr : attr == 'true'; + return typeof attr === 'boolean' ? attr : attr == 'true'; }; @@ -330,7 +328,7 @@ goog.a11y.aria.getStateNumber = function(element, stateName) { element.getAttribute( goog.a11y.aria.getAriaAttributeName_(stateName))); goog.asserts.assert( - (attr == null || !isNaN(Number(attr))) && !goog.isBoolean(attr)); + (attr == null || !isNaN(Number(attr))) && typeof attr !== 'boolean'); return attr == null ? null : Number(attr); }; @@ -346,7 +344,7 @@ goog.a11y.aria.getStateString = function(element, stateName) { var attr = element.getAttribute(goog.a11y.aria.getAriaAttributeName_(stateName)); goog.asserts.assert( - (attr == null || goog.isString(attr)) && + (attr == null || typeof attr === 'string') && (attr == '' || isNaN(Number(attr))) && attr != 'true' && attr != 'false'); return (attr == null || attr == '') ? null : attr; }; diff --git a/third_party/closure/goog/a11y/aria/attributes.js b/third_party/closure/goog/a11y/aria/attributes.js index f4e0a3d0746ab..f1e62358b74a4 100644 --- a/third_party/closure/goog/a11y/aria/attributes.js +++ b/third_party/closure/goog/a11y/aria/attributes.js @@ -62,6 +62,11 @@ goog.a11y.aria.State = { // undefined}. CHECKED: 'checked', + // ARIA state that defines an element's column index or position with respect + // to the total number of columns within a table, grid, or treegrid. + // Value: number. + COLINDEX: 'colindex', + // ARIA property that identifies the element or elements whose contents or // presence are controlled by this element. // Value: space-separated IDs of other elements. @@ -160,6 +165,11 @@ goog.a11y.aria.State = { // before a form may be submitted. Value: one of {true, false}. REQUIRED: 'required', + // ARIA state that defines an element's row index or position with respect + // to the total number of rows within a table, grid, or treegrid. + // Value: number. + ROWINDEX: 'rowindex', + // ARIA state for setting the currently selected item in the list. // Value: one of {true, false, undefined}. SELECTED: 'selected', diff --git a/third_party/closure/goog/array/BUILD.bazel b/third_party/closure/goog/array/BUILD.bazel new file mode 100644 index 0000000000000..bd0701abab6e2 --- /dev/null +++ b/third_party/closure/goog/array/BUILD.bazel @@ -0,0 +1,19 @@ +# DO NOT EDIT -- bazel run //third_party/closure/goog:regenerate -- "$PWD" + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +closure_js_library( + name = "all_js", + exports = [":array"], +) + +closure_js_library( + name = "array", + srcs = ["array.js"], + lenient = True, + deps = ["//third_party/closure/goog/asserts"], +) diff --git a/third_party/closure/goog/array/array.js b/third_party/closure/goog/array/array.js index 0acfbd85fd056..611f81ed22570 100644 --- a/third_party/closure/goog/array/array.js +++ b/third_party/closure/goog/array/array.js @@ -14,8 +14,6 @@ /** * @fileoverview Utilities for manipulating arrays. - * - * @author arv@google.com (Erik Arvidsson) */ @@ -39,15 +37,17 @@ goog.require('goog.asserts'); * Setting goog.TRUSTED_SITE to false will automatically set * NATIVE_ARRAY_PROTOTYPES to false. */ -goog.define('goog.NATIVE_ARRAY_PROTOTYPES', goog.TRUSTED_SITE); +goog.NATIVE_ARRAY_PROTOTYPES = + goog.define('goog.NATIVE_ARRAY_PROTOTYPES', goog.TRUSTED_SITE); /** * @define {boolean} If true, JSCompiler will use the native implementation of - * array functions where appropriate (e.g., {@code Array#filter}) and remove the + * array functions where appropriate (e.g., `Array#filter`) and remove the * unused pure JS implementation. */ -goog.define('goog.array.ASSUME_NATIVE_FUNCTIONS', false); +goog.array.ASSUME_NATIVE_FUNCTIONS = goog.define( + 'goog.array.ASSUME_NATIVE_FUNCTIONS', goog.FEATURESET_YEAR > 2012); /** @@ -104,9 +104,9 @@ goog.array.indexOf = goog.NATIVE_ARRAY_PROTOTYPES && (opt_fromIndex < 0 ? Math.max(0, arr.length + opt_fromIndex) : opt_fromIndex); - if (goog.isString(arr)) { + if (typeof arr === 'string') { // Array.prototype.indexOf uses === so only strings should be found. - if (!goog.isString(obj) || obj.length != 1) { + if (typeof obj !== 'string' || obj.length != 1) { return -1; } return arr.indexOf(obj, fromIndex); @@ -149,9 +149,9 @@ goog.array.lastIndexOf = goog.NATIVE_ARRAY_PROTOTYPES && fromIndex = Math.max(0, arr.length + fromIndex); } - if (goog.isString(arr)) { + if (typeof arr === 'string') { // Array.prototype.lastIndexOf uses === so only strings should be found. - if (!goog.isString(obj) || obj.length != 1) { + if (typeof obj !== 'string' || obj.length != 1) { return -1; } return arr.lastIndexOf(obj, fromIndex); @@ -185,7 +185,7 @@ goog.array.forEach = goog.NATIVE_ARRAY_PROTOTYPES && } : function(arr, f, opt_obj) { var l = arr.length; // must be fixed during loop... see docs - var arr2 = goog.isString(arr) ? arr.split('') : arr; + var arr2 = (typeof arr === 'string') ? arr.split('') : arr; for (var i = 0; i < l; i++) { if (i in arr2) { f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr); @@ -210,7 +210,7 @@ goog.array.forEach = goog.NATIVE_ARRAY_PROTOTYPES && */ goog.array.forEachRight = function(arr, f, opt_obj) { var l = arr.length; // must be fixed during loop... see docs - var arr2 = goog.isString(arr) ? arr.split('') : arr; + var arr2 = (typeof arr === 'string') ? arr.split('') : arr; for (var i = l - 1; i >= 0; --i) { if (i in arr2) { f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr); @@ -249,7 +249,7 @@ goog.array.filter = goog.NATIVE_ARRAY_PROTOTYPES && var l = arr.length; // must be fixed during loop... see docs var res = []; var resLength = 0; - var arr2 = goog.isString(arr) ? arr.split('') : arr; + var arr2 = (typeof arr === 'string') ? arr.split('') : arr; for (var i = 0; i < l; i++) { if (i in arr2) { var val = arr2[i]; // in case f mutates arr2 @@ -288,7 +288,7 @@ goog.array.map = goog.NATIVE_ARRAY_PROTOTYPES && function(arr, f, opt_obj) { var l = arr.length; // must be fixed during loop... see docs var res = new Array(l); - var arr2 = goog.isString(arr) ? arr.split('') : arr; + var arr2 = (typeof arr === 'string') ? arr.split('') : arr; for (var i = 0; i < l; i++) { if (i in arr2) { res[i] = f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr); @@ -411,7 +411,7 @@ goog.array.some = goog.NATIVE_ARRAY_PROTOTYPES && } : function(arr, f, opt_obj) { var l = arr.length; // must be fixed during loop... see docs - var arr2 = goog.isString(arr) ? arr.split('') : arr; + var arr2 = (typeof arr === 'string') ? arr.split('') : arr; for (var i = 0; i < l; i++) { if (i in arr2 && f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr)) { return true; @@ -447,7 +447,7 @@ goog.array.every = goog.NATIVE_ARRAY_PROTOTYPES && } : function(arr, f, opt_obj) { var l = arr.length; // must be fixed during loop... see docs - var arr2 = goog.isString(arr) ? arr.split('') : arr; + var arr2 = (typeof arr === 'string') ? arr.split('') : arr; for (var i = 0; i < l; i++) { if (i in arr2 && !f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr)) { return false; @@ -495,7 +495,7 @@ goog.array.count = function(arr, f, opt_obj) { */ goog.array.find = function(arr, f, opt_obj) { var i = goog.array.findIndex(arr, f, opt_obj); - return i < 0 ? null : goog.isString(arr) ? arr.charAt(i) : arr[i]; + return i < 0 ? null : typeof arr === 'string' ? arr.charAt(i) : arr[i]; }; @@ -515,7 +515,7 @@ goog.array.find = function(arr, f, opt_obj) { */ goog.array.findIndex = function(arr, f, opt_obj) { var l = arr.length; // must be fixed during loop... see docs - var arr2 = goog.isString(arr) ? arr.split('') : arr; + var arr2 = (typeof arr === 'string') ? arr.split('') : arr; for (var i = 0; i < l; i++) { if (i in arr2 && f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr)) { return i; @@ -541,7 +541,7 @@ goog.array.findIndex = function(arr, f, opt_obj) { */ goog.array.findRight = function(arr, f, opt_obj) { var i = goog.array.findIndexRight(arr, f, opt_obj); - return i < 0 ? null : goog.isString(arr) ? arr.charAt(i) : arr[i]; + return i < 0 ? null : typeof arr === 'string' ? arr.charAt(i) : arr[i]; }; @@ -561,7 +561,7 @@ goog.array.findRight = function(arr, f, opt_obj) { */ goog.array.findIndexRight = function(arr, f, opt_obj) { var l = arr.length; // must be fixed during loop... see docs - var arr2 = goog.isString(arr) ? arr.split('') : arr; + var arr2 = (typeof arr === 'string') ? arr.split('') : arr; for (var i = l - 1; i >= 0; i--) { if (i in arr2 && f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr)) { return i; @@ -819,7 +819,7 @@ goog.array.join = function(var_args) { goog.array.toArray = function(object) { var length = object.length; - // If length is not a number the following it false. This case is kept for + // If length is not a number the following is false. This case is kept for // backwards compatibility since there are callers that pass objects that are // not array like. if (length > 0) { @@ -855,8 +855,8 @@ goog.array.clone = goog.array.toArray; * a; // [0, 1, 2] * * @param {Array} arr1 The array to modify. - * @param {...(Array|VALUE)} var_args The elements or arrays of elements - * to add to arr1. + * @param {...(IArrayLike|VALUE)} var_args The elements or arrays of + * elements to add to arr1. * @template VALUE */ goog.array.extend = function(arr1, var_args) { @@ -982,8 +982,8 @@ goog.array.removeDuplicates = function(arr, opt_rv, opt_hashFn) { * behavior for homogeneous arrays of String(s) and Number(s). The array * specified must be sorted in ascending order (as defined by the * comparison function). If the array is not sorted, results are undefined. - * If the array contains multiple instances of the specified target value, any - * of these instances may be found. + * If the array contains multiple instances of the specified target value, the + * left-most instance will be found. * * Runtime: O(log n) * @@ -991,9 +991,9 @@ goog.array.removeDuplicates = function(arr, opt_rv, opt_hashFn) { * @param {TARGET} target The sought value. * @param {function(TARGET, VALUE): number=} opt_compareFn Optional comparison * function by which the array is ordered. Should take 2 arguments to - * compare, and return a negative number, zero, or a positive number - * depending on whether the first argument is less than, equal to, or - * greater than the second. + * compare, the target value and an element from your array, and return a + * negative number, zero, or a positive number depending on whether the + * first argument is less than, equal to, or greater than the second. * @return {number} Lowest index of the target value if found, otherwise * (-(insertion point) - 1). The insertion point is where the value should * be inserted into arr to preserve the sorted property. Return value >= 0 @@ -1072,7 +1072,7 @@ goog.array.binarySearch_ = function( var right = arr.length; // exclusive var found; while (left < right) { - var middle = (left + right) >> 1; + var middle = left + ((right - left) >>> 1); var compareResult; if (isEvaluator) { compareResult = compareFn.call(opt_selfObj, arr[middle], middle, arr); @@ -1091,8 +1091,10 @@ goog.array.binarySearch_ = function( } } // left is the index if found, or the insertion point otherwise. - // ~left is a shorthand for -left - 1. - return found ? left : ~left; + // Avoiding bitwise not operator, as that causes a loss in precision for array + // indexes outside the bounds of a 32-bit signed integer. Array indexes have + // a maximum value of 2^32-2 https://tc39.es/ecma262/#array-index + return found ? left : -left - 1; }; @@ -1201,7 +1203,7 @@ goog.array.sortObjectsByKey = function(arr, key, opt_compareFn) { /** * Tells if the array is sorted. - * @param {!Array} arr The array. + * @param {!IArrayLike} arr The array. * @param {?function(T,T):number=} opt_compareFn Function to compare the * array elements. * Should take 2 arguments to compare, and return a negative number, zero, @@ -1365,15 +1367,15 @@ goog.array.binaryRemove = function(array, value, opt_compareFn) { /** * Splits an array into disjoint buckets according to a splitting function. - * @param {Array} array The array. - * @param {function(this:S, T,number,Array):?} sorter Function to call for - * every element. This takes 3 arguments (the element, the index and the - * array) and must return a valid object key (a string, number, etc), or - * undefined, if that object should not be placed in a bucket. + * @param {IArrayLike} array The array. + * @param {function(this:S, T, number, !IArrayLike):?} sorter Function to + * call for every element. This takes 3 arguments (the element, the index + * and the array) and must return a valid object key (a string, number, + * etc), or undefined, if that object should not be placed in a bucket. * @param {S=} opt_obj The object to be used as the value of 'this' within * sorter. - * @return {!Object} An object, with keys being all of the unique return values - * of sorter, and values being arrays containing the items for + * @return {!Object>} An object, with keys being all of the unique + * return values of sorter, and values being arrays containing the items for * which the splitter returned that key. * @template T,S */ @@ -1383,7 +1385,7 @@ goog.array.bucket = function(array, sorter, opt_obj) { for (var i = 0; i < array.length; i++) { var value = array[i]; var key = sorter.call(/** @type {?} */ (opt_obj), value, i, array); - if (goog.isDef(key)) { + if (key !== undefined) { // Push the value to the right bucket, creating it if necessary. var bucket = buckets[key] || (buckets[key] = []); bucket.push(value); @@ -1604,7 +1606,7 @@ goog.array.zip = function(var_args) { * Shuffles the values in the specified array using the Fisher-Yates in-place * shuffle (also known as the Knuth Shuffle). By default, calls Math.random() * and so resets the state of that random number generator. Similarly, may reset - * the state of the any other specified random number generator. + * the state of any other specified random number generator. * * Runtime: O(n) * @@ -1633,8 +1635,8 @@ goog.array.shuffle = function(arr, opt_randFn) { * provided by index_arr. For example, the result of index copying * ['a', 'b', 'c'] with index_arr [1,0,0,2] is ['b', 'a', 'a', 'c']. * - * @param {!Array} arr The array to get a indexed copy from. - * @param {!Array} index_arr An array of indexes to get from arr. + * @param {!IArrayLike} arr The array to get a indexed copy from. + * @param {!IArrayLike} index_arr An array of indexes to get from arr. * @return {!Array} A new array of elements from arr in index_arr order. * @template T */ diff --git a/third_party/closure/goog/asserts/BUILD.bazel b/third_party/closure/goog/asserts/BUILD.bazel new file mode 100644 index 0000000000000..0d5d23202aef6 --- /dev/null +++ b/third_party/closure/goog/asserts/BUILD.bazel @@ -0,0 +1,22 @@ +# DO NOT EDIT -- bazel run //third_party/closure/goog:regenerate -- "$PWD" + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +closure_js_library( + name = "all_js", + exports = [":asserts"], +) + +closure_js_library( + name = "asserts", + srcs = ["asserts.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/debug:error", + "//third_party/closure/goog/dom:nodetype", + ], +) diff --git a/third_party/closure/goog/asserts/asserts.js b/third_party/closure/goog/asserts/asserts.js index 1f4b65305c143..090efe536f972 100644 --- a/third_party/closure/goog/asserts/asserts.js +++ b/third_party/closure/goog/asserts/asserts.js @@ -16,13 +16,17 @@ * @fileoverview Utilities to check the preconditions, postconditions and * invariants runtime. * - * Methods in this package should be given special treatment by the compiler + * Methods in this package are given special treatment by the compiler * for type-inference. For example, goog.asserts.assert(foo) - * will restrict foo to a truthy value. + * will make the compiler treat foo as non-nullable. Similarly, + * goog.asserts.assertNumber(foo) informs the compiler about the + * type of foo. Where applicable, such assertions are preferable to + * casts by jsdoc with @type. * * The compiler has an option to disable asserts. So code like: * - * var x = goog.asserts.assert(foo()); goog.asserts.assert(bar()); + * var x = goog.asserts.assert(foo()); + * goog.asserts.assert(bar()); * * will be transformed into: * @@ -31,7 +35,13 @@ * The compiler will leave in foo() (because its return value is used), * but it will remove bar() because it assumes it does not have side-effects. * - * @author agrieve@google.com (Andrew Grieve) + * Additionally, note the compiler will consider the type to be "tightened" for + * all statements after the assertion. For example: + * + * const /** ?Object &#ast;/ value = foo(); + * goog.asserts.assert(value); + * // "value" is of type {!Object} at this point. + * */ goog.provide('goog.asserts'); @@ -39,13 +49,13 @@ goog.provide('goog.asserts.AssertionError'); goog.require('goog.debug.Error'); goog.require('goog.dom.NodeType'); -goog.require('goog.string'); /** * @define {boolean} Whether to strip out asserts or to leave them in. */ -goog.define('goog.asserts.ENABLE_ASSERTS', goog.DEBUG); +goog.asserts.ENABLE_ASSERTS = + goog.define('goog.asserts.ENABLE_ASSERTS', goog.DEBUG); @@ -58,11 +68,7 @@ goog.define('goog.asserts.ENABLE_ASSERTS', goog.DEBUG); * @final */ goog.asserts.AssertionError = function(messagePattern, messageArgs) { - messageArgs.unshift(messagePattern); - goog.debug.Error.call(this, goog.string.subs.apply(null, messageArgs)); - // Remove the messagePattern afterwards to avoid permanently modifying the - // passed in array. - messageArgs.shift(); + goog.debug.Error.call(this, goog.asserts.subs_(messagePattern, messageArgs)); /** * The message pattern used to format the error message. Error handlers can @@ -94,6 +100,31 @@ goog.asserts.DEFAULT_ERROR_HANDLER = function(e) { goog.asserts.errorHandler_ = goog.asserts.DEFAULT_ERROR_HANDLER; +/** + * Does simple python-style string substitution. + * subs("foo%s hot%s", "bar", "dog") becomes "foobar hotdog". + * @param {string} pattern The string containing the pattern. + * @param {!Array<*>} subs The items to substitute into the pattern. + * @return {string} A copy of `str` in which each occurrence of + * {@code %s} has been replaced an argument from `var_args`. + * @private + */ +goog.asserts.subs_ = function(pattern, subs) { + var splitParts = pattern.split('%s'); + var returnString = ''; + + // Replace up to the last split part. We are inserting in the + // positions between split parts. + var subLast = splitParts.length - 1; + for (var i = 0; i < subLast; i++) { + // keep unsupplied as '%s' + var sub = (i < subs.length) ? subs[i] : '%s'; + returnString += splitParts[i] + sub; + } + return returnString + splitParts[subLast]; +}; + + /** * Throws an exception with the given message and "Assertion failed" prefixed * onto it. @@ -145,6 +176,7 @@ goog.asserts.setErrorHandler = function(errorHandler) { * @param {...*} var_args The items to substitute into the failure message. * @return {T} The value of the condition. * @throws {goog.asserts.AssertionError} When the condition evaluates to false. + * @closurePrimitive {asserts.truthy} */ goog.asserts.assert = function(condition, opt_message, var_args) { if (goog.asserts.ENABLE_ASSERTS && !condition) { @@ -155,6 +187,38 @@ goog.asserts.assert = function(condition, opt_message, var_args) { }; +/** + * Checks if `value` is `null` or `undefined` if goog.asserts.ENABLE_ASSERTS is + * true. + * + * @param {T} value The value to check. + * @param {string=} opt_message Error message in case of failure. + * @param {...*} var_args The items to substitute into the failure message. + * @return {R} `value` with its type narrowed to exclude `null` and `undefined`. + * + * @template T + * @template R := + * mapunion(T, (V) => + * cond(eq(V, 'null'), + * none(), + * cond(eq(V, 'undefined'), + * none(), + * V))) + * =: + * + * @throws {!goog.asserts.AssertionError} When `value` is `null` or `undefined`. + * @closurePrimitive {asserts.matchesReturn} + */ +goog.asserts.assertExists = function(value, opt_message, var_args) { + if (goog.asserts.ENABLE_ASSERTS && value == null) { + goog.asserts.doAssertFailure_( + 'Expected to exist: %s.', [value], opt_message, + Array.prototype.slice.call(arguments, 2)); + } + return value; +}; + + /** * Fails if goog.asserts.ENABLE_ASSERTS is true. This function is useful in case * when we want to add a check in the unreachable area like switch-case @@ -172,6 +236,7 @@ goog.asserts.assert = function(condition, opt_message, var_args) { * @param {string=} opt_message Error message in case of failure. * @param {...*} var_args The items to substitute into the failure message. * @throws {goog.asserts.AssertionError} Failure. + * @closurePrimitive {asserts.fail} */ goog.asserts.fail = function(opt_message, var_args) { if (goog.asserts.ENABLE_ASSERTS) { @@ -190,9 +255,10 @@ goog.asserts.fail = function(opt_message, var_args) { * @param {...*} var_args The items to substitute into the failure message. * @return {number} The value, guaranteed to be a number when asserts enabled. * @throws {goog.asserts.AssertionError} When the value is not a number. + * @closurePrimitive {asserts.matchesReturn} */ goog.asserts.assertNumber = function(value, opt_message, var_args) { - if (goog.asserts.ENABLE_ASSERTS && !goog.isNumber(value)) { + if (goog.asserts.ENABLE_ASSERTS && typeof value !== 'number') { goog.asserts.doAssertFailure_( 'Expected number but got %s: %s.', [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); @@ -208,9 +274,10 @@ goog.asserts.assertNumber = function(value, opt_message, var_args) { * @param {...*} var_args The items to substitute into the failure message. * @return {string} The value, guaranteed to be a string when asserts enabled. * @throws {goog.asserts.AssertionError} When the value is not a string. + * @closurePrimitive {asserts.matchesReturn} */ goog.asserts.assertString = function(value, opt_message, var_args) { - if (goog.asserts.ENABLE_ASSERTS && !goog.isString(value)) { + if (goog.asserts.ENABLE_ASSERTS && typeof value !== 'string') { goog.asserts.doAssertFailure_( 'Expected string but got %s: %s.', [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); @@ -227,6 +294,7 @@ goog.asserts.assertString = function(value, opt_message, var_args) { * @return {!Function} The value, guaranteed to be a function when asserts * enabled. * @throws {goog.asserts.AssertionError} When the value is not a function. + * @closurePrimitive {asserts.matchesReturn} */ goog.asserts.assertFunction = function(value, opt_message, var_args) { if (goog.asserts.ENABLE_ASSERTS && !goog.isFunction(value)) { @@ -245,6 +313,7 @@ goog.asserts.assertFunction = function(value, opt_message, var_args) { * @param {...*} var_args The items to substitute into the failure message. * @return {!Object} The value, guaranteed to be a non-null object. * @throws {goog.asserts.AssertionError} When the value is not an object. + * @closurePrimitive {asserts.matchesReturn} */ goog.asserts.assertObject = function(value, opt_message, var_args) { if (goog.asserts.ENABLE_ASSERTS && !goog.isObject(value)) { @@ -263,6 +332,7 @@ goog.asserts.assertObject = function(value, opt_message, var_args) { * @param {...*} var_args The items to substitute into the failure message. * @return {!Array} The value, guaranteed to be a non-null array. * @throws {goog.asserts.AssertionError} When the value is not an array. + * @closurePrimitive {asserts.matchesReturn} */ goog.asserts.assertArray = function(value, opt_message, var_args) { if (goog.asserts.ENABLE_ASSERTS && !goog.isArray(value)) { @@ -282,9 +352,10 @@ goog.asserts.assertArray = function(value, opt_message, var_args) { * @return {boolean} The value, guaranteed to be a boolean when asserts are * enabled. * @throws {goog.asserts.AssertionError} When the value is not a boolean. + * @closurePrimitive {asserts.matchesReturn} */ goog.asserts.assertBoolean = function(value, opt_message, var_args) { - if (goog.asserts.ENABLE_ASSERTS && !goog.isBoolean(value)) { + if (goog.asserts.ENABLE_ASSERTS && typeof value !== 'boolean') { goog.asserts.doAssertFailure_( 'Expected boolean but got %s: %s.', [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); @@ -301,6 +372,7 @@ goog.asserts.assertBoolean = function(value, opt_message, var_args) { * @return {!Element} The value, likely to be a DOM Element when asserts are * enabled. * @throws {goog.asserts.AssertionError} When the value is not an Element. + * @closurePrimitive {asserts.matchesReturn} */ goog.asserts.assertElement = function(value, opt_message, var_args) { if (goog.asserts.ENABLE_ASSERTS && @@ -327,6 +399,7 @@ goog.asserts.assertElement = function(value, opt_message, var_args) { * type. * @return {T} * @template T + * @closurePrimitive {asserts.matchesReturn} */ goog.asserts.assertInstanceof = function(value, type, opt_message, var_args) { if (goog.asserts.ENABLE_ASSERTS && !(value instanceof type)) { @@ -339,6 +412,27 @@ goog.asserts.assertInstanceof = function(value, type, opt_message, var_args) { }; +/** + * Checks whether the value is a finite number, if goog.asserts.ENABLE_ASSERTS + * is true. + * + * @param {*} value The value to check. + * @param {string=} opt_message Error message in case of failure. + * @param {...*} var_args The items to substitute into the failure message. + * @throws {goog.asserts.AssertionError} When the value is not a number, or is + * a non-finite number such as NaN, Infinity or -Infinity. + * @return {number} The value initially passed in. + */ +goog.asserts.assertFinite = function(value, opt_message, var_args) { + if (goog.asserts.ENABLE_ASSERTS && + (typeof value != 'number' || !isFinite(value))) { + goog.asserts.doAssertFailure_( + 'Expected %s to be a finite number but it is not.', [value], + opt_message, Array.prototype.slice.call(arguments, 2)); + } + return /** @type {number} */ (value); +}; + /** * Checks that no enumerable keys are present in Object.prototype. Such keys * would break most code that use {@code for (var ... in ...)} loops. @@ -361,8 +455,8 @@ goog.asserts.getType_ = function(value) { if (value instanceof Function) { return value.displayName || value.name || 'unknown type name'; } else if (value instanceof Object) { - return value.constructor.displayName || value.constructor.name || - Object.prototype.toString.call(value); + return /** @type {string} */ (value.constructor.displayName) || + value.constructor.name || Object.prototype.toString.call(value); } else { return value === null ? 'null' : typeof value; } diff --git a/third_party/closure/goog/async/BUILD.bazel b/third_party/closure/goog/async/BUILD.bazel new file mode 100644 index 0000000000000..b7bd08dd1f638 --- /dev/null +++ b/third_party/closure/goog/async/BUILD.bazel @@ -0,0 +1,117 @@ +# DO NOT EDIT -- bazel run //third_party/closure/goog:regenerate -- "$PWD" + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +closure_js_library( + name = "all_js", + exports = [ + ":animationdelay", + ":conditionaldelay", + ":debouncer", + ":delay", + ":freelist", + ":nexttick", + ":run", + ":throttle", + ":workqueue", + ], +) + +closure_js_library( + name = "animationdelay", + srcs = ["animationdelay.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/disposable", + "//third_party/closure/goog/events", + "//third_party/closure/goog/functions", + ], +) + +closure_js_library( + name = "conditionaldelay", + srcs = ["conditionaldelay.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/async:delay", + "//third_party/closure/goog/disposable", + ], +) + +closure_js_library( + name = "debouncer", + srcs = ["debouncer.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/disposable", + "//third_party/closure/goog/timer", + ], +) + +closure_js_library( + name = "delay", + srcs = ["delay.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/disposable", + "//third_party/closure/goog/timer", + ], +) + +closure_js_library( + name = "freelist", + srcs = ["freelist.js"], + lenient = True, +) + +closure_js_library( + name = "nexttick", + srcs = ["nexttick.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/debug:entrypointregistry", + "//third_party/closure/goog/dom", + "//third_party/closure/goog/dom:safe", + "//third_party/closure/goog/dom:tagname", + "//third_party/closure/goog/functions", + "//third_party/closure/goog/html:safehtml", + "//third_party/closure/goog/html:trustedresourceurl", + "//third_party/closure/goog/labs/useragent:browser", + "//third_party/closure/goog/labs/useragent:engine", + "//third_party/closure/goog/string:const", + ], +) + +closure_js_library( + name = "run", + srcs = ["run.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/async:nexttick", + "//third_party/closure/goog/async:workqueue", + ], +) + +closure_js_library( + name = "throttle", + srcs = ["throttle.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/disposable", + "//third_party/closure/goog/timer", + ], +) + +closure_js_library( + name = "workqueue", + srcs = ["workqueue.js"], + lenient = True, + deps = [ + "//third_party/closure/goog/asserts", + "//third_party/closure/goog/async:freelist", + ], +) diff --git a/third_party/closure/goog/async/animationdelay.js b/third_party/closure/goog/async/animationdelay.js index d9057d86ee1c2..b900d3beb18a6 100644 --- a/third_party/closure/goog/async/animationdelay.js +++ b/third_party/closure/goog/async/animationdelay.js @@ -15,8 +15,6 @@ /** * @fileoverview A delayed callback that pegs to the next animation frame * instead of a user-configurable timeout. - * - * @author nicksantos@google.com (Nick Santos) */ goog.provide('goog.async.AnimationDelay'); @@ -64,7 +62,7 @@ goog.async.AnimationDelay = function(listener, opt_window, opt_handler) { /** * Identifier of the active delay timeout, or event listener, * or null when inactive. - * @private {goog.events.Key|number} + * @private {?goog.events.Key|number} */ this.id_ = null; diff --git a/third_party/closure/goog/async/conditionaldelay.js b/third_party/closure/goog/async/conditionaldelay.js index 1ad0d629976c0..c57f5119b6d80 100644 --- a/third_party/closure/goog/async/conditionaldelay.js +++ b/third_party/closure/goog/async/conditionaldelay.js @@ -39,7 +39,6 @@ * * // Stop the deferred function call (does nothing if it's not active). * deferredCall.stop(); - * */ @@ -53,16 +52,16 @@ goog.require('goog.async.Delay'); /** * A ConditionalDelay object invokes the associated function after a specified * interval delay and checks its return value. If the function returns - * {@code true} the conditional delay is cancelled and {@see #onSuccess} + * `true` the conditional delay is cancelled and {@see #onSuccess} * is called. Otherwise this object keeps to invoke the deferred function until - * either it returns {@code true} or the timeout is exceeded. In the latter case + * either it returns `true` or the timeout is exceeded. In the latter case * the {@see #onFailure} method will be called. * * The interval duration and timeout can be specified each time the delay is * started. Calling start on an active delay will reset the timer. * * @param {function():boolean} listener Function to call when the delay - * completes. Should return a value that type-converts to {@code true} if + * completes. Should return a value that type-converts to `true` if * the call succeeded and this delay should be stopped. * @param {Object=} opt_handler The object scope to invoke the function in. * @constructor @@ -88,7 +87,7 @@ goog.async.ConditionalDelay = function(listener, opt_handler) { this.runUntil_ = 0; /** - * True if the listener has been executed, and it returned {@code true}. + * True if the listener has been executed, and it returned `true`. * @private {boolean} */ this.isDone_ = false; @@ -127,12 +126,12 @@ goog.async.ConditionalDelay.prototype.disposeInternal = function() { /** * Starts the delay timer. The provided listener function will be called * repeatedly after the specified interval until the function returns - * {@code true} or the timeout is exceeded. Calling start on an active timer + * `true` or the timeout is exceeded. Calling start on an active timer * will stop the timer first. * @param {number=} opt_interval The time interval between the function * invocations (in milliseconds). Default is 0. * @param {number=} opt_timeout The timeout interval (in milliseconds). Takes - * precedence over the {@code opt_interval}, i.e. if the timeout is less + * precedence over the `opt_interval`, i.e. if the timeout is less * than the invocation interval, the function will be called when the * timeout is exceeded. A negative value means no timeout. Default is 0. */ @@ -168,7 +167,7 @@ goog.async.ConditionalDelay.prototype.isActive = function() { /** * @return {boolean} True if the listener has been executed and returned - * {@code true} since the last call to {@see #start}. + * `true` since the last call to {@see #start}. */ goog.async.ConditionalDelay.prototype.isDone = function() { return this.isDone_; @@ -177,7 +176,7 @@ goog.async.ConditionalDelay.prototype.isDone = function() { /** * Called when the listener has been successfully executed and returned - * {@code true}. The {@see #isDone} method should return {@code true} by now. + * `true`. The {@see #isDone} method should return `true` by now. * Designed for inheritance, should be overridden by subclasses or on the * instances if they care. */ @@ -188,7 +187,7 @@ goog.async.ConditionalDelay.prototype.onSuccess = function() { /** * Called when this delayed call is cancelled because the timeout has been - * exceeded, and the listener has never returned {@code true}. + * exceeded, and the listener has never returned `true`. * Designed for inheritance, should be overridden by subclasses or on the * instances if they care. */ @@ -198,8 +197,8 @@ goog.async.ConditionalDelay.prototype.onFailure = function() { /** - * A callback function for the underlying {@code goog.async.Delay} object. When - * executed the listener function is called, and if it returns {@code true} + * A callback function for the underlying `goog.async.Delay` object. When + * executed the listener function is called, and if it returns `true` * the delay is stopped and the {@see #onSuccess} method is invoked. * If the timeout is exceeded the delay is stopped and the * {@see #onFailure} method is called. diff --git a/third_party/closure/goog/async/debouncer.js b/third_party/closure/goog/async/debouncer.js index 729be486f6e45..848c09cead65d 100644 --- a/third_party/closure/goog/async/debouncer.js +++ b/third_party/closure/goog/async/debouncer.js @@ -92,7 +92,7 @@ goog.async.Debouncer = function(listener, interval, opt_handler) { this.refireAt_ = null; /** - * The last arguments passed into {@code fire}. + * The last arguments passed into `fire`. * @private {!IArrayLike} */ this.args_ = []; diff --git a/third_party/closure/goog/async/delay.js b/third_party/closure/goog/async/delay.js index 17d50a298fb55..4ebbf30a28fa5 100644 --- a/third_party/closure/goog/async/delay.js +++ b/third_party/closure/goog/async/delay.js @@ -17,7 +17,6 @@ * invoked after a delay, especially when that delay is frequently restarted. * Examples include delaying before displaying a tooltip, menu hysteresis, * idle timers, etc. - * @author brenneman@google.com (Shawn Brenneman) * @see ../demos/timers.html */ @@ -123,7 +122,8 @@ goog.async.Delay.prototype.disposeInternal = function() { goog.async.Delay.prototype.start = function(opt_interval) { this.stop(); this.id_ = goog.Timer.callOnce( - this.callback_, goog.isDef(opt_interval) ? opt_interval : this.interval_); + this.callback_, + opt_interval !== undefined ? opt_interval : this.interval_); }; diff --git a/third_party/closure/goog/async/freelist.js b/third_party/closure/goog/async/freelist.js index c58ddf704bfb6..92bba2b753490 100644 --- a/third_party/closure/goog/async/freelist.js +++ b/third_party/closure/goog/async/freelist.js @@ -26,13 +26,13 @@ goog.provide('goog.async.FreeList'); /** * @template ITEM */ -goog.async.FreeList = goog.defineClass(null, { +goog.async.FreeList = class { /** * @param {function():ITEM} create * @param {function(ITEM):void} reset * @param {number} limit */ - constructor: function(create, reset, limit) { + constructor(create, reset, limit) { /** @private @const {number} */ this.limit_ = limit; /** @private @const {function()} */ @@ -44,13 +44,13 @@ goog.async.FreeList = goog.defineClass(null, { this.occupants_ = 0; /** @private {ITEM} */ this.head_ = null; - }, + } /** * @return {ITEM} */ - get: function() { - var item; + get() { + let item; if (this.occupants_ > 0) { this.occupants_--; item = this.head_; @@ -60,24 +60,26 @@ goog.async.FreeList = goog.defineClass(null, { item = this.create_(); } return item; - }, + } /** * @param {ITEM} item An item available for possible future reuse. */ - put: function(item) { + put(item) { this.reset_(item); if (this.occupants_ < this.limit_) { this.occupants_++; item.next = this.head_; this.head_ = item; } - }, + } /** * Visible for testing. * @package * @return {number} */ - occupants: function() { return this.occupants_; } -}); + occupants() { + return this.occupants_; + } +}; diff --git a/third_party/closure/goog/async/nexttick.js b/third_party/closure/goog/async/nexttick.js index bd3fb0807344b..af837214425f1 100644 --- a/third_party/closure/goog/async/nexttick.js +++ b/third_party/closure/goog/async/nexttick.js @@ -16,17 +16,21 @@ * @fileoverview Provides a function to schedule running a function as soon * as possible after the current JS execution stops and yields to the event * loop. - * */ goog.provide('goog.async.nextTick'); goog.provide('goog.async.throwException'); goog.require('goog.debug.entryPointRegistry'); +goog.require('goog.dom'); goog.require('goog.dom.TagName'); +goog.require('goog.dom.safe'); goog.require('goog.functions'); +goog.require('goog.html.SafeHtml'); +goog.require('goog.html.TrustedResourceUrl'); goog.require('goog.labs.userAgent.browser'); goog.require('goog.labs.userAgent.engine'); +goog.require('goog.string.Const'); /** @@ -100,6 +104,7 @@ goog.async.nextTick = function(callback, opt_context, opt_useSetImmediate) { * @return {boolean} Whether to use the implementation of setImmediate defined * on Window. * @private + * @suppress {missingProperties} For "Window.prototype.setImmediate" */ goog.async.nextTick.useSetImmediate_ = function() { // Not a browser environment. @@ -157,15 +162,16 @@ goog.async.nextTick.getSetImmediateEmulator_ = function() { /** @constructor */ Channel = function() { // Make an empty, invisible iframe. - var iframe = /** @type {!HTMLIFrameElement} */ ( - document.createElement(String(goog.dom.TagName.IFRAME))); + var iframe = goog.dom.createElement(goog.dom.TagName.IFRAME); iframe.style.display = 'none'; - iframe.src = ''; + goog.dom.safe.setIframeSrc( + iframe, + goog.html.TrustedResourceUrl.fromConstant(goog.string.Const.EMPTY)); document.documentElement.appendChild(iframe); var win = iframe.contentWindow; var doc = win.document; doc.open(); - doc.write(''); + goog.dom.safe.documentWrite(doc, goog.html.SafeHtml.EMPTY); doc.close(); // Do not post anything sensitive over this channel, as the workaround for // pages with file: origin could allow that information to be modified or @@ -173,7 +179,6 @@ goog.async.nextTick.getSetImmediateEmulator_ = function() { var message = 'callImmediate' + Math.random(); // The same origin policy rejects attempts to postMessage from file: urls // unless the origin is '*'. - // TODO(b/16335441): Use '*' origin for data: and other similar protocols. var origin = win.location.protocol == 'file:' ? '*' : win.location.protocol + '//' + win.location.host; @@ -205,7 +210,7 @@ goog.async.nextTick.getSetImmediateEmulator_ = function() { var head = {}; var tail = head; channel['port1'].onmessage = function() { - if (goog.isDef(head.next)) { + if (head.next !== undefined) { head = head.next; var cb = head.cb; head.cb = null; @@ -221,10 +226,9 @@ goog.async.nextTick.getSetImmediateEmulator_ = function() { // Implementation for IE6 to IE10: Script elements fire an asynchronous // onreadystatechange event when inserted into the DOM. if (typeof document !== 'undefined' && - 'onreadystatechange' in - document.createElement(String(goog.dom.TagName.SCRIPT))) { + 'onreadystatechange' in goog.dom.createElement(goog.dom.TagName.SCRIPT)) { return function(cb) { - var script = document.createElement(String(goog.dom.TagName.SCRIPT)); + var script = goog.dom.createElement(goog.dom.TagName.SCRIPT); script.onreadystatechange = function() { // Clean up and call the callback. script.onreadystatechange = null; diff --git a/third_party/closure/goog/async/run.js b/third_party/closure/goog/async/run.js index 832b6faf3e915..18a09df8f2a6a 100644 --- a/third_party/closure/goog/async/run.js +++ b/third_party/closure/goog/async/run.js @@ -18,6 +18,12 @@ goog.require('goog.async.WorkQueue'); goog.require('goog.async.nextTick'); goog.require('goog.async.throwException'); +/** + * @define {boolean} If true, use the global Promise to implement goog.async.run + * assuming either the native, or polyfill version will be used. Does still + * permit tests to use forceNextTick. + */ +goog.ASSUME_NATIVE_PROMISE = goog.define('goog.ASSUME_NATIVE_PROMISE', false); /** * Fires the provided callback just before the current callstack unwinds, or as @@ -46,13 +52,12 @@ goog.async.run = function(callback, opt_context) { * @private */ goog.async.run.initializeRunner_ = function() { - // If native Promises are available in the browser, just schedule the callback - // on a fulfilled promise, which is specified to be async, but as fast as - // possible. Use goog.global.Promise instead of just Promise because the - // relevant externs may be missing, and don't alias it because this could - // confuse the compiler into thinking the polyfill is required when it should - // be treated as optional. - if (String(goog.global.Promise).indexOf('[native code]') != -1) { + if (goog.ASSUME_NATIVE_PROMISE || + (goog.global.Promise && goog.global.Promise.resolve)) { + // Use goog.global.Promise instead of just Promise because the relevant + // externs may be missing, and don't alias it because this could confuse the + // compiler into thinking the polyfill is required when it should be treated + // as optional. var promise = goog.global.Promise.resolve(undefined); goog.async.run.schedule_ = function() { promise.then(goog.async.run.processWorkQueue); diff --git a/third_party/closure/goog/async/throttle.js b/third_party/closure/goog/async/throttle.js index 504a34334d8be..cb9f1221f021e 100644 --- a/third_party/closure/goog/async/throttle.js +++ b/third_party/closure/goog/async/throttle.js @@ -68,7 +68,7 @@ goog.async.Throttle = function(listener, interval, opt_handler) { this.callback_ = goog.bind(this.onTimer_, this); /** - * The last arguments passed into {@code fire}. + * The last arguments passed into `fire`. * @private {!IArrayLike} */ this.args_ = []; diff --git a/third_party/closure/goog/async/workqueue.js b/third_party/closure/goog/async/workqueue.js index 1ff6e9e5ea97a..86a1ce3ac2ded 100644 --- a/third_party/closure/goog/async/workqueue.js +++ b/third_party/closure/goog/async/workqueue.js @@ -40,7 +40,8 @@ goog.async.WorkQueue = function() { /** @define {number} The maximum number of entries to keep for recycling. */ -goog.define('goog.async.WorkQueue.DEFAULT_MAX_UNUSED', 100); +goog.async.WorkQueue.DEFAULT_MAX_UNUSED = + goog.define('goog.async.WorkQueue.DEFAULT_MAX_UNUSED', 100); /** @const @private {goog.async.FreeList} */ @@ -112,7 +113,7 @@ goog.async.WorkQueue.prototype.getUnusedItem_ = function() { goog.async.WorkItem = function() { /** @type {?function()} */ this.fn = null; - /** @type {Object|null|undefined} */ + /** @type {?Object|null|undefined} */ this.scope = null; /** @type {?goog.async.WorkItem} */ this.next = null; diff --git a/third_party/closure/goog/base.js b/third_party/closure/goog/base.js index f1716c09b5d74..7a069f70f6b9a 100644 --- a/third_party/closure/goog/base.js +++ b/third_party/closure/goog/base.js @@ -41,19 +41,35 @@ var COMPILED = false; */ var goog = goog || {}; - /** - * Reference to the global context. In most cases this will be 'window'. + * Reference to the global object. + * https://www.ecma-international.org/ecma-262/9.0/index.html#sec-global-object + * + * More info on this implementation here: + * https://docs.google.com/document/d/1NAeW4Wk7I7FV0Y2tcUFvQdGMc89k2vdgSXInw8_nvCI/edit + * + * @const + * @suppress {undefinedVars} self won't be referenced unless `this` is falsy. + * @type {!Global} */ -goog.global = this; +goog.global = + // Check `this` first for backwards compatibility. + // Valid unless running as an ES module or in a function wrapper called + // without setting `this` properly. + // Note that base.js can't usefully be imported as an ES module, but it may + // be compiled into bundles that are loadable as ES modules. + this || + // https://developer.mozilla.org/en-US/docs/Web/API/Window/self + // For in-page browser environments and workers. + self; /** * A hook for overriding the define values in uncompiled mode. * - * In uncompiled mode, {@code CLOSURE_UNCOMPILED_DEFINES} may be defined before - * loading base.js. If a key is defined in {@code CLOSURE_UNCOMPILED_DEFINES}, - * {@code goog.define} will use the value instead of the default value. This + * In uncompiled mode, `CLOSURE_UNCOMPILED_DEFINES` may be defined before + * loading base.js. If a key is defined in `CLOSURE_UNCOMPILED_DEFINES`, + * `goog.define` will use the value instead of the default value. This * allows flags to be overwritten without compilation (this is normally * accomplished with the compiler's "define" flag). * @@ -93,6 +109,7 @@ goog.global.CLOSURE_DEFINES; * * @param {?} val Variable to test. * @return {boolean} Whether variable is defined. + * @deprecated Use `val !== undefined` instead. */ goog.isDef = function(val) { // void 0 always evaluates to undefined and hence we do not need to depend on @@ -104,6 +121,7 @@ goog.isDef = function(val) { * Returns true if the specified value is a string. * @param {?} val Variable to test. * @return {boolean} Whether variable is a string. + * @deprecated Use `typeof val === 'string'` instead. */ goog.isString = function(val) { return typeof val == 'string'; @@ -114,6 +132,7 @@ goog.isString = function(val) { * Returns true if the specified value is a boolean. * @param {?} val Variable to test. * @return {boolean} Whether variable is boolean. + * @deprecated Use `typeof val === 'boolean'` instead. */ goog.isBoolean = function(val) { return typeof val == 'boolean'; @@ -124,6 +143,7 @@ goog.isBoolean = function(val) { * Returns true if the specified value is a number. * @param {?} val Variable to test. * @return {boolean} Whether variable is a number. + * @deprecated Use `typeof val === 'number'` instead. */ goog.isNumber = function(val) { return typeof val == 'number'; @@ -148,12 +168,12 @@ goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) { // Internet Explorer exhibits strange behavior when throwing errors from // methods externed in this manner. See the testExportSymbolExceptions in // base_test.html for an example. - if (!(parts[0] in cur) && cur.execScript) { + if (!(parts[0] in cur) && typeof cur.execScript != 'undefined') { cur.execScript('var ' + parts[0]); } for (var part; parts.length && (part = parts.shift());) { - if (!parts.length && goog.isDef(opt_object)) { + if (!parts.length && opt_object !== undefined) { // last part and we have an object; use it cur[part] = opt_object; } else if (cur[part] && cur[part] !== Object.prototype[part]) { @@ -169,35 +189,66 @@ goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) { * Defines a named value. In uncompiled mode, the value is retrieved from * CLOSURE_DEFINES or CLOSURE_UNCOMPILED_DEFINES if the object is defined and * has the property specified, and otherwise used the defined defaultValue. - * When compiled the default can be overridden using the compiler - * options or the value set in the CLOSURE_DEFINES object. + * When compiled the default can be overridden using the compiler options or the + * value set in the CLOSURE_DEFINES object. Returns the defined value so that it + * can be used safely in modules. Note that the value type MUST be either + * boolean, number, or string. * * @param {string} name The distinguished name to provide. - * @param {string|number|boolean} defaultValue + * @param {T} defaultValue + * @return {T} The defined value. + * @template T */ goog.define = function(name, defaultValue) { var value = defaultValue; if (!COMPILED) { - if (goog.global.CLOSURE_UNCOMPILED_DEFINES && + var uncompiledDefines = goog.global.CLOSURE_UNCOMPILED_DEFINES; + var defines = goog.global.CLOSURE_DEFINES; + if (uncompiledDefines && // Anti DOM-clobbering runtime check (b/37736576). - /** @type {?} */ (goog.global.CLOSURE_UNCOMPILED_DEFINES).nodeType === - undefined && - Object.prototype.hasOwnProperty.call( - goog.global.CLOSURE_UNCOMPILED_DEFINES, name)) { - value = goog.global.CLOSURE_UNCOMPILED_DEFINES[name]; + /** @type {?} */ (uncompiledDefines).nodeType === undefined && + Object.prototype.hasOwnProperty.call(uncompiledDefines, name)) { + value = uncompiledDefines[name]; } else if ( - goog.global.CLOSURE_DEFINES && + defines && // Anti DOM-clobbering runtime check (b/37736576). - /** @type {?} */ (goog.global.CLOSURE_DEFINES).nodeType === undefined && - Object.prototype.hasOwnProperty.call( - goog.global.CLOSURE_DEFINES, name)) { - value = goog.global.CLOSURE_DEFINES[name]; + /** @type {?} */ (defines).nodeType === undefined && + Object.prototype.hasOwnProperty.call(defines, name)) { + value = defines[name]; } } - goog.exportPath_(name, value); + return value; }; +/** + * @define {number} Integer year indicating the set of browser features that are + * guaranteed to be present. This is defined to include exactly features that + * work correctly on all "modern" browsers that are stable on January 1 of the + * specified year. For example, + * ```js + * if (goog.FEATURESET_YEAR >= 2019) { + * // use APIs known to be available on all major stable browsers Jan 1, 2019 + * } else { + * // polyfill for older browsers + * } + * ``` + * This is intended to be the primary define for removing + * unnecessary browser compatibility code (such as ponyfills and workarounds), + * and should inform the default value for most other defines: + * ```js + * const ASSUME_NATIVE_PROMISE = + * goog.define('ASSUME_NATIVE_PROMISE', goog.FEATURESET_YEAR >= 2016); + * ``` + * + * The default assumption is that IE9 is the lowest supported browser, which was + * first available Jan 1, 2012. + * + * TODO(user): Reference more thorough documentation when it's available. + */ +goog.FEATURESET_YEAR = goog.define('goog.FEATURESET_YEAR', 2012); + + /** * @define {boolean} DEBUG is provided as a convenience so that debugging code * that should not be included in a production. It can be easily stripped @@ -207,7 +258,7 @@ goog.define = function(name, defaultValue) { * purposes and it is difficult for the JSCompiler to statically determine * whether they are used. */ -goog.define('goog.DEBUG', true); +goog.DEBUG = goog.define('goog.DEBUG', true); /** @@ -230,7 +281,7 @@ goog.define('goog.DEBUG', true); * be used instead of the new code (he). * */ -goog.define('goog.LOCALE', 'en'); // default to en +goog.LOCALE = goog.define('goog.LOCALE', 'en'); // default to en /** @@ -244,7 +295,7 @@ goog.define('goog.LOCALE', 'en'); // default to en * relying on non-standard implementations, specify * "--define goog.TRUSTED_SITE=false" to the compiler. */ -goog.define('goog.TRUSTED_SITE', true); +goog.TRUSTED_SITE = goog.define('goog.TRUSTED_SITE', true); /** @@ -255,21 +306,23 @@ goog.define('goog.TRUSTED_SITE', true); * @see https://goo.gl/PudQ4y * */ -goog.define('goog.STRICT_MODE_COMPATIBLE', false); +goog.STRICT_MODE_COMPATIBLE = goog.define('goog.STRICT_MODE_COMPATIBLE', false); /** * @define {boolean} Whether code that calls {@link goog.setTestOnly} should * be disallowed in the compilation unit. */ -goog.define('goog.DISALLOW_TEST_ONLY_CODE', COMPILED && !goog.DEBUG); +goog.DISALLOW_TEST_ONLY_CODE = + goog.define('goog.DISALLOW_TEST_ONLY_CODE', COMPILED && !goog.DEBUG); /** * @define {boolean} Whether to use a Chrome app CSP-compliant method for * loading scripts via goog.require. @see appendScriptSrcNode_. */ -goog.define('goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING', false); +goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING = + goog.define('goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING', false); /** @@ -296,13 +349,13 @@ goog.define('goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING', false); */ goog.provide = function(name) { if (goog.isInModuleLoader_()) { - throw Error('goog.provide can not be used within a goog.module.'); + throw new Error('goog.provide cannot be used within a module.'); } if (!COMPILED) { // Ensure that the same namespace isn't provided twice. // A goog.module/goog.provide maps a goog.require to a specific file if (goog.isProvided_(name)) { - throw Error('Namespace "' + name + '" already declared.'); + throw new Error('Namespace "' + name + '" already declared.'); } } @@ -333,6 +386,59 @@ goog.constructNamespace_ = function(name, opt_obj) { }; +/** + * Returns CSP nonce, if set for any script tag. + * @param {?Window=} opt_window The window context used to retrieve the nonce. + * Defaults to global context. + * @return {string} CSP nonce or empty string if no nonce is present. + */ +goog.getScriptNonce = function(opt_window) { + if (opt_window && opt_window != goog.global) { + return goog.getScriptNonce_(opt_window.document); + } + if (goog.cspNonce_ === null) { + goog.cspNonce_ = goog.getScriptNonce_(goog.global.document); + } + return goog.cspNonce_; +}; + + +/** + * According to the CSP3 spec a nonce must be a valid base64 string. + * @see https://www.w3.org/TR/CSP3/#grammardef-base64-value + * @private @const + */ +goog.NONCE_PATTERN_ = /^[\w+/_-]+[=]{0,2}$/; + + +/** + * @private {?string} + */ +goog.cspNonce_ = null; + + +/** + * Returns CSP nonce, if set for any script tag. + * @param {!Document} doc + * @return {string} CSP nonce or empty string if no nonce is present. + * @private + */ +goog.getScriptNonce_ = function(doc) { + var script = doc.querySelector && doc.querySelector('script[nonce]'); + if (script) { + // Try to get the nonce from the IDL property first, because browsers that + // implement additional nonce protection features (currently only Chrome) to + // prevent nonce stealing via CSS do not expose the nonce via attributes. + // See https://github.com/whatwg/html/issues/2369 + var nonce = script['nonce'] || script.getAttribute('nonce'); + if (nonce && goog.NONCE_PATTERN_.test(nonce)) { + return nonce; + } + } + return ''; +}; + + /** * Module identifier validation regexp. * Note: This is a conservative check, it is very possible to be more lenient, @@ -376,12 +482,12 @@ goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/; * @return {void} */ goog.module = function(name) { - if (!goog.isString(name) || !name || + if (typeof name !== 'string' || !name || name.search(goog.VALID_MODULE_RE_) == -1) { - throw Error('Invalid module identifier'); + throw new Error('Invalid module identifier'); } - if (!goog.isInModuleLoader_()) { - throw Error( + if (!goog.isInGoogModuleLoader_()) { + throw new Error( 'Module ' + name + ' has been loaded incorrectly. Note, ' + 'modules cannot be loaded as normal scripts. They require some kind of ' + 'pre-processing step. You\'re likely trying to load a module via a ' + @@ -390,7 +496,7 @@ goog.module = function(name) { 'https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.'); } if (goog.moduleLoaderState_.moduleName) { - throw Error('goog.module may only be called once per module.'); + throw new Error('goog.module may only be called once per module.'); } // Store the module name for the loader. @@ -399,7 +505,7 @@ goog.module = function(name) { // Ensure that the same namespace isn't provided twice. // A goog.module/goog.provide maps a goog.require to a specific file if (goog.isProvided_(name)) { - throw Error('Namespace "' + name + '" already declared.'); + throw new Error('Namespace "' + name + '" already declared.'); } delete goog.implicitNamespaces_[name]; } @@ -429,7 +535,7 @@ goog.module.get = function(name) { goog.module.getInternal_ = function(name) { if (!COMPILED) { if (name in goog.loadedModules_) { - return goog.loadedModules_[name]; + return goog.loadedModules_[name].exports; } else if (!goog.implicitNamespaces_[name]) { var ns = goog.getObjectByName(name); return ns != null ? ns : null; @@ -440,17 +546,74 @@ goog.module.getInternal_ = function(name) { /** - * @private {?{moduleName: (string|undefined), declareLegacyNamespace:boolean}} + * Types of modules the debug loader can load. + * @enum {string} + */ +goog.ModuleType = { + ES6: 'es6', + GOOG: 'goog' +}; + + +/** + * @private {?{ + * moduleName: (string|undefined), + * declareLegacyNamespace:boolean, + * type: ?goog.ModuleType + * }} */ goog.moduleLoaderState_ = null; /** * @private - * @return {boolean} Whether a goog.module is currently being initialized. + * @return {boolean} Whether a goog.module or an es6 module is currently being + * initialized. */ goog.isInModuleLoader_ = function() { - return goog.moduleLoaderState_ != null; + return goog.isInGoogModuleLoader_() || goog.isInEs6ModuleLoader_(); +}; + + +/** + * @private + * @return {boolean} Whether a goog.module is currently being initialized. + */ +goog.isInGoogModuleLoader_ = function() { + return !!goog.moduleLoaderState_ && + goog.moduleLoaderState_.type == goog.ModuleType.GOOG; +}; + + +/** + * @private + * @return {boolean} Whether an es6 module is currently being initialized. + */ +goog.isInEs6ModuleLoader_ = function() { + var inLoader = !!goog.moduleLoaderState_ && + goog.moduleLoaderState_.type == goog.ModuleType.ES6; + + if (inLoader) { + return true; + } + + var jscomp = goog.global['$jscomp']; + + if (jscomp) { + // jscomp may not have getCurrentModulePath if this is a compiled bundle + // that has some of the runtime, but not all of it. This can happen if + // optimizations are turned on so the unused runtime is removed but renaming + // and Closure pass are off (so $jscomp is still named $jscomp and the + // goog.provide/require calls still exist). + if (typeof jscomp.getCurrentModulePath != 'function') { + return false; + } + + // Bundled ES6 module. + return !!jscomp.getCurrentModulePath(); + } + + return false; }; @@ -461,13 +624,13 @@ goog.isInModuleLoader_ = function() { * @suppress {missingProvide} */ goog.module.declareLegacyNamespace = function() { - if (!COMPILED && !goog.isInModuleLoader_()) { + if (!COMPILED && !goog.isInGoogModuleLoader_()) { throw new Error( 'goog.module.declareLegacyNamespace must be called from ' + 'within a goog.module'); } if (!COMPILED && !goog.moduleLoaderState_.moduleName) { - throw Error( + throw new Error( 'goog.module must be called prior to ' + 'goog.module.declareLegacyNamespace.'); } @@ -475,6 +638,54 @@ goog.module.declareLegacyNamespace = function() { }; +/** + * Associates an ES6 module with a Closure module ID so that is available via + * goog.require. The associated ID acts like a goog.module ID - it does not + * create any global names, it is merely available via goog.require / + * goog.module.get / goog.forwardDeclare / goog.requireType. goog.require and + * goog.module.get will return the entire module as if it was import *'d. This + * allows Closure files to reference ES6 modules for the sake of migration. + * + * @param {string} namespace + * @suppress {missingProvide} + */ +goog.declareModuleId = function(namespace) { + if (!COMPILED) { + if (!goog.isInEs6ModuleLoader_()) { + throw new Error( + 'goog.declareModuleId may only be called from ' + + 'within an ES6 module'); + } + if (goog.moduleLoaderState_ && goog.moduleLoaderState_.moduleName) { + throw new Error( + 'goog.declareModuleId may only be called once per module.'); + } + if (namespace in goog.loadedModules_) { + throw new Error( + 'Module with namespace "' + namespace + '" already exists.'); + } + } + if (goog.moduleLoaderState_) { + // Not bundled - debug loading. + goog.moduleLoaderState_.moduleName = namespace; + } else { + // Bundled - not debug loading, no module loader state. + var jscomp = goog.global['$jscomp']; + if (!jscomp || typeof jscomp.getCurrentModulePath != 'function') { + throw new Error( + 'Module with namespace "' + namespace + + '" has been loaded incorrectly.'); + } + var exports = jscomp.require(jscomp.getCurrentModulePath()); + goog.loadedModules_[namespace] = { + exports: exports, + type: goog.ModuleType.ES6, + moduleId: namespace + }; + } +}; + + /** * Marks that the current file should only be used for testing, and never for * live code in production. @@ -489,7 +700,7 @@ goog.module.declareLegacyNamespace = function() { goog.setTestOnly = function(opt_message) { if (goog.DISALLOW_TEST_ONLY_CODE) { opt_message = opt_message || ''; - throw Error( + throw new Error( 'Importing test-only code into non-debug environment' + (opt_message ? ': ' + opt_message : '.')); } @@ -538,8 +749,7 @@ if (!COMPILED) { */ goog.isProvided_ = function(name) { return (name in goog.loadedModules_) || - (!goog.implicitNamespaces_[name] && - goog.isDefAndNotNull(goog.getObjectByName(name))); + (!goog.implicitNamespaces_[name] && goog.getObjectByName(name) != null); }; /** @@ -573,10 +783,9 @@ if (!COMPILED) { goog.getObjectByName = function(name, opt_obj) { var parts = name.split('.'); var cur = opt_obj || goog.global; - for (var part; part = parts.shift();) { - if (goog.isDefAndNotNull(cur[part])) { - cur = cur[part]; - } else { + for (var i = 0; i < parts.length; i++) { + cur = cur[parts[i]]; + if (cur == null) { return null; } } @@ -613,23 +822,8 @@ goog.globalize = function(obj, opt_global) { * and values include {'module': 'goog'} and {'lang': 'es6'}. */ goog.addDependency = function(relPath, provides, requires, opt_loadFlags) { - if (goog.DEPENDENCIES_ENABLED) { - var provide, require; - var path = relPath.replace(/\\/g, '/'); - var deps = goog.dependencies_; - if (!opt_loadFlags || typeof opt_loadFlags === 'boolean') { - opt_loadFlags = opt_loadFlags ? {'module': 'goog'} : {}; - } - for (var i = 0; provide = provides[i]; i++) { - deps.nameToPath[provide] = path; - deps.loadFlags[path] = opt_loadFlags; - } - for (var j = 0; require = requires[j]; j++) { - if (!(path in deps.requires)) { - deps.requires[path] = {}; - } - deps.requires[path][require] = true; - } + if (!COMPILED && goog.DEPENDENCIES_ENABLED) { + goog.debugLoader_.addDependency(relPath, provides, requires, opt_loadFlags); } }; @@ -650,7 +844,7 @@ goog.addDependency = function(relPath, provides, requires, opt_loadFlags) { // Externally: https://developers.google.com/closure/library/docs/depswriter // // Because of legacy clients, the DOM loader can't be easily removed from -// base.js. Work is being done to make it disableable or replaceable for +// base.js. Work was done to make it disableable or replaceable for // different environments (DOM-less JavaScript interpreters like Rhino or V8, // for example). See bootstrap/ for more information. @@ -665,7 +859,7 @@ goog.addDependency = function(relPath, provides, requires, opt_loadFlags) { * provided (and depend on the fact that some outside tool correctly ordered * the script). */ -goog.define('goog.ENABLE_DEBUG_LOADER', true); +goog.ENABLE_DEBUG_LOADER = goog.define('goog.ENABLE_DEBUG_LOADER', true); /** @@ -681,34 +875,36 @@ goog.logToConsole_ = function(msg) { /** * Implements a system for the dynamic resolution of dependencies that works in - * parallel with the BUILD system. Note that all calls to goog.require will be - * stripped by the compiler. + * parallel with the BUILD system. + * + * Note that all calls to goog.require will be stripped by the compiler. + * * @see goog.provide - * @param {string} name Namespace to include (as was given in goog.provide()) in - * the form "goog.package.part". - * @return {?} If called within a goog.module file, the associated namespace or - * module otherwise null. + * @param {string} namespace Namespace (as was given in goog.provide, + * goog.module, or goog.declareModuleId) in the form + * "goog.package.part". + * @return {?} If called within a goog.module or ES6 module file, the associated + * namespace or module otherwise null. */ -goog.require = function(name) { - // If the object already exists we do not need do do anything. +goog.require = function(namespace) { if (!COMPILED) { - if (goog.ENABLE_DEBUG_LOADER && goog.IS_OLD_IE_) { - goog.maybeProcessDeferredDep_(name); + // Might need to lazy load on old IE. + if (goog.ENABLE_DEBUG_LOADER) { + goog.debugLoader_.requested(namespace); } - if (goog.isProvided_(name)) { + // If the object already exists we do not need to do anything. + if (goog.isProvided_(namespace)) { if (goog.isInModuleLoader_()) { - return goog.module.getInternal_(name); + return goog.module.getInternal_(namespace); } } else if (goog.ENABLE_DEBUG_LOADER) { - var path = goog.getPathFromDeps_(name); - if (path) { - goog.writeScripts_(path); - } else { - var errorMessage = 'goog.require could not find: ' + name; - goog.logToConsole_(errorMessage); - - throw Error(errorMessage); + var moduleLoaderState = goog.moduleLoaderState_; + goog.moduleLoaderState_ = null; + try { + goog.debugLoader_.load_(namespace); + } finally { + goog.moduleLoaderState_ = moduleLoaderState; } } @@ -717,6 +913,30 @@ goog.require = function(name) { }; +/** + * Requires a symbol for its type information. This is an indication to the + * compiler that the symbol may appear in type annotations, yet it is not + * referenced at runtime. + * + * When called within a goog.module or ES6 module file, the return value may be + * assigned to or destructured into a variable, but it may not be otherwise used + * in code outside of a type annotation. + * + * Note that all calls to goog.requireType will be stripped by the compiler. + * + * @param {string} namespace Namespace (as was given in goog.provide, + * goog.module, or goog.declareModuleId) in the form + * "goog.package.part". + * @return {?} + */ +goog.requireType = function(namespace) { + // Return an empty object so that single-level destructuring of the return + // value doesn't crash at runtime when using the debug loader. Multi-level + // destructuring isn't supported. + return {}; +}; + + /** * Path for included scripts. * @type {string} @@ -745,9 +965,11 @@ goog.global.CLOSURE_NO_DEPS; * in the global scope so that it can be set before base.js is loaded, which * allows deps.js to be imported properly. * - * The function is passed the script source, which is a relative URI. It should - * return true if the script was imported, false otherwise. - * @type {(function(string): boolean)|undefined} + * The first parameter the script source, which is a relative URI. The second, + * optional parameter is the script contents, in the event the script needed + * transformation. It should return true if the script was imported, false + * otherwise. + * @type {(function(string, string=): boolean)|undefined} */ goog.global.CLOSURE_IMPORT_SCRIPT; @@ -768,22 +990,29 @@ goog.nullFunction = function() {}; * * @type {!Function} * @throws {Error} when invoked to indicate the method should be overridden. + * @deprecated Use "@abstract" annotation instead of goog.abstractMethod in new + * code. See + * https://github.com/google/closure-compiler/wiki/@abstract-classes-and-methods */ goog.abstractMethod = function() { - throw Error('unimplemented abstract method'); + throw new Error('unimplemented abstract method'); }; /** - * Adds a {@code getInstance} static method that always returns the same + * Adds a `getInstance` static method that always returns the same * instance object. * @param {!Function} ctor The constructor for the class to add the static * method to. + * @suppress {missingProperties} 'instance_' isn't a property on 'Function' + * but we don't have a better type to use here. */ goog.addSingletonGetter = function(ctor) { // instance_ is immediately set to prevent issues with sealed constructors // such as are encountered when a constructor is returned as the export object // of a goog.module in unoptimized code. + // Delcare type to avoid conformance violations that ctor.instance_ is unknown + /** @type {undefined|!Object} @suppress {underscore} */ ctor.instance_ = undefined; ctor.getInstance = function() { if (ctor.instance_) { @@ -793,14 +1022,15 @@ goog.addSingletonGetter = function(ctor) { // NOTE: JSCompiler can't optimize away Array#push. goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = ctor; } - return ctor.instance_ = new ctor; + // Cast to avoid conformance violations that ctor.instance_ is unknown + return /** @type {!Object|undefined} */ (ctor.instance_) = new ctor; }; }; /** * All singleton classes that have been instantiated, for testing. Don't read - * it directly, use the {@code goog.testing.singleton} module. The compiler + * it directly, use the `goog.testing.singleton` module. The compiler * removes this variable if unused. * @type {!Array} * @private @@ -809,32 +1039,32 @@ goog.instantiatedSingletons_ = []; /** - * @define {boolean} Whether to load goog.modules using {@code eval} when using + * @define {boolean} Whether to load goog.modules using `eval` when using * the debug loader. This provides a better debugging experience as the * source is unmodified and can be edited using Chrome Workspaces or similar. - * However in some environments the use of {@code eval} is banned + * However in some environments the use of `eval` is banned * so we provide an alternative. */ -goog.define('goog.LOAD_MODULE_USING_EVAL', true); +goog.LOAD_MODULE_USING_EVAL = goog.define('goog.LOAD_MODULE_USING_EVAL', true); /** * @define {boolean} Whether the exports of goog.modules should be sealed when * possible. */ -goog.define('goog.SEAL_MODULE_EXPORTS', goog.DEBUG); +goog.SEAL_MODULE_EXPORTS = goog.define('goog.SEAL_MODULE_EXPORTS', goog.DEBUG); /** * The registry of initialized modules: - * the module identifier to module exports map. - * @private @const {!Object} + * The module identifier or path to module exports map. + * @private @const {!Object} */ goog.loadedModules_ = {}; /** - * True if goog.dependencies_ is available. + * True if the debug loader enabled and used. * @const {boolean} */ goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER; @@ -846,2076 +1076,3119 @@ goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER; * use feature detection to determine which language levels need * transpilation. */ -// NOTE(user): we could expand this to accept a language level to bypass +// NOTE(sdh): we could expand this to accept a language level to bypass // detection: e.g. goog.TRANSPILE == 'es5' would transpile ES6 files but // would leave ES3 and ES5 files alone. -goog.define('goog.TRANSPILE', 'detect'); +goog.TRANSPILE = goog.define('goog.TRANSPILE', 'detect'); + +/** + * @define {boolean} If true assume that ES modules have already been + * transpiled by the jscompiler (in the same way that transpile.js would + * transpile them - to jscomp modules). Useful only for servers that wish to use + * the debug loader and transpile server side. Thus this is only respected if + * goog.TRANSPILE is "never". + */ +goog.ASSUME_ES_MODULES_TRANSPILED = + goog.define('goog.ASSUME_ES_MODULES_TRANSPILED', false); /** - * @define {string} Path to the transpiler. Executing the script at this - * path (relative to base.js) should define a function $jscomp.transpile. + * @define {string} If a file needs to be transpiled what the output language + * should be. By default this is the highest language level this file detects + * the current environment supports. Generally this flag should not be set, but + * it could be useful to override. Example: If the current environment supports + * ES6 then by default ES7+ files will be transpiled to ES6, unless this is + * overridden. + * + * Valid values include: es3, es5, es6, es7, and es8. Anything not recognized + * is treated as es3. + * + * Note that setting this value does not force transpilation. Just if + * transpilation occurs this will be the output. So this is most useful when + * goog.TRANSPILE is set to 'always' and then forcing the language level to be + * something lower than what the environment detects. */ -goog.define('goog.TRANSPILER', 'transpile.js'); +goog.TRANSPILE_TO_LANGUAGE = goog.define('goog.TRANSPILE_TO_LANGUAGE', ''); -if (goog.DEPENDENCIES_ENABLED) { - /** - * This object is used to keep track of dependencies and other data that is - * used for loading scripts. - * @private - * @type {{ - * loadFlags: !Object>, - * nameToPath: !Object, - * requires: !Object>, - * visited: !Object, - * written: !Object, - * deferred: !Object - * }} - */ - goog.dependencies_ = { - loadFlags: {}, // 1 to 1 +/** + * @define {string} Path to the transpiler. Executing the script at this + * path (relative to base.js) should define a function $jscomp.transpile. + */ +goog.TRANSPILER = goog.define('goog.TRANSPILER', 'transpile.js'); - nameToPath: {}, // 1 to 1 - requires: {}, // 1 to many +/** + * @package {?boolean} + * Visible for testing. + */ +goog.hasBadLetScoping = null; - // Used when resolving dependencies to prevent us from visiting file twice. - visited: {}, - written: {}, // Used to keep track of script files we have written. +/** + * @return {boolean} + * @package Visible for testing. + */ +goog.useSafari10Workaround = function() { + if (goog.hasBadLetScoping == null) { + var hasBadLetScoping; + try { + hasBadLetScoping = !eval( + '"use strict";' + + 'let x = 1; function f() { return typeof x; };' + + 'f() == "number";'); + } catch (e) { + // Assume that ES6 syntax isn't supported. + hasBadLetScoping = false; + } + goog.hasBadLetScoping = hasBadLetScoping; + } + return goog.hasBadLetScoping; +}; - deferred: {} // Used to track deferred module evaluations in old IEs - }; +/** + * @param {string} moduleDef + * @return {string} + * @package Visible for testing. + */ +goog.workaroundSafari10EvalBug = function(moduleDef) { + return '(function(){' + moduleDef + + '\n' + // Terminate any trailing single line comment. + ';' + // Terminate any trailing expression. + '})();\n'; +}; - /** - * Tries to detect whether is in the context of an HTML document. - * @return {boolean} True if it looks like HTML document. - * @private - */ - goog.inHtmlDocument_ = function() { - /** @type {Document} */ - var doc = goog.global.document; - return doc != null && 'write' in doc; // XULDocument misses write. - }; +/** + * @param {function(?):?|string} moduleDef The module definition. + */ +goog.loadModule = function(moduleDef) { + // NOTE: we allow function definitions to be either in the from + // of a string to eval (which keeps the original source intact) or + // in a eval forbidden environment (CSP) we allow a function definition + // which in its body must call `goog.module`, and return the exports + // of the module. + var previousState = goog.moduleLoaderState_; + try { + goog.moduleLoaderState_ = { + moduleName: '', + declareLegacyNamespace: false, + type: goog.ModuleType.GOOG + }; + var exports; + if (goog.isFunction(moduleDef)) { + exports = moduleDef.call(undefined, {}); + } else if (typeof moduleDef === 'string') { + if (goog.useSafari10Workaround()) { + moduleDef = goog.workaroundSafari10EvalBug(moduleDef); + } - /** - * Tries to detect the base path of base.js script that bootstraps Closure. - * @private - */ - goog.findBasePath_ = function() { - if (goog.isDef(goog.global.CLOSURE_BASE_PATH) && - // Anti DOM-clobbering runtime check (b/37736576). - goog.isString(goog.global.CLOSURE_BASE_PATH)) { - goog.basePath = goog.global.CLOSURE_BASE_PATH; - return; - } else if (!goog.inHtmlDocument_()) { - return; - } - /** @type {Document} */ - var doc = goog.global.document; - // If we have a currentScript available, use it exclusively. - var currentScript = doc.currentScript; - if (currentScript) { - var scripts = [currentScript]; + exports = goog.loadModuleFromSource_.call(undefined, moduleDef); } else { - var scripts = doc.getElementsByTagName('SCRIPT'); - } - // Search backwards since the current script is in almost all cases the one - // that has base.js. - for (var i = scripts.length - 1; i >= 0; --i) { - var script = /** @type {!HTMLScriptElement} */ (scripts[i]); - var src = script.src; - var qmark = src.lastIndexOf('?'); - var l = qmark == -1 ? src.length : qmark; - if (src.substr(l - 7, 7) == 'base.js') { - goog.basePath = src.substr(0, l - 7); - return; - } + throw new Error('Invalid module definition'); } - }; + var moduleName = goog.moduleLoaderState_.moduleName; + if (typeof moduleName === 'string' && moduleName) { + // Don't seal legacy namespaces as they may be used as a parent of + // another namespace + if (goog.moduleLoaderState_.declareLegacyNamespace) { + goog.constructNamespace_(moduleName, exports); + } else if ( + goog.SEAL_MODULE_EXPORTS && Object.seal && + typeof exports == 'object' && exports != null) { + Object.seal(exports); + } - /** - * Imports a script if, and only if, that script hasn't already been imported. - * (Must be called at execution time) - * @param {string} src Script source. - * @param {string=} opt_sourceText The optionally source text to evaluate - * @private - */ - goog.importScript_ = function(src, opt_sourceText) { - var importScript = - goog.global.CLOSURE_IMPORT_SCRIPT || goog.writeScriptTag_; - if (importScript(src, opt_sourceText)) { - goog.dependencies_.written[src] = true; + var data = { + exports: exports, + type: goog.ModuleType.GOOG, + moduleId: goog.moduleLoaderState_.moduleName + }; + goog.loadedModules_[moduleName] = data; + } else { + throw new Error('Invalid module name \"' + moduleName + '\"'); } - }; - - - /** - * Whether the browser is IE9 or earlier, which needs special handling - * for deferred modules. - * @const @private {boolean} - */ - goog.IS_OLD_IE_ = - !!(!goog.global.atob && goog.global.document && goog.global.document.all); - - - /** - * Whether IE9 or earlier is waiting on a dependency. This ensures that - * deferred modules that have no non-deferred dependencies actually get - * loaded, since if we defer them and then never pull in a non-deferred - * script, then `goog.loadQueuedModules_` will never be called. Instead, - * if not waiting on anything we simply don't defer in the first place. - * @private {boolean} - */ - goog.oldIeWaiting_ = false; + } finally { + goog.moduleLoaderState_ = previousState; + } +}; - /** - * Given a URL initiate retrieval and execution of a script that needs - * pre-processing. - * @param {string} src Script source URL. - * @param {boolean} isModule Whether this is a goog.module. - * @param {boolean} needsTranspile Whether this source needs transpilation. - * @private - */ - goog.importProcessedScript_ = function(src, isModule, needsTranspile) { - // In an attempt to keep browsers from timing out loading scripts using - // synchronous XHRs, put each load in its own script block. - var bootstrap = 'goog.retrieveAndExec_("' + src + '", ' + isModule + ', ' + - needsTranspile + ');'; +/** + * @private @const + */ +goog.loadModuleFromSource_ = /** @type {function(string):?} */ (function() { + // NOTE: we avoid declaring parameters or local variables here to avoid + // masking globals or leaking values into the module definition. + 'use strict'; + var exports = {}; + eval(arguments[0]); + return exports; +}); - goog.importScript_('', bootstrap); - }; +/** + * Normalize a file path by removing redundant ".." and extraneous "." file + * path components. + * @param {string} path + * @return {string} + * @private + */ +goog.normalizePath_ = function(path) { + var components = path.split('/'); + var i = 0; + while (i < components.length) { + if (components[i] == '.') { + components.splice(i, 1); + } else if ( + i && components[i] == '..' && components[i - 1] && + components[i - 1] != '..') { + components.splice(--i, 2); + } else { + i++; + } + } + return components.join('/'); +}; + + +/** + * Provides a hook for loading a file when using Closure's goog.require() API + * with goog.modules. In particular this hook is provided to support Node.js. + * + * @type {(function(string):string)|undefined} + */ +goog.global.CLOSURE_LOAD_FILE_SYNC; + + +/** + * Loads file by synchronous XHR. Should not be used in production environments. + * @param {string} src Source URL. + * @return {?string} File contents, or null if load failed. + * @private + */ +goog.loadFileSync_ = function(src) { + if (goog.global.CLOSURE_LOAD_FILE_SYNC) { + return goog.global.CLOSURE_LOAD_FILE_SYNC(src); + } else { + try { + /** @type {XMLHttpRequest} */ + var xhr = new goog.global['XMLHttpRequest'](); + xhr.open('get', src, false); + xhr.send(); + // NOTE: Successful http: requests have a status of 200, but successful + // file: requests may have a status of zero. Any other status, or a + // thrown exception (particularly in case of file: requests) indicates + // some sort of error, which we treat as a missing or unavailable file. + return xhr.status == 0 || xhr.status == 200 ? xhr.responseText : null; + } catch (err) { + // No need to rethrow or log, since errors should show up on their own. + return null; + } + } +}; + + +/** + * Lazily retrieves the transpiler and applies it to the source. + * @param {string} code JS code. + * @param {string} path Path to the code. + * @param {string} target Language level output. + * @return {string} The transpiled code. + * @private + */ +goog.transpile_ = function(code, path, target) { + var jscomp = goog.global['$jscomp']; + if (!jscomp) { + goog.global['$jscomp'] = jscomp = {}; + } + var transpile = jscomp.transpile; + if (!transpile) { + var transpilerPath = goog.basePath + goog.TRANSPILER; + var transpilerCode = goog.loadFileSync_(transpilerPath); + if (transpilerCode) { + // This must be executed synchronously, since by the time we know we + // need it, we're about to load and write the ES6 code synchronously, + // so a normal script-tag load will be too slow. Wrapped in a function + // so that code is eval'd in the global scope. + (function() { + (0, eval)(transpilerCode + '\n//# sourceURL=' + transpilerPath); + }).call(goog.global); + // Even though the transpiler is optional, if $gwtExport is found, it's + // a sign the transpiler was loaded and the $jscomp.transpile *should* + // be there. + if (goog.global['$gwtExport'] && goog.global['$gwtExport']['$jscomp'] && + !goog.global['$gwtExport']['$jscomp']['transpile']) { + throw new Error( + 'The transpiler did not properly export the "transpile" ' + + 'method. $gwtExport: ' + JSON.stringify(goog.global['$gwtExport'])); + } + // transpile.js only exports a single $jscomp function, transpile. We + // grab just that and add it to the existing definition of $jscomp which + // contains the polyfills. + goog.global['$jscomp'].transpile = + goog.global['$gwtExport']['$jscomp']['transpile']; + jscomp = goog.global['$jscomp']; + transpile = jscomp.transpile; + } + } + if (!transpile) { + // The transpiler is an optional component. If it's not available then + // replace it with a pass-through function that simply logs. + var suffix = ' requires transpilation but no transpiler was found.'; + transpile = jscomp.transpile = function(code, path) { + // TODO(sdh): figure out some way to get this error to show up + // in test results, noting that the failure may occur in many + // different ways, including in loadModule() before the test + // runner even comes up. + goog.logToConsole_(path + suffix); + return code; + }; + } + // Note: any transpilation errors/warnings will be logged to the console. + return transpile(code, path, target); +}; + +//============================================================================== +// Language Enhancements +//============================================================================== + + +/** + * This is a "fixed" version of the typeof operator. It differs from the typeof + * operator in such a way that null returns 'null' and arrays return 'array'. + * @param {?} value The value to get the type of. + * @return {string} The name of the type. + */ +goog.typeOf = function(value) { + var s = typeof value; + if (s == 'object') { + if (value) { + // Check these first, so we can avoid calling Object.prototype.toString if + // possible. + // + // IE improperly marshals typeof across execution contexts, but a + // cross-context object will still return false for "instanceof Object". + if (value instanceof Array) { + return 'array'; + } else if (value instanceof Object) { + return s; + } + + // HACK: In order to use an Object prototype method on the arbitrary + // value, the compiler requires the value be cast to type Object, + // even though the ECMA spec explicitly allows it. + var className = Object.prototype.toString.call( + /** @type {!Object} */ (value)); + // In Firefox 3.6, attempting to access iframe window objects' length + // property throws an NS_ERROR_FAILURE, so we need to special-case it + // here. + if (className == '[object Window]') { + return 'object'; + } + + // We cannot always use constructor == Array or instanceof Array because + // different frames have different Array objects. In IE6, if the iframe + // where the array was created is destroyed, the array loses its + // prototype. Then dereferencing val.splice here throws an exception, so + // we can't use goog.isFunction. Calling typeof directly returns 'unknown' + // so that will work. In this case, this function will return false and + // most array functions will still work because the array is still + // array-like (supports length and []) even though it has lost its + // prototype. + // Mark Miller noticed that Object.prototype.toString + // allows access to the unforgeable [[Class]] property. + // 15.2.4.2 Object.prototype.toString ( ) + // When the toString method is called, the following steps are taken: + // 1. Get the [[Class]] property of this object. + // 2. Compute a string value by concatenating the three strings + // "[object ", Result(1), and "]". + // 3. Return Result(2). + // and this behavior survives the destruction of the execution context. + if ((className == '[object Array]' || + // In IE all non value types are wrapped as objects across window + // boundaries (not iframe though) so we have to do object detection + // for this edge case. + typeof value.length == 'number' && + typeof value.splice != 'undefined' && + typeof value.propertyIsEnumerable != 'undefined' && + !value.propertyIsEnumerable('splice') + + )) { + return 'array'; + } + // HACK: There is still an array case that fails. + // function ArrayImpostor() {} + // ArrayImpostor.prototype = []; + // var impostor = new ArrayImpostor; + // this can be fixed by getting rid of the fast path + // (value instanceof Array) and solely relying on + // (value && Object.prototype.toString.vall(value) === '[object Array]') + // but that would require many more function calls and is not warranted + // unless closure code is receiving objects from untrusted sources. + + // IE in cross-window calls does not correctly marshal the function type + // (it appears just as an object) so we cannot use just typeof val == + // 'function'. However, if the object has a call property, it is a + // function. + if ((className == '[object Function]' || + typeof value.call != 'undefined' && + typeof value.propertyIsEnumerable != 'undefined' && + !value.propertyIsEnumerable('call'))) { + return 'function'; + } + + } else { + return 'null'; + } + + } else if (s == 'function' && typeof value.call == 'undefined') { + // In Safari typeof nodeList returns 'function', and on Firefox typeof + // behaves similarly for HTML{Applet,Embed,Object}, Elements and RegExps. We + // would like to return object for those and we can detect an invalid + // function by making sure that the function object has a call method. + return 'object'; + } + return s; +}; + + +/** + * Returns true if the specified value is null. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is null. + * @deprecated Use `val === null` instead. + */ +goog.isNull = function(val) { + return val === null; +}; + + +/** + * Returns true if the specified value is defined and not null. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is defined and not null. + * @deprecated Use `val != null` instead. + */ +goog.isDefAndNotNull = function(val) { + // Note that undefined == null. + return val != null; +}; + + +/** + * Returns true if the specified value is an array. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is an array. + */ +goog.isArray = function(val) { + return goog.typeOf(val) == 'array'; +}; + + +/** + * Returns true if the object looks like an array. To qualify as array like + * the value needs to be either a NodeList or an object with a Number length + * property. Note that for this function neither strings nor functions are + * considered "array-like". + * + * @param {?} val Variable to test. + * @return {boolean} Whether variable is an array. + */ +goog.isArrayLike = function(val) { + var type = goog.typeOf(val); + // We do not use goog.isObject here in order to exclude function values. + return type == 'array' || type == 'object' && typeof val.length == 'number'; +}; + + +/** + * Returns true if the object looks like a Date. To qualify as Date-like the + * value needs to be an object and have a getFullYear() function. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is a like a Date. + */ +goog.isDateLike = function(val) { + return goog.isObject(val) && typeof val.getFullYear == 'function'; +}; + + +/** + * Returns true if the specified value is a function. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is a function. + */ +goog.isFunction = function(val) { + return goog.typeOf(val) == 'function'; +}; + + +/** + * Returns true if the specified value is an object. This includes arrays and + * functions. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is an object. + */ +goog.isObject = function(val) { + var type = typeof val; + return type == 'object' && val != null || type == 'function'; + // return Object(val) === val also works, but is slower, especially if val is + // not an object. +}; + + +/** + * Gets a unique ID for an object. This mutates the object so that further calls + * with the same object as a parameter returns the same value. The unique ID is + * guaranteed to be unique across the current session amongst objects that are + * passed into `getUid`. There is no guarantee that the ID is unique or + * consistent across sessions. It is unsafe to generate unique ID for function + * prototypes. + * + * @param {Object} obj The object to get the unique ID for. + * @return {number} The unique ID for the object. + */ +goog.getUid = function(obj) { + // TODO(arv): Make the type stricter, do not accept null. + + // In Opera window.hasOwnProperty exists but always returns false so we avoid + // using it. As a consequence the unique ID generated for BaseClass.prototype + // and SubClass.prototype will be the same. + // TODO(b/141512323): UUIDs are broken for ctors with class-side inheritance. + return obj[goog.UID_PROPERTY_] || + (obj[goog.UID_PROPERTY_] = ++goog.uidCounter_); +}; + + +/** + * Whether the given object is already assigned a unique ID. + * + * This does not modify the object. + * + * @param {!Object} obj The object to check. + * @return {boolean} Whether there is an assigned unique id for the object. + */ +goog.hasUid = function(obj) { + return !!obj[goog.UID_PROPERTY_]; +}; + + +/** + * Removes the unique ID from an object. This is useful if the object was + * previously mutated using `goog.getUid` in which case the mutation is + * undone. + * @param {Object} obj The object to remove the unique ID field from. + */ +goog.removeUid = function(obj) { + // TODO(arv): Make the type stricter, do not accept null. + + // In IE, DOM nodes are not instances of Object and throw an exception if we + // try to delete. Instead we try to use removeAttribute. + if (obj !== null && 'removeAttribute' in obj) { + obj.removeAttribute(goog.UID_PROPERTY_); + } + + try { + delete obj[goog.UID_PROPERTY_]; + } catch (ex) { + } +}; + + +/** + * Name for unique ID property. Initialized in a way to help avoid collisions + * with other closure JavaScript on the same page. + * @type {string} + * @private + */ +goog.UID_PROPERTY_ = 'closure_uid_' + ((Math.random() * 1e9) >>> 0); + + +/** + * Counter for UID. + * @type {number} + * @private + */ +goog.uidCounter_ = 0; + + +/** + * Adds a hash code field to an object. The hash code is unique for the + * given object. + * @param {Object} obj The object to get the hash code for. + * @return {number} The hash code for the object. + * @deprecated Use goog.getUid instead. + */ +goog.getHashCode = goog.getUid; + + +/** + * Removes the hash code field from an object. + * @param {Object} obj The object to remove the field from. + * @deprecated Use goog.removeUid instead. + */ +goog.removeHashCode = goog.removeUid; + + +/** + * Clones a value. The input may be an Object, Array, or basic type. Objects and + * arrays will be cloned recursively. + * + * WARNINGS: + * goog.cloneObject does not detect reference loops. Objects that + * refer to themselves will cause infinite recursion. + * + * goog.cloneObject is unaware of unique identifiers, and copies + * UIDs created by getUid into cloned results. + * + * @param {*} obj The value to clone. + * @return {*} A clone of the input value. + * @deprecated goog.cloneObject is unsafe. Prefer the goog.object methods. + */ +goog.cloneObject = function(obj) { + var type = goog.typeOf(obj); + if (type == 'object' || type == 'array') { + if (typeof obj.clone === 'function') { + return obj.clone(); + } + var clone = type == 'array' ? [] : {}; + for (var key in obj) { + clone[key] = goog.cloneObject(obj[key]); + } + return clone; + } + + return obj; +}; + + +/** + * A native implementation of goog.bind. + * @param {?function(this:T, ...)} fn A function to partially apply. + * @param {T} selfObj Specifies the object which this should point to when the + * function is run. + * @param {...*} var_args Additional arguments that are partially applied to the + * function. + * @return {!Function} A partially-applied form of the function goog.bind() was + * invoked as a method of. + * @template T + * @private + */ +goog.bindNative_ = function(fn, selfObj, var_args) { + return /** @type {!Function} */ (fn.call.apply(fn.bind, arguments)); +}; + + +/** + * A pure-JS implementation of goog.bind. + * @param {?function(this:T, ...)} fn A function to partially apply. + * @param {T} selfObj Specifies the object which this should point to when the + * function is run. + * @param {...*} var_args Additional arguments that are partially applied to the + * function. + * @return {!Function} A partially-applied form of the function goog.bind() was + * invoked as a method of. + * @template T + * @private + */ +goog.bindJs_ = function(fn, selfObj, var_args) { + if (!fn) { + throw new Error(); + } + + if (arguments.length > 2) { + var boundArgs = Array.prototype.slice.call(arguments, 2); + return function() { + // Prepend the bound arguments to the current arguments. + var newArgs = Array.prototype.slice.call(arguments); + Array.prototype.unshift.apply(newArgs, boundArgs); + return fn.apply(selfObj, newArgs); + }; + + } else { + return function() { + return fn.apply(selfObj, arguments); + }; + } +}; + + +/** + * Partially applies this function to a particular 'this object' and zero or + * more arguments. The result is a new function with some arguments of the first + * function pre-filled and the value of this 'pre-specified'. + * + * Remaining arguments specified at call-time are appended to the pre-specified + * ones. + * + * Also see: {@link #partial}. + * + * Usage: + *
var barMethBound = goog.bind(myFunction, myObj, 'arg1', 'arg2');
+ * barMethBound('arg3', 'arg4');
+ * + * @param {?function(this:T, ...)} fn A function to partially apply. + * @param {T} selfObj Specifies the object which this should point to when the + * function is run. + * @param {...*} var_args Additional arguments that are partially applied to the + * function. + * @return {!Function} A partially-applied form of the function goog.bind() was + * invoked as a method of. + * @template T + * @suppress {deprecated} See above. + */ +goog.bind = function(fn, selfObj, var_args) { + // TODO(nicksantos): narrow the type signature. + if (Function.prototype.bind && + // NOTE(nicksantos): Somebody pulled base.js into the default Chrome + // extension environment. This means that for Chrome extensions, they get + // the implementation of Function.prototype.bind that calls goog.bind + // instead of the native one. Even worse, we don't want to introduce a + // circular dependency between goog.bind and Function.prototype.bind, so + // we have to hack this to make sure it works correctly. + Function.prototype.bind.toString().indexOf('native code') != -1) { + goog.bind = goog.bindNative_; + } else { + goog.bind = goog.bindJs_; + } + return goog.bind.apply(null, arguments); +}; + + +/** + * Like goog.bind(), except that a 'this object' is not required. Useful when + * the target function is already bound. + * + * Usage: + * var g = goog.partial(f, arg1, arg2); + * g(arg3, arg4); + * + * @param {Function} fn A function to partially apply. + * @param {...*} var_args Additional arguments that are partially applied to fn. + * @return {!Function} A partially-applied form of the function goog.partial() + * was invoked as a method of. + */ +goog.partial = function(fn, var_args) { + var args = Array.prototype.slice.call(arguments, 1); + return function() { + // Clone the array (with slice()) and append additional arguments + // to the existing arguments. + var newArgs = args.slice(); + newArgs.push.apply(newArgs, arguments); + return fn.apply(/** @type {?} */ (this), newArgs); + }; +}; + + +/** + * Copies all the members of a source object to a target object. This method + * does not work on all browsers for all objects that contain keys such as + * toString or hasOwnProperty. Use goog.object.extend for this purpose. + * + * NOTE: Some have advocated for the use of goog.mixin to setup classes + * with multiple inheritence (traits, mixins, etc). However, as it simply + * uses "for in", this is not compatible with ES6 classes whose methods are + * non-enumerable. Changing this, would break cases where non-enumerable + * properties are not expected. + * + * @param {Object} target Target. + * @param {Object} source Source. + * @deprecated Prefer Object.assign + */ +goog.mixin = function(target, source) { + for (var x in source) { + target[x] = source[x]; + } + + // For IE7 or lower, the for-in-loop does not contain any properties that are + // not enumerable on the prototype object (for example, isPrototypeOf from + // Object.prototype) but also it will not include 'replace' on objects that + // extend String and change 'replace' (not that it is common for anyone to + // extend anything except Object). +}; + + +/** + * @return {number} An integer value representing the number of milliseconds + * between midnight, January 1, 1970 and the current time. + * @deprecated Use Date.now + */ +goog.now = (goog.TRUSTED_SITE && Date.now) || (function() { + // Unary plus operator converts its operand to a number which in + // the case of + // a date is done by calling getTime(). + return +new Date(); + }); - /** @private {!Array} */ - goog.queuedModules_ = []; +/** + * Evals JavaScript in the global scope. In IE this uses execScript, other + * browsers use goog.global.eval. If goog.global.eval does not evaluate in the + * global scope (for example, in Safari), appends a script tag instead. + * Throws an exception if neither execScript or eval is defined. + * @param {string} script JavaScript string. + */ +goog.globalEval = function(script) { + if (goog.global.execScript) { + goog.global.execScript(script, 'JavaScript'); + } else if (goog.global.eval) { + // Test to see if eval works + if (goog.evalWorksForGlobals_ == null) { + try { + goog.global.eval('var _evalTest_ = 1;'); + } catch (ignore) { + } + if (typeof goog.global['_evalTest_'] != 'undefined') { + try { + delete goog.global['_evalTest_']; + } catch (ignore) { + // Microsoft edge fails the deletion above in strict mode. + } + goog.evalWorksForGlobals_ = true; + } else { + goog.evalWorksForGlobals_ = false; + } + } - /** - * Return an appropriate module text. Suitable to insert into - * a script tag (that is unescaped). - * @param {string} srcUrl - * @param {string} scriptText - * @return {string} - * @private - */ - goog.wrapModule_ = function(srcUrl, scriptText) { - if (!goog.LOAD_MODULE_USING_EVAL || !goog.isDef(goog.global.JSON)) { - return '' + - 'goog.loadModule(function(exports) {' + - '"use strict";' + scriptText + - '\n' + // terminate any trailing single line comment. - ';return exports' + - '});' + - '\n//# sourceURL=' + srcUrl + '\n'; + if (goog.evalWorksForGlobals_) { + goog.global.eval(script); } else { - return '' + - 'goog.loadModule(' + - goog.global.JSON.stringify( - scriptText + '\n//# sourceURL=' + srcUrl + '\n') + - ');'; + /** @type {!Document} */ + var doc = goog.global.document; + var scriptElt = + /** @type {!HTMLScriptElement} */ (doc.createElement('script')); + scriptElt.type = 'text/javascript'; + scriptElt.defer = false; + // Note(user): can't use .innerHTML since "t('')" will fail and + // .text doesn't work in Safari 2. Therefore we append a text node. + scriptElt.appendChild(doc.createTextNode(script)); + doc.head.appendChild(scriptElt); + doc.head.removeChild(scriptElt); } - }; + } else { + throw new Error('goog.globalEval not available'); + } +}; - // On IE9 and earlier, it is necessary to handle - // deferred module loads. In later browsers, the - // code to be evaluated is simply inserted as a script - // block in the correct order. To eval deferred - // code at the right time, we piggy back on goog.require to call - // goog.maybeProcessDeferredDep_. - // - // The goog.requires are used both to bootstrap - // the loading process (when no deps are available) and - // declare that they should be available. - // - // Here we eval the sources, if all the deps are available - // either already eval'd or goog.require'd. This will - // be the case when all the dependencies have already - // been loaded, and the dependent module is loaded. - // - // But this alone isn't sufficient because it is also - // necessary to handle the case where there is no root - // that is not deferred. For that there we register for an event - // and trigger goog.loadQueuedModules_ handle any remaining deferred - // evaluations. - /** - * Handle any remaining deferred goog.module evals. - * @private - */ - goog.loadQueuedModules_ = function() { - var count = goog.queuedModules_.length; - if (count > 0) { - var queue = goog.queuedModules_; - goog.queuedModules_ = []; - for (var i = 0; i < count; i++) { - var path = queue[i]; - goog.maybeProcessDeferredPath_(path); - } - } - goog.oldIeWaiting_ = false; - }; +/** + * Indicates whether or not we can call 'eval' directly to eval code in the + * global scope. Set to a Boolean by the first call to goog.globalEval (which + * empirically tests whether eval works for globals). @see goog.globalEval + * @type {?boolean} + * @private + */ +goog.evalWorksForGlobals_ = null; - /** - * Eval the named module if its dependencies are - * available. - * @param {string} name The module to load. - * @private - */ - goog.maybeProcessDeferredDep_ = function(name) { - if (goog.isDeferredModule_(name) && goog.allDepsAreAvailable_(name)) { - var path = goog.getPathFromDeps_(name); - goog.maybeProcessDeferredPath_(goog.basePath + path); - } +/** + * Optional map of CSS class names to obfuscated names used with + * goog.getCssName(). + * @private {!Object|undefined} + * @see goog.setCssNameMapping + */ +goog.cssNameMapping_; + + +/** + * Optional obfuscation style for CSS class names. Should be set to either + * 'BY_WHOLE' or 'BY_PART' if defined. + * @type {string|undefined} + * @private + * @see goog.setCssNameMapping + */ +goog.cssNameMappingStyle_; + + + +/** + * A hook for modifying the default behavior goog.getCssName. The function + * if present, will receive the standard output of the goog.getCssName as + * its input. + * + * @type {(function(string):string)|undefined} + */ +goog.global.CLOSURE_CSS_NAME_MAP_FN; + + +/** + * Handles strings that are intended to be used as CSS class names. + * + * This function works in tandem with @see goog.setCssNameMapping. + * + * Without any mapping set, the arguments are simple joined with a hyphen and + * passed through unaltered. + * + * When there is a mapping, there are two possible styles in which these + * mappings are used. In the BY_PART style, each part (i.e. in between hyphens) + * of the passed in css name is rewritten according to the map. In the BY_WHOLE + * style, the full css name is looked up in the map directly. If a rewrite is + * not specified by the map, the compiler will output a warning. + * + * When the mapping is passed to the compiler, it will replace calls to + * goog.getCssName with the strings from the mapping, e.g. + * var x = goog.getCssName('foo'); + * var y = goog.getCssName(this.baseClass, 'active'); + * becomes: + * var x = 'foo'; + * var y = this.baseClass + '-active'; + * + * If one argument is passed it will be processed, if two are passed only the + * modifier will be processed, as it is assumed the first argument was generated + * as a result of calling goog.getCssName. + * + * @param {string} className The class name. + * @param {string=} opt_modifier A modifier to be appended to the class name. + * @return {string} The class name or the concatenation of the class name and + * the modifier. + */ +goog.getCssName = function(className, opt_modifier) { + // String() is used for compatibility with compiled soy where the passed + // className can be non-string objects. + if (String(className).charAt(0) == '.') { + throw new Error( + 'className passed in goog.getCssName must not start with ".".' + + ' You passed: ' + className); + } + + var getMapping = function(cssName) { + return goog.cssNameMapping_[cssName] || cssName; }; - /** - * @param {string} name The module to check. - * @return {boolean} Whether the name represents a - * module whose evaluation has been deferred. - * @private - */ - goog.isDeferredModule_ = function(name) { - var path = goog.getPathFromDeps_(name); - var loadFlags = path && goog.dependencies_.loadFlags[path] || {}; - var languageLevel = loadFlags['lang'] || 'es3'; - if (path && (loadFlags['module'] == 'goog' || - goog.needsTranspile_(languageLevel))) { - var abspath = goog.basePath + path; - return (abspath) in goog.dependencies_.deferred; - } - return false; + var renameByParts = function(cssName) { + // Remap all the parts individually. + var parts = cssName.split('-'); + var mapped = []; + for (var i = 0; i < parts.length; i++) { + mapped.push(getMapping(parts[i])); + } + return mapped.join('-'); }; - /** - * @param {string} name The module to check. - * @return {boolean} Whether the name represents a - * module whose declared dependencies have all been loaded - * (eval'd or a deferred module load) - * @private - */ - goog.allDepsAreAvailable_ = function(name) { - var path = goog.getPathFromDeps_(name); - if (path && (path in goog.dependencies_.requires)) { - for (var requireName in goog.dependencies_.requires[path]) { - if (!goog.isProvided_(requireName) && - !goog.isDeferredModule_(requireName)) { - return false; - } - } - } - return true; - }; + var rename; + if (goog.cssNameMapping_) { + rename = + goog.cssNameMappingStyle_ == 'BY_WHOLE' ? getMapping : renameByParts; + } else { + rename = function(a) { + return a; + }; + } + + var result = + opt_modifier ? className + '-' + rename(opt_modifier) : rename(className); + + // The special CLOSURE_CSS_NAME_MAP_FN allows users to specify further + // processing of the class name. + if (goog.global.CLOSURE_CSS_NAME_MAP_FN) { + return goog.global.CLOSURE_CSS_NAME_MAP_FN(result); + } + + return result; +}; + + +/** + * Sets the map to check when returning a value from goog.getCssName(). Example: + *
+ * goog.setCssNameMapping({
+ *   "goog": "a",
+ *   "disabled": "b",
+ * });
+ *
+ * var x = goog.getCssName('goog');
+ * // The following evaluates to: "a a-b".
+ * goog.getCssName('goog') + ' ' + goog.getCssName(x, 'disabled')
+ * 
+ * When declared as a map of string literals to string literals, the JSCompiler + * will replace all calls to goog.getCssName() using the supplied map if the + * --process_closure_primitives flag is set. + * + * @param {!Object} mapping A map of strings to strings where keys are possible + * arguments to goog.getCssName() and values are the corresponding values + * that should be returned. + * @param {string=} opt_style The style of css name mapping. There are two valid + * options: 'BY_PART', and 'BY_WHOLE'. + * @see goog.getCssName for a description. + */ +goog.setCssNameMapping = function(mapping, opt_style) { + goog.cssNameMapping_ = mapping; + goog.cssNameMappingStyle_ = opt_style; +}; + + +/** + * To use CSS renaming in compiled mode, one of the input files should have a + * call to goog.setCssNameMapping() with an object literal that the JSCompiler + * can extract and use to replace all calls to goog.getCssName(). In uncompiled + * mode, JavaScript code should be loaded before this base.js file that declares + * a global variable, CLOSURE_CSS_NAME_MAPPING, which is used below. This is + * to ensure that the mapping is loaded before any calls to goog.getCssName() + * are made in uncompiled mode. + * + * A hook for overriding the CSS name mapping. + * @type {!Object|undefined} + */ +goog.global.CLOSURE_CSS_NAME_MAPPING; + + +if (!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING) { + // This does not call goog.setCssNameMapping() because the JSCompiler + // requires that goog.setCssNameMapping() be called with an object literal. + goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING; +} + + +/** + * Gets a localized message. + * + * This function is a compiler primitive. If you give the compiler a localized + * message bundle, it will replace the string at compile-time with a localized + * version, and expand goog.getMsg call to a concatenated string. + * + * Messages must be initialized in the form: + * + * var MSG_NAME = goog.getMsg('Hello {$placeholder}', {'placeholder': 'world'}); + * + * + * This function produces a string which should be treated as plain text. Use + * {@link goog.html.SafeHtmlFormatter} in conjunction with goog.getMsg to + * produce SafeHtml. + * + * @param {string} str Translatable string, places holders in the form {$foo}. + * @param {Object=} opt_values Maps place holder name to value. + * @param {{html: boolean}=} opt_options Options: + * html: Escape '<' in str to '<'. Used by Closure Templates where the + * generated code size and performance is critical which is why {@link + * goog.html.SafeHtmlFormatter} is not used. The value must be literal true + * or false. + * @return {string} message with placeholders filled. + */ +goog.getMsg = function(str, opt_values, opt_options) { + if (opt_options && opt_options.html) { + // Note that '&' is not replaced because the translation can contain HTML + // entities. + str = str.replace(/var x = goog.getMsgWithFallback(MSG_A, MSG_B);
+ * where MSG_A and MSG_B were initialized with goog.getMsg. + * + * @param {string} a The preferred message. + * @param {string} b The fallback message. + * @return {string} The best translated message. + */ +goog.getMsgWithFallback = function(a, b) { + return a; +}; - /** - * @param {string} abspath - * @private - */ - goog.maybeProcessDeferredPath_ = function(abspath) { - if (abspath in goog.dependencies_.deferred) { - var src = goog.dependencies_.deferred[abspath]; - delete goog.dependencies_.deferred[abspath]; - goog.globalEval(src); - } - }; +/** + * Exposes an unobfuscated global namespace path for the given object. + * Note that fields of the exported object *will* be obfuscated, unless they are + * exported in turn via this function or goog.exportProperty. + * + * Also handy for making public items that are defined in anonymous closures. + * + * ex. goog.exportSymbol('public.path.Foo', Foo); + * + * ex. goog.exportSymbol('public.path.Foo.staticFunction', Foo.staticFunction); + * public.path.Foo.staticFunction(); + * + * ex. goog.exportSymbol('public.path.Foo.prototype.myMethod', + * Foo.prototype.myMethod); + * new public.path.Foo().myMethod(); + * + * @param {string} publicPath Unobfuscated name to export. + * @param {*} object Object the name should point to. + * @param {Object=} opt_objectToExportTo The object to add the path to; default + * is goog.global. + */ +goog.exportSymbol = function(publicPath, object, opt_objectToExportTo) { + goog.exportPath_(publicPath, object, opt_objectToExportTo); +}; - /** - * Load a goog.module from the provided URL. This is not a general purpose - * code loader and does not support late loading code, that is it should only - * be used during page load. This method exists to support unit tests and - * "debug" loaders that would otherwise have inserted script tags. Under the - * hood this needs to use a synchronous XHR and is not recommeneded for - * production code. - * - * The module's goog.requires must have already been satisified; an exception - * will be thrown if this is not the case. This assumption is that no - * "deps.js" file exists, so there is no way to discover and locate the - * module-to-be-loaded's dependencies and no attempt is made to do so. - * - * There should only be one attempt to load a module. If - * "goog.loadModuleFromUrl" is called for an already loaded module, an - * exception will be throw. - * - * @param {string} url The URL from which to attempt to load the goog.module. - */ - goog.loadModuleFromUrl = function(url) { - // Because this executes synchronously, we don't need to do any additional - // bookkeeping. When "goog.loadModule" the namespace will be marked as - // having been provided which is sufficient. - goog.retrieveAndExec_(url, true, false); - }; +/** + * Exports a property unobfuscated into the object's namespace. + * ex. goog.exportProperty(Foo, 'staticFunction', Foo.staticFunction); + * ex. goog.exportProperty(Foo.prototype, 'myMethod', Foo.prototype.myMethod); + * @param {Object} object Object whose static property is being exported. + * @param {string} publicName Unobfuscated name to export. + * @param {*} symbol Object the name should point to. + */ +goog.exportProperty = function(object, publicName, symbol) { + object[publicName] = symbol; +}; - /** - * Writes a new script pointing to {@code src} directly into the DOM. - * - * NOTE: This method is not CSP-compliant. @see goog.appendScriptSrcNode_ for - * the fallback mechanism. - * - * @param {string} src The script URL. - * @private - */ - goog.writeScriptSrcNode_ = function(src) { - goog.global.document.write( - ' - - -

Closure Performance Tests - byteArrayToString

-
-
- - - - diff --git a/third_party/closure/goog/crypt/bytestring_perf.js b/third_party/closure/goog/crypt/bytestring_perf.js deleted file mode 100644 index 7f9fe7b08330e..0000000000000 --- a/third_party/closure/goog/crypt/bytestring_perf.js +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2014 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Performance test for different implementations of - * byteArrayToString. - */ - - -goog.provide('goog.crypt.byteArrayToStringPerf'); - -goog.require('goog.array'); -goog.require('goog.dom'); -goog.require('goog.testing.PerformanceTable'); - -goog.setTestOnly('goog.crypt.byteArrayToStringPerf'); - - -var table = new goog.testing.PerformanceTable(goog.dom.getElement('perfTable')); - - -var BYTES_LENGTH = Math.pow(2, 20); -var CHUNK_SIZE = 8192; - -function getBytes() { - var bytes = []; - for (var i = 0; i < BYTES_LENGTH; i++) { - bytes.push('A'.charCodeAt(0)); - } - return bytes; -} - -function copyAndSpliceByteArray(bytes) { - // Copy the passed byte array since we're going to destroy it. - var remainingBytes = goog.array.clone(bytes); - var strings = []; - - // Convert each chunk to a string. - while (remainingBytes.length) { - var chunk = goog.array.splice(remainingBytes, 0, CHUNK_SIZE); - strings.push(String.fromCharCode.apply(null, chunk)); - } - return strings.join(''); -} - -function sliceByteArrayConcat(bytes) { - var str = ''; - for (var i = 0; i < bytes.length; i += CHUNK_SIZE) { - var chunk = goog.array.slice(bytes, i, i + CHUNK_SIZE); - str += String.fromCharCode.apply(null, chunk); - } - return str; -} - - -function sliceByteArrayJoin(bytes) { - var strings = []; - for (var i = 0; i < bytes.length; i += CHUNK_SIZE) { - var chunk = goog.array.slice(bytes, i, i + CHUNK_SIZE); - strings.push(String.fromCharCode.apply(null, chunk)); - } - return strings.join(''); -} - -function mapByteArray(bytes) { - var strings = goog.array.map(bytes, String.fromCharCode); - return strings.join(''); -} - -function forLoopByteArrayConcat(bytes) { - var str = ''; - for (var i = 0; i < bytes.length; i++) { - str += String.fromCharCode(bytes[i]); - } - return str; -} - -function forLoopByteArrayJoin(bytes) { - var strs = []; - for (var i = 0; i < bytes.length; i++) { - strs.push(String.fromCharCode(bytes[i])); - } - return strs.join(''); -} - - -function run() { - var bytes = getBytes(); - table.run( - goog.partial(copyAndSpliceByteArray, getBytes()), - 'Copy array and splice out chunks.'); - - table.run( - goog.partial(sliceByteArrayConcat, getBytes()), - 'Slice out copies of the byte array, concatenating results'); - - table.run( - goog.partial(sliceByteArrayJoin, getBytes()), - 'Slice out copies of the byte array, joining results'); - - table.run( - goog.partial(forLoopByteArrayConcat, getBytes()), - 'Use for loop with concat.'); - - table.run( - goog.partial(forLoopByteArrayJoin, getBytes()), - 'Use for loop with join.'); - - // Purposefully commented out. This ends up being tremendously expensive. - // table.run(goog.partial(mapByteArray, getBytes()), - // 'Use goog.array.map and fromCharCode.'); -} - -run(); diff --git a/third_party/closure/goog/crypt/cbc.js b/third_party/closure/goog/crypt/cbc.js deleted file mode 100644 index b3d3f9ce233bc..0000000000000 --- a/third_party/closure/goog/crypt/cbc.js +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2012 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Implementation of CBC mode for block ciphers. See - * http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation - * #Cipher-block_chaining_.28CBC.29. for description. - * - * @author nnaze@google.com (Nathan Naze) - */ - -goog.provide('goog.crypt.Cbc'); - -goog.require('goog.array'); -goog.require('goog.asserts'); -goog.require('goog.crypt'); -goog.require('goog.crypt.BlockCipher'); - - - -/** - * Implements the CBC mode for block ciphers. See - * http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation - * #Cipher-block_chaining_.28CBC.29 - * - * @param {!goog.crypt.BlockCipher} cipher The block cipher to use. - * @constructor - * @final - * @struct - */ -goog.crypt.Cbc = function(cipher) { - - /** - * Block cipher. - * @type {!goog.crypt.BlockCipher} - * @private - */ - this.cipher_ = cipher; -}; - - -/** - * Encrypt a message. - * - * @param {!Array|!Uint8Array} plainText Message to encrypt. An array of - * bytes. The length should be a multiple of the block size. - * @param {!Array|!Uint8Array} initialVector Initial vector for the CBC - * mode. An array of bytes with the same length as the block size. - * @return {!Array} Encrypted message. - */ -goog.crypt.Cbc.prototype.encrypt = function(plainText, initialVector) { - - goog.asserts.assert( - plainText.length % this.cipher_.BLOCK_SIZE == 0, - 'Data\'s length must be multiple of block size.'); - - goog.asserts.assert( - initialVector.length == this.cipher_.BLOCK_SIZE, - 'Initial vector must be size of one block.'); - - // Implementation of - // http://en.wikipedia.org/wiki/File:Cbc_encryption.png - - var cipherText = []; - var vector = initialVector; - - // Generate each block of the encrypted cypher text. - for (var blockStartIndex = 0; blockStartIndex < plainText.length; - blockStartIndex += this.cipher_.BLOCK_SIZE) { - // Takes one block from the input message. - var plainTextBlock = goog.array.slice( - plainText, blockStartIndex, blockStartIndex + this.cipher_.BLOCK_SIZE); - - var input = goog.crypt.xorByteArray(plainTextBlock, vector); - var resultBlock = this.cipher_.encrypt(input); - - goog.array.extend(cipherText, resultBlock); - vector = resultBlock; - } - - return cipherText; -}; - - -/** - * Decrypt a message. - * - * @param {!Array|!Uint8Array} cipherText Message to decrypt. An array - * of bytes. The length should be a multiple of the block size. - * @param {!Array|!Uint8Array} initialVector Initial vector for the CBC - * mode. An array of bytes with the same length as the block size. - * @return {!Array} Decrypted message. - */ -goog.crypt.Cbc.prototype.decrypt = function(cipherText, initialVector) { - - goog.asserts.assert( - cipherText.length % this.cipher_.BLOCK_SIZE == 0, - 'Data\'s length must be multiple of block size.'); - - goog.asserts.assert( - initialVector.length == this.cipher_.BLOCK_SIZE, - 'Initial vector must be size of one block.'); - - // Implementation of - // http://en.wikipedia.org/wiki/File:Cbc_decryption.png - - var plainText = []; - var blockStartIndex = 0; - var vector = initialVector; - - // Generate each block of the decrypted plain text. - while (blockStartIndex < cipherText.length) { - // Takes one block. - var cipherTextBlock = goog.array.slice( - cipherText, blockStartIndex, blockStartIndex + this.cipher_.BLOCK_SIZE); - - var resultBlock = this.cipher_.decrypt(cipherTextBlock); - var plainTextBlock = goog.crypt.xorByteArray(vector, resultBlock); - - goog.array.extend(plainText, plainTextBlock); - vector = cipherTextBlock; - - blockStartIndex += this.cipher_.BLOCK_SIZE; - } - - return plainText; -}; diff --git a/third_party/closure/goog/crypt/crypt.js b/third_party/closure/goog/crypt/crypt.js deleted file mode 100644 index e1f8c1dc67bb6..0000000000000 --- a/third_party/closure/goog/crypt/crypt.js +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2008 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Namespace with crypto related helper functions. - */ - -goog.provide('goog.crypt'); - -goog.require('goog.array'); -goog.require('goog.asserts'); - - -/** - * Turns a string into an array of bytes; a "byte" being a JS number in the - * range 0-255. - * @param {string} str String value to arrify. - * @return {!Array} Array of numbers corresponding to the - * UCS character codes of each character in str. - */ -goog.crypt.stringToByteArray = function(str) { - var output = [], p = 0; - for (var i = 0; i < str.length; i++) { - var c = str.charCodeAt(i); - while (c > 0xff) { - output[p++] = c & 0xff; - c >>= 8; - } - output[p++] = c; - } - return output; -}; - - -/** - * Turns an array of numbers into the string given by the concatenation of the - * characters to which the numbers correspond. - * @param {!Uint8Array|!Array} bytes Array of numbers representing - * characters. - * @return {string} Stringification of the array. - */ -goog.crypt.byteArrayToString = function(bytes) { - var CHUNK_SIZE = 8192; - - // Special-case the simple case for speed's sake. - if (bytes.length <= CHUNK_SIZE) { - return String.fromCharCode.apply(null, bytes); - } - - // The remaining logic splits conversion by chunks since - // Function#apply() has a maximum parameter count. - // See discussion: http://goo.gl/LrWmZ9 - - var str = ''; - for (var i = 0; i < bytes.length; i += CHUNK_SIZE) { - var chunk = goog.array.slice(bytes, i, i + CHUNK_SIZE); - str += String.fromCharCode.apply(null, chunk); - } - return str; -}; - - -/** - * Turns an array of numbers into the hex string given by the concatenation of - * the hex values to which the numbers correspond. - * @param {Uint8Array|Array} array Array of numbers representing - * characters. - * @return {string} Hex string. - */ -goog.crypt.byteArrayToHex = function(array) { - return goog.array - .map( - array, - function(numByte) { - var hexByte = numByte.toString(16); - return hexByte.length > 1 ? hexByte : '0' + hexByte; - }) - .join(''); -}; - - -/** - * Converts a hex string into an integer array. - * @param {string} hexString Hex string of 16-bit integers (two characters - * per integer). - * @return {!Array} Array of {0,255} integers for the given string. - */ -goog.crypt.hexToByteArray = function(hexString) { - goog.asserts.assert( - hexString.length % 2 == 0, 'Key string length must be multiple of 2'); - var arr = []; - for (var i = 0; i < hexString.length; i += 2) { - arr.push(parseInt(hexString.substring(i, i + 2), 16)); - } - return arr; -}; - - -/** - * Converts a JS string to a UTF-8 "byte" array. - * @param {string} str 16-bit unicode string. - * @return {!Array} UTF-8 byte array. - */ -goog.crypt.stringToUtf8ByteArray = function(str) { - // TODO(user): Use native implementations if/when available - var out = [], p = 0; - for (var i = 0; i < str.length; i++) { - var c = str.charCodeAt(i); - if (c < 128) { - out[p++] = c; - } else if (c < 2048) { - out[p++] = (c >> 6) | 192; - out[p++] = (c & 63) | 128; - } else if ( - ((c & 0xFC00) == 0xD800) && (i + 1) < str.length && - ((str.charCodeAt(i + 1) & 0xFC00) == 0xDC00)) { - // Surrogate Pair - c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF); - out[p++] = (c >> 18) | 240; - out[p++] = ((c >> 12) & 63) | 128; - out[p++] = ((c >> 6) & 63) | 128; - out[p++] = (c & 63) | 128; - } else { - out[p++] = (c >> 12) | 224; - out[p++] = ((c >> 6) & 63) | 128; - out[p++] = (c & 63) | 128; - } - } - return out; -}; - - -/** - * Converts a UTF-8 byte array to JavaScript's 16-bit Unicode. - * @param {Uint8Array|Array} bytes UTF-8 byte array. - * @return {string} 16-bit Unicode string. - */ -goog.crypt.utf8ByteArrayToString = function(bytes) { - // TODO(user): Use native implementations if/when available - var out = [], pos = 0, c = 0; - while (pos < bytes.length) { - var c1 = bytes[pos++]; - if (c1 < 128) { - out[c++] = String.fromCharCode(c1); - } else if (c1 > 191 && c1 < 224) { - var c2 = bytes[pos++]; - out[c++] = String.fromCharCode((c1 & 31) << 6 | c2 & 63); - } else if (c1 > 239 && c1 < 365) { - // Surrogate Pair - var c2 = bytes[pos++]; - var c3 = bytes[pos++]; - var c4 = bytes[pos++]; - var u = ((c1 & 7) << 18 | (c2 & 63) << 12 | (c3 & 63) << 6 | c4 & 63) - - 0x10000; - out[c++] = String.fromCharCode(0xD800 + (u >> 10)); - out[c++] = String.fromCharCode(0xDC00 + (u & 1023)); - } else { - var c2 = bytes[pos++]; - var c3 = bytes[pos++]; - out[c++] = - String.fromCharCode((c1 & 15) << 12 | (c2 & 63) << 6 | c3 & 63); - } - } - return out.join(''); -}; - - -/** - * XOR two byte arrays. - * @param {!Uint8Array|!Int8Array|!Array} bytes1 Byte array 1. - * @param {!Uint8Array|!Int8Array|!Array} bytes2 Byte array 2. - * @return {!Array} Resulting XOR of the two byte arrays. - */ -goog.crypt.xorByteArray = function(bytes1, bytes2) { - goog.asserts.assert( - bytes1.length == bytes2.length, 'XOR array lengths must match'); - - var result = []; - for (var i = 0; i < bytes1.length; i++) { - result.push(bytes1[i] ^ bytes2[i]); - } - return result; -}; diff --git a/third_party/closure/goog/crypt/crypt_perf.html b/third_party/closure/goog/crypt/crypt_perf.html deleted file mode 100644 index 5f073759f5a04..0000000000000 --- a/third_party/closure/goog/crypt/crypt_perf.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - Closure Performance Tests - UTF8 encoding and decoding - - - - - -

Closure Performance Tests - UTF8 encoding and decoding

-

- User-agent: - -

-
-
- - - - diff --git a/third_party/closure/goog/crypt/ctr.js b/third_party/closure/goog/crypt/ctr.js deleted file mode 100644 index d2f9a6b8d8de7..0000000000000 --- a/third_party/closure/goog/crypt/ctr.js +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2016 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -goog.provide('goog.crypt.Ctr'); - -goog.require('goog.array'); -goog.require('goog.asserts'); -goog.require('goog.crypt'); - -/** - * Implementation of Ctr mode for block ciphers. See - * http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation - * #Cipher-block_chaining_.28Ctr.29. for an overview, and - * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf - * for the spec. - * - * @param {!goog.crypt.BlockCipher} cipher The block cipher to use. - * @constructor - * @final - * @struct - */ -goog.crypt.Ctr = function(cipher) { - - /** - * Block cipher. - * @type {!goog.crypt.BlockCipher} - * @private - */ - this.cipher_ = cipher; -}; - -/** - * Encrypts a message. - * - * @param {!Array|!Uint8Array} plainText Message to encrypt. An array of - * bytes. The length does not have to be a multiple of the blocksize. - * @param {!Array|!Uint8Array} initialVector Initial vector for the Ctr - * mode. An array of bytes with the same length as the block size, that - * should be not reused when using the same key. - * @return {!Array} Encrypted message. - */ -goog.crypt.Ctr.prototype.encrypt = function(plainText, initialVector) { - - goog.asserts.assert( - initialVector.length == this.cipher_.BLOCK_SIZE, - 'Initial vector must be size of one block.'); - - // Copy the IV, so it's not modified. - var counter = goog.array.clone(initialVector); - - var keyStreamBlock = []; - var encryptedArray = []; - var plainTextBlock = []; - - while (encryptedArray.length < plainText.length) { - keyStreamBlock = this.cipher_.encrypt(counter); - goog.crypt.Ctr.incrementBigEndianCounter_(counter); - - plainTextBlock = goog.array.slice( - plainText, encryptedArray.length, - encryptedArray.length + this.cipher_.BLOCK_SIZE); - goog.array.extend( - encryptedArray, - goog.crypt.xorByteArray( - plainTextBlock, - goog.array.slice(keyStreamBlock, 0, plainTextBlock.length))); - } - - return encryptedArray; -}; - - -/** - * Decrypts a message. In CTR, this is the same as encrypting. - * - * @param {!Array|!Uint8Array} cipherText Message to decrypt. The length - * does not have to be a multiple of the blocksize. - * @param {!Array|!Uint8Array} initialVector Initial vector for the Ctr - * mode. An array of bytes with the same length as the block size. - * @return {!Array} Decrypted message. - */ -goog.crypt.Ctr.prototype.decrypt = goog.crypt.Ctr.prototype.encrypt; - -/** - * Increments the big-endian integer represented in counter in-place. - * - * @param {!Array|!Uint8Array} counter The array of bytes to modify. - * @private - */ -goog.crypt.Ctr.incrementBigEndianCounter_ = function(counter) { - for (var i = counter.length - 1; i >= 0; i--) { - var currentByte = counter[i]; - currentByte = (currentByte + 1) & 0xFF; // Allow wrapping around. - counter[i] = currentByte; - if (currentByte != 0) { - // This iteration hasn't wrapped around, which means there is - // no carry to add to the next byte. - return; - } // else, repeat with next byte. - } -}; diff --git a/third_party/closure/goog/crypt/hash.js b/third_party/closure/goog/crypt/hash.js deleted file mode 100644 index cef806aef9637..0000000000000 --- a/third_party/closure/goog/crypt/hash.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2011 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Abstract cryptographic hash interface. - * - * See goog.crypt.Sha1 and goog.crypt.Md5 for sample implementations. - * - */ - -goog.provide('goog.crypt.Hash'); - - - -/** - * Create a cryptographic hash instance. - * - * @constructor - * @struct - */ -goog.crypt.Hash = function() { - /** - * The block size for the hasher. - * @type {number} - */ - this.blockSize = -1; -}; - - -/** - * Resets the internal accumulator. - */ -goog.crypt.Hash.prototype.reset = goog.abstractMethod; - - -/** - * Adds a byte array (array with values in [0-255] range) or a string (must - * only contain 8-bit, i.e., Latin1 characters) to the internal accumulator. - * - * Many hash functions operate on blocks of data and implement optimizations - * when a full chunk of data is readily available. Hence it is often preferable - * to provide large chunks of data (a kilobyte or more) than to repeatedly - * call the update method with few tens of bytes. If this is not possible, or - * not feasible, it might be good to provide data in multiplies of hash block - * size (often 64 bytes). Please see the implementation and performance tests - * of your favourite hash. - * - * @param {Array|Uint8Array|string} bytes Data used for the update. - * @param {number=} opt_length Number of bytes to use. - */ -goog.crypt.Hash.prototype.update = goog.abstractMethod; - - -/** - * @return {!Array} The finalized hash computed - * from the internal accumulator. - */ -goog.crypt.Hash.prototype.digest = goog.abstractMethod; diff --git a/third_party/closure/goog/crypt/hash32.js b/third_party/closure/goog/crypt/hash32.js deleted file mode 100644 index e25ef75a5cfb9..0000000000000 --- a/third_party/closure/goog/crypt/hash32.js +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2008 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Implementation of 32-bit hashing functions. - * - * This is a direct port from the Google Java Hash class - * - */ - -goog.provide('goog.crypt.hash32'); - -goog.require('goog.crypt'); - - -/** - * Default seed used during hashing, digits of pie. - * See SEED32 in http://go/base.hash.java - * @type {number} - */ -goog.crypt.hash32.SEED32 = 314159265; - - -/** - * Arbitrary constant used during hashing. - * See CONSTANT32 in http://go/base.hash.java - * @type {number} - */ -goog.crypt.hash32.CONSTANT32 = -1640531527; - - -/** - * Hashes a string to a 32-bit value. - * @param {string} str String to hash. - * @return {number} 32-bit hash. - */ -goog.crypt.hash32.encodeString = function(str) { - return goog.crypt.hash32.encodeByteArray(goog.crypt.stringToByteArray(str)); -}; - - -/** - * Hashes a string to a 32-bit value, converting the string to UTF-8 before - * doing the encoding. - * @param {string} str String to hash. - * @return {number} 32-bit hash. - */ -goog.crypt.hash32.encodeStringUtf8 = function(str) { - return goog.crypt.hash32.encodeByteArray( - goog.crypt.stringToUtf8ByteArray(str)); -}; - - -/** - * Hashes an integer to a 32-bit value. - * @param {number} value Number to hash. - * @return {number} 32-bit hash. - */ -goog.crypt.hash32.encodeInteger = function(value) { - // TODO(user): Does this make sense in JavaScript with doubles? Should we - // force the value to be in the correct range? - return goog.crypt.hash32.mix32_( - {a: value, b: goog.crypt.hash32.CONSTANT32, c: goog.crypt.hash32.SEED32}); -}; - - -/** - * Hashes a "byte" array to a 32-bit value using the supplied seed. - * @param {Array} bytes Array of bytes. - * @param {number=} opt_offset The starting position to use for hash - * computation. - * @param {number=} opt_length Number of bytes that are used for hashing. - * @param {number=} opt_seed The seed. - * @return {number} 32-bit hash. - */ -goog.crypt.hash32.encodeByteArray = function( - bytes, opt_offset, opt_length, opt_seed) { - var offset = opt_offset || 0; - var length = opt_length || bytes.length; - var seed = opt_seed || goog.crypt.hash32.SEED32; - - var mix = { - a: goog.crypt.hash32.CONSTANT32, - b: goog.crypt.hash32.CONSTANT32, - c: seed - }; - - var keylen; - for (keylen = length; keylen >= 12; keylen -= 12, offset += 12) { - mix.a += goog.crypt.hash32.wordAt_(bytes, offset); - mix.b += goog.crypt.hash32.wordAt_(bytes, offset + 4); - mix.c += goog.crypt.hash32.wordAt_(bytes, offset + 8); - goog.crypt.hash32.mix32_(mix); - } - // Hash any remaining bytes - mix.c += length; - switch (keylen) { // deal with rest. Some cases fall through - case 11: - mix.c += (bytes[offset + 10]) << 24; - case 10: - mix.c += (bytes[offset + 9] & 0xff) << 16; - case 9: - mix.c += (bytes[offset + 8] & 0xff) << 8; - // the first byte of c is reserved for the length - case 8: - mix.b += goog.crypt.hash32.wordAt_(bytes, offset + 4); - mix.a += goog.crypt.hash32.wordAt_(bytes, offset); - break; - case 7: - mix.b += (bytes[offset + 6] & 0xff) << 16; - case 6: - mix.b += (bytes[offset + 5] & 0xff) << 8; - case 5: - mix.b += (bytes[offset + 4] & 0xff); - case 4: - mix.a += goog.crypt.hash32.wordAt_(bytes, offset); - break; - case 3: - mix.a += (bytes[offset + 2] & 0xff) << 16; - case 2: - mix.a += (bytes[offset + 1] & 0xff) << 8; - case 1: - mix.a += (bytes[offset + 0] & 0xff); - // case 0 : nothing left to add - } - return goog.crypt.hash32.mix32_(mix); -}; - - -/** - * Performs an inplace mix of an object with the integer properties (a, b, c) - * and returns the final value of c. - * @param {Object} mix Object with properties, a, b, and c. - * @return {number} The end c-value for the mixing. - * @private - */ -goog.crypt.hash32.mix32_ = function(mix) { - var a = mix.a, b = mix.b, c = mix.c; - a -= b; - a -= c; - a ^= c >>> 13; - b -= c; - b -= a; - b ^= a << 8; - c -= a; - c -= b; - c ^= b >>> 13; - a -= b; - a -= c; - a ^= c >>> 12; - b -= c; - b -= a; - b ^= a << 16; - c -= a; - c -= b; - c ^= b >>> 5; - a -= b; - a -= c; - a ^= c >>> 3; - b -= c; - b -= a; - b ^= a << 10; - c -= a; - c -= b; - c ^= b >>> 15; - mix.a = a; - mix.b = b; - mix.c = c; - return c; -}; - - -/** - * Returns the word at a given offset. Treating an array of bytes a word at a - * time is far more efficient than byte-by-byte. - * @param {Array} bytes Array of bytes. - * @param {number} offset Offset in the byte array. - * @return {number} Integer value for the word. - * @private - */ -goog.crypt.hash32.wordAt_ = function(bytes, offset) { - var a = goog.crypt.hash32.toSigned_(bytes[offset + 0]); - var b = goog.crypt.hash32.toSigned_(bytes[offset + 1]); - var c = goog.crypt.hash32.toSigned_(bytes[offset + 2]); - var d = goog.crypt.hash32.toSigned_(bytes[offset + 3]); - return a + (b << 8) + (c << 16) + (d << 24); -}; - - -/** - * Converts an unsigned "byte" to signed, that is, convert a value in the range - * (0, 2^8-1) to (-2^7, 2^7-1) in order to be compatible with Java's byte type. - * @param {number} n Unsigned "byte" value. - * @return {number} Signed "byte" value. - * @private - */ -goog.crypt.hash32.toSigned_ = function(n) { - return n > 127 ? n - 256 : n; -}; diff --git a/third_party/closure/goog/crypt/hashtester.js b/third_party/closure/goog/crypt/hashtester.js deleted file mode 100644 index 369e782306a81..0000000000000 --- a/third_party/closure/goog/crypt/hashtester.js +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2011 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Unit tests for the abstract cryptographic hash interface. - * - */ - -goog.provide('goog.crypt.hashTester'); - -goog.require('goog.array'); -goog.require('goog.crypt'); -goog.require('goog.dom'); -goog.require('goog.dom.TagName'); -goog.require('goog.testing.PerformanceTable'); -goog.require('goog.testing.PseudoRandom'); -goog.require('goog.testing.asserts'); -goog.setTestOnly('hashTester'); - - -/** - * Runs basic tests. - * - * @param {!goog.crypt.Hash} hash A hash instance. - */ -goog.crypt.hashTester.runBasicTests = function(hash) { - // Compute first hash. - hash.update([97, 158]); - var golden1 = hash.digest(); - - // Compute second hash. - hash.reset(); - hash.update('aB'); - var golden2 = hash.digest(); - assertTrue( - 'Two different inputs resulted in a hash collision', - !!goog.testing.asserts.findDifferences(golden1, golden2)); - - // Empty hash. - hash.reset(); - var empty = hash.digest(); - assertTrue( - 'Empty hash collided with a non-trivial one', - !!goog.testing.asserts.findDifferences(golden1, empty) && - !!goog.testing.asserts.findDifferences(golden2, empty)); - - // Zero-length array update. - hash.reset(); - hash.update([]); - assertArrayEquals( - 'Updating with an empty array did not give an empty hash', empty, - hash.digest()); - - // Zero-length string update. - hash.reset(); - hash.update(''); - assertArrayEquals( - 'Updating with an empty string did not give an empty hash', empty, - hash.digest()); - - // Recompute the first hash. - hash.reset(); - hash.update([97, 158]); - assertArrayEquals( - 'The reset did not produce the initial state', golden1, hash.digest()); - - // Check for a trivial collision. - hash.reset(); - hash.update([158, 97]); - assertTrue( - 'Swapping bytes resulted in a hash collision', - !!goog.testing.asserts.findDifferences(golden1, hash.digest())); - - // Compare array and string input. - hash.reset(); - hash.update([97, 66]); - assertArrayEquals( - 'String and array inputs should give the same result', golden2, - hash.digest()); - - // Compute in parts. - hash.reset(); - hash.update('a'); - hash.update([158]); - assertArrayEquals( - 'Partial updates resulted in a different hash', golden1, hash.digest()); - - // Test update with specified length. - hash.reset(); - hash.update('aB', 0); - hash.update([97, 158, 32], 2); - assertArrayEquals( - 'Updating with an explicit buffer length did not work', golden1, - hash.digest()); -}; - - -/** - * Runs block tests. - * - * @param {!goog.crypt.Hash} hash A hash instance. - * @param {number} blockBytes Size of the hash block. - */ -goog.crypt.hashTester.runBlockTests = function(hash, blockBytes) { - // Compute a message which is 1 byte shorter than hash block size. - var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var message = ''; - for (var i = 0; i < blockBytes - 1; i++) { - message += chars.charAt(i % chars.length); - } - - // Compute golden hash for 1 block + 2 bytes. - hash.update(message + '123'); - var golden1 = hash.digest(); - - // Compute golden hash for 2 blocks + 1 byte. - hash.reset(); - hash.update(message + message + '123'); - var golden2 = hash.digest(); - - // Almost fill a block, then overflow. - hash.reset(); - hash.update(message); - hash.update('123'); - assertArrayEquals(golden1, hash.digest()); - - // Fill a block. - hash.reset(); - hash.update(message + '1'); - hash.update('23'); - assertArrayEquals(golden1, hash.digest()); - - // Overflow a block. - hash.reset(); - hash.update(message + '12'); - hash.update('3'); - assertArrayEquals(golden1, hash.digest()); - - // Test single overflow with an array. - hash.reset(); - hash.update(goog.crypt.stringToByteArray(message + '123')); - assertArrayEquals(golden1, hash.digest()); - - // Almost fill a block, then overflow this and the next block. - hash.reset(); - hash.update(message); - hash.update(message + '123'); - assertArrayEquals(golden2, hash.digest()); - - // Fill two blocks. - hash.reset(); - hash.update(message + message + '12'); - hash.update('3'); - assertArrayEquals(golden2, hash.digest()); - - // Test double overflow with an array. - hash.reset(); - hash.update(goog.crypt.stringToByteArray(message)); - hash.update(goog.crypt.stringToByteArray(message + '123')); - assertArrayEquals(golden2, hash.digest()); -}; - - -/** - * Runs performance tests. - * - * @param {function():!goog.crypt.Hash} hashFactory A hash factory. - * @param {string} hashName Name of the hashing function. - */ -goog.crypt.hashTester.runPerfTests = function(hashFactory, hashName) { - var body = goog.dom.getDocument().body; - var perfTable = goog.dom.createElement(goog.dom.TagName.DIV); - goog.dom.appendChild(body, perfTable); - - var table = new goog.testing.PerformanceTable(perfTable); - - function runPerfTest(byteLength, updateCount) { - var label = - (hashName + ': ' + updateCount + ' update(s) of ' + byteLength + - ' bytes'); - - function run(data, dataType) { - table.run(function() { - var hash = hashFactory(); - for (var i = 0; i < updateCount; i++) { - hash.update(data, byteLength); - } - var digest = hash.digest(); - }, label + ' (' + dataType + ')'); - } - - var byteArray = goog.crypt.hashTester.createRandomByteArray_(byteLength); - var byteString = goog.crypt.hashTester.createByteString_(byteArray); - - run(byteArray, 'byte array'); - run(byteString, 'byte string'); - } - - var MESSAGE_LENGTH_LONG = 10000000; // 10 Mbytes - var MESSAGE_LENGTH_SHORT = 10; // 10 bytes - var MESSAGE_COUNT_SHORT = MESSAGE_LENGTH_LONG / MESSAGE_LENGTH_SHORT; - - runPerfTest(MESSAGE_LENGTH_LONG, 1); - runPerfTest(MESSAGE_LENGTH_SHORT, MESSAGE_COUNT_SHORT); -}; - - -/** - * Creates and returns a random byte array. - * - * @param {number} length Length of the byte array. - * @return {!Array} An array of bytes. - * @private - */ -goog.crypt.hashTester.createRandomByteArray_ = function(length) { - var random = new goog.testing.PseudoRandom(0); - var bytes = []; - - for (var i = 0; i < length; ++i) { - // Generates an integer from 0 to 255. - var b = Math.floor(random.random() * 0x100); - bytes.push(b); - } - - return bytes; -}; - - -/** - * Creates a string from an array of bytes. - * - * @param {!Array} bytes An array of bytes. - * @return {string} The string encoded by the bytes. - * @private - */ -goog.crypt.hashTester.createByteString_ = function(bytes) { - var str = ''; - goog.array.forEach(bytes, function(b) { str += String.fromCharCode(b); }); - return str; -}; diff --git a/third_party/closure/goog/crypt/hmac.js b/third_party/closure/goog/crypt/hmac.js deleted file mode 100644 index 15e0e1dffb53a..0000000000000 --- a/third_party/closure/goog/crypt/hmac.js +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2011 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Implementation of HMAC in JavaScript. - * - * Usage: - * var hmac = new goog.crypt.Hmac(new goog.crypt.sha1(), key, 64); - * var digest = hmac.getHmac(bytes); - * - * @author benyu@google.com (Jige Yu) - port to closure - */ - - -goog.provide('goog.crypt.Hmac'); - -goog.require('goog.crypt.Hash'); - - - -/** - * @constructor - * @param {!goog.crypt.Hash} hasher An object to serve as a hash function. - * @param {Array} key The secret key to use to calculate the hmac. - * Should be an array of not more than {@code blockSize} integers in - {0, 255}. - * @param {number=} opt_blockSize Optional. The block size {@code hasher} uses. - * If not specified, uses the block size from the hasher, or 16 if it is - * not specified. - * @extends {goog.crypt.Hash} - * @final - * @struct - */ -goog.crypt.Hmac = function(hasher, key, opt_blockSize) { - goog.crypt.Hmac.base(this, 'constructor'); - - /** - * The underlying hasher to calculate hash. - * - * @type {!goog.crypt.Hash} - * @private - */ - this.hasher_ = hasher; - - this.blockSize = opt_blockSize || hasher.blockSize || 16; - - /** - * The outer padding array of hmac - * - * @type {!Array} - * @private - */ - this.keyO_ = new Array(this.blockSize); - - /** - * The inner padding array of hmac - * - * @type {!Array} - * @private - */ - this.keyI_ = new Array(this.blockSize); - - this.initialize_(key); -}; -goog.inherits(goog.crypt.Hmac, goog.crypt.Hash); - - -/** - * Outer padding byte of HMAC algorith, per http://en.wikipedia.org/wiki/HMAC - * - * @type {number} - * @private - */ -goog.crypt.Hmac.OPAD_ = 0x5c; - - -/** - * Inner padding byte of HMAC algorith, per http://en.wikipedia.org/wiki/HMAC - * - * @type {number} - * @private - */ -goog.crypt.Hmac.IPAD_ = 0x36; - - -/** - * Initializes Hmac by precalculating the inner and outer paddings. - * - * @param {Array} key The secret key to use to calculate the hmac. - * Should be an array of not more than {@code blockSize} integers in - {0, 255}. - * @private - */ -goog.crypt.Hmac.prototype.initialize_ = function(key) { - if (key.length > this.blockSize) { - this.hasher_.update(key); - key = this.hasher_.digest(); - this.hasher_.reset(); - } - // Precalculate padded and xor'd keys. - var keyByte; - for (var i = 0; i < this.blockSize; i++) { - if (i < key.length) { - keyByte = key[i]; - } else { - keyByte = 0; - } - this.keyO_[i] = keyByte ^ goog.crypt.Hmac.OPAD_; - this.keyI_[i] = keyByte ^ goog.crypt.Hmac.IPAD_; - } - // Be ready for an immediate update. - this.hasher_.update(this.keyI_); -}; - - -/** @override */ -goog.crypt.Hmac.prototype.reset = function() { - this.hasher_.reset(); - this.hasher_.update(this.keyI_); -}; - - -/** @override */ -goog.crypt.Hmac.prototype.update = function(bytes, opt_length) { - this.hasher_.update(bytes, opt_length); -}; - - -/** @override */ -goog.crypt.Hmac.prototype.digest = function() { - var temp = this.hasher_.digest(); - this.hasher_.reset(); - this.hasher_.update(this.keyO_); - this.hasher_.update(temp); - return this.hasher_.digest(); -}; - - -/** - * Calculates an HMAC for a given message. - * - * @param {Array|Uint8Array|string} message Data to Hmac. - * @return {!Array} the digest of the given message. - */ -goog.crypt.Hmac.prototype.getHmac = function(message) { - this.reset(); - this.update(message); - return this.digest(); -}; diff --git a/third_party/closure/goog/crypt/md5.js b/third_party/closure/goog/crypt/md5.js deleted file mode 100644 index 62ca9bbd7cf1d..0000000000000 --- a/third_party/closure/goog/crypt/md5.js +++ /dev/null @@ -1,433 +0,0 @@ -// Copyright 2011 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview MD5 cryptographic hash. - * Implementation of http://tools.ietf.org/html/rfc1321 with common - * optimizations and tweaks (see http://en.wikipedia.org/wiki/MD5). - * - * Usage: - * var md5 = new goog.crypt.Md5(); - * md5.update(bytes); - * var hash = md5.digest(); - * - * Performance: - * Chrome 23 ~680 Mbit/s - * Chrome 13 (in a VM) ~250 Mbit/s - * Firefox 6.0 (in a VM) ~100 Mbit/s - * IE9 (in a VM) ~27 Mbit/s - * Firefox 3.6 ~15 Mbit/s - * IE8 (in a VM) ~13 Mbit/s - * - */ - -goog.provide('goog.crypt.Md5'); - -goog.require('goog.crypt.Hash'); - - - -/** - * MD5 cryptographic hash constructor. - * @constructor - * @extends {goog.crypt.Hash} - * @final - * @struct - */ -goog.crypt.Md5 = function() { - goog.crypt.Md5.base(this, 'constructor'); - - this.blockSize = 512 / 8; - - /** - * Holds the current values of accumulated A-D variables (MD buffer). - * @type {!Array} - * @private - */ - this.chain_ = new Array(4); - - /** - * A buffer holding the data until the whole block can be processed. - * @type {!Array} - * @private - */ - this.block_ = new Array(this.blockSize); - - /** - * The length of yet-unprocessed data as collected in the block. - * @type {number} - * @private - */ - this.blockLength_ = 0; - - /** - * The total length of the message so far. - * @type {number} - * @private - */ - this.totalLength_ = 0; - - this.reset(); -}; -goog.inherits(goog.crypt.Md5, goog.crypt.Hash); - - -/** - * Integer rotation constants used by the abbreviated implementation. - * They are hardcoded in the unrolled implementation, so it is left - * here commented out. - * @type {Array} - * @private - * -goog.crypt.Md5.S_ = [ - 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, - 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, - 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, - 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21 -]; - */ - -/** - * Sine function constants used by the abbreviated implementation. - * They are hardcoded in the unrolled implementation, so it is left - * here commented out. - * @type {Array} - * @private - * -goog.crypt.Md5.T_ = [ - 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, - 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, - 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, - 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, - 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, - 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, - 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, - 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, - 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, - 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, - 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, - 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, - 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, - 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, - 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, - 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 -]; - */ - - -/** @override */ -goog.crypt.Md5.prototype.reset = function() { - this.chain_[0] = 0x67452301; - this.chain_[1] = 0xefcdab89; - this.chain_[2] = 0x98badcfe; - this.chain_[3] = 0x10325476; - - this.blockLength_ = 0; - this.totalLength_ = 0; -}; - - -/** - * Internal compress helper function. It takes a block of data (64 bytes) - * and updates the accumulator. - * @param {Array|Uint8Array|string} buf The block to compress. - * @param {number=} opt_offset Offset of the block in the buffer. - * @private - */ -goog.crypt.Md5.prototype.compress_ = function(buf, opt_offset) { - if (!opt_offset) { - opt_offset = 0; - } - - // We allocate the array every time, but it's cheap in practice. - var X = new Array(16); - - // Get 16 little endian words. It is not worth unrolling this for Chrome 11. - if (goog.isString(buf)) { - for (var i = 0; i < 16; ++i) { - X[i] = (buf.charCodeAt(opt_offset++)) | - (buf.charCodeAt(opt_offset++) << 8) | - (buf.charCodeAt(opt_offset++) << 16) | - (buf.charCodeAt(opt_offset++) << 24); - } - } else { - for (var i = 0; i < 16; ++i) { - X[i] = (buf[opt_offset++]) | (buf[opt_offset++] << 8) | - (buf[opt_offset++] << 16) | (buf[opt_offset++] << 24); - } - } - - var A = this.chain_[0]; - var B = this.chain_[1]; - var C = this.chain_[2]; - var D = this.chain_[3]; - var sum = 0; - - /* - * This is an abbreviated implementation, it is left here commented out for - * reference purposes. See below for an unrolled version in use. - * - var f, n, tmp; - for (var i = 0; i < 64; ++i) { - - if (i < 16) { - f = (D ^ (B & (C ^ D))); - n = i; - } else if (i < 32) { - f = (C ^ (D & (B ^ C))); - n = (5 * i + 1) % 16; - } else if (i < 48) { - f = (B ^ C ^ D); - n = (3 * i + 5) % 16; - } else { - f = (C ^ (B | (~D))); - n = (7 * i) % 16; - } - - tmp = D; - D = C; - C = B; - sum = (A + f + goog.crypt.Md5.T_[i] + X[n]) & 0xffffffff; - B += ((sum << goog.crypt.Md5.S_[i]) & 0xffffffff) | - (sum >>> (32 - goog.crypt.Md5.S_[i])); - A = tmp; - } - */ - - /* - * This is an unrolled MD5 implementation, which gives ~30% speedup compared - * to the abbreviated implementation above, as measured on Chrome 11. It is - * important to keep 32-bit croppings to minimum and inline the integer - * rotation. - */ - sum = (A + (D ^ (B & (C ^ D))) + X[0] + 0xd76aa478) & 0xffffffff; - A = B + (((sum << 7) & 0xffffffff) | (sum >>> 25)); - sum = (D + (C ^ (A & (B ^ C))) + X[1] + 0xe8c7b756) & 0xffffffff; - D = A + (((sum << 12) & 0xffffffff) | (sum >>> 20)); - sum = (C + (B ^ (D & (A ^ B))) + X[2] + 0x242070db) & 0xffffffff; - C = D + (((sum << 17) & 0xffffffff) | (sum >>> 15)); - sum = (B + (A ^ (C & (D ^ A))) + X[3] + 0xc1bdceee) & 0xffffffff; - B = C + (((sum << 22) & 0xffffffff) | (sum >>> 10)); - sum = (A + (D ^ (B & (C ^ D))) + X[4] + 0xf57c0faf) & 0xffffffff; - A = B + (((sum << 7) & 0xffffffff) | (sum >>> 25)); - sum = (D + (C ^ (A & (B ^ C))) + X[5] + 0x4787c62a) & 0xffffffff; - D = A + (((sum << 12) & 0xffffffff) | (sum >>> 20)); - sum = (C + (B ^ (D & (A ^ B))) + X[6] + 0xa8304613) & 0xffffffff; - C = D + (((sum << 17) & 0xffffffff) | (sum >>> 15)); - sum = (B + (A ^ (C & (D ^ A))) + X[7] + 0xfd469501) & 0xffffffff; - B = C + (((sum << 22) & 0xffffffff) | (sum >>> 10)); - sum = (A + (D ^ (B & (C ^ D))) + X[8] + 0x698098d8) & 0xffffffff; - A = B + (((sum << 7) & 0xffffffff) | (sum >>> 25)); - sum = (D + (C ^ (A & (B ^ C))) + X[9] + 0x8b44f7af) & 0xffffffff; - D = A + (((sum << 12) & 0xffffffff) | (sum >>> 20)); - sum = (C + (B ^ (D & (A ^ B))) + X[10] + 0xffff5bb1) & 0xffffffff; - C = D + (((sum << 17) & 0xffffffff) | (sum >>> 15)); - sum = (B + (A ^ (C & (D ^ A))) + X[11] + 0x895cd7be) & 0xffffffff; - B = C + (((sum << 22) & 0xffffffff) | (sum >>> 10)); - sum = (A + (D ^ (B & (C ^ D))) + X[12] + 0x6b901122) & 0xffffffff; - A = B + (((sum << 7) & 0xffffffff) | (sum >>> 25)); - sum = (D + (C ^ (A & (B ^ C))) + X[13] + 0xfd987193) & 0xffffffff; - D = A + (((sum << 12) & 0xffffffff) | (sum >>> 20)); - sum = (C + (B ^ (D & (A ^ B))) + X[14] + 0xa679438e) & 0xffffffff; - C = D + (((sum << 17) & 0xffffffff) | (sum >>> 15)); - sum = (B + (A ^ (C & (D ^ A))) + X[15] + 0x49b40821) & 0xffffffff; - B = C + (((sum << 22) & 0xffffffff) | (sum >>> 10)); - sum = (A + (C ^ (D & (B ^ C))) + X[1] + 0xf61e2562) & 0xffffffff; - A = B + (((sum << 5) & 0xffffffff) | (sum >>> 27)); - sum = (D + (B ^ (C & (A ^ B))) + X[6] + 0xc040b340) & 0xffffffff; - D = A + (((sum << 9) & 0xffffffff) | (sum >>> 23)); - sum = (C + (A ^ (B & (D ^ A))) + X[11] + 0x265e5a51) & 0xffffffff; - C = D + (((sum << 14) & 0xffffffff) | (sum >>> 18)); - sum = (B + (D ^ (A & (C ^ D))) + X[0] + 0xe9b6c7aa) & 0xffffffff; - B = C + (((sum << 20) & 0xffffffff) | (sum >>> 12)); - sum = (A + (C ^ (D & (B ^ C))) + X[5] + 0xd62f105d) & 0xffffffff; - A = B + (((sum << 5) & 0xffffffff) | (sum >>> 27)); - sum = (D + (B ^ (C & (A ^ B))) + X[10] + 0x02441453) & 0xffffffff; - D = A + (((sum << 9) & 0xffffffff) | (sum >>> 23)); - sum = (C + (A ^ (B & (D ^ A))) + X[15] + 0xd8a1e681) & 0xffffffff; - C = D + (((sum << 14) & 0xffffffff) | (sum >>> 18)); - sum = (B + (D ^ (A & (C ^ D))) + X[4] + 0xe7d3fbc8) & 0xffffffff; - B = C + (((sum << 20) & 0xffffffff) | (sum >>> 12)); - sum = (A + (C ^ (D & (B ^ C))) + X[9] + 0x21e1cde6) & 0xffffffff; - A = B + (((sum << 5) & 0xffffffff) | (sum >>> 27)); - sum = (D + (B ^ (C & (A ^ B))) + X[14] + 0xc33707d6) & 0xffffffff; - D = A + (((sum << 9) & 0xffffffff) | (sum >>> 23)); - sum = (C + (A ^ (B & (D ^ A))) + X[3] + 0xf4d50d87) & 0xffffffff; - C = D + (((sum << 14) & 0xffffffff) | (sum >>> 18)); - sum = (B + (D ^ (A & (C ^ D))) + X[8] + 0x455a14ed) & 0xffffffff; - B = C + (((sum << 20) & 0xffffffff) | (sum >>> 12)); - sum = (A + (C ^ (D & (B ^ C))) + X[13] + 0xa9e3e905) & 0xffffffff; - A = B + (((sum << 5) & 0xffffffff) | (sum >>> 27)); - sum = (D + (B ^ (C & (A ^ B))) + X[2] + 0xfcefa3f8) & 0xffffffff; - D = A + (((sum << 9) & 0xffffffff) | (sum >>> 23)); - sum = (C + (A ^ (B & (D ^ A))) + X[7] + 0x676f02d9) & 0xffffffff; - C = D + (((sum << 14) & 0xffffffff) | (sum >>> 18)); - sum = (B + (D ^ (A & (C ^ D))) + X[12] + 0x8d2a4c8a) & 0xffffffff; - B = C + (((sum << 20) & 0xffffffff) | (sum >>> 12)); - sum = (A + (B ^ C ^ D) + X[5] + 0xfffa3942) & 0xffffffff; - A = B + (((sum << 4) & 0xffffffff) | (sum >>> 28)); - sum = (D + (A ^ B ^ C) + X[8] + 0x8771f681) & 0xffffffff; - D = A + (((sum << 11) & 0xffffffff) | (sum >>> 21)); - sum = (C + (D ^ A ^ B) + X[11] + 0x6d9d6122) & 0xffffffff; - C = D + (((sum << 16) & 0xffffffff) | (sum >>> 16)); - sum = (B + (C ^ D ^ A) + X[14] + 0xfde5380c) & 0xffffffff; - B = C + (((sum << 23) & 0xffffffff) | (sum >>> 9)); - sum = (A + (B ^ C ^ D) + X[1] + 0xa4beea44) & 0xffffffff; - A = B + (((sum << 4) & 0xffffffff) | (sum >>> 28)); - sum = (D + (A ^ B ^ C) + X[4] + 0x4bdecfa9) & 0xffffffff; - D = A + (((sum << 11) & 0xffffffff) | (sum >>> 21)); - sum = (C + (D ^ A ^ B) + X[7] + 0xf6bb4b60) & 0xffffffff; - C = D + (((sum << 16) & 0xffffffff) | (sum >>> 16)); - sum = (B + (C ^ D ^ A) + X[10] + 0xbebfbc70) & 0xffffffff; - B = C + (((sum << 23) & 0xffffffff) | (sum >>> 9)); - sum = (A + (B ^ C ^ D) + X[13] + 0x289b7ec6) & 0xffffffff; - A = B + (((sum << 4) & 0xffffffff) | (sum >>> 28)); - sum = (D + (A ^ B ^ C) + X[0] + 0xeaa127fa) & 0xffffffff; - D = A + (((sum << 11) & 0xffffffff) | (sum >>> 21)); - sum = (C + (D ^ A ^ B) + X[3] + 0xd4ef3085) & 0xffffffff; - C = D + (((sum << 16) & 0xffffffff) | (sum >>> 16)); - sum = (B + (C ^ D ^ A) + X[6] + 0x04881d05) & 0xffffffff; - B = C + (((sum << 23) & 0xffffffff) | (sum >>> 9)); - sum = (A + (B ^ C ^ D) + X[9] + 0xd9d4d039) & 0xffffffff; - A = B + (((sum << 4) & 0xffffffff) | (sum >>> 28)); - sum = (D + (A ^ B ^ C) + X[12] + 0xe6db99e5) & 0xffffffff; - D = A + (((sum << 11) & 0xffffffff) | (sum >>> 21)); - sum = (C + (D ^ A ^ B) + X[15] + 0x1fa27cf8) & 0xffffffff; - C = D + (((sum << 16) & 0xffffffff) | (sum >>> 16)); - sum = (B + (C ^ D ^ A) + X[2] + 0xc4ac5665) & 0xffffffff; - B = C + (((sum << 23) & 0xffffffff) | (sum >>> 9)); - sum = (A + (C ^ (B | (~D))) + X[0] + 0xf4292244) & 0xffffffff; - A = B + (((sum << 6) & 0xffffffff) | (sum >>> 26)); - sum = (D + (B ^ (A | (~C))) + X[7] + 0x432aff97) & 0xffffffff; - D = A + (((sum << 10) & 0xffffffff) | (sum >>> 22)); - sum = (C + (A ^ (D | (~B))) + X[14] + 0xab9423a7) & 0xffffffff; - C = D + (((sum << 15) & 0xffffffff) | (sum >>> 17)); - sum = (B + (D ^ (C | (~A))) + X[5] + 0xfc93a039) & 0xffffffff; - B = C + (((sum << 21) & 0xffffffff) | (sum >>> 11)); - sum = (A + (C ^ (B | (~D))) + X[12] + 0x655b59c3) & 0xffffffff; - A = B + (((sum << 6) & 0xffffffff) | (sum >>> 26)); - sum = (D + (B ^ (A | (~C))) + X[3] + 0x8f0ccc92) & 0xffffffff; - D = A + (((sum << 10) & 0xffffffff) | (sum >>> 22)); - sum = (C + (A ^ (D | (~B))) + X[10] + 0xffeff47d) & 0xffffffff; - C = D + (((sum << 15) & 0xffffffff) | (sum >>> 17)); - sum = (B + (D ^ (C | (~A))) + X[1] + 0x85845dd1) & 0xffffffff; - B = C + (((sum << 21) & 0xffffffff) | (sum >>> 11)); - sum = (A + (C ^ (B | (~D))) + X[8] + 0x6fa87e4f) & 0xffffffff; - A = B + (((sum << 6) & 0xffffffff) | (sum >>> 26)); - sum = (D + (B ^ (A | (~C))) + X[15] + 0xfe2ce6e0) & 0xffffffff; - D = A + (((sum << 10) & 0xffffffff) | (sum >>> 22)); - sum = (C + (A ^ (D | (~B))) + X[6] + 0xa3014314) & 0xffffffff; - C = D + (((sum << 15) & 0xffffffff) | (sum >>> 17)); - sum = (B + (D ^ (C | (~A))) + X[13] + 0x4e0811a1) & 0xffffffff; - B = C + (((sum << 21) & 0xffffffff) | (sum >>> 11)); - sum = (A + (C ^ (B | (~D))) + X[4] + 0xf7537e82) & 0xffffffff; - A = B + (((sum << 6) & 0xffffffff) | (sum >>> 26)); - sum = (D + (B ^ (A | (~C))) + X[11] + 0xbd3af235) & 0xffffffff; - D = A + (((sum << 10) & 0xffffffff) | (sum >>> 22)); - sum = (C + (A ^ (D | (~B))) + X[2] + 0x2ad7d2bb) & 0xffffffff; - C = D + (((sum << 15) & 0xffffffff) | (sum >>> 17)); - sum = (B + (D ^ (C | (~A))) + X[9] + 0xeb86d391) & 0xffffffff; - B = C + (((sum << 21) & 0xffffffff) | (sum >>> 11)); - - this.chain_[0] = (this.chain_[0] + A) & 0xffffffff; - this.chain_[1] = (this.chain_[1] + B) & 0xffffffff; - this.chain_[2] = (this.chain_[2] + C) & 0xffffffff; - this.chain_[3] = (this.chain_[3] + D) & 0xffffffff; -}; - - -/** @override */ -goog.crypt.Md5.prototype.update = function(bytes, opt_length) { - if (!goog.isDef(opt_length)) { - opt_length = bytes.length; - } - var lengthMinusBlock = opt_length - this.blockSize; - - // Copy some object properties to local variables in order to save on access - // time from inside the loop (~10% speedup was observed on Chrome 11). - var block = this.block_; - var blockLength = this.blockLength_; - var i = 0; - - // The outer while loop should execute at most twice. - while (i < opt_length) { - // When we have no data in the block to top up, we can directly process the - // input buffer (assuming it contains sufficient data). This gives ~30% - // speedup on Chrome 14 and ~70% speedup on Firefox 6.0, but requires that - // the data is provided in large chunks (or in multiples of 64 bytes). - if (blockLength == 0) { - while (i <= lengthMinusBlock) { - this.compress_(bytes, i); - i += this.blockSize; - } - } - - if (goog.isString(bytes)) { - while (i < opt_length) { - block[blockLength++] = bytes.charCodeAt(i++); - if (blockLength == this.blockSize) { - this.compress_(block); - blockLength = 0; - // Jump to the outer loop so we use the full-block optimization. - break; - } - } - } else { - while (i < opt_length) { - block[blockLength++] = bytes[i++]; - if (blockLength == this.blockSize) { - this.compress_(block); - blockLength = 0; - // Jump to the outer loop so we use the full-block optimization. - break; - } - } - } - } - - this.blockLength_ = blockLength; - this.totalLength_ += opt_length; -}; - - -/** @override */ -goog.crypt.Md5.prototype.digest = function() { - // This must accommodate at least 1 padding byte (0x80), 8 bytes of - // total bitlength, and must end at a 64-byte boundary. - var pad = new Array( - (this.blockLength_ < 56 ? this.blockSize : this.blockSize * 2) - - this.blockLength_); - - // Add padding: 0x80 0x00* - pad[0] = 0x80; - for (var i = 1; i < pad.length - 8; ++i) { - pad[i] = 0; - } - // Add the total number of bits, little endian 64-bit integer. - var totalBits = this.totalLength_ * 8; - for (var i = pad.length - 8; i < pad.length; ++i) { - pad[i] = totalBits & 0xff; - totalBits /= 0x100; // Don't use bit-shifting here! - } - this.update(pad); - - var digest = new Array(16); - var n = 0; - for (var i = 0; i < 4; ++i) { - for (var j = 0; j < 32; j += 8) { - digest[n++] = (this.chain_[i] >>> j) & 0xff; - } - } - return digest; -}; diff --git a/third_party/closure/goog/crypt/md5_perf.html b/third_party/closure/goog/crypt/md5_perf.html deleted file mode 100644 index 57aa8c88f8724..0000000000000 --- a/third_party/closure/goog/crypt/md5_perf.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - -Closure Performance Tests - goog.crypt.Md5 - - - - - -

Closure Performance Tests - goog.crypt.Md5

-

-User-agent: - -

- - - diff --git a/third_party/closure/goog/crypt/pbkdf2.js b/third_party/closure/goog/crypt/pbkdf2.js deleted file mode 100644 index 366abcb961609..0000000000000 --- a/third_party/closure/goog/crypt/pbkdf2.js +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2012 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Implementation of PBKDF2 in JavaScript. - * @see http://en.wikipedia.org/wiki/PBKDF2 - * - * Currently we only support HMAC-SHA1 as the underlying hash function. To add a - * new hash function, add a static method similar to deriveKeyFromPasswordSha1() - * and implement the specific computeBlockCallback() using the hash function. - * - * Usage: - * var key = pbkdf2.deriveKeySha1( - * stringToByteArray('password'), stringToByteArray('salt'), 1000, 128); - * - */ - -goog.provide('goog.crypt.pbkdf2'); - -goog.require('goog.array'); -goog.require('goog.asserts'); -goog.require('goog.crypt'); -goog.require('goog.crypt.Hmac'); -goog.require('goog.crypt.Sha1'); - - -/** - * Derives key from password using PBKDF2-SHA1 - * @param {!Array} password Byte array representation of the password - * from which the key is derived. - * @param {!Array} initialSalt Byte array representation of the salt. - * @param {number} iterations Number of interations when computing the key. - * @param {number} keyLength Length of the output key in bits. - * Must be multiple of 8. - * @return {!Array} Byte array representation of the output key. - */ -goog.crypt.pbkdf2.deriveKeySha1 = function( - password, initialSalt, iterations, keyLength) { - // Length of the HMAC-SHA1 output in bits. - var HASH_LENGTH = 160; - - /** - * Compute each block of the key using HMAC-SHA1. - * @param {!Array} index Byte array representation of the index of - * the block to be computed. - * @return {!Array} Byte array representation of the output block. - */ - var computeBlock = function(index) { - // Initialize the result to be array of 0 such that its xor with the first - // block would be the first block. - var result = goog.array.repeat(0, HASH_LENGTH / 8); - // Initialize the salt of the first iteration to initialSalt || i. - var salt = initialSalt.concat(index); - var hmac = new goog.crypt.Hmac(new goog.crypt.Sha1(), password, 64); - // Compute and XOR each iteration. - for (var i = 0; i < iterations; i++) { - // The salt of the next iteration is the result of the current iteration. - salt = hmac.getHmac(salt); - result = goog.crypt.xorByteArray(result, salt); - } - return result; - }; - - return goog.crypt.pbkdf2.deriveKeyFromPassword_( - computeBlock, HASH_LENGTH, keyLength); -}; - - -/** - * Compute each block of the key using PBKDF2. - * @param {Function} computeBlock Function to compute each block of the output - * key. - * @param {number} hashLength Length of each block in bits. This is determined - * by the specific hash function used. Must be multiple of 8. - * @param {number} keyLength Length of the output key in bits. - * Must be multiple of 8. - * @return {!Array} Byte array representation of the output key. - * @private - */ -goog.crypt.pbkdf2.deriveKeyFromPassword_ = function( - computeBlock, hashLength, keyLength) { - goog.asserts.assert(keyLength % 8 == 0, 'invalid output key length'); - - // Compute and concactate each block of the output key. - var numBlocks = Math.ceil(keyLength / hashLength); - goog.asserts.assert(numBlocks >= 1, 'invalid number of blocks'); - var result = []; - for (var i = 1; i <= numBlocks; i++) { - var indexBytes = goog.crypt.pbkdf2.integerToByteArray_(i); - result = result.concat(computeBlock(indexBytes)); - } - - // Trim the last block if needed. - var lastBlockSize = keyLength % hashLength; - if (lastBlockSize != 0) { - var desiredBytes = ((numBlocks - 1) * hashLength + lastBlockSize) / 8; - result.splice(desiredBytes, (hashLength - lastBlockSize) / 8); - } - return result; -}; - - -/** - * Converts an integer number to a 32-bit big endian byte array. - * @param {number} n Integer number to be converted. - * @return {!Array} Byte Array representation of the 32-bit big endian - * encoding of n. - * @private - */ -goog.crypt.pbkdf2.integerToByteArray_ = function(n) { - var result = new Array(4); - result[0] = n >> 24 & 0xFF; - result[1] = n >> 16 & 0xFF; - result[2] = n >> 8 & 0xFF; - result[3] = n & 0xFF; - return result; -}; diff --git a/third_party/closure/goog/crypt/sha1.js b/third_party/closure/goog/crypt/sha1.js deleted file mode 100644 index b6735fe7b4004..0000000000000 --- a/third_party/closure/goog/crypt/sha1.js +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright 2005 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview SHA-1 cryptographic hash. - * Variable names follow the notation in FIPS PUB 180-3: - * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf. - * - * Usage: - * var sha1 = new goog.crypt.sha1(); - * sha1.update(bytes); - * var hash = sha1.digest(); - * - * Performance: - * Chrome 23: ~400 Mbit/s - * Firefox 16: ~250 Mbit/s - * - */ - -goog.provide('goog.crypt.Sha1'); - -goog.require('goog.crypt.Hash'); - - - -/** - * SHA-1 cryptographic hash constructor. - * - * The properties declared here are discussed in the above algorithm document. - * @constructor - * @extends {goog.crypt.Hash} - * @final - * @struct - */ -goog.crypt.Sha1 = function() { - goog.crypt.Sha1.base(this, 'constructor'); - - this.blockSize = 512 / 8; - - /** - * Holds the previous values of accumulated variables a-e in the compress_ - * function. - * @type {!Array} - * @private - */ - this.chain_ = []; - - /** - * A buffer holding the partially computed hash result. - * @type {!Array} - * @private - */ - this.buf_ = []; - - /** - * An array of 80 bytes, each a part of the message to be hashed. Referred to - * as the message schedule in the docs. - * @type {!Array} - * @private - */ - this.W_ = []; - - /** - * Contains data needed to pad messages less than 64 bytes. - * @type {!Array} - * @private - */ - this.pad_ = []; - - this.pad_[0] = 128; - for (var i = 1; i < this.blockSize; ++i) { - this.pad_[i] = 0; - } - - /** - * @private {number} - */ - this.inbuf_ = 0; - - /** - * @private {number} - */ - this.total_ = 0; - - this.reset(); -}; -goog.inherits(goog.crypt.Sha1, goog.crypt.Hash); - - -/** @override */ -goog.crypt.Sha1.prototype.reset = function() { - this.chain_[0] = 0x67452301; - this.chain_[1] = 0xefcdab89; - this.chain_[2] = 0x98badcfe; - this.chain_[3] = 0x10325476; - this.chain_[4] = 0xc3d2e1f0; - - this.inbuf_ = 0; - this.total_ = 0; -}; - - -/** - * Internal compress helper function. - * @param {!Array|!Uint8Array|string} buf Block to compress. - * @param {number=} opt_offset Offset of the block in the buffer. - * @private - */ -goog.crypt.Sha1.prototype.compress_ = function(buf, opt_offset) { - if (!opt_offset) { - opt_offset = 0; - } - - var W = this.W_; - - // get 16 big endian words - if (goog.isString(buf)) { - for (var i = 0; i < 16; i++) { - // TODO(user): [bug 8140122] Recent versions of Safari for Mac OS and iOS - // have a bug that turns the post-increment ++ operator into pre-increment - // during JIT compilation. We have code that depends heavily on SHA-1 for - // correctness and which is affected by this bug, so I've removed all uses - // of post-increment ++ in which the result value is used. We can revert - // this change once the Safari bug - // (https://bugs.webkit.org/show_bug.cgi?id=109036) has been fixed and - // most clients have been updated. - W[i] = (buf.charCodeAt(opt_offset) << 24) | - (buf.charCodeAt(opt_offset + 1) << 16) | - (buf.charCodeAt(opt_offset + 2) << 8) | - (buf.charCodeAt(opt_offset + 3)); - opt_offset += 4; - } - } else { - for (var i = 0; i < 16; i++) { - W[i] = (buf[opt_offset] << 24) | (buf[opt_offset + 1] << 16) | - (buf[opt_offset + 2] << 8) | (buf[opt_offset + 3]); - opt_offset += 4; - } - } - - // expand to 80 words - for (var i = 16; i < 80; i++) { - var t = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; - W[i] = ((t << 1) | (t >>> 31)) & 0xffffffff; - } - - var a = this.chain_[0]; - var b = this.chain_[1]; - var c = this.chain_[2]; - var d = this.chain_[3]; - var e = this.chain_[4]; - var f, k; - - // TODO(user): Try to unroll this loop to speed up the computation. - for (var i = 0; i < 80; i++) { - if (i < 40) { - if (i < 20) { - f = d ^ (b & (c ^ d)); - k = 0x5a827999; - } else { - f = b ^ c ^ d; - k = 0x6ed9eba1; - } - } else { - if (i < 60) { - f = (b & c) | (d & (b | c)); - k = 0x8f1bbcdc; - } else { - f = b ^ c ^ d; - k = 0xca62c1d6; - } - } - - var t = (((a << 5) | (a >>> 27)) + f + e + k + W[i]) & 0xffffffff; - e = d; - d = c; - c = ((b << 30) | (b >>> 2)) & 0xffffffff; - b = a; - a = t; - } - - this.chain_[0] = (this.chain_[0] + a) & 0xffffffff; - this.chain_[1] = (this.chain_[1] + b) & 0xffffffff; - this.chain_[2] = (this.chain_[2] + c) & 0xffffffff; - this.chain_[3] = (this.chain_[3] + d) & 0xffffffff; - this.chain_[4] = (this.chain_[4] + e) & 0xffffffff; -}; - - -/** @override */ -goog.crypt.Sha1.prototype.update = function(bytes, opt_length) { - // TODO(johnlenz): tighten the function signature and remove this check - if (bytes == null) { - return; - } - - if (!goog.isDef(opt_length)) { - opt_length = bytes.length; - } - - var lengthMinusBlock = opt_length - this.blockSize; - var n = 0; - // Using local instead of member variables gives ~5% speedup on Firefox 16. - var buf = this.buf_; - var inbuf = this.inbuf_; - - // The outer while loop should execute at most twice. - while (n < opt_length) { - // When we have no data in the block to top up, we can directly process the - // input buffer (assuming it contains sufficient data). This gives ~25% - // speedup on Chrome 23 and ~15% speedup on Firefox 16, but requires that - // the data is provided in large chunks (or in multiples of 64 bytes). - if (inbuf == 0) { - while (n <= lengthMinusBlock) { - this.compress_(bytes, n); - n += this.blockSize; - } - } - - if (goog.isString(bytes)) { - while (n < opt_length) { - buf[inbuf] = bytes.charCodeAt(n); - ++inbuf; - ++n; - if (inbuf == this.blockSize) { - this.compress_(buf); - inbuf = 0; - // Jump to the outer loop so we use the full-block optimization. - break; - } - } - } else { - while (n < opt_length) { - buf[inbuf] = bytes[n]; - ++inbuf; - ++n; - if (inbuf == this.blockSize) { - this.compress_(buf); - inbuf = 0; - // Jump to the outer loop so we use the full-block optimization. - break; - } - } - } - } - - this.inbuf_ = inbuf; - this.total_ += opt_length; -}; - - -/** @override */ -goog.crypt.Sha1.prototype.digest = function() { - var digest = []; - var totalBits = this.total_ * 8; - - // Add pad 0x80 0x00*. - if (this.inbuf_ < 56) { - this.update(this.pad_, 56 - this.inbuf_); - } else { - this.update(this.pad_, this.blockSize - (this.inbuf_ - 56)); - } - - // Add # bits. - for (var i = this.blockSize - 1; i >= 56; i--) { - this.buf_[i] = totalBits & 255; - totalBits /= 256; // Don't use bit-shifting here! - } - - this.compress_(this.buf_); - - var n = 0; - for (var i = 0; i < 5; i++) { - for (var j = 24; j >= 0; j -= 8) { - digest[n] = (this.chain_[i] >> j) & 255; - ++n; - } - } - - return digest; -}; diff --git a/third_party/closure/goog/crypt/sha1_perf.html b/third_party/closure/goog/crypt/sha1_perf.html deleted file mode 100644 index b26c155340d71..0000000000000 --- a/third_party/closure/goog/crypt/sha1_perf.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - -Closure Performance Tests - goog.crypt.Sha1 - - - - - -

Closure Performance Tests - goog.crypt.Sha1

-

-User-agent: - -

- - - - diff --git a/third_party/closure/goog/crypt/sha2.js b/third_party/closure/goog/crypt/sha2.js deleted file mode 100644 index 2778a3a1734a9..0000000000000 --- a/third_party/closure/goog/crypt/sha2.js +++ /dev/null @@ -1,327 +0,0 @@ -// Copyright 2012 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Base class for SHA-2 cryptographic hash. - * - * Variable names follow the notation in FIPS PUB 180-3: - * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf. - * - * Some code similar to SHA1 are borrowed from sha1.js written by mschilder@. - * - */ - -goog.provide('goog.crypt.Sha2'); - -goog.require('goog.array'); -goog.require('goog.asserts'); -goog.require('goog.crypt.Hash'); - - - -/** - * SHA-2 cryptographic hash constructor. - * This constructor should not be used directly to create the object. Rather, - * one should use the constructor of the sub-classes. - * @param {number} numHashBlocks The size of output in 16-byte blocks. - * @param {!Array} initHashBlocks The hash-specific initialization - * @constructor - * @extends {goog.crypt.Hash} - * @struct - */ -goog.crypt.Sha2 = function(numHashBlocks, initHashBlocks) { - goog.crypt.Sha2.base(this, 'constructor'); - - this.blockSize = goog.crypt.Sha2.BLOCKSIZE_; - - /** - * A chunk holding the currently processed message bytes. Once the chunk has - * 64 bytes, we feed it into computeChunk_ function and reset this.chunk_. - * @private {!Array|!Uint8Array} - */ - this.chunk_ = goog.global['Uint8Array'] ? new Uint8Array(this.blockSize) : - new Array(this.blockSize); - - /** - * Current number of bytes in this.chunk_. - * @private {number} - */ - this.inChunk_ = 0; - - /** - * Total number of bytes in currently processed message. - * @private {number} - */ - this.total_ = 0; - - - /** - * Holds the previous values of accumulated hash a-h in the computeChunk_ - * function. - * @private {!Array|!Int32Array} - */ - this.hash_ = []; - - /** - * The number of output hash blocks (each block is 4 bytes long). - * @private {number} - */ - this.numHashBlocks_ = numHashBlocks; - - /** - * @private {!Array} initHashBlocks - */ - this.initHashBlocks_ = initHashBlocks; - - /** - * Temporary array used in chunk computation. Allocate here as a - * member rather than as a local within computeChunk_() as a - * performance optimization to reduce the number of allocations and - * reduce garbage collection. - * @private {!Int32Array|!Array} - */ - this.w_ = goog.global['Int32Array'] ? new Int32Array(64) : new Array(64); - - if (!goog.isDef(goog.crypt.Sha2.Kx_)) { - // This is the first time this constructor has been called. - if (goog.global['Int32Array']) { - // Typed arrays exist - goog.crypt.Sha2.Kx_ = new Int32Array(goog.crypt.Sha2.K_); - } else { - // Typed arrays do not exist - goog.crypt.Sha2.Kx_ = goog.crypt.Sha2.K_; - } - } - - this.reset(); -}; -goog.inherits(goog.crypt.Sha2, goog.crypt.Hash); - - -/** - * The block size - * @private {number} - */ -goog.crypt.Sha2.BLOCKSIZE_ = 512 / 8; - - -/** - * Contains data needed to pad messages less than BLOCK_SIZE_ bytes. - * @private {!Array} - */ -goog.crypt.Sha2.PADDING_ = goog.array.concat( - 128, goog.array.repeat(0, goog.crypt.Sha2.BLOCKSIZE_ - 1)); - - -/** @override */ -goog.crypt.Sha2.prototype.reset = function() { - this.inChunk_ = 0; - this.total_ = 0; - this.hash_ = goog.global['Int32Array'] ? - new Int32Array(this.initHashBlocks_) : - goog.array.clone(this.initHashBlocks_); -}; - - -/** - * Helper function to compute the hashes for a given 512-bit message chunk. - * @private - */ -goog.crypt.Sha2.prototype.computeChunk_ = function() { - var chunk = this.chunk_; - goog.asserts.assert(chunk.length == this.blockSize); - var rounds = 64; - - // Divide the chunk into 16 32-bit-words. - var w = this.w_; - var index = 0; - var offset = 0; - while (offset < chunk.length) { - w[index++] = (chunk[offset] << 24) | (chunk[offset + 1] << 16) | - (chunk[offset + 2] << 8) | (chunk[offset + 3]); - offset = index * 4; - } - - // Extend the w[] array to be the number of rounds. - for (var i = 16; i < rounds; i++) { - var w_15 = w[i - 15] | 0; - var s0 = ((w_15 >>> 7) | (w_15 << 25)) ^ ((w_15 >>> 18) | (w_15 << 14)) ^ - (w_15 >>> 3); - var w_2 = w[i - 2] | 0; - var s1 = ((w_2 >>> 17) | (w_2 << 15)) ^ ((w_2 >>> 19) | (w_2 << 13)) ^ - (w_2 >>> 10); - - // As a performance optimization, construct the sum a pair at a time - // with casting to integer (bitwise OR) to eliminate unnecessary - // double<->integer conversions. - var partialSum1 = ((w[i - 16] | 0) + s0) | 0; - var partialSum2 = ((w[i - 7] | 0) + s1) | 0; - w[i] = (partialSum1 + partialSum2) | 0; - } - - var a = this.hash_[0] | 0; - var b = this.hash_[1] | 0; - var c = this.hash_[2] | 0; - var d = this.hash_[3] | 0; - var e = this.hash_[4] | 0; - var f = this.hash_[5] | 0; - var g = this.hash_[6] | 0; - var h = this.hash_[7] | 0; - for (var i = 0; i < rounds; i++) { - var S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ - ((a >>> 22) | (a << 10)); - var maj = ((a & b) ^ (a & c) ^ (b & c)); - var t2 = (S0 + maj) | 0; - var S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ - ((e >>> 25) | (e << 7)); - var ch = ((e & f) ^ ((~e) & g)); - - // As a performance optimization, construct the sum a pair at a time - // with casting to integer (bitwise OR) to eliminate unnecessary - // double<->integer conversions. - var partialSum1 = (h + S1) | 0; - var partialSum2 = (ch + (goog.crypt.Sha2.Kx_[i] | 0)) | 0; - var partialSum3 = (partialSum2 + (w[i] | 0)) | 0; - var t1 = (partialSum1 + partialSum3) | 0; - - h = g; - g = f; - f = e; - e = (d + t1) | 0; - d = c; - c = b; - b = a; - a = (t1 + t2) | 0; - } - - this.hash_[0] = (this.hash_[0] + a) | 0; - this.hash_[1] = (this.hash_[1] + b) | 0; - this.hash_[2] = (this.hash_[2] + c) | 0; - this.hash_[3] = (this.hash_[3] + d) | 0; - this.hash_[4] = (this.hash_[4] + e) | 0; - this.hash_[5] = (this.hash_[5] + f) | 0; - this.hash_[6] = (this.hash_[6] + g) | 0; - this.hash_[7] = (this.hash_[7] + h) | 0; -}; - - -/** @override */ -goog.crypt.Sha2.prototype.update = function(message, opt_length) { - if (!goog.isDef(opt_length)) { - opt_length = message.length; - } - // Process the message from left to right up to |opt_length| bytes. - // When we get a 512-bit chunk, compute the hash of it and reset - // this.chunk_. The message might not be multiple of 512 bits so we - // might end up with a chunk that is less than 512 bits. We store - // such partial chunk in this.chunk_ and it will be filled up later - // in digest(). - var n = 0; - var inChunk = this.inChunk_; - - // The input message could be either byte array of string. - if (goog.isString(message)) { - while (n < opt_length) { - this.chunk_[inChunk++] = message.charCodeAt(n++); - if (inChunk == this.blockSize) { - this.computeChunk_(); - inChunk = 0; - } - } - } else if (goog.isArrayLike(message)) { - while (n < opt_length) { - var b = message[n++]; - if (!('number' == typeof b && 0 <= b && 255 >= b && b == (b | 0))) { - throw Error('message must be a byte array'); - } - this.chunk_[inChunk++] = b; - if (inChunk == this.blockSize) { - this.computeChunk_(); - inChunk = 0; - } - } - } else { - throw Error('message must be string or array'); - } - - // Record the current bytes in chunk to support partial update. - this.inChunk_ = inChunk; - - // Record total message bytes we have processed so far. - this.total_ += opt_length; -}; - - -/** @override */ -goog.crypt.Sha2.prototype.digest = function() { - var digest = []; - var totalBits = this.total_ * 8; - - // Append pad 0x80 0x00*. - if (this.inChunk_ < 56) { - this.update(goog.crypt.Sha2.PADDING_, 56 - this.inChunk_); - } else { - this.update( - goog.crypt.Sha2.PADDING_, this.blockSize - (this.inChunk_ - 56)); - } - - // Append # bits in the 64-bit big-endian format. - for (var i = 63; i >= 56; i--) { - this.chunk_[i] = totalBits & 255; - totalBits /= 256; // Don't use bit-shifting here! - } - this.computeChunk_(); - - // Finally, output the result digest. - var n = 0; - for (var i = 0; i < this.numHashBlocks_; i++) { - for (var j = 24; j >= 0; j -= 8) { - digest[n++] = ((this.hash_[i] >> j) & 255); - } - } - return digest; -}; - - -/** - * Constants used in SHA-2. - * @const - * @private {!Array} - */ -goog.crypt.Sha2.K_ = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, - 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, - 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, - 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, - 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, - 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 -]; - - -/** - * Sha2.K as an Int32Array if this JS supports typed arrays; otherwise, - * the same array as Sha2.K. - * - * The compiler cannot remove an Int32Array, even if it is not needed - * (There are certain cases where creating an Int32Array is not - * side-effect free). Instead, the first time we construct a Sha2 - * instance, we convert or assign Sha2.K as appropriate. - * @private {undefined|!Array|!Int32Array} - */ -goog.crypt.Sha2.Kx_; diff --git a/third_party/closure/goog/crypt/sha224.js b/third_party/closure/goog/crypt/sha224.js deleted file mode 100644 index f7855553702a4..0000000000000 --- a/third_party/closure/goog/crypt/sha224.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview SHA-224 cryptographic hash. - * - * Usage: - * var sha224 = new goog.crypt.Sha224(); - * sha224.update(bytes); - * var hash = sha224.digest(); - * - */ - -goog.provide('goog.crypt.Sha224'); - -goog.require('goog.crypt.Sha2'); - - - -/** - * SHA-224 cryptographic hash constructor. - * - * @constructor - * @extends {goog.crypt.Sha2} - * @final - * @struct - */ -goog.crypt.Sha224 = function() { - goog.crypt.Sha224.base( - this, 'constructor', 7, goog.crypt.Sha224.INIT_HASH_BLOCK_); -}; -goog.inherits(goog.crypt.Sha224, goog.crypt.Sha2); - - -/** @private {!Array} */ -goog.crypt.Sha224.INIT_HASH_BLOCK_ = [ - 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, - 0x64f98fa7, 0xbefa4fa4 -]; diff --git a/third_party/closure/goog/crypt/sha224_perf.html b/third_party/closure/goog/crypt/sha224_perf.html deleted file mode 100644 index 4c39e6440a56b..0000000000000 --- a/third_party/closure/goog/crypt/sha224_perf.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - -Closure Performance Tests - goog.crypt.Sha224 - - - - - -

Closure Performance Tests - goog.crypt.Sha224

-

-User-agent: - -

- - - - diff --git a/third_party/closure/goog/crypt/sha256.js b/third_party/closure/goog/crypt/sha256.js deleted file mode 100644 index 1d7380e6e0837..0000000000000 --- a/third_party/closure/goog/crypt/sha256.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview SHA-256 cryptographic hash. - * - * Usage: - * var sha256 = new goog.crypt.Sha256(); - * sha256.update(bytes); - * var hash = sha256.digest(); - * - */ - -goog.provide('goog.crypt.Sha256'); - -goog.require('goog.crypt.Sha2'); - - - -/** - * SHA-256 cryptographic hash constructor. - * - * @constructor - * @extends {goog.crypt.Sha2} - * @final - * @struct - */ -goog.crypt.Sha256 = function() { - goog.crypt.Sha256.base( - this, 'constructor', 8, goog.crypt.Sha256.INIT_HASH_BLOCK_); -}; -goog.inherits(goog.crypt.Sha256, goog.crypt.Sha2); - - -/** @private {!Array} */ -goog.crypt.Sha256.INIT_HASH_BLOCK_ = [ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, - 0x1f83d9ab, 0x5be0cd19 -]; diff --git a/third_party/closure/goog/crypt/sha256_perf.html b/third_party/closure/goog/crypt/sha256_perf.html deleted file mode 100644 index 0b7922b3f232a..0000000000000 --- a/third_party/closure/goog/crypt/sha256_perf.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - -Closure Performance Tests - goog.crypt.Sha256 - - - - - -

Closure Performance Tests - goog.crypt.Sha256

-

-User-agent: - -

- - - - diff --git a/third_party/closure/goog/crypt/sha2_64bit.js b/third_party/closure/goog/crypt/sha2_64bit.js deleted file mode 100644 index e45a6a078c24f..0000000000000 --- a/third_party/closure/goog/crypt/sha2_64bit.js +++ /dev/null @@ -1,528 +0,0 @@ -// Copyright 2014 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview Base class for the 64-bit SHA-2 cryptographic hashes. - * - * Variable names follow the notation in FIPS PUB 180-3: - * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf. - * - * This code borrows heavily from the 32-bit SHA2 implementation written by - * Yue Zhang (zysxqn@). - * - * @author fy@google.com (Frank Yellin) - */ - -goog.provide('goog.crypt.Sha2_64bit'); - -goog.require('goog.array'); -goog.require('goog.asserts'); -goog.require('goog.crypt.Hash'); -goog.require('goog.math.Long'); - - - -/** - * Constructs a SHA-2 64-bit cryptographic hash. - * This class should not be used. Rather, one should use one of its - * subclasses. - * @constructor - * @param {number} numHashBlocks The size of the output in 16-byte blocks - * @param {!Array} initHashBlocks The hash-specific initialization - * vector, as a sequence of sixteen 32-bit numbers. - * @extends {goog.crypt.Hash} - * @struct - */ -goog.crypt.Sha2_64bit = function(numHashBlocks, initHashBlocks) { - goog.crypt.Sha2_64bit.base(this, 'constructor'); - - /** - * The number of bytes that are digested in each pass of this hasher. - * @const {number} - */ - this.blockSize = goog.crypt.Sha2_64bit.BLOCK_SIZE_; - - /** - * A chunk holding the currently processed message bytes. Once the chunk has - * {@code this.blocksize} bytes, we feed it into [@code computeChunk_}. - * @private {!Uint8Array|!Array} - */ - this.chunk_ = goog.global['Uint8Array'] ? new Uint8Array(this.blockSize) : - new Array(this.blockSize); - - /** - * Current number of bytes in {@code this.chunk_}. - * @private {number} - */ - this.chunkBytes_ = 0; - - /** - * Total number of bytes in currently processed message. - * @private {number} - */ - this.total_ = 0; - - /** - * Holds the previous values of accumulated hash a-h in the - * {@code computeChunk_} function. - * @private {!Array} - */ - this.hash_ = []; - - /** - * The number of blocks of output produced by this hash function, where each - * block is eight bytes long. - * @private {number} - */ - this.numHashBlocks_ = numHashBlocks; - - /** - * Temporary array used in chunk computation. Allocate here as a - * member rather than as a local within computeChunk_() as a - * performance optimization to reduce the number of allocations and - * reduce garbage collection. - * @type {!Array} - * @private - */ - this.w_ = []; - - /** - * The value to which {@code this.hash_} should be reset when this - * Hasher is reset. - * @private @const {!Array} - */ - this.initHashBlocks_ = goog.crypt.Sha2_64bit.toLongArray_(initHashBlocks); - - /** - * If true, we have taken the digest from this hasher, but we have not - * yet reset it. - * - * @private {boolean} - */ - this.needsReset_ = false; - - this.reset(); -}; -goog.inherits(goog.crypt.Sha2_64bit, goog.crypt.Hash); - - -/** - * The number of bytes that are digested in each pass of this hasher. - * @private @const {number} - */ -goog.crypt.Sha2_64bit.BLOCK_SIZE_ = 1024 / 8; - - -/** - * Contains data needed to pad messages less than {@code blocksize} bytes. - * @private {!Array} - */ -goog.crypt.Sha2_64bit.PADDING_ = goog.array.concat( - [0x80], goog.array.repeat(0, goog.crypt.Sha2_64bit.BLOCK_SIZE_ - 1)); - - -/** - * Resets this hash function. - * @override - */ -goog.crypt.Sha2_64bit.prototype.reset = function() { - this.chunkBytes_ = 0; - this.total_ = 0; - this.hash_ = goog.array.clone(this.initHashBlocks_); - this.needsReset_ = false; -}; - - -/** @override */ -goog.crypt.Sha2_64bit.prototype.update = function(message, opt_length) { - var length = goog.isDef(opt_length) ? opt_length : message.length; - - // Make sure this hasher is usable. - if (this.needsReset_) { - throw Error('this hasher needs to be reset'); - } - // Process the message from left to right up to |length| bytes. - // When we get a 512-bit chunk, compute the hash of it and reset - // this.chunk_. The message might not be multiple of 512 bits so we - // might end up with a chunk that is less than 512 bits. We store - // such partial chunk in chunk_ and it will be filled up later - // in digest(). - var chunkBytes = this.chunkBytes_; - - // The input message could be either byte array or string. - if (goog.isString(message)) { - for (var i = 0; i < length; i++) { - var b = message.charCodeAt(i); - if (b > 255) { - throw Error('Characters must be in range [0,255]'); - } - this.chunk_[chunkBytes++] = b; - if (chunkBytes == this.blockSize) { - this.computeChunk_(); - chunkBytes = 0; - } - } - } else if (goog.isArrayLike(message)) { - for (var i = 0; i < length; i++) { - var b = message[i]; - // Hack: b|0 coerces b to an integer, so the last part confirms that - // b has no fractional part. - if (!goog.isNumber(b) || b < 0 || b > 255 || b != (b | 0)) { - throw Error('message must be a byte array'); - } - this.chunk_[chunkBytes++] = b; - if (chunkBytes == this.blockSize) { - this.computeChunk_(); - chunkBytes = 0; - } - } - } else { - throw Error('message must be string or array'); - } - - // Record the current bytes in chunk to support partial update. - this.chunkBytes_ = chunkBytes; - - // Record total message bytes we have processed so far. - this.total_ += length; -}; - - -/** @override */ -goog.crypt.Sha2_64bit.prototype.digest = function() { - if (this.needsReset_) { - throw Error('this hasher needs to be reset'); - } - var totalBits = this.total_ * 8; - - // Append pad 0x80 0x00* until this.chunkBytes_ == 112 - if (this.chunkBytes_ < 112) { - this.update(goog.crypt.Sha2_64bit.PADDING_, 112 - this.chunkBytes_); - } else { - // the rest of this block, plus 112 bytes of next block - this.update( - goog.crypt.Sha2_64bit.PADDING_, - this.blockSize - this.chunkBytes_ + 112); - } - - // Append # bits in the 64-bit big-endian format. - for (var i = 127; i >= 112; i--) { - this.chunk_[i] = totalBits & 255; - totalBits /= 256; // Don't use bit-shifting here! - } - this.computeChunk_(); - - // Finally, output the result digest. - var n = 0; - var digest = new Array(8 * this.numHashBlocks_); - for (var i = 0; i < this.numHashBlocks_; i++) { - var block = this.hash_[i]; - var high = block.getHighBits(); - var low = block.getLowBits(); - for (var j = 24; j >= 0; j -= 8) { - digest[n++] = ((high >> j) & 255); - } - for (var j = 24; j >= 0; j -= 8) { - digest[n++] = ((low >> j) & 255); - } - } - - // The next call to this hasher must be a reset - this.needsReset_ = true; - return digest; -}; - - -/** - * Updates this hash by processing the 1024-bit message chunk in this.chunk_. - * @private - */ -goog.crypt.Sha2_64bit.prototype.computeChunk_ = function() { - var chunk = this.chunk_; - var K_ = goog.crypt.Sha2_64bit.K_; - - // Divide the chunk into 16 64-bit-words. - var w = this.w_; - for (var i = 0; i < 16; i++) { - var offset = i * 8; - w[i] = new goog.math.Long( - (chunk[offset + 4] << 24) | (chunk[offset + 5] << 16) | - (chunk[offset + 6] << 8) | (chunk[offset + 7]), - (chunk[offset] << 24) | (chunk[offset + 1] << 16) | - (chunk[offset + 2] << 8) | (chunk[offset + 3])); - } - - // Extend the w[] array to be the number of rounds. - for (var i = 16; i < 80; i++) { - var s0 = this.sigma0_(w[i - 15]); - var s1 = this.sigma1_(w[i - 2]); - w[i] = this.sum_(w[i - 16], w[i - 7], s0, s1); - } - - var a = this.hash_[0]; - var b = this.hash_[1]; - var c = this.hash_[2]; - var d = this.hash_[3]; - var e = this.hash_[4]; - var f = this.hash_[5]; - var g = this.hash_[6]; - var h = this.hash_[7]; - for (var i = 0; i < 80; i++) { - var S0 = this.Sigma0_(a); - var maj = this.majority_(a, b, c); - var t2 = S0.add(maj); - var S1 = this.Sigma1_(e); - var ch = this.choose_(e, f, g); - var t1 = this.sum_(h, S1, ch, K_[i], w[i]); - h = g; - g = f; - f = e; - e = d.add(t1); - d = c; - c = b; - b = a; - a = t1.add(t2); - } - - this.hash_[0] = this.hash_[0].add(a); - this.hash_[1] = this.hash_[1].add(b); - this.hash_[2] = this.hash_[2].add(c); - this.hash_[3] = this.hash_[3].add(d); - this.hash_[4] = this.hash_[4].add(e); - this.hash_[5] = this.hash_[5].add(f); - this.hash_[6] = this.hash_[6].add(g); - this.hash_[7] = this.hash_[7].add(h); -}; - - -/** - * Calculates the SHA2 64-bit sigma0 function. - * rotateRight(value, 1) ^ rotateRight(value, 8) ^ (value >>> 7) - * - * @private - * @param {!goog.math.Long} value - * @return {!goog.math.Long} - */ -goog.crypt.Sha2_64bit.prototype.sigma0_ = function(value) { - var valueLow = value.getLowBits(); - var valueHigh = value.getHighBits(); - // Implementation note: We purposely do not use the shift operations defined - // in goog.math.Long. Inlining the code for specific values of shifting and - // not generating the intermediate results doubles the speed of this code. - var low = (valueLow >>> 1) ^ (valueHigh << 31) ^ (valueLow >>> 8) ^ - (valueHigh << 24) ^ (valueLow >>> 7) ^ (valueHigh << 25); - var high = (valueHigh >>> 1) ^ (valueLow << 31) ^ (valueHigh >>> 8) ^ - (valueLow << 24) ^ (valueHigh >>> 7); - return new goog.math.Long(low, high); -}; - - -/** - * Calculates the SHA2 64-bit sigma1 function. - * rotateRight(value, 19) ^ rotateRight(value, 61) ^ (value >>> 6) - * - * @private - * @param {!goog.math.Long} value - * @return {!goog.math.Long} - */ -goog.crypt.Sha2_64bit.prototype.sigma1_ = function(value) { - var valueLow = value.getLowBits(); - var valueHigh = value.getHighBits(); - // Implementation note: See _sigma0() above - var low = (valueLow >>> 19) ^ (valueHigh << 13) ^ (valueHigh >>> 29) ^ - (valueLow << 3) ^ (valueLow >>> 6) ^ (valueHigh << 26); - var high = (valueHigh >>> 19) ^ (valueLow << 13) ^ (valueLow >>> 29) ^ - (valueHigh << 3) ^ (valueHigh >>> 6); - return new goog.math.Long(low, high); -}; - - -/** - * Calculates the SHA2 64-bit Sigma0 function. - * rotateRight(value, 28) ^ rotateRight(value, 34) ^ rotateRight(value, 39) - * - * @private - * @param {!goog.math.Long} value - * @return {!goog.math.Long} - */ -goog.crypt.Sha2_64bit.prototype.Sigma0_ = function(value) { - var valueLow = value.getLowBits(); - var valueHigh = value.getHighBits(); - // Implementation note: See _sigma0() above - var low = (valueLow >>> 28) ^ (valueHigh << 4) ^ (valueHigh >>> 2) ^ - (valueLow << 30) ^ (valueHigh >>> 7) ^ (valueLow << 25); - var high = (valueHigh >>> 28) ^ (valueLow << 4) ^ (valueLow >>> 2) ^ - (valueHigh << 30) ^ (valueLow >>> 7) ^ (valueHigh << 25); - return new goog.math.Long(low, high); -}; - - -/** - * Calculates the SHA2 64-bit Sigma1 function. - * rotateRight(value, 14) ^ rotateRight(value, 18) ^ rotateRight(value, 41) - * - * @private - * @param {!goog.math.Long} value - * @return {!goog.math.Long} - */ -goog.crypt.Sha2_64bit.prototype.Sigma1_ = function(value) { - var valueLow = value.getLowBits(); - var valueHigh = value.getHighBits(); - // Implementation note: See _sigma0() above - var low = (valueLow >>> 14) ^ (valueHigh << 18) ^ (valueLow >>> 18) ^ - (valueHigh << 14) ^ (valueHigh >>> 9) ^ (valueLow << 23); - var high = (valueHigh >>> 14) ^ (valueLow << 18) ^ (valueHigh >>> 18) ^ - (valueLow << 14) ^ (valueLow >>> 9) ^ (valueHigh << 23); - return new goog.math.Long(low, high); -}; - - -/** - * Calculates the SHA-2 64-bit choose function. - * - * This function uses {@code value} as a mask to choose bits from either - * {@code one} if the bit is set or {@code two} if the bit is not set. - * - * @private - * @param {!goog.math.Long} value - * @param {!goog.math.Long} one - * @param {!goog.math.Long} two - * @return {!goog.math.Long} - */ -goog.crypt.Sha2_64bit.prototype.choose_ = function(value, one, two) { - var valueLow = value.getLowBits(); - var valueHigh = value.getHighBits(); - return new goog.math.Long( - (valueLow & one.getLowBits()) | (~valueLow & two.getLowBits()), - (valueHigh & one.getHighBits()) | (~valueHigh & two.getHighBits())); -}; - - -/** - * Calculates the SHA-2 64-bit majority function. - * This function returns, for each bit position, the bit held by the majority - * of its three arguments. - * - * @private - * @param {!goog.math.Long} one - * @param {!goog.math.Long} two - * @param {!goog.math.Long} three - * @return {!goog.math.Long} - */ -goog.crypt.Sha2_64bit.prototype.majority_ = function(one, two, three) { - return new goog.math.Long( - (one.getLowBits() & two.getLowBits()) | - (two.getLowBits() & three.getLowBits()) | - (one.getLowBits() & three.getLowBits()), - (one.getHighBits() & two.getHighBits()) | - (two.getHighBits() & three.getHighBits()) | - (one.getHighBits() & three.getHighBits())); -}; - - -/** - * Adds two or more goog.math.Long values. - * - * @private - * @param {!goog.math.Long} one first summand - * @param {!goog.math.Long} two second summand - * @param {...goog.math.Long} var_args more arguments to sum - * @return {!goog.math.Long} The resulting sum. - */ -goog.crypt.Sha2_64bit.prototype.sum_ = function(one, two, var_args) { - // The low bits may be signed, but they represent a 32-bit unsigned quantity. - // We must be careful to normalize them. - // This doesn't matter for the high bits. - // Implementation note: Performance testing shows that this method runs - // fastest when the first two arguments are pulled out of the loop. - var low = (one.getLowBits() ^ 0x80000000) + (two.getLowBits() ^ 0x80000000); - var high = one.getHighBits() + two.getHighBits(); - for (var i = arguments.length - 1; i >= 2; --i) { - low += arguments[i].getLowBits() ^ 0x80000000; - high += arguments[i].getHighBits(); - } - // Because of the ^0x80000000, each value we added is 0x80000000 too small. - // Add arguments.length * 0x80000000 to the current sum. We can do this - // quickly by adding 0x80000000 to low when the number of arguments is - // odd, and adding (number of arguments) >> 1 to high. - if (arguments.length & 1) { - low += 0x80000000; - } - high += arguments.length >> 1; - - // If low is outside the range [0, 0xFFFFFFFF], its overflow or underflow - // should be added to high. We don't actually need to modify low or - // normalize high because the goog.math.Long constructor already does that. - high += Math.floor(low / 0x100000000); - return new goog.math.Long(low, high); -}; - - -/** - * Converts an array of 32-bit integers into an array of goog.math.Long - * elements. - * - * @private - * @param {!Array} values An array of 32-bit numbers. Its length - * must be even. Each pair of numbers represents a 64-bit integer - * in big-endian order - * @return {!Array} - */ -goog.crypt.Sha2_64bit.toLongArray_ = function(values) { - goog.asserts.assert(values.length % 2 == 0); - var result = []; - for (var i = 0; i < values.length; i += 2) { - result.push(new goog.math.Long(values[i + 1], values[i])); - } - return result; -}; - - -/** - * Fixed constants used in SHA-512 variants. - * - * These values are from Section 4.2.3 of - * http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf - * @const - * @private {!Array} - */ -goog.crypt.Sha2_64bit.K_ = goog.crypt.Sha2_64bit.toLongArray_([ - 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, - 0xe9b5dba5, 0x8189dbbc, 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, - 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 0xd807aa98, 0xa3030242, - 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, - 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, - 0xc19bf174, 0xcf692694, 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, - 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, 0x2de92c6f, 0x592b0275, - 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, - 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, - 0xbf597fc7, 0xbeef0ee4, 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, - 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, 0x27b70a85, 0x46d22ffc, - 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, - 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, - 0x92722c85, 0x1482353b, 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, - 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, 0xd192e819, 0xd6ef5218, - 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, - 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, - 0x34b0bcb5, 0xe19b48a8, 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, - 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, 0x748f82ee, 0x5defb2fc, - 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, - 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, - 0xc67178f2, 0xe372532b, 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, - 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, 0x06f067aa, 0x72176fba, - 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, - 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, - 0x431d67c4, 0x9c100d4c, 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, - 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 -]); diff --git a/third_party/closure/goog/crypt/sha384.js b/third_party/closure/goog/crypt/sha384.js deleted file mode 100644 index 1feab8482933b..0000000000000 --- a/third_party/closure/goog/crypt/sha384.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2014 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview SHA-384 cryptographic hash. - * - * Usage: - * var sha384 = new goog.crypt.Sha384(); - * sha384.update(bytes); - * var hash = sha384.digest(); - * - * @author fy@google.com (Frank Yellin) - */ - -goog.provide('goog.crypt.Sha384'); - -goog.require('goog.crypt.Sha2_64bit'); - - - -/** - * Constructs a SHA-384 cryptographic hash. - * - * @constructor - * @extends {goog.crypt.Sha2_64bit} - * @final - * @struct - */ -goog.crypt.Sha384 = function() { - goog.crypt.Sha384.base( - this, 'constructor', 6 /* numHashBlocks */, - goog.crypt.Sha384.INIT_HASH_BLOCK_); -}; -goog.inherits(goog.crypt.Sha384, goog.crypt.Sha2_64bit); - - -/** @private {!Array} */ -goog.crypt.Sha384.INIT_HASH_BLOCK_ = [ - // Section 5.3.4 of - // csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf - 0xcbbb9d5d, 0xc1059ed8, // H0 - 0x629a292a, 0x367cd507, // H1 - 0x9159015a, 0x3070dd17, // H2 - 0x152fecd8, 0xf70e5939, // H3 - 0x67332667, 0xffc00b31, // H4 - 0x8eb44a87, 0x68581511, // H5 - 0xdb0c2e0d, 0x64f98fa7, // H6 - 0x47b5481d, 0xbefa4fa4 // H7 -]; diff --git a/third_party/closure/goog/crypt/sha512.js b/third_party/closure/goog/crypt/sha512.js deleted file mode 100644 index 100484b76803e..0000000000000 --- a/third_party/closure/goog/crypt/sha512.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2014 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview SHA-512 cryptographic hash. - * - * Usage: - * var sha512 = new goog.crypt.Sha512(); - * sha512.update(bytes); - * var hash = sha512.digest(); - * - * @author fy@google.com (Frank Yellin) - */ - -goog.provide('goog.crypt.Sha512'); - -goog.require('goog.crypt.Sha2_64bit'); - - - -/** - * Constructs a SHA-512 cryptographic hash. - * - * @constructor - * @extends {goog.crypt.Sha2_64bit} - * @final - * @struct - */ -goog.crypt.Sha512 = function() { - goog.crypt.Sha512.base( - this, 'constructor', 8 /* numHashBlocks */, - goog.crypt.Sha512.INIT_HASH_BLOCK_); -}; -goog.inherits(goog.crypt.Sha512, goog.crypt.Sha2_64bit); - - -/** @private {!Array} */ -goog.crypt.Sha512.INIT_HASH_BLOCK_ = [ - // Section 5.3.5 of - // csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf - 0x6a09e667, 0xf3bcc908, // H0 - 0xbb67ae85, 0x84caa73b, // H1 - 0x3c6ef372, 0xfe94f82b, // H2 - 0xa54ff53a, 0x5f1d36f1, // H3 - 0x510e527f, 0xade682d1, // H4 - 0x9b05688c, 0x2b3e6c1f, // H5 - 0x1f83d9ab, 0xfb41bd6b, // H6 - 0x5be0cd19, 0x137e2179 // H7 -]; diff --git a/third_party/closure/goog/crypt/sha512_256.js b/third_party/closure/goog/crypt/sha512_256.js deleted file mode 100644 index 7e423982ddaf5..0000000000000 --- a/third_party/closure/goog/crypt/sha512_256.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2014 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview SHA-512/256 cryptographic hash. - * - * WARNING: SHA-256 and SHA-512/256 are different members of the SHA-2 - * family of hashes. Although both give 32-byte results, the two results - * should bear no relationship to each other. - * - * Please be careful before using this hash function. - *

- * Usage: - * var sha512_256 = new goog.crypt.Sha512_256(); - * sha512_256.update(bytes); - * var hash = sha512_256.digest(); - * - * @author fy@google.com (Frank Yellin) - */ - -goog.provide('goog.crypt.Sha512_256'); - -goog.require('goog.crypt.Sha2_64bit'); - - - -/** - * Constructs a SHA-512/256 cryptographic hash. - * - * @constructor - * @extends {goog.crypt.Sha2_64bit} - * @final - * @struct - */ -goog.crypt.Sha512_256 = function() { - goog.crypt.Sha512_256.base( - this, 'constructor', 4 /* numHashBlocks */, - goog.crypt.Sha512_256.INIT_HASH_BLOCK_); -}; -goog.inherits(goog.crypt.Sha512_256, goog.crypt.Sha2_64bit); - - -/** @private {!Array} */ -goog.crypt.Sha512_256.INIT_HASH_BLOCK_ = [ - // Section 5.3.6.2 of - // csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf - 0x22312194, 0xFC2BF72C, // H0 - 0x9F555FA3, 0xC84C64C2, // H1 - 0x2393B86B, 0x6F53B151, // H2 - 0x96387719, 0x5940EABD, // H3 - 0x96283EE2, 0xA88EFFE3, // H4 - 0xBE5E1E25, 0x53863992, // H5 - 0x2B0199FC, 0x2C85B8AA, // H6 - 0x0EB72DDC, 0x81C52CA2 // H7 -]; diff --git a/third_party/closure/goog/crypt/sha512_perf.html b/third_party/closure/goog/crypt/sha512_perf.html deleted file mode 100644 index e7cf5d21acc90..0000000000000 --- a/third_party/closure/goog/crypt/sha512_perf.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - -Closure Performance Tests - goog.crypt.Sha512 - - - - - -

Closure Performance Tests - goog.crypt.Sha512

-

-User-agent: - -

- - - - diff --git a/third_party/closure/goog/css/autocomplete.css b/third_party/closure/goog/css/autocomplete.css deleted file mode 100644 index 033ceba42755a..0000000000000 --- a/third_party/closure/goog/css/autocomplete.css +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styles for goog.ui.ac.AutoComplete and its derivatives. - * Note: these styles need some work to get them working properly at various - * font sizes other than the default. - * - * @author pupius@google.com (Daniel Pupius) - * @author annams@google.com (Srinivas Annam) - */ - - -/* - * TODO(annams): Rename (here and in renderer.js) to specify class name as - * goog-autocomplete-renderer - */ -.ac-renderer { - font: normal 13px Arial, sans-serif; - position: absolute; - background: #fff; - border: 1px solid #666; - -moz-box-shadow: 2px 2px 2px rgba(102, 102, 102, .4); - -webkit-box-shadow: 2px 2px 2px rgba(102, 102, 102, .4); - width: 300px; -} - -.ac-row { - cursor: pointer; - padding: .4em; -} - -.ac-highlighted { - font-weight: bold; -} - -.ac-active { - background-color: #b2b4bf; -} diff --git a/third_party/closure/goog/css/bubble.css b/third_party/closure/goog/css/bubble.css deleted file mode 100644 index 4e8d612bffb13..0000000000000 --- a/third_party/closure/goog/css/bubble.css +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2010 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -.goog-bubble-font { - font-size: 80%; - color: #888888; -} - -.goog-bubble-close-button { - background-image:url(//ssl.gstatic.com/closure/bubble_close.jpg); - background-color: white; - background-position: top right; - background-repeat: no-repeat; - width: 16px; - height: 16px; -} - -.goog-bubble-left { - background-image:url(//ssl.gstatic.com/closure/bubble_left.gif); - background-position:left; - background-repeat:repeat-y; - width: 4px; -} - -.goog-bubble-right { - background-image:url(//ssl.gstatic.com/closure/bubble_right.gif); - background-position: right; - background-repeat: repeat-y; - width: 4px; -} - -.goog-bubble-top-right-anchor { - background-image:url(//ssl.gstatic.com/closure/right_anchor_bubble_top.gif); - background-position: center; - background-repeat: no-repeat; - width: 147px; - height: 16px; -} - -.goog-bubble-top-left-anchor { - background-image:url(//ssl.gstatic.com/closure/left_anchor_bubble_top.gif); - background-position: center; - background-repeat: no-repeat; - width: 147px; - height: 16px; -} - -.goog-bubble-top-no-anchor { - background-image:url(//ssl.gstatic.com/closure/no_anchor_bubble_top.gif); - background-position: center; - background-repeat: no-repeat; - width: 147px; - height: 6px; -} - -.goog-bubble-bottom-right-anchor { - background-image:url(//ssl.gstatic.com/closure/right_anchor_bubble_bot.gif); - background-position: center; - background-repeat: no-repeat; - width: 147px; - height: 16px; -} - -.goog-bubble-bottom-left-anchor { - background-image:url(//ssl.gstatic.com/closure/left_anchor_bubble_bot.gif); - background-position: center; - background-repeat: no-repeat; - width: 147px; - height: 16px; -} - -.goog-bubble-bottom-no-anchor { - background-image:url(//ssl.gstatic.com/closure/no_anchor_bubble_bot.gif); - background-position: center; - background-repeat: no-repeat; - width: 147px; - height: 8px; -} - - diff --git a/third_party/closure/goog/css/button.css b/third_party/closure/goog/css/button.css deleted file mode 100644 index b80a92f142dad..0000000000000 --- a/third_party/closure/goog/css/button.css +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styling for buttons rendered by goog.ui.ButtonRenderer. - * - * @author attila@google.com (Attila Bodis) - */ - -.goog-button { - color: #036; - border-color: #036; - background-color: #69c; -} - -/* State: disabled. */ -.goog-button-disabled { - border-color: #333; - color: #333; - background-color: #999; -} - -/* State: hover. */ -.goog-button-hover { - color: #369; - border-color: #369; - background-color: #9cf; -} - -/* State: active. */ -.goog-button-active { - color: #69c; - border-color: #69c; -} diff --git a/third_party/closure/goog/css/charpicker.css b/third_party/closure/goog/css/charpicker.css deleted file mode 100644 index fb33447746c7e..0000000000000 --- a/third_party/closure/goog/css/charpicker.css +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: pupius@google.com (Daniel Pupius) */ -/* Author: cibu@google.com (Cibu Johny) */ - -.goog-char-picker { - background-color: #ddd; - padding: 16px; - border: 1px solid #777; -} - -/* goog.ui.HoverCard */ -.goog-char-picker-hovercard { - border: solid 5px #ffcc33; - min-width: 64px; - max-width: 160px; - padding: 16px; - background-color: white; - text-align: center; - position: absolute; - visibility: hidden; -} - -.goog-char-picker-name { - font-size: x-small; -} - -.goog-char-picker-unicode { - font-size: x-small; - color: GrayText; -} - -.goog-char-picker-char-zoom { - font-size: xx-large; -} - -/* - * grid - */ -.goog-char-picker-grid-container { - border: 1px solid #777; - background-color: #fff; - width: 272px; -} - -.goog-char-picker-grid { - overflow: hidden; - height: 250px; - width: 250px; - position: relative; -} - -.goog-stick { - width: 1px; - overflow: hidden; -} -.goog-stickwrap { - width: 17px; - height: 250px; - float: right; - overflow: auto; -} - -.goog-char-picker-recents { - border: 1px solid #777; - background-color: #fff; - height: 25px; - width: 275px; - margin: 0 0 16px 0; - position: relative; -} - -.goog-char-picker-notice { - font-size: x-small; - height: 16px; - color: GrayText; - margin: 0 0 16px 0; -} - -/* - * Hex entry - */ - -.goog-char-picker-uplus { -} - -.goog-char-picker-input-box { - width: 96px; -} - -.label-input-label { - color: GrayText; -} - -.goog-char-picker-okbutton { -} - -/* - * Grid buttons - */ -.goog-char-picker-grid .goog-flat-button { - position: relative; - width: 24px; - height: 24px; - line-height: 24px; - border-bottom: 1px solid #ddd; - border-right: 1px solid #ddd; - text-align: center; - cursor: pointer; - outline: none; -} - -.goog-char-picker-grid .goog-flat-button-hover, -.goog-char-picker-grid .goog-flat-button-focus { - background-color: #ffcc33; -} - -/* - * goog.ui.Menu - */ - -/* State: resting. */ -.goog-char-picker-button { - border-width: 0px; - margin: 0; - padding: 0; - position: absolute; - background-position: center left; -} - -/* State: resting. */ -.goog-char-picker-menu { - background-color: #fff; - border-color: #ccc #666 #666 #ccc; - border-style: solid; - border-width: 1px; - cursor: default; - margin: 0; - outline: none; - padding: 0; - position: absolute; - max-height: 400px; - overflow-y: auto; - overflow-x: hide; -} - -/* - * goog.ui.MenuItem - */ - -/* State: resting. */ -.goog-char-picker-menu .goog-menuitem { - color: #000; - list-style: none; - margin: 0; - /* 28px on the left for icon or checkbox; 10ex on the right for shortcut. */ - padding: 1px 32px 1px 8px; - white-space: nowrap; -} - -.goog-char-picker-menu2 .goog-menuitem { - color: #000; - list-style: none; - margin: 0; - /* 28px on the left for icon or checkbox; 10ex on the right for shortcut. */ - padding: 1px 32px 1px 8px; - white-space: nowrap; -} - -.goog-char-picker-menu .goog-subtitle { - color: #fff !important; - background-color: #666; - font-weight: bold; - list-style: none; - margin: 0; - /* 28px on the left for icon or checkbox; 10ex on the right for shortcut. */ - padding: 3px 32px 3px 8px; - white-space: nowrap; -} - -/* BiDi override for the resting state. */ -.goog-char-picker-menu .goog-menuitem-rtl { - /* Flip left/right padding for BiDi. */ - padding: 2px 16px 2px 32px !important; -} - -/* State: hover. */ -.goog-char-picker-menu .goog-menuitem-highlight { - background-color: #d6e9f8; -} -/* - * goog.ui.MenuSeparator - */ - -/* State: resting. */ -.goog-char-picker-menu .goog-menuseparator { - border-top: 1px solid #ccc; - margin: 2px 0; - padding: 0; -} - diff --git a/third_party/closure/goog/css/checkbox.css b/third_party/closure/goog/css/checkbox.css deleted file mode 100644 index 2aed8b5188c0d..0000000000000 --- a/third_party/closure/goog/css/checkbox.css +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: pallosp@google.com (Peter Pallos) */ - -/* Sample 3-state checkbox styles. */ - -.goog-checkbox { - border: 1px solid #1C5180; - display: -moz-inline-box; - display: inline-block; - font-size: 1px; /* Fixes the height in IE6 */ - height: 11px; - margin: 0 4px 0 1px; - vertical-align: text-bottom; - width: 11px; -} - -.goog-checkbox-checked { - background: #fff url(//ssl.gstatic.com/closure/check-sprite.gif) no-repeat 2px center; -} - -.goog-checkbox-undetermined { - background: #bbb url(//ssl.gstatic.com/closure/check-sprite.gif) no-repeat 2px center; -} - -.goog-checkbox-unchecked { - background: #fff; -} - -.goog-checkbox-disabled { - border: 1px solid lightgray; - background-position: -7px; -} diff --git a/third_party/closure/goog/css/colorpicker-simplegrid.css b/third_party/closure/goog/css/colorpicker-simplegrid.css deleted file mode 100644 index b98f5dccf6d28..0000000000000 --- a/third_party/closure/goog/css/colorpicker-simplegrid.css +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: pupius@google.com (Daniel Pupius) */ - -/* - Styles to make the colorpicker look like the old gmail color picker - NOTE: without CSS scoping this will override styles defined in palette.css -*/ -.goog-palette { - outline: none; - cursor: default; -} - -.goog-palette-table { - border: 1px solid #666; - border-collapse: collapse; -} - -.goog-palette-cell { - height: 13px; - width: 15px; - margin: 0; - border: 0; - text-align: center; - vertical-align: middle; - border-right: 1px solid #666; - font-size: 1px; -} - -.goog-palette-colorswatch { - position: relative; - height: 13px; - width: 15px; - border: 1px solid #666; -} - -.goog-palette-cell-hover .goog-palette-colorswatch { - border: 1px solid #FFF; -} - -.goog-palette-cell-selected .goog-palette-colorswatch { - border: 1px solid #000; - color: #fff; -} diff --git a/third_party/closure/goog/css/combobox.css b/third_party/closure/goog/css/combobox.css deleted file mode 100644 index dd1571ab453ec..0000000000000 --- a/third_party/closure/goog/css/combobox.css +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: pupius@google.com (Daniel Pupius) */ -/* Author: pallosp@google.com (Peter Pallos) */ - -/* Styles for goog.ui.ComboBox and its derivatives. */ - - -.goog-combobox { - background: #ddd url(//ssl.gstatic.com/closure/button-bg.gif) repeat-x scroll left top; - border: 1px solid #b5b6b5; - font: normal small arial, sans-serif; -} - -.goog-combobox input { - background-color: #fff; - border: 0; - border-right: 1px solid #b5b6b5; - color: #000; - font: normal small arial, sans-serif; - margin: 0; - padding: 0 0 0 2px; - vertical-align: bottom; /* override demo.css */ - width: 200px; -} - -.goog-combobox input.label-input-label { - background-color: #fff; - color: #aaa; -} - -.goog-combobox .goog-menu { - margin-top: -1px; - width: 219px; /* input width + button width + 3 * 1px border */ - z-index: 1000; -} - -.goog-combobox-button { - cursor: pointer; - display: inline-block; - font-size: 10px; - text-align: center; - width: 16px; -} - -/* IE6 only hack */ -* html .goog-combobox-button { - padding: 0 3px; -} diff --git a/third_party/closure/goog/css/common.css b/third_party/closure/goog/css/common.css deleted file mode 100644 index de140b88eed54..0000000000000 --- a/third_party/closure/goog/css/common.css +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Cross-browser implementation of the "display: inline-block" CSS property. - * See http://www.w3.org/TR/CSS21/visuren.html#propdef-display for details. - * Tested on IE 6 & 7, FF 1.5 & 2.0, Safari 2 & 3, Webkit, and Opera 9. - * - * @author attila@google.com (Attila Bodis) - */ - -/* - * Default rule; only Safari, Webkit, and Opera handle it without hacks. - */ -.goog-inline-block { - position: relative; - display: -moz-inline-box; /* Ignored by FF3 and later. */ - display: inline-block; -} - -/* - * Pre-IE7 IE hack. On IE, "display: inline-block" only gives the element - * layout, but doesn't give it inline behavior. Subsequently setting display - * to inline does the trick. - */ -* html .goog-inline-block { - display: inline; -} - -/* - * IE7-only hack. On IE, "display: inline-block" only gives the element - * layout, but doesn't give it inline behavior. Subsequently setting display - * to inline does the trick. - */ -*:first-child+html .goog-inline-block { - display: inline; -} diff --git a/third_party/closure/goog/css/css3button.css b/third_party/closure/goog/css/css3button.css deleted file mode 100644 index a26306f397b0a..0000000000000 --- a/third_party/closure/goog/css/css3button.css +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2010 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: slightlyoff@google.com (Alex Russell) */ -/* Author: eae@google.com (Emil A Eklund) */ - -/* Imageless button styles. */ -.goog-css3-button { - margin: 0 2px; - padding: 3px 6px; - text-align: center; - vertical-align: middle; - white-space: nowrap; - cursor: default; - outline: none; - font-family: Arial, sans-serif; - color: #000; - border: 1px solid #bbb; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - /* TODO(eae): Change this to -webkit-linear-gradient once - https://bugs.webkit.org/show_bug.cgi?id=28152 is resolved. */ - background: -webkit-gradient(linear, 0% 40%, 0% 70%, from(#f9f9f9), - to(#e3e3e3)); - /* @alternate */ background: -moz-linear-gradient(top, #f9f9f9, #e3e3e3); -} - - -/* Styles for different states (hover, active, focused, open, checked). */ -.goog-css3-button-hover { - border-color: #939393 !important; -} - -.goog-css3-button-focused { - border-color: #444; -} - -.goog-css3-button-active, .goog-css3-button-open, .goog-css3-button-checked { - border-color: #444 !important; - background: -webkit-gradient(linear, 0% 40%, 0% 70%, from(#e3e3e3), - to(#f9f9f9)); - /* @alternate */ background: -moz-linear-gradient(top, #e3e3e3, #f9f9f9); -} - -.goog-css3-button-disabled { - color: #888; -} - -.goog-css3-button-primary { - font-weight: bold; -} - - -/* - * Pill (collapsed border) styles. - */ -.goog-css3-button-collapse-right { - margin-right: 0 !important; - border-right: 1px solid #bbb; - -webkit-border-top-right-radius: 0px; - -webkit-border-bottom-right-radius: 0px; - -moz-border-radius-topright: 0px; - -moz-border-radius-bottomright: 0px; -} - -.goog-css3-button-collapse-left { - border-left: 1px solid #f9f9f9; - margin-left: 0 !important; - -webkit-border-top-left-radius: 0px; - -webkit-border-bottom-left-radius: 0px; - -moz-border-radius-topleft: 0px; - -moz-border-radius-bottomleft: 0px; -} diff --git a/third_party/closure/goog/css/css3menubutton.css b/third_party/closure/goog/css/css3menubutton.css deleted file mode 100644 index a02070067e58c..0000000000000 --- a/third_party/closure/goog/css/css3menubutton.css +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for buttons created by goog.ui.Css3MenuButtonRenderer. - * - * @author attila@google.com (Attila Bodis) - * @author dalewis@google.com (Darren Lewis) - */ - -/* Dropdown arrow style. */ -.goog-css3-button-dropdown { - height: 16px; - width: 7px; - /* Client apps may override the URL at which they serve the sprite. */ - background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -388px 0; - vertical-align: top; - margin-left: 3px; -} diff --git a/third_party/closure/goog/css/custombutton.css b/third_party/closure/goog/css/custombutton.css deleted file mode 100644 index 1f17052708284..0000000000000 --- a/third_party/closure/goog/css/custombutton.css +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styling for custom buttons rendered by goog.ui.CustomButtonRenderer. - * - * @author attila@google.com (Attila Bodis) - */ - -.goog-custom-button { - margin: 2px; - border: 0; - padding: 0; - font-family: Arial, sans-serif; - color: #000; - /* Client apps may override the URL at which they serve the image. */ - background: #ddd url(//ssl.gstatic.com/editor/button-bg.png) repeat-x top left; - text-decoration: none; - list-style: none; - vertical-align: middle; - cursor: default; - outline: none; -} - -/* Pseudo-rounded corners. */ -.goog-custom-button-outer-box, -.goog-custom-button-inner-box { - border-style: solid; - border-color: #aaa; - vertical-align: top; -} - -.goog-custom-button-outer-box { - margin: 0; - border-width: 1px 0; - padding: 0; -} - -.goog-custom-button-inner-box { - margin: 0 -1px; - border-width: 0 1px; - padding: 3px 4px; - white-space: nowrap; /* Prevents buttons from line breaking on android. */ -} - -/* Pre-IE7 IE hack; ignored by IE7 and all non-IE browsers. */ -* html .goog-custom-button-inner-box { - /* IE6 needs to have the box shifted to make the borders line up. */ - left: -1px; -} -/* Pre-IE7 BiDi fixes. */ -* html .goog-custom-button-rtl .goog-custom-button-outer-box { - /* @noflip */ left: -1px; -} -* html .goog-custom-button-rtl .goog-custom-button-inner-box { - /* @noflip */ right: auto; -} - -/* IE7-only hack; ignored by all other browsers. */ -*:first-child+html .goog-custom-button-inner-box { - /* IE7 needs to have the box shifted to make the borders line up. */ - left: -1px; -} -/* IE7 BiDi fix. */ -*:first-child+html .goog-custom-button-rtl .goog-custom-button-inner-box { - /* @noflip */ left: 1px; -} - -/* Safari-only hacks. */ -::root .goog-custom-button, -::root .goog-custom-button-outer-box { - /* Required to make pseudo-rounded corners work on Safari. */ - line-height: 0; -} - -::root .goog-custom-button-inner-box { - /* Required to make pseudo-rounded corners work on Safari. */ - line-height: normal; -} - -/* State: disabled. */ -.goog-custom-button-disabled { - background-image: none !important; - opacity: 0.3; - -moz-opacity: 0.3; - filter: alpha(opacity=30); -} - -.goog-custom-button-disabled .goog-custom-button-outer-box, -.goog-custom-button-disabled .goog-custom-button-inner-box { - color: #333 !important; - border-color: #999 !important; -} - -/* Pre-IE7 IE hack; ignored by IE7 and all non-IE browsers. */ -* html .goog-custom-button-disabled { - margin: 2px 1px !important; - padding: 0 1px !important; -} - -/* IE7-only hack; ignored by all other browsers. */ -*:first-child+html .goog-custom-button-disabled { - margin: 2px 1px !important; - padding: 0 1px !important; -} - -/* State: hover. */ -.goog-custom-button-hover .goog-custom-button-outer-box, -.goog-custom-button-hover .goog-custom-button-inner-box { - border-color: #9cf #69e #69e #7af !important; /* Hover border wins. */ -} - -/* State: active, checked. */ -.goog-custom-button-active, -.goog-custom-button-checked { - background-color: #bbb; - background-position: bottom left; -} - -/* State: focused. */ -.goog-custom-button-focused .goog-custom-button-outer-box, -.goog-custom-button-focused .goog-custom-button-inner-box { - border-color: orange; -} - -/* Pill (collapsed border) styles. */ -.goog-custom-button-collapse-right, -.goog-custom-button-collapse-right .goog-custom-button-outer-box, -.goog-custom-button-collapse-right .goog-custom-button-inner-box { - margin-right: 0; -} - -.goog-custom-button-collapse-left, -.goog-custom-button-collapse-left .goog-custom-button-outer-box, -.goog-custom-button-collapse-left .goog-custom-button-inner-box { - margin-left: 0; -} - -.goog-custom-button-collapse-left .goog-custom-button-inner-box { - border-left: 1px solid #fff; -} - -.goog-custom-button-collapse-left.goog-custom-button-checked -.goog-custom-button-inner-box { - border-left: 1px solid #ddd; -} - -/* Pre-IE7 IE hack; ignored by IE7 and all non-IE browsers. */ -* html .goog-custom-button-collapse-left .goog-custom-button-inner-box { - left: 0; -} - -/* IE7-only hack; ignored by all other browsers. */ -*:first-child+html .goog-custom-button-collapse-left -.goog-custom-button-inner-box { - left: 0; -} diff --git a/third_party/closure/goog/css/datepicker.css b/third_party/closure/goog/css/datepicker.css deleted file mode 100644 index 6d5b914d035b1..0000000000000 --- a/third_party/closure/goog/css/datepicker.css +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for a goog.ui.DatePicker. - * - * @author arv@google.com (Erik Arvidsson) - */ - -.goog-date-picker, -.goog-date-picker th, -.goog-date-picker td { - font: 13px Arial, sans-serif; -} - -.goog-date-picker { - -moz-user-focus: normal; - -moz-user-select: none; - position: relative; - border: 1px solid #000; - float: left; - padding: 2px; - color: #000; - background: #c3d9ff; - cursor: default; -} - -.goog-date-picker th { - text-align: center; -} - -.goog-date-picker td { - text-align: center; - vertical-align: middle; - padding: 1px 3px; -} - - -.goog-date-picker-menu { - position: absolute; - background: threedface; - border: 1px solid gray; - -moz-user-focus: normal; - z-index: 1; - outline: none; -} - -.goog-date-picker-menu ul { - list-style: none; - margin: 0px; - padding: 0px; -} - -.goog-date-picker-menu ul li { - cursor: default; -} - -.goog-date-picker-menu-selected { - background: #ccf; -} - -.goog-date-picker th { - font-size: .9em; -} - -.goog-date-picker td div { - float: left; -} - -.goog-date-picker button { - padding: 0px; - margin: 1px 0; - border: 0; - color: #20c; - font-weight: bold; - background: transparent; -} - -.goog-date-picker-date { - background: #fff; -} - -.goog-date-picker-week, -.goog-date-picker-wday { - padding: 1px 3px; - border: 0; - border-color: #a2bbdd; - border-style: solid; -} - -.goog-date-picker-week { - border-right-width: 1px; -} - -.goog-date-picker-wday { - border-bottom-width: 1px; -} - -.goog-date-picker-head td { - text-align: center; -} - -/** Use td.className instead of !important */ -td.goog-date-picker-today-cont { - text-align: center; -} - -/** Use td.className instead of !important */ -td.goog-date-picker-none-cont { - text-align: center; -} - -.goog-date-picker-month { - min-width: 11ex; - white-space: nowrap; -} - -.goog-date-picker-year { - min-width: 6ex; - white-space: nowrap; -} - -.goog-date-picker-monthyear { - white-space: nowrap; -} - -.goog-date-picker table { - border-collapse: collapse; -} - -.goog-date-picker-other-month { - color: #888; -} - -.goog-date-picker-wkend-start, -.goog-date-picker-wkend-end { - background: #eee; -} - -/** Use td.className instead of !important */ -td.goog-date-picker-selected { - background: #c3d9ff; -} - -.goog-date-picker-today { - background: #9ab; - font-weight: bold !important; - border-color: #246 #9bd #9bd #246; - color: #fff; -} diff --git a/third_party/closure/goog/css/dialog.css b/third_party/closure/goog/css/dialog.css deleted file mode 100644 index 6bf9020ab1b39..0000000000000 --- a/third_party/closure/goog/css/dialog.css +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for goog.ui.Dialog. - * - * @author ssaviano@google.com (Steven Saviano) - * @author attila@google.com (Attila Bodis) - */ - - -.modal-dialog { - background: #c1d9ff; - border: 1px solid #3a5774; - color: #000; - padding: 4px; - position: absolute; -} - -.modal-dialog a, -.modal-dialog a:link, -.modal-dialog a:visited { - color: #06c; - cursor: pointer; -} - -.modal-dialog-bg { - background: #666; - left: 0; - position: absolute; - top: 0; -} - -.modal-dialog-title { - background: #e0edfe; - color: #000; - cursor: pointer; - font-size: 120%; - font-weight: bold; - - /* Add padding on the right to ensure the close button has room. */ - padding: 8px 31px 8px 8px; - - position: relative; - _zoom: 1; /* Ensures proper width in IE6 RTL. */ -} - -.modal-dialog-title-close { - /* Client apps may override the URL at which they serve the sprite. */ - background: #e0edfe url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -528px 0; - cursor: default; - height: 15px; - position: absolute; - right: 10px; - top: 8px; - width: 15px; - vertical-align: middle; -} - -.modal-dialog-buttons, -.modal-dialog-content { - background-color: #fff; - padding: 8px; -} - -.goog-buttonset-default { - font-weight: bold; -} diff --git a/third_party/closure/goog/css/dimensionpicker.css b/third_party/closure/goog/css/dimensionpicker.css deleted file mode 100644 index 5c51ab85f62a3..0000000000000 --- a/third_party/closure/goog/css/dimensionpicker.css +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styling for dimension pickers rendered by goog.ui.DimensionPickerRenderer. - * - * Author: robbyw@google.com (Robby Walker) - * Author: abefettig@google.com (Abe Fettig) - */ - -.goog-dimension-picker { - font-size: 18px; - padding: 4px; -} - -.goog-dimension-picker div { - position: relative; -} - -.goog-dimension-picker div.goog-dimension-picker-highlighted { -/* Client apps must provide the URL at which they serve the image. */ - /* background: url(dimension-highlighted.png); */ - left: 0; - overflow: hidden; - position: absolute; - top: 0; -} - -.goog-dimension-picker-unhighlighted { - /* Client apps must provide the URL at which they serve the image. */ - /* background: url(dimension-unhighlighted.png); */ -} - -.goog-dimension-picker-status { - font-size: 10pt; - text-align: center; -} - -.goog-dimension-picker div.goog-dimension-picker-mousecatcher { - left: 0; - position: absolute !important; - top: 0; -} diff --git a/third_party/closure/goog/css/dragdropdetector.css b/third_party/closure/goog/css/dragdropdetector.css deleted file mode 100644 index 88266d6ccffa3..0000000000000 --- a/third_party/closure/goog/css/dragdropdetector.css +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styling for the drag drop detector. - * - * Author: robbyw@google.com (Robby Walker) - * Author: wcrosby@google.com (Wayne Crosby) - */ - -.goog-dragdrop-w3c-editable-iframe { - position: absolute; - width: 100%; - height: 10px; - top: -150px; - left: 0; - z-index: 10000; - padding: 0; - overflow: hidden; - opacity: 0; - -moz-opacity: 0; -} - -.goog-dragdrop-ie-editable-iframe { - width: 100%; - height: 5000px; -} - -.goog-dragdrop-ie-input { - width: 100%; - height: 5000px; -} - -.goog-dragdrop-ie-div { - position: absolute; - top: -5000px; - left: 0; - width: 100%; - height: 5000px; - z-index: 10000; - background-color: white; - filter: alpha(opacity=0); - overflow: hidden; -} diff --git a/third_party/closure/goog/css/editor/bubble.css b/third_party/closure/goog/css/editor/bubble.css deleted file mode 100644 index c76f98f77c32a..0000000000000 --- a/third_party/closure/goog/css/editor/bubble.css +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2005 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Bubble styles. - * - * @author robbyw@google.com (Robby Walker) - * @author nicksantos@google.com (Nick Santos) - * @author jparent@google.com (Julie Parent) - */ - -div.tr_bubble { - position: absolute; - - background-color: #e0ecff; - border: 1px solid #99c0ff; - border-radius: 2px; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - font-size: 83%; - font-family: Arial, Helvetica, sans-serif; - padding: 2px 19px 6px 6px; - white-space: nowrap; -} - -.tr_bubble_link { - color: #00c; - text-decoration: underline; - cursor: pointer; - font-size: 100%; -} - -.tr_bubble .tr_option-link, -.tr_bubble #tr_delete-image, -.tr_bubble #tr_module-options-link { - font-size: 83%; -} - -.tr_bubble_closebox { - position: absolute; - cursor: default; - background: url(//ssl.gstatic.com/editor/bubble_closebox.gif) top left no-repeat; - padding: 0; - margin: 0; - width: 10px; - height: 10px; - top: 3px; - right: 5px; -} - -div.tr_bubble_panel { - padding: 2px 0 1px; -} - -div.tr_bubble_panel_title { - display: none; -} - -div.tr_multi_bubble div.tr_bubble_panel_title { - margin-right: 1px; - display: block; - float: left; - width: 50px; -} - -div.tr_multi_bubble div.tr_bubble_panel { - padding: 2px 0 1px; - margin-right: 50px; -} diff --git a/third_party/closure/goog/css/editor/dialog.css b/third_party/closure/goog/css/editor/dialog.css deleted file mode 100644 index 8868a1054c583..0000000000000 --- a/third_party/closure/goog/css/editor/dialog.css +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styles for Editor dialogs and their sub-components. - * - * @author marcosalmeida@google.com (Marcos Almeida) - */ - - -.tr-dialog { - width: 475px; -} - -.tr-dialog .goog-tab-content { - margin: 0; - border: 1px solid #6b90da; - padding: 4px 8px; - background: #fff; - overflow: auto; -} - -.tr-tabpane { - font-size: 10pt; - padding: 1.3ex 0; -} - -.tr-tabpane-caption { - font-size: 10pt; - margin-bottom: 0.7ex; - background-color: #fffaf5; - line-height: 1.3em; -} - -.tr-tabpane .goog-tab-content { - border: none; - padding: 5px 7px 1px; -} - -.tr-tabpane .goog-tab { - background-color: #fff; - border: none; - width: 136px; - line-height: 1.3em; - margin-bottom: 0.7ex; -} - -.tr-tabpane .goog-tab { - text-decoration: underline; - color: blue; - cursor: pointer; -} - -.tr-tabpane .goog-tab-selected { - font-weight: bold; - text-decoration: none; - color: black; -} - -.tr-tabpane .goog-tab input { - margin: -2px 5px 0 0; -} diff --git a/third_party/closure/goog/css/editor/equationeditor.css b/third_party/closure/goog/css/editor/equationeditor.css deleted file mode 100644 index b6aff348b360d..0000000000000 --- a/third_party/closure/goog/css/editor/equationeditor.css +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * The CSS definition for everything inside equation editor dialog. - * - * Author: yoah@google.com (Yoah Bar-David) - * Author: kfk@google.com (Ming Zhang) - */ - -.ee-modal-dialog { - width: 475px; -} - -.ee-content { - background: #FFF; - border: 1px solid #369; - overflow: auto; - padding: 4px 8px; -} - -.ee-tex { - border: 1px solid #000; - display: block; - height: 7.5em; - margin: 4px 0 10px 0; - width: 100%; -} - -.ee-section-title { - font-weight: bold; -} - -.ee-section-title-floating { - float: left; -} - -#ee-section-learn-more { - float: right; -} - -.ee-preview-container { - border: 1px dashed #ccc; - height: 80px; - margin: 4px 0 10px 0; - width: 100%; - overflow: auto; -} - -.ee-warning { - color: #F00; -} - -.ee-palette { - border: 1px solid #aaa; - left: 0; - outline: none; - position: absolute; -} - -.ee-palette-table { - border: 0; - border-collapse: separate; -} - -.ee-palette-cell { - background: #F0F0F0; - border: 1px solid #FFF; - margin: 0; - padding: 1px; -} - -.ee-palette-cell-hover { - background: #E2ECF9 !important; - border: 1px solid #000; - padding: 1px; -} - -.ee-palette-cell-selected { - background: #F0F0F0; - border: 1px solid #CCC !important; - padding: 1px; -} - -.ee-menu-palette-table { - margin-right: 10px; -} - -.ee-menu-palette { - outline: none; - padding-top: 2px; -} - -.ee-menu-palette-cell { - background: #F0F0F0 none repeat scroll 0 0; - border-color: #888 #AAA #AAA #888; - border-style: solid; - border-width: 1px; -} -.ee-menu-palette-cell-hover, -.ee-menu-palette-cell-selected { - background: #F0F0F0; -} - -.ee-palette-item, -.ee-menu-palette-item { - background-image: url(//ssl.gstatic.com/editor/ee-palettes.gif); -} - diff --git a/third_party/closure/goog/css/editor/linkdialog.css b/third_party/closure/goog/css/editor/linkdialog.css deleted file mode 100644 index a58a4b2a222b8..0000000000000 --- a/third_party/closure/goog/css/editor/linkdialog.css +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/** - * Styles for the Editor's Edit Link dialog. - * - * @author marcosalmeida@google.com (Marcos Almeida) - */ - - -.tr-link-dialog-explanation-text { - font-size: 83%; - margin-top: 15px; -} - -.tr-link-dialog-target-input { - width: 98%; /* 98% prevents scroll bars in standards mode. */ - /* Input boxes for URLs and email address should always be LTR. */ - direction: ltr; -} - -.tr-link-dialog-email-warning { - text-align: center; - color: #c00; - font-weight: bold; -} - -.tr_pseudo-link { - color: #00c; - text-decoration: underline; - cursor: pointer; -} diff --git a/third_party/closure/goog/css/filteredmenu.css b/third_party/closure/goog/css/filteredmenu.css deleted file mode 100644 index b43a113253af8..0000000000000 --- a/third_party/closure/goog/css/filteredmenu.css +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: pupius@google.com (Daniel Pupius) */ - -/* goog.ui.FilteredMenu */ - -.goog-menu-filter { - margin: 2px; - border: 1px solid silver; - background: white; - overflow: hidden; -} - -.goog-menu-filter div { - color: gray; - position: absolute; - padding: 1px; -} - -.goog-menu-filter input { - margin: 0; - border: 0; - background: transparent; - width: 100%; -} diff --git a/third_party/closure/goog/css/filterobservingmenuitem.css b/third_party/closure/goog/css/filterobservingmenuitem.css deleted file mode 100644 index d48a609ac48f2..0000000000000 --- a/third_party/closure/goog/css/filterobservingmenuitem.css +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: pupius@google.com (Daniel Pupius) */ - -/* goog.ui.FilterObservingMenuItem */ - -.goog-filterobsmenuitem { - padding: 2px 5px; - margin: 0; - list-style: none; -} - -.goog-filterobsmenuitem-highlight { - background-color: #4279A5; - color: #FFF; -} - -.goog-filterobsmenuitem-disabled { - color: #999; -} diff --git a/third_party/closure/goog/css/flatbutton.css b/third_party/closure/goog/css/flatbutton.css deleted file mode 100644 index 1cc39b6916235..0000000000000 --- a/third_party/closure/goog/css/flatbutton.css +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styling for flat buttons created by goog.ui.FlatButtonRenderer. - * - * @author brianp@google.com (Brian Peterson) - */ - -.goog-flat-button { - position: relative; - /*width: 20ex;*/ - margin: 2px; - border: 1px solid #000; - padding: 2px 6px; - font: normal 13px "Trebuchet MS", Tahoma, Arial, sans-serif; - color: #fff; - background-color: #8c2425; - cursor: pointer; - outline: none; -} - -/* State: disabled. */ -.goog-flat-button-disabled { - border-color: #888; - color: #888; - background-color: #ccc; - cursor: default; -} - -/* State: hover. */ -.goog-flat-button-hover { - border-color: #8c2425; - color: #8c2425; - background-color: #eaa4a5; -} - -/* State: active, selected, checked. */ -.goog-flat-button-active, -.goog-flat-button-selected, -.goog-flat-button-checked { - border-color: #5b4169; - color: #5b4169; - background-color: #d1a8ea; -} - -/* State: focused. */ -.goog-flat-button-focused { - border-color: #5b4169; -} - -/* Pill (collapsed border) styles. */ -.goog-flat-button-collapse-right { - margin-right: 0; -} - -.goog-flat-button-collapse-left { - margin-left: 0; - border-left: none; -} diff --git a/third_party/closure/goog/css/flatmenubutton.css b/third_party/closure/goog/css/flatmenubutton.css deleted file mode 100644 index 577821782c4e2..0000000000000 --- a/third_party/closure/goog/css/flatmenubutton.css +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for buttons created by goog.ui.FlatMenuButtonRenderer. - * - * @author attila@google.com (Attila Bodis) - * @author tlb@google.com (Thierry Le Boulenge) - */ - - -.goog-flat-menu-button { - background-color: #fff; - border: 1px solid #c9c9c9; - color: #333; - cursor: pointer; - font: normal 95%; - list-style: none; - margin: 0 2px; - outline: none; - padding: 1px 4px; - position: relative; - text-decoration: none; - vertical-align: middle; -} - -.goog-flat-menu-button-disabled * { - border-color: #ccc; - color: #999; - cursor: default; -} - -.goog-flat-menu-button-hover { - border-color: #9cf #69e #69e #7af !important; /* Hover border wins. */ -} - -.goog-flat-menu-button-active { - background-color: #bbb; - background-position: bottom left; -} - -.goog-flat-menu-button-focused { - border-color: #bbb; -} - -.goog-flat-menu-button-caption { - padding-right: 10px; - vertical-align: top; -} - -.goog-flat-menu-button-dropdown { - /* Client apps may override the URL at which they serve the sprite. */ - background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -388px 0; - position: absolute; - right: 2px; - top: 0; - vertical-align: top; - width: 7px; -} diff --git a/third_party/closure/goog/css/hovercard.css b/third_party/closure/goog/css/hovercard.css deleted file mode 100644 index 2d64e4fbf018d..0000000000000 --- a/third_party/closure/goog/css/hovercard.css +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: larrypo@google.com (Larry Powelson) */ - -.goog-hovercard div { - border: solid 5px #69748C; - width: 300px; - height: 115px; - background-color: white; - font-family: arial, sans-serif; -} - -.goog-hovercard .goog-shadow { - border: transparent; - background-color: black; - filter: alpha(Opacity=1); - opacity: 0.01; - -moz-opacity: 0.01; -} - -.goog-hovercard table { - border-collapse: collapse; - border-spacing: 0px; -} - -.goog-hovercard-icons td { - border-bottom: 1px solid #ccc; - padding: 0px; - margin: 0px; - text-align: center; - height: 19px; - width: 100px; - font-size: 90%; -} - -.goog-hovercard-icons td + td { - border-left: 1px solid #ccc; -} - -.goog-hovercard-content { - border-collapse: collapse; -} - -.goog-hovercard-content td { - padding-left: 15px; -} diff --git a/third_party/closure/goog/css/hsvapalette.css b/third_party/closure/goog/css/hsvapalette.css deleted file mode 100644 index ec52e3927eec1..0000000000000 --- a/third_party/closure/goog/css/hsvapalette.css +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * All Rights Reserved. - * - * Styles for the HSV color palette. - * - * @author smcbride@google.com (Sean McBride) - * @author arv@google.com (Erik Arvidsson) - * @author manucornet@google.com (Manu Cornet) - */ - -.goog-hsva-palette, -.goog-hsva-palette-sm { - position: relative; - border: 1px solid #999; - border-color: #ccc #999 #999 #ccc; - width: 442px; - height: 276px; -} - -.goog-hsva-palette-sm { - width: 205px; - height: 185px; -} - -.goog-hsva-palette label span, -.goog-hsva-palette-sm label span { - display: none; -} - -.goog-hsva-palette-hs-backdrop, -.goog-hsva-palette-sm-hs-backdrop, -.goog-hsva-palette-hs-image, -.goog-hsva-palette-sm-hs-image { - position: absolute; - top: 10px; - left: 10px; - width: 256px; - height: 256px; - border: 1px solid #999; -} - -.goog-hsva-palette-sm-hs-backdrop, -.goog-hsva-palette-sm-hs-image { - top: 45px; - width: 128px; - height: 128px; -} - -.goog-hsva-palette-hs-backdrop, -.goog-hsva-palette-sm-hs-backdrop { - background-color: #000; -} - -.goog-hsva-palette-hs-image, -.goog-hsva-palette-v-image, -.goog-hsva-palette-a-image, -.goog-hsva-palette-hs-handle, -.goog-hsva-palette-v-handle, -.goog-hsva-palette-a-handle, -.goog-hsva-palette-swatch-backdrop { - background-image: url(//ssl.gstatic.com/closure/hsva-sprite.png); -} - -.goog-hsva-palette-noalpha .goog-hsva-palette-hs-image, -.goog-hsva-palette-noalpha .goog-hsva-palette-v-image, -.goog-hsva-palette-noalpha .goog-hsva-palette-a-image, -.goog-hsva-palette-noalpha .goog-hsva-palette-hs-handle, -.goog-hsva-palette-noalpha .goog-hsva-palette-v-handle, -.goog-hsva-palette-noalpha .goog-hsva-palette-a-handle, -.goog-hsva-palette-noalpha .goog-hsva-palette-swatch-backdrop { - background-image: url(//ssl.gstatic.com/closure/hsva-sprite.gif); -} - -.goog-hsva-palette-sm-hs-image, -.goog-hsva-palette-sm-v-image, -.goog-hsva-palette-sm-a-image, -.goog-hsva-palette-sm-hs-handle, -.goog-hsva-palette-sm-v-handle, -.goog-hsva-palette-sm-a-handle, -.goog-hsva-palette-sm-swatch-backdrop { - background-image: url(//ssl.gstatic.com/closure/hsva-sprite-sm.png); -} - -.goog-hsva-palette-noalpha .goog-hsva-palette-sm-hs-image, -.goog-hsva-palette-noalpha .goog-hsva-palette-sm-v-image, -.goog-hsva-palette-noalpha .goog-hsva-palette-sm-a-image, -.goog-hsva-palette-noalpha .goog-hsva-palette-sm-hs-handle, -.goog-hsva-palette-noalpha .goog-hsva-palette-sm-v-handle, -.goog-hsva-palette-noalpha .goog-hsva-palette-sm-a-handle, -.goog-hsva-palette-noalpha .goog-hsva-palette-swatch-backdrop { - background-image: url(//ssl.gstatic.com/closure/hsva-sprite-sm.gif); -} - -.goog-hsva-palette-hs-image, -.goog-hsva-palette-sm-hs-image { - background-position: 0 0; -} - -.goog-hsva-palette-hs-handle, -.goog-hsva-palette-sm-hs-handle { - position: absolute; - left: 5px; - top: 5px; - width: 11px; - height: 11px; - overflow: hidden; - background-position: 0 -256px; -} - -.goog-hsva-palette-sm-hs-handle { - top: 40px; - background-position: 0 -128px; -} - -.goog-hsva-palette-v-image, -.goog-hsva-palette-a-image, -.goog-hsva-palette-sm-v-image, -.goog-hsva-palette-sm-a-image { - position: absolute; - top: 10px; - left: 286px; - width: 19px; - height: 256px; - border: 1px solid #999; - background-color: #fff; - background-position: -256px 0; -} - -.goog-hsva-palette-a-image { - left: 325px; - background-position: -275px 0; -} - -.goog-hsva-palette-sm-v-image, -.goog-hsva-palette-sm-a-image { - top: 45px; - left: 155px; - width: 9px; - height: 128px; - background-position: -128px 0; -} - -.goog-hsva-palette-sm-a-image { - left: 182px; - background-position: -137px 0; -} - -.goog-hsva-palette-v-handle, -.goog-hsva-palette-a-handle, -.goog-hsva-palette-sm-v-handle, -.goog-hsva-palette-sm-a-handle { - position: absolute; - top: 5px; - left: 279px; - width: 35px; - height: 11px; - background-position: -11px -256px; - overflow: hidden; -} - -.goog-hsva-palette-a-handle { - left: 318px; -} - -.goog-hsva-palette-sm-v-handle, -.goog-hsva-palette-sm-a-handle { - top: 40px; - left: 148px; - width: 25px; - background-position: -11px -128px; -} - -.goog-hsva-palette-sm-a-handle { - left: 175px; -} - -.goog-hsva-palette-swatch, -.goog-hsva-palette-swatch-backdrop, -.goog-hsva-palette-sm-swatch, -.goog-hsva-palette-sm-swatch-backdrop { - position: absolute; - top: 10px; - right: 10px; - width: 65px; - height: 65px; - border: 1px solid #999; - background-color: #fff; - background-position: -294px 0; -} - -.goog-hsva-palette-sm-swatch, -.goog-hsva-palette-sm-swatch-backdrop { - top: 10px; - right: auto; - left: 10px; - width: 30px; - height: 22px; - background-position: -36px -128px; -} - -.goog-hsva-palette-swatch, -.goog-hsva-palette-sm-swatch { - z-index: 5; -} - -.goog-hsva-palette-swatch-backdrop, -.goog-hsva-palette-sm-swatch-backdrop { - z-index: 1; -} - -.goog-hsva-palette-input, -.goog-hsva-palette-sm-input { - position: absolute; - top: 85px; - right: 10px; - width: 65px; - font-size: 80%; -} - -.goog-hsva-palette-sm-input { - top: 10px; - right: auto; - left: 50px; -} diff --git a/third_party/closure/goog/css/hsvpalette.css b/third_party/closure/goog/css/hsvpalette.css deleted file mode 100644 index 8449ed59aa44e..0000000000000 --- a/third_party/closure/goog/css/hsvpalette.css +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * All Rights Reserved. - * - * Styles for the HSV color palette. - * - * @author smcbride@google.com (Sean McBride) - * @author arv@google.com (Erik Arvidsson) - * @author manucornet@google.com (Manu Cornet) - */ - -.goog-hsv-palette, -.goog-hsv-palette-sm { - position: relative; - border: 1px solid #999; - border-color: #ccc #999 #999 #ccc; - width: 400px; - height: 276px; -} - -.goog-hsv-palette-sm { - width: 182px; - height: 185px; -} - -.goog-hsv-palette label span, -.goog-hsv-palette-sm label span { - display: none; -} - -.goog-hsv-palette-hs-backdrop, -.goog-hsv-palette-sm-hs-backdrop, -.goog-hsv-palette-hs-image, -.goog-hsv-palette-sm-hs-image { - position: absolute; - top: 10px; - left: 10px; - width: 256px; - height: 256px; - border: 1px solid #999; -} - -.goog-hsv-palette-sm-hs-backdrop, -.goog-hsv-palette-sm-hs-image { - top: 45px; - width: 128px; - height: 128px; -} - -.goog-hsv-palette-hs-backdrop, -.goog-hsv-palette-sm-hs-backdrop { - background-color: #000; -} - -.goog-hsv-palette-hs-image, -.goog-hsv-palette-v-image, -.goog-hsv-palette-hs-handle, -.goog-hsv-palette-v-handle { - background-image: url(//ssl.gstatic.com/closure/hsv-sprite.png); -} - -.goog-hsv-palette-noalpha .goog-hsv-palette-hs-image, -.goog-hsv-palette-noalpha .goog-hsv-palette-v-image, -.goog-hsv-palette-noalpha .goog-hsv-palette-hs-handle, -.goog-hsv-palette-noalpha .goog-hsv-palette-v-handle { - background-image: url(//ssl.gstatic.com/closure/hsv-sprite.gif); -} - -.goog-hsv-palette-sm-hs-image, -.goog-hsv-palette-sm-v-image, -.goog-hsv-palette-sm-hs-handle, -.goog-hsv-palette-sm-v-handle { - background-image: url(//ssl.gstatic.com/closure/hsv-sprite-sm.png); -} - -.goog-hsv-palette-noalpha .goog-hsv-palette-sm-hs-image, -.goog-hsv-palette-noalpha .goog-hsv-palette-sm-v-image, -.goog-hsv-palette-noalpha .goog-hsv-palette-sm-hs-handle, -.goog-hsv-palette-noalpha .goog-hsv-palette-sm-v-handle { - background-image: url(//ssl.gstatic.com/closure/hsv-sprite-sm.gif); -} - -.goog-hsv-palette-hs-image, -.goog-hsv-palette-sm-hs-image { - background-position: 0 0; -} - -.goog-hsv-palette-hs-handle, -.goog-hsv-palette-sm-hs-handle { - position: absolute; - left: 5px; - top: 5px; - width: 11px; - height: 11px; - overflow: hidden; - background-position: 0 -256px; -} - -.goog-hsv-palette-sm-hs-handle { - top: 40px; - background-position: 0 -128px; -} - -.goog-hsv-palette-v-image, -.goog-hsv-palette-sm-v-image { - position: absolute; - top: 10px; - left: 286px; - width: 19px; - height: 256px; - border: 1px solid #999; - background-color: #fff; - background-position: -256px 0; -} - -.goog-hsv-palette-sm-v-image { - top: 45px; - left: 155px; - width: 9px; - height: 128px; - background-position: -128px 0; -} - -.goog-hsv-palette-v-handle, -.goog-hsv-palette-sm-v-handle { - position: absolute; - top: 5px; - left: 279px; - width: 35px; - height: 11px; - background-position: -11px -256px; - overflow: hidden; -} - -.goog-hsv-palette-sm-v-handle { - top: 40px; - left: 148px; - width: 25px; - background-position: -11px -128px; -} - -.goog-hsv-palette-swatch, -.goog-hsv-palette-sm-swatch { - position: absolute; - top: 10px; - right: 10px; - width: 65px; - height: 65px; - border: 1px solid #999; - background-color: #fff; -} - -.goog-hsv-palette-sm-swatch { - top: 10px; - right: auto; - left: 10px; - width: 30px; - height: 22px; -} - -.goog-hsv-palette-input, -.goog-hsv-palette-sm-input { - position: absolute; - top: 85px; - right: 10px; - width: 65px; -} - -.goog-hsv-palette-sm-input { - top: 10px; - right: auto; - left: 50px; -} diff --git a/third_party/closure/goog/css/imagelessbutton.css b/third_party/closure/goog/css/imagelessbutton.css deleted file mode 100644 index 23c7fee6b275c..0000000000000 --- a/third_party/closure/goog/css/imagelessbutton.css +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styling for buttons created by goog.ui.ImagelessButtonRenderer. - * - * WARNING: This file uses some ineffecient selectors and it may be - * best to avoid using this file in extremely large, or performance - * critical applications. - * - * @author: eae@google.com (Emil A Eklund) - * @author: gboyer@google.com (Garrett Boyer) - */ - - -/* Imageless button styles. */ - -/* The base element of the button. */ -.goog-imageless-button { - /* Set the background color at the outermost level. */ - background: #e3e3e3; - /* Place a top and bottom border. Do it on this outermost div so that - * it is easier to make pill buttons work properly. */ - border-color: #bbb; - border-style: solid; - border-width: 1px 0; - color: #222; /* Text content color. */ - cursor: default; - font-family: Arial, sans-serif; - line-height: 0; /* For Opera and old WebKit. */ - list-style: none; - /* Built-in margin for the component. Because of the negative margins - * used to simulate corner rounding, the effective left and right margin is - * actually only 1px. */ - margin: 2px; - outline: none; - padding: 0; - text-decoration: none; - vertical-align: middle; -} - -/* - * Pseudo-rounded corners. Works by pulling the left and right sides slightly - * outside of the parent bounding box before drawing the left and right - * borders. - */ -.goog-imageless-button-outer-box { - /* Left and right border that protrude outside the parent. */ - border-color: #bbb; - border-style: solid; - border-width: 0 1px; - /* Same as margin: 0 -1px, except works better cross browser. These are - * intended to be RTL flipped to work better in IE7. */ - left: -1px; - margin-right: -2px; -} - -/* - * A div to give the light and medium shades of the button that takes up no - * vertical space. - */ -.goog-imageless-button-top-shadow { - /* Light top color in the content. */ - background: #f9f9f9; - /* Thin medium shade. */ - border-bottom: 3px solid #eee; - /* Control height with line-height, since height: will trigger hasLayout. - * Specified in pixels, as a compromise to avoid rounding errors. */ - line-height: 9px; - /* Undo all space this takes up. */ - margin-bottom: -12px; -} - -/* Actual content area for the button. */ -.goog-imageless-button-content { - line-height: 1.5em; - padding: 0px 4px; - text-align: center; -} - - -/* Pill (collapsed border) styles. */ -.goog-imageless-button-collapse-right { - /* Draw a border on the root element to square the button off. The border - * on the outer-box element remains, but gets obscured by the next button. */ - border-right-width: 1px; - margin-right: -2px; /* Undoes the margins between the two buttons. */ -} - -.goog-imageless-button-collapse-left .goog-imageless-button-outer-box { - /* Don't bleed to the left -- keep the border self contained in the box. */ - border-left-color: #eee; - left: 0; - margin-right: -1px; /* Versus the default of -2px. */ -} - - -/* Disabled styles. */ -.goog-imageless-button-disabled, -.goog-imageless-button-disabled .goog-imageless-button-outer-box { - background: #eee; - border-color: #ccc; - color: #666; /* For text */ -} - -.goog-imageless-button-disabled .goog-imageless-button-top-shadow { - /* Just hide the shadow instead of setting individual colors. */ - visibility: hidden; -} - - -/* - * Active and checked styles. - * Identical except for text color according to GUIG. - */ -.goog-imageless-button-active, .goog-imageless-button-checked { - background: #f9f9f9; -} - -.goog-imageless-button-active .goog-imageless-button-top-shadow, -.goog-imageless-button-checked .goog-imageless-button-top-shadow { - background: #e3e3e3; -} - -.goog-imageless-button-active { - color: #000; -} - - -/* Hover styles. Higher priority to override other border styles. */ -.goog-imageless-button-hover, -.goog-imageless-button-hover .goog-imageless-button-outer-box, -.goog-imageless-button-focused, -.goog-imageless-button-focused .goog-imageless-button-outer-box { - border-color: #000; -} - - -/* IE6 hacks. This is the only place inner-box is used. */ -* html .goog-imageless-button-inner-box { - /* Give the element inline-block behavior so that the shadow appears. - * The main requirement is to give the element layout without having the side - * effect of taking up a full line. */ - display: inline; - /* Allow the shadow to show through, overriding position:relative from the - * goog-inline-block styles. */ - position: static; - zoom: 1; -} - -* html .goog-imageless-button-outer-box { - /* In RTL mode, IE is off by one pixel. To fix, override the left: -1px - * (which was flipped to right) without having any effect on LTR mode - * (where IE ignores right when left is specified). */ - /* @noflip */ right: 0; -} diff --git a/third_party/closure/goog/css/imagelessmenubutton.css b/third_party/closure/goog/css/imagelessmenubutton.css deleted file mode 100644 index 0c8b6fdcc9f4e..0000000000000 --- a/third_party/closure/goog/css/imagelessmenubutton.css +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for buttons created by goog.ui.ImagelessMenuButtonRenderer. - * - * @author attila@google.com (Attila Bodis) - * @author dalewis@google.com (Darren Lewis) - */ - -/* Dropdown arrow style. */ -.goog-imageless-button-dropdown { - height: 16px; - width: 7px; - /* Client apps may override the URL at which they serve the sprite. */ - background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -388px 0; - vertical-align: top; - margin-right: 2px; -} diff --git a/third_party/closure/goog/css/inputdatepicker.css b/third_party/closure/goog/css/inputdatepicker.css deleted file mode 100644 index 4f93182196dcb..0000000000000 --- a/third_party/closure/goog/css/inputdatepicker.css +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: arv@google.com (Erik Arvidsson) */ - -/* goog.ui.InputDatePicker */ - -@import url(popupdatepicker.css); diff --git a/third_party/closure/goog/css/linkbutton.css b/third_party/closure/goog/css/linkbutton.css deleted file mode 100644 index 9f9ec3a3f94cd..0000000000000 --- a/third_party/closure/goog/css/linkbutton.css +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Styling for link buttons created by goog.ui.LinkButtonRenderer. - * - * @author robbyw@google.com (Robby Walker) - */ - -.goog-link-button { - position: relative; - color: #00f; - text-decoration: underline; - cursor: pointer; -} - -/* State: disabled. */ -.goog-link-button-disabled { - color: #888; - text-decoration: none; - cursor: default; -} diff --git a/third_party/closure/goog/css/menu.css b/third_party/closure/goog/css/menu.css deleted file mode 100644 index da66222d72dff..0000000000000 --- a/third_party/closure/goog/css/menu.css +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for menus created by goog.ui.MenuRenderer. - * - * @author attila@google.com (Attila Bodis) - */ - - -.goog-menu { - background: #fff; - border-color: #ccc #666 #666 #ccc; - border-style: solid; - border-width: 1px; - cursor: default; - font: normal 13px Arial, sans-serif; - margin: 0; - outline: none; - padding: 4px 0; - position: absolute; - z-index: 20000; /* Arbitrary, but some apps depend on it... */ -} diff --git a/third_party/closure/goog/css/menubar.css b/third_party/closure/goog/css/menubar.css deleted file mode 100644 index 6f69b4664c062..0000000000000 --- a/third_party/closure/goog/css/menubar.css +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2012 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * styling for goog.ui.menuBar and child buttons. - * - * @author tvykruta@google.com (Tomas Vykruta) - */ - - -.goog-menubar { - cursor: default; - outline: none; - position: relative; - white-space: nowrap; - background: #fff; -} - -.goog-menubar .goog-menu-button { - padding: 1px 1px; - margin: 0px 0px; - outline: none; - border: none; - background: #fff; - /* @alternate */ border: 1px solid #fff; -} - -.goog-menubar .goog-menu-button-dropdown { - display: none; -} - -.goog-menubar .goog-menu-button-outer-box { - border: none; -} - -.goog-menubar .goog-menu-button-inner-box { - border: none; -} - -.goog-menubar .goog-menu-button-hover { - background: #eee; - border: 1px solid #eee; -} - -.goog-menubar .goog-menu-button-open { - background: #fff; - border-left: 1px solid #ccc; - border-right: 1px solid #ccc; -} - -.goog-menubar .goog-menu-button-disabled { - color: #ccc; -} diff --git a/third_party/closure/goog/css/menubutton.css b/third_party/closure/goog/css/menubutton.css deleted file mode 100644 index 82c94b248a444..0000000000000 --- a/third_party/closure/goog/css/menubutton.css +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for buttons created by goog.ui.MenuButtonRenderer. - * - * @author attila@google.com (Attila Bodis) - */ - - -/* State: resting. */ -.goog-menu-button { - /* Client apps may override the URL at which they serve the image. */ - background: #ddd url(//ssl.gstatic.com/editor/button-bg.png) repeat-x top left; - border: 0; - color: #000; - cursor: pointer; - list-style: none; - margin: 2px; - outline: none; - padding: 0; - text-decoration: none; - vertical-align: middle; -} - -/* Pseudo-rounded corners. */ -.goog-menu-button-outer-box, -.goog-menu-button-inner-box { - border-style: solid; - border-color: #aaa; - vertical-align: top; -} -.goog-menu-button-outer-box { - margin: 0; - border-width: 1px 0; - padding: 0; -} -.goog-menu-button-inner-box { - margin: 0 -1px; - border-width: 0 1px; - padding: 3px 4px; -} - -/* Pre-IE7 IE hack; ignored by IE7 and all non-IE browsers. */ -* html .goog-menu-button-inner-box { - /* IE6 needs to have the box shifted to make the borders line up. */ - left: -1px; -} - -/* Pre-IE7 BiDi fixes. */ -* html .goog-menu-button-rtl .goog-menu-button-outer-box { - /* @noflip */ left: -1px; - /* @noflip */ right: auto; -} -* html .goog-menu-button-rtl .goog-menu-button-inner-box { - /* @noflip */ right: auto; -} - -/* IE7-only hack; ignored by all other browsers. */ -*:first-child+html .goog-menu-button-inner-box { - /* IE7 needs to have the box shifted to make the borders line up. */ - left: -1px; -} -/* IE7 BiDi fix. */ -*:first-child+html .goog-menu-button-rtl .goog-menu-button-inner-box { - /* @noflip */ left: 1px; - /* @noflip */ right: auto; -} - -/* Safari-only hacks. */ -::root .goog-menu-button, -::root .goog-menu-button-outer-box, -::root .goog-menu-button-inner-box { - /* Required to make pseudo-rounded corners work on Safari. */ - line-height: 0; -} -::root .goog-menu-button-caption, -::root .goog-menu-button-dropdown { - /* Required to make pseudo-rounded corners work on Safari. */ - line-height: normal; -} - -/* State: disabled. */ -.goog-menu-button-disabled { - background-image: none !important; - opacity: 0.3; - -moz-opacity: 0.3; - filter: alpha(opacity=30); -} -.goog-menu-button-disabled .goog-menu-button-outer-box, -.goog-menu-button-disabled .goog-menu-button-inner-box, -.goog-menu-button-disabled .goog-menu-button-caption, -.goog-menu-button-disabled .goog-menu-button-dropdown { - color: #333 !important; - border-color: #999 !important; -} - -/* Pre-IE7 IE hack; ignored by IE7 and all non-IE browsers. */ -* html .goog-menu-button-disabled { - margin: 2px 1px !important; - padding: 0 1px !important; -} - -/* IE7-only hack; ignored by all other browsers. */ -*:first-child+html .goog-menu-button-disabled { - margin: 2px 1px !important; - padding: 0 1px !important; -} - -/* State: hover. */ -.goog-menu-button-hover .goog-menu-button-outer-box, -.goog-menu-button-hover .goog-menu-button-inner-box { - border-color: #9cf #69e #69e #7af !important; /* Hover border wins. */ -} - -/* State: active, open. */ -.goog-menu-button-active, -.goog-menu-button-open { - background-color: #bbb; - background-position: bottom left; -} - -/* State: focused. */ -.goog-menu-button-focused .goog-menu-button-outer-box, -.goog-menu-button-focused .goog-menu-button-inner-box { - border-color: orange; -} - -/* Caption style. */ -.goog-menu-button-caption { - padding: 0 4px 0 0; - vertical-align: top; -} - -/* Dropdown arrow style. */ -.goog-menu-button-dropdown { - height: 15px; - width: 7px; - /* Client apps may override the URL at which they serve the sprite. */ - background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -388px 0; - vertical-align: top; -} - -/* Pill (collapsed border) styles. */ -/* TODO(gboyer): Remove specific menu button styles and have any button support being a menu button. */ -.goog-menu-button-collapse-right, -.goog-menu-button-collapse-right .goog-menu-button-outer-box, -.goog-menu-button-collapse-right .goog-menu-button-inner-box { - margin-right: 0; -} - -.goog-menu-button-collapse-left, -.goog-menu-button-collapse-left .goog-menu-button-outer-box, -.goog-menu-button-collapse-left .goog-menu-button-inner-box { - margin-left: 0; -} - -.goog-menu-button-collapse-left .goog-menu-button-inner-box { - border-left: 1px solid #fff; -} - -.goog-menu-button-collapse-left.goog-menu-button-checked -.goog-menu-button-inner-box { - border-left: 1px solid #ddd; -} diff --git a/third_party/closure/goog/css/menuitem.css b/third_party/closure/goog/css/menuitem.css deleted file mode 100644 index cea9de68015e7..0000000000000 --- a/third_party/closure/goog/css/menuitem.css +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for menus created by goog.ui.MenuItemRenderer. - * - * @author attila@google.com (Attila Bodis) - */ - - -/** - * State: resting. - * - * NOTE(mleibman,chrishenry): - * The RTL support in Closure is provided via two mechanisms -- "rtl" CSS - * classes and BiDi flipping done by the CSS compiler. Closure supports RTL - * with or without the use of the CSS compiler. In order for them not - * to conflict with each other, the "rtl" CSS classes need to have the @noflip - * annotation. The non-rtl counterparts should ideally have them as well, but, - * since .goog-menuitem existed without .goog-menuitem-rtl for so long before - * being added, there is a risk of people having templates where they are not - * rendering the .goog-menuitem-rtl class when in RTL and instead rely solely - * on the BiDi flipping by the CSS compiler. That's why we're not adding the - * @noflip to .goog-menuitem. - */ -.goog-menuitem { - color: #000; - font: normal 13px Arial, sans-serif; - list-style: none; - margin: 0; - /* 28px on the left for icon or checkbox; 7em on the right for shortcut. */ - padding: 4px 7em 4px 28px; - white-space: nowrap; -} - -/* BiDi override for the resting state. */ -/* @noflip */ -.goog-menuitem.goog-menuitem-rtl { - /* Flip left/right padding for BiDi. */ - padding-left: 7em; - padding-right: 28px; -} - -/* If a menu doesn't have checkable items or items with icons, remove padding. */ -.goog-menu-nocheckbox .goog-menuitem, -.goog-menu-noicon .goog-menuitem { - padding-left: 12px; -} - -/* - * If a menu doesn't have items with shortcuts, leave just enough room for - * submenu arrows, if they are rendered. - */ -.goog-menu-noaccel .goog-menuitem { - padding-right: 20px; -} - -.goog-menuitem-content { - color: #000; - font: normal 13px Arial, sans-serif; -} - -/* State: disabled. */ -.goog-menuitem-disabled .goog-menuitem-accel, -.goog-menuitem-disabled .goog-menuitem-content { - color: #ccc !important; -} -.goog-menuitem-disabled .goog-menuitem-icon { - opacity: 0.3; - -moz-opacity: 0.3; - filter: alpha(opacity=30); -} - -/* State: hover. */ -.goog-menuitem-highlight, -.goog-menuitem-hover { - background-color: #d6e9f8; - /* Use an explicit top and bottom border so that the selection is visible - * in high contrast mode. */ - border-color: #d6e9f8; - border-style: dotted; - border-width: 1px 0; - padding-bottom: 3px; - padding-top: 3px; -} - -/* State: selected/checked. */ -.goog-menuitem-checkbox, -.goog-menuitem-icon { - background-repeat: no-repeat; - height: 16px; - left: 6px; - position: absolute; - right: auto; - vertical-align: middle; - width: 16px; -} - -/* BiDi override for the selected/checked state. */ -/* @noflip */ -.goog-menuitem-rtl .goog-menuitem-checkbox, -.goog-menuitem-rtl .goog-menuitem-icon { - /* Flip left/right positioning. */ - left: auto; - right: 6px; -} - -.goog-option-selected .goog-menuitem-checkbox, -.goog-option-selected .goog-menuitem-icon { - /* Client apps may override the URL at which they serve the sprite. */ - background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -512px 0; -} - -/* Keyboard shortcut ("accelerator") style. */ -.goog-menuitem-accel { - color: #999; - /* Keyboard shortcuts are untranslated; always left-to-right. */ - /* @noflip */ direction: ltr; - left: auto; - padding: 0 6px; - position: absolute; - right: 0; - text-align: right; -} - -/* BiDi override for shortcut style. */ -/* @noflip */ -.goog-menuitem-rtl .goog-menuitem-accel { - /* Flip left/right positioning and text alignment. */ - left: 0; - right: auto; - text-align: left; -} - -/* Mnemonic styles. */ -.goog-menuitem-mnemonic-hint { - text-decoration: underline; -} - -.goog-menuitem-mnemonic-separator { - color: #999; - font-size: 12px; - padding-left: 4px; -} diff --git a/third_party/closure/goog/css/menuseparator.css b/third_party/closure/goog/css/menuseparator.css deleted file mode 100644 index de1354f70dd59..0000000000000 --- a/third_party/closure/goog/css/menuseparator.css +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for menus created by goog.ui.MenuSeparatorRenderer. - * - * @author attila@google.com (Attila Bodis) - */ - - -.goog-menuseparator { - border-top: 1px solid #ccc; - margin: 4px 0; - padding: 0; -} diff --git a/third_party/closure/goog/css/multitestrunner.css b/third_party/closure/goog/css/multitestrunner.css deleted file mode 100644 index 2cdffeac30452..0000000000000 --- a/third_party/closure/goog/css/multitestrunner.css +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: pupius@google.com (Daniel Pupius) */ - -.goog-testrunner { - background-color: #EEE; - border: 1px solid #999; - padding: 10px; - padding-bottom: 25px; -} - -.goog-testrunner-progress { - width: auto; - height: 20px; - background-color: #FFF; - border: 1px solid #999; -} - -.goog-testrunner-progress table { - width: 100%; - height: 20px; - border-collapse: collapse; -} - -.goog-testrunner-buttons { - margin-top: 7px; -} - -.goog-testrunner-buttons button { - width: 75px; -} - -.goog-testrunner-log, -.goog-testrunner-report, -.goog-testrunner-stats { - margin-top: 7px; - width: auto; - height: 400px; - background-color: #FFF; - border: 1px solid #999; - font: normal medium monospace; - padding: 5px; - overflow: auto; /* Opera doesn't support overflow-y. */ - overflow-y: scroll; - overflow-x: auto; -} - -.goog-testrunner-report div { - margin-bottom: 6px; - border-bottom: 1px solid #999; -} - -.goog-testrunner-stats table { - margin-top: 20px; - border-collapse: collapse; - border: 1px solid #EEE; -} - -.goog-testrunner-stats td, -.goog-testrunner-stats th { - padding: 2px 6px; - border: 1px solid #F0F0F0; -} - -.goog-testrunner-stats th { - font-weight: bold; -} - -.goog-testrunner-stats .center { - text-align: center; -} - -.goog-testrunner-progress-summary { - font: bold small sans-serif; -} - -.goog-testrunner iframe { - position: absolute; - left: -640px; - top: -480px; - width: 640px; - height: 480px; - margin: 0; - border: 0; - padding: 0; -} - -.goog-testrunner-report-failure { - color: #900; -} - -.goog-testrunner-reporttab, -.goog-testrunner-logtab, -.goog-testrunner-statstab { - float: left; - width: 50px; - height: 16px; - text-align: center; - font: normal small arial, helvetica, sans-serif; - color: #666; - background-color: #DDD; - border: 1px solid #999; - border-top: 0; - cursor: pointer; -} - -.goog-testrunner-reporttab, -.goog-testrunner-logtab { - border-right: 0; -} - -.goog-testrunner-activetab { - font-weight: bold; - color: #000; - background-color: #CCC; -} diff --git a/third_party/closure/goog/css/popupdatepicker.css b/third_party/closure/goog/css/popupdatepicker.css deleted file mode 100644 index 133173ab53b3c..0000000000000 --- a/third_party/closure/goog/css/popupdatepicker.css +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for a goog.ui.PopupDatePicker. - * - * @author arv@google.com (Erik Arvidsson) - */ - -.goog-date-picker { - position: absolute; -} - diff --git a/third_party/closure/goog/css/roundedpanel.css b/third_party/closure/goog/css/roundedpanel.css deleted file mode 100644 index d931e41d1f79b..0000000000000 --- a/third_party/closure/goog/css/roundedpanel.css +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2010 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styles for RoundedPanel. - * - * @author pallosp@google.com (Peter Pallos) - */ - -.goog-roundedpanel { - position: relative; - z-index: 0; -} - -.goog-roundedpanel-background { - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - z-index: -1; -} - -.goog-roundedpanel-content { -} diff --git a/third_party/closure/goog/css/roundedtab.css b/third_party/closure/goog/css/roundedtab.css deleted file mode 100644 index 17fe155f56525..0000000000000 --- a/third_party/closure/goog/css/roundedtab.css +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: attila@google.com (Attila Bodis) */ - - -/* - * Styles used by goog.ui.RoundedTabRenderer. - */ -.goog-rounded-tab { - border: 0; - cursor: default; - padding: 0; -} - -.goog-tab-bar-top .goog-rounded-tab, -.goog-tab-bar-bottom .goog-rounded-tab { - float: left; - margin: 0 4px 0 0; -} - -.goog-tab-bar-start .goog-rounded-tab, -.goog-tab-bar-end .goog-rounded-tab { - margin: 0 0 4px 0; -} - -.goog-rounded-tab-caption { - border: 0; - color: #fff; - margin: 0; - padding: 4px 8px; -} - -.goog-rounded-tab-caption, -.goog-rounded-tab-inner-edge, -.goog-rounded-tab-outer-edge { - background: #036; - border-right: 1px solid #003; -} - -.goog-rounded-tab-inner-edge, -.goog-rounded-tab-outer-edge { - font-size: 1px; - height: 1px; - overflow: hidden; -} - -/* State: Hover */ -.goog-rounded-tab-hover .goog-rounded-tab-caption, -.goog-rounded-tab-hover .goog-rounded-tab-inner-edge, -.goog-rounded-tab-hover .goog-rounded-tab-outer-edge { - background-color: #69c; - border-right: 1px solid #369; -} - -/* State: Disabled */ -.goog-rounded-tab-disabled .goog-rounded-tab-caption, -.goog-rounded-tab-disabled .goog-rounded-tab-inner-edge, -.goog-rounded-tab-disabled .goog-rounded-tab-outer-edge { - background: #ccc; - border-right: 1px solid #ccc; -} - -/* State: Selected */ -.goog-rounded-tab-selected .goog-rounded-tab-caption, -.goog-rounded-tab-selected .goog-rounded-tab-inner-edge, -.goog-rounded-tab-selected .goog-rounded-tab-outer-edge { - background: #369 !important; /* Selected trumps hover. */ - border-right: 1px solid #036 !important; -} - - -/* - * Styles for horizontal (top or bottom) tabs. - */ -.goog-tab-bar-top .goog-rounded-tab { - vertical-align: bottom; -} - -.goog-tab-bar-bottom .goog-rounded-tab { - vertical-align: top; -} - -.goog-tab-bar-top .goog-rounded-tab-outer-edge, -.goog-tab-bar-bottom .goog-rounded-tab-outer-edge { - margin: 0 3px; -} - -.goog-tab-bar-top .goog-rounded-tab-inner-edge, -.goog-tab-bar-bottom .goog-rounded-tab-inner-edge { - margin: 0 1px; -} - - -/* - * Styles for vertical (start or end) tabs. - */ -.goog-tab-bar-start .goog-rounded-tab-table, -.goog-tab-bar-end .goog-rounded-tab-table { - width: 100%; -} - -.goog-tab-bar-start .goog-rounded-tab-inner-edge { - margin-left: 1px; -} - -.goog-tab-bar-start .goog-rounded-tab-outer-edge { - margin-left: 3px; -} - -.goog-tab-bar-end .goog-rounded-tab-inner-edge { - margin-right: 1px; -} - -.goog-tab-bar-end .goog-rounded-tab-outer-edge { - margin-right: 3px; -} - - -/* - * Overrides for start tabs. - */ -.goog-tab-bar-start .goog-rounded-tab-table, -.goog-tab-bar-end .goog-rounded-tab-table { - width: 12ex; /* TODO(attila): Make this work for variable width. */ -} - -.goog-tab-bar-start .goog-rounded-tab-caption, -.goog-tab-bar-start .goog-rounded-tab-inner-edge, -.goog-tab-bar-start .goog-rounded-tab-outer-edge { - border-left: 1px solid #003; - border-right: 0; -} - -.goog-tab-bar-start .goog-rounded-tab-hover .goog-rounded-tab-caption, -.goog-tab-bar-start .goog-rounded-tab-hover .goog-rounded-tab-inner-edge, -.goog-tab-bar-start .goog-rounded-tab-hover .goog-rounded-tab-outer-edge { - border-left: 1px solid #369 !important; - border-right: 0 !important; -} - -.goog-tab-bar-start .goog-rounded-tab-selected .goog-rounded-tab-outer-edge, -.goog-tab-bar-start .goog-rounded-tab-selected .goog-rounded-tab-inner-edge, -.goog-tab-bar-start .goog-rounded-tab-selected .goog-rounded-tab-caption { - border-left: 1px solid #036 !important; - border-right: 0 !important; -} - -.goog-tab-bar-start .goog-rounded-tab-disabled .goog-rounded-tab-outer-edge, -.goog-tab-bar-start .goog-rounded-tab-disabled .goog-rounded-tab-inner-edge, -.goog-tab-bar-start .goog-rounded-tab-disabled .goog-rounded-tab-caption { - border-left: 1px solid #ccc !important; - border-right: 0 !important; -} diff --git a/third_party/closure/goog/css/submenu.css b/third_party/closure/goog/css/submenu.css deleted file mode 100644 index 1159b289cf38f..0000000000000 --- a/third_party/closure/goog/css/submenu.css +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2009 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* - * Standard styling for menus created by goog.ui.SubMenuRenderer. - * - * @author attila@google.com (Attila Bodis) - */ - - -/* State: resting. */ -/* @noflip */ -.goog-submenu-arrow { - color: #000; - left: auto; - padding-right: 6px; - position: absolute; - right: 0; - text-align: right; -} - -/* BiDi override. */ -/* @noflip */ -.goog-menuitem-rtl .goog-submenu-arrow { - text-align: left; - left: 0; - right: auto; - padding-left: 6px; -} - -/* State: disabled. */ -.goog-menuitem-disabled .goog-submenu-arrow { - color: #ccc; -} diff --git a/third_party/closure/goog/css/tab.css b/third_party/closure/goog/css/tab.css deleted file mode 100644 index 6c7dfe2ef07d1..0000000000000 --- a/third_party/closure/goog/css/tab.css +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: attila@google.com (Attila Bodis) */ -/* Author: eae@google.com (Emil A. Eklund) */ - - -/* - * Styles used by goog.ui.TabRenderer. - */ -.goog-tab { - position: relative; - padding: 4px 8px; - color: #00c; - text-decoration: underline; - cursor: default; -} - -.goog-tab-bar-top .goog-tab { - margin: 1px 4px 0 0; - border-bottom: 0; - float: left; -} - -.goog-tab-bar-top:after, -.goog-tab-bar-bottom:after { - content: " "; - display: block; - height: 0; - clear: both; - visibility: hidden; -} - -.goog-tab-bar-bottom .goog-tab { - margin: 0 4px 1px 0; - border-top: 0; - float: left; -} - -.goog-tab-bar-start .goog-tab { - margin: 0 0 4px 1px; - border-right: 0; -} - -.goog-tab-bar-end .goog-tab { - margin: 0 1px 4px 0; - border-left: 0; -} - -/* State: Hover */ -.goog-tab-hover { - background: #eee; -} - -/* State: Disabled */ -.goog-tab-disabled { - color: #666; -} - -/* State: Selected */ -.goog-tab-selected { - color: #000; - background: #fff; - text-decoration: none; - font-weight: bold; - border: 1px solid #6b90da; -} - -.goog-tab-bar-top { - padding-top: 5px !important; - padding-left: 5px !important; - border-bottom: 1px solid #6b90da !important; -} -/* - * Shift selected tabs 1px towards the contents (and compensate via margin and - * padding) to visually merge the borders of the tab with the borders of the - * content area. - */ -.goog-tab-bar-top .goog-tab-selected { - top: 1px; - margin-top: 0; - padding-bottom: 5px; -} - -.goog-tab-bar-bottom .goog-tab-selected { - top: -1px; - margin-bottom: 0; - padding-top: 5px; -} - -.goog-tab-bar-start .goog-tab-selected { - left: 1px; - margin-left: 0; - padding-right: 9px; -} - -.goog-tab-bar-end .goog-tab-selected { - left: -1px; - margin-right: 0; - padding-left: 9px; -} diff --git a/third_party/closure/goog/css/tabbar.css b/third_party/closure/goog/css/tabbar.css deleted file mode 100644 index 514aa9bacd229..0000000000000 --- a/third_party/closure/goog/css/tabbar.css +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: attila@google.com (Attila Bodis) */ -/* Author: eae@google.com (Emil A. Eklund) */ - - -/* - * Styles used by goog.ui.TabBarRenderer. - */ -.goog-tab-bar { - margin: 0; - border: 0; - padding: 0; - list-style: none; - cursor: default; - outline: none; - background: #ebeff9; -} - -.goog-tab-bar-clear { - clear: both; - height: 0; - overflow: hidden; -} - -.goog-tab-bar-start { - float: left; -} - -.goog-tab-bar-end { - float: right; -} - - -/* - * IE6-only hacks to fix the gap between the floated tabs and the content. - * IE7 and later will ignore these. - */ -/* @if user.agent ie6 */ -* html .goog-tab-bar-start { - margin-right: -3px; -} - -* html .goog-tab-bar-end { - margin-left: -3px; -} -/* @endif */ diff --git a/third_party/closure/goog/css/tablesorter.css b/third_party/closure/goog/css/tablesorter.css deleted file mode 100644 index 126f007ffbe6b..0000000000000 --- a/third_party/closure/goog/css/tablesorter.css +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2008 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: robbyw@google.com (Robby Walker) */ - -/* Styles for goog.ui.TableSorter. */ - -.goog-tablesorter-header { - cursor: pointer -} diff --git a/third_party/closure/goog/css/tooltip.css b/third_party/closure/goog/css/tooltip.css deleted file mode 100644 index 026458327af23..0000000000000 --- a/third_party/closure/goog/css/tooltip.css +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2010 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -.goog-tooltip { - background: #ffe; - border: 1px solid #999; - border-width: 1px 2px 2px 1px; - padding: 6px; - z-index: 30000; -} diff --git a/third_party/closure/goog/css/tree.css b/third_party/closure/goog/css/tree.css deleted file mode 100644 index aeb1d0b3d4338..0000000000000 --- a/third_party/closure/goog/css/tree.css +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: arv@google.com (Erik Arvidsson) */ -/* Author: eae@google.com (Emil A Eklund) */ -/* Author: jonp@google.com (Jon Perlow) */ - -/* - TODO(arv): Currently the sprite image has the height 16px. We should make the - image taller which would allow better flexibility when it comes to the height - of a tree row. -*/ - -.goog-tree-root:focus { - outline: none; -} - -.goog-tree-row { - white-space: nowrap; - font: icon; - line-height: 16px; - height: 16px; -} - -.goog-tree-row span { - overflow: hidden; - text-overflow: ellipsis; -} - -.goog-tree-children { - background-repeat: repeat-y; - background-image: url(//ssl.gstatic.com/closure/tree/I.png) !important; - background-position-y: 1px !important; /* IE only */ - font: icon; -} - -.goog-tree-children-nolines { - font: icon; -} - -.goog-tree-icon { - background-image: url(//ssl.gstatic.com/closure/tree/tree.png); -} - -.goog-tree-expand-icon { - vertical-align: middle; - height: 16px; - width: 16px; - cursor: default; -} - -.goog-tree-expand-icon-plus { - width: 19px; - background-position: 0 0; -} - -.goog-tree-expand-icon-minus { - width: 19px; - background-position: -24px 0; -} - -.goog-tree-expand-icon-tplus { - width: 19px; - background-position: -48px 0; -} - -.goog-tree-expand-icon-tminus { - width: 19px; - background-position: -72px 0; -} - -.goog-tree-expand-icon-lplus { - width: 19px; - background-position: -96px 0; -} - -.goog-tree-expand-icon-lminus { - width: 19px; - background-position: -120px 0; -} - -.goog-tree-expand-icon-t { - width: 19px; - background-position: -144px 0; -} - -.goog-tree-expand-icon-l { - width: 19px; - background-position: -168px 0; -} - -.goog-tree-expand-icon-blank { - width: 19px; - background-position: -168px -24px; -} - -.goog-tree-collapsed-folder-icon { - vertical-align: middle; - height: 16px; - width: 16px; - background-position: -0px -24px; -} - -.goog-tree-expanded-folder-icon { - vertical-align: middle; - height: 16px; - width: 16px; - background-position: -24px -24px; -} - -.goog-tree-file-icon { - vertical-align: middle; - height: 16px; - width: 16px; - background-position: -48px -24px; -} - -.goog-tree-item-label { - margin-left: 3px; - padding: 1px 2px 1px 2px; - text-decoration: none; - color: WindowText; - cursor: default; -} - -.goog-tree-item-label:hover { - text-decoration: underline; -} - -.selected .goog-tree-item-label { - background-color: ButtonFace; - color: ButtonText; -} - -.focused .selected .goog-tree-item-label { - background-color: Highlight; - color: HighlightText; -} - -.goog-tree-hide-root { - display: none; -} diff --git a/third_party/closure/goog/css/tristatemenuitem.css b/third_party/closure/goog/css/tristatemenuitem.css deleted file mode 100644 index 8c98448afba46..0000000000000 --- a/third_party/closure/goog/css/tristatemenuitem.css +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2007 The Closure Library Authors. All Rights Reserved. - * - * Use of this source code is governed by the Apache License, Version 2.0. - * See the COPYING file for details. - */ - -/* Author: pupius@google.com (Daniel Pupius) */ - -/* goog.ui.TriStateMenuItem */ - -.goog-tristatemenuitem { - padding: 2px 5px; - margin: 0; - list-style: none; -} - -.goog-tristatemenuitem-highlight { - background-color: #4279A5; - color: #FFF; -} - -.goog-tristatemenuitem-disabled { - color: #999; -} - -.goog-tristatemenuitem-checkbox { - float: left; - width: 10px; - height: 1.1em; -} - -.goog-tristatemenuitem-partially-checked { - background-image: url(//ssl.gstatic.com/closure/check-outline.gif); - background-position: 4px 50%; - background-repeat: no-repeat; -} - -.goog-tristatemenuitem-fully-checked { - background-image: url(//ssl.gstatic.com/closure/check.gif); - background-position: 4px 50%; - background-repeat: no-repeat; -} diff --git a/third_party/closure/goog/cssom/cssom.js b/third_party/closure/goog/cssom/cssom.js deleted file mode 100644 index 1ff34e2561ee5..0000000000000 --- a/third_party/closure/goog/cssom/cssom.js +++ /dev/null @@ -1,454 +0,0 @@ -// Copyright 2008 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview CSS Object Model helper functions. - * References: - * - W3C: http://dev.w3.org/csswg/cssom/ - * - MSDN: http://msdn.microsoft.com/en-us/library/ms531209(VS.85).aspx. - * TODO(user): Consider hacking page, media, etc.. to work. - * This would be pretty challenging. IE returns the text for any rule - * regardless of whether or not the media is correct or not. Firefox at - * least supports CSSRule.type to figure out if it's a media type and then - * we could do something interesting, but IE offers no way for us to tell. - */ - -goog.provide('goog.cssom'); -goog.provide('goog.cssom.CssRuleType'); - -goog.require('goog.array'); -goog.require('goog.dom'); -goog.require('goog.dom.TagName'); - - -/** - * Enumeration of {@code CSSRule} types. - * @enum {number} - */ -goog.cssom.CssRuleType = { - STYLE: 1, - IMPORT: 3, - MEDIA: 4, - FONT_FACE: 5, - PAGE: 6, - NAMESPACE: 7 -}; - - -/** - * Recursively gets all CSS as text, optionally starting from a given - * CSSStyleSheet. - * @param {(CSSStyleSheet|StyleSheetList)=} opt_styleSheet The CSSStyleSheet. - * @return {string} css text. - */ -goog.cssom.getAllCssText = function(opt_styleSheet) { - var styleSheet = opt_styleSheet || document.styleSheets; - return /** @type {string} */ (goog.cssom.getAllCss_(styleSheet, true)); -}; - - -/** - * Recursively gets all CSSStyleRules, optionally starting from a given - * CSSStyleSheet. - * Note that this excludes any CSSImportRules, CSSMediaRules, etc.. - * @param {(CSSStyleSheet|StyleSheetList)=} opt_styleSheet The CSSStyleSheet. - * @return {Array} A list of CSSStyleRules. - */ -goog.cssom.getAllCssStyleRules = function(opt_styleSheet) { - var styleSheet = opt_styleSheet || document.styleSheets; - return /** @type {!Array} */ ( - goog.cssom.getAllCss_(styleSheet, false)); -}; - - -/** - * Returns the CSSRules from a styleSheet. - * Worth noting here is that IE and FF differ in terms of what they will return. - * Firefox will return styleSheet.cssRules, which includes ImportRules and - * anything which implements the CSSRules interface. IE returns simply a list of - * CSSRules. - * @param {CSSStyleSheet} styleSheet The CSSStyleSheet. - * @throws {Error} If we cannot access the rules on a stylesheet object - this - * can happen if a stylesheet object's rules are accessed before the rules - * have been downloaded and parsed and are "ready". - * @return {CSSRuleList} An array of CSSRules or null. - */ -goog.cssom.getCssRulesFromStyleSheet = function(styleSheet) { - var cssRuleList = null; - try { - // Select cssRules unless it isn't present. For pre-IE9 IE, use the rules - // collection instead. - // It's important to be consistent in using only the W3C or IE apis on - // IE9+ where both are present to ensure that there is no indexing - // mismatches - the collections are subtly different in what the include or - // exclude which can lead to one collection being longer than the other - // depending on the page's construction. - cssRuleList = styleSheet.cssRules /* W3C */ || styleSheet.rules /* IE */; - } catch (e) { - // This can happen if we try to access the CSSOM before it's "ready". - if (e.code == 15) { - // Firefox throws an NS_ERROR_DOM_INVALID_ACCESS_ERR error if a stylesheet - // is read before it has been fully parsed. Let the caller know which - // stylesheet failed. - e.styleSheet = styleSheet; - throw e; - } - } - return cssRuleList; -}; - - -/** - * Gets all CSSStyleSheet objects starting from some CSSStyleSheet. Note that we - * want to return the sheets in the order of the cascade, therefore if we - * encounter an import, we will splice that CSSStyleSheet object in front of - * the CSSStyleSheet that contains it in the returned array of CSSStyleSheets. - * @param {(CSSStyleSheet|StyleSheetList)=} opt_styleSheet A CSSStyleSheet. - * @param {boolean=} opt_includeDisabled If true, includes disabled stylesheets, - * defaults to false. - * @return {!Array} A list of CSSStyleSheet objects. - */ -goog.cssom.getAllCssStyleSheets = function( - opt_styleSheet, opt_includeDisabled) { - var styleSheetsOutput = []; - var styleSheet = opt_styleSheet || document.styleSheets; - var includeDisabled = - goog.isDef(opt_includeDisabled) ? opt_includeDisabled : false; - - // Imports need to go first. - if (styleSheet.imports && styleSheet.imports.length) { - for (var i = 0, n = styleSheet.imports.length; i < n; i++) { - goog.array.extend( - styleSheetsOutput, - goog.cssom.getAllCssStyleSheets( - /** @type {CSSStyleSheet} */ (styleSheet.imports[i]))); - } - - } else if (styleSheet.length) { - // In case we get a StyleSheetList object. - // http://dev.w3.org/csswg/cssom/#the-stylesheetlist - for (var i = 0, n = styleSheet.length; i < n; i++) { - goog.array.extend( - styleSheetsOutput, goog.cssom.getAllCssStyleSheets( - /** @type {!CSSStyleSheet} */ (styleSheet[i]))); - } - } else { - // We need to walk through rules in browsers which implement .cssRules - // to see if there are styleSheets buried in there. - // If we have a CSSStyleSheet within CssRules. - var cssRuleList = goog.cssom.getCssRulesFromStyleSheet( - /** @type {!CSSStyleSheet} */ (styleSheet)); - if (cssRuleList && cssRuleList.length) { - // Chrome does not evaluate cssRuleList[i] to undefined when i >=n; - // so we use a (i < n) check instead of cssRuleList[i] in the loop below - // and in other places where we iterate over a rules list. - // See issue # 5917 in Chromium. - for (var i = 0, n = cssRuleList.length, cssRule; i < n; i++) { - cssRule = cssRuleList[i]; - // There are more stylesheets to get on this object.. - if (cssRule.styleSheet) { - goog.array.extend( - styleSheetsOutput, - goog.cssom.getAllCssStyleSheets(cssRule.styleSheet)); - } - } - } - } - - // This is a CSSStyleSheet. (IE uses .rules, W3c and Opera cssRules.) - if ((styleSheet.type || styleSheet.rules || styleSheet.cssRules) && - (!styleSheet.disabled || includeDisabled)) { - styleSheetsOutput.push(styleSheet); - } - - return styleSheetsOutput; -}; - - -/** - * Gets the cssText from a CSSRule object cross-browserly. - * @param {CSSRule} cssRule A CSSRule. - * @return {string} cssText The text for the rule, including the selector. - */ -goog.cssom.getCssTextFromCssRule = function(cssRule) { - var cssText = ''; - - if (cssRule.cssText) { - // W3C. - cssText = cssRule.cssText; - } else if (cssRule.style && cssRule.style.cssText && cssRule.selectorText) { - // IE: The spacing here is intended to make the result consistent with - // FF and Webkit. - // We also remove the special properties that we may have added in - // getAllCssStyleRules since IE includes those in the cssText. - var styleCssText = - cssRule.style.cssText - .replace(/\s*-closure-parent-stylesheet:\s*\[object\];?\s*/gi, '') - .replace(/\s*-closure-rule-index:\s*[\d]+;?\s*/gi, ''); - var thisCssText = cssRule.selectorText + ' { ' + styleCssText + ' }'; - cssText = thisCssText; - } - - return cssText; -}; - - -/** - * Get the index of the CSSRule in it's CSSStyleSheet. - * @param {CSSRule} cssRule A CSSRule. - * @param {CSSStyleSheet=} opt_parentStyleSheet A reference to the stylesheet - * object this cssRule belongs to. - * @throws {Error} When we cannot get the parentStyleSheet. - * @return {number} The index of the CSSRule, or -1. - */ -goog.cssom.getCssRuleIndexInParentStyleSheet = function( - cssRule, opt_parentStyleSheet) { - // Look for our special style.ruleIndex property from getAllCss. - if (cssRule.style && /** @type {!Object} */ (cssRule.style)['-closure-rule-index']) { - return (/** @type {!Object} */ (cssRule.style))['-closure-rule-index']; - } - - var parentStyleSheet = - opt_parentStyleSheet || goog.cssom.getParentStyleSheet(cssRule); - - if (!parentStyleSheet) { - // We could call getAllCssStyleRules() here to get our special indexes on - // the style object, but that seems like it could be wasteful. - throw Error('Cannot find a parentStyleSheet.'); - } - - var cssRuleList = goog.cssom.getCssRulesFromStyleSheet(parentStyleSheet); - if (cssRuleList && cssRuleList.length) { - for (var i = 0, n = cssRuleList.length, thisCssRule; i < n; i++) { - thisCssRule = cssRuleList[i]; - if (thisCssRule == cssRule) { - return i; - } - } - } - return -1; -}; - - -/** - * We do some trickery in getAllCssStyleRules that hacks this in for IE. - * If the cssRule object isn't coming from a result of that function call, this - * method will return undefined in IE. - * @param {CSSRule} cssRule The CSSRule. - * @return {CSSStyleSheet} A styleSheet object. - */ -goog.cssom.getParentStyleSheet = function(cssRule) { - return cssRule.parentStyleSheet || - cssRule.style && - (/** @type {!Object} */ (cssRule.style))['-closure-parent-stylesheet']; -}; - - -/** - * Replace a cssRule with some cssText for a new rule. - * If the cssRule object is not one of objects returned by - * getAllCssStyleRules, then you'll need to provide both the styleSheet and - * possibly the index, since we can't infer them from the standard cssRule - * object in IE. We do some trickery in getAllCssStyleRules to hack this in. - * @param {CSSRule} cssRule A CSSRule. - * @param {string} cssText The text for the new CSSRule. - * @param {CSSStyleSheet=} opt_parentStyleSheet A reference to the stylesheet - * object this cssRule belongs to. - * @param {number=} opt_index The index of the cssRule in its parentStylesheet. - * @throws {Error} If we cannot find a parentStyleSheet. - * @throws {Error} If we cannot find a css rule index. - */ -goog.cssom.replaceCssRule = function( - cssRule, cssText, opt_parentStyleSheet, opt_index) { - var parentStyleSheet = - opt_parentStyleSheet || goog.cssom.getParentStyleSheet(cssRule); - if (parentStyleSheet) { - var index = Number(opt_index) >= 0 ? - Number(opt_index) : - goog.cssom.getCssRuleIndexInParentStyleSheet(cssRule, parentStyleSheet); - if (index >= 0) { - goog.cssom.removeCssRule(parentStyleSheet, index); - goog.cssom.addCssRule(parentStyleSheet, cssText, index); - } else { - throw Error('Cannot proceed without the index of the cssRule.'); - } - } else { - throw Error('Cannot proceed without the parentStyleSheet.'); - } -}; - - -/** - * Cross browser function to add a CSSRule into a CSSStyleSheet, optionally - * at a given index. - * @param {CSSStyleSheet} cssStyleSheet The CSSRule's parentStyleSheet. - * @param {string} cssText The text for the new CSSRule. - * @param {number=} opt_index The index of the cssRule in its parentStylesheet. - * @throws {Error} If the css rule text appears to be ill-formatted. - * TODO(bowdidge): Inserting at index 0 fails on Firefox 2 and 3 with an - * exception warning "Node cannot be inserted at the specified point in - * the hierarchy." - */ -goog.cssom.addCssRule = function(cssStyleSheet, cssText, opt_index) { - var index = opt_index; - if (index == undefined || index < 0) { - // If no index specified, insert at the end of the current list - // of rules. - var rules = goog.cssom.getCssRulesFromStyleSheet(cssStyleSheet); - index = rules.length; - } - if (cssStyleSheet.insertRule) { - // W3C (including IE9+). - cssStyleSheet.insertRule(cssText, index); - - } else { - // IE, pre 9: We have to parse the cssRule text to get the selector - // separated from the style text. - // aka Everything that isn't a colon, followed by a colon, then - // the rest is the style part. - var matches = /^([^\{]+)\{([^\{]+)\}/.exec(cssText); - if (matches.length == 3) { - var selector = matches[1]; - var style = matches[2]; - cssStyleSheet.addRule(selector, style, index); - } else { - throw Error('Your CSSRule appears to be ill-formatted.'); - } - } -}; - - -/** - * Cross browser function to remove a CSSRule in a CSSStyleSheet at an index. - * @param {CSSStyleSheet} cssStyleSheet The CSSRule's parentStyleSheet. - * @param {number} index The CSSRule's index in the parentStyleSheet. - */ -goog.cssom.removeCssRule = function(cssStyleSheet, index) { - if (cssStyleSheet.deleteRule) { - // W3C. - cssStyleSheet.deleteRule(index); - - } else { - // IE. - cssStyleSheet.removeRule(index); - } -}; - - -/** - * Appends a DOM node to HEAD containing the css text that's passed in. - * @param {string} cssText CSS to add to the end of the document. - * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper user for - * document interactions. - * @return {!Element} The newly created STYLE element. - */ -goog.cssom.addCssText = function(cssText, opt_domHelper) { - var domHelper = opt_domHelper || goog.dom.getDomHelper(); - var document = domHelper.getDocument(); - var cssNode = domHelper.createElement(goog.dom.TagName.STYLE); - cssNode.type = 'text/css'; - var head = domHelper.getElementsByTagName(goog.dom.TagName.HEAD)[0]; - head.appendChild(cssNode); - if (cssNode.styleSheet) { - // IE. - cssNode.styleSheet.cssText = cssText; - } else { - // W3C. - var cssTextNode = document.createTextNode(cssText); - cssNode.appendChild(cssTextNode); - } - return cssNode; -}; - - -/** - * Cross browser method to get the filename from the StyleSheet's href. - * Explorer only returns the filename in the href, while other agents return - * the full path. - * @param {!StyleSheet} styleSheet Any valid StyleSheet object with an href. - * @throws {Error} When there's no href property found. - * @return {?string} filename The filename, or null if not an external - * styleSheet. - */ -goog.cssom.getFileNameFromStyleSheet = function(styleSheet) { - var href = styleSheet.href; - - // Another IE/FF difference. IE returns an empty string, while FF and others - // return null for CSSStyleSheets not from an external file. - if (!href) { - return null; - } - - // We need the regexp to ensure we get the filename minus any query params. - var matches = /([^\/\?]+)[^\/]*$/.exec(href); - var filename = matches[1]; - return filename; -}; - - -/** - * Recursively gets all CSS text or rules. - * @param {CSSStyleSheet|StyleSheetList} styleSheet The CSSStyleSheet. - * @param {boolean} isTextOutput If true, output is cssText, otherwise cssRules. - * @return {string|!Array} cssText or cssRules. - * @private - */ -goog.cssom.getAllCss_ = function(styleSheet, isTextOutput) { - var cssOut = []; - var styleSheets = goog.cssom.getAllCssStyleSheets(styleSheet); - - for (var i = 0; styleSheet = styleSheets[i]; i++) { - var cssRuleList = goog.cssom.getCssRulesFromStyleSheet(styleSheet); - - if (cssRuleList && cssRuleList.length) { - var ruleIndex = 0; - for (var j = 0, n = cssRuleList.length, cssRule; j < n; j++) { - cssRule = cssRuleList[j]; - // Gets cssText output, ignoring CSSImportRules. - if (isTextOutput && !cssRule.href) { - var res = goog.cssom.getCssTextFromCssRule(cssRule); - cssOut.push(res); - - } else if (!cssRule.href) { - // Gets cssRules output, ignoring CSSImportRules. - if (cssRule.style) { - // This is a fun little hack to get parentStyleSheet into the rule - // object for IE since it failed to implement rule.parentStyleSheet. - // We can later read this property when doing things like hunting - // for indexes in order to delete a given CSSRule. - // Unfortunately we have to use the style object to store these - // pieces of info since the rule object is read-only. - if (!cssRule.parentStyleSheet) { - (/** @type {!Object} */ (cssRule.style))[ - '-closure-parent-stylesheet'] = styleSheet; - } - - // This is a hack to help with possible removal of the rule later, - // where we just append the rule's index in its parentStyleSheet - // onto the style object as a property. - // Unfortunately we have to use the style object to store these - // pieces of info since the rule object is read-only. - (/** @type {!Object} */ (cssRule.style))['-closure-rule-index'] = - isTextOutput ? undefined : ruleIndex; - } - cssOut.push(cssRule); - } - if (!isTextOutput) { - ruleIndex++; - } - } - } - } - return isTextOutput ? cssOut.join(' ') : cssOut; -}; diff --git a/third_party/closure/goog/cssom/iframe/style.js b/third_party/closure/goog/cssom/iframe/style.js deleted file mode 100644 index 660e182269b5b..0000000000000 --- a/third_party/closure/goog/cssom/iframe/style.js +++ /dev/null @@ -1,984 +0,0 @@ -// Copyright 2007 The Closure Library Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS-IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// All Rights Reserved. - -/** - * @fileoverview Provides utility routines for copying modified - * {@code CSSRule} objects from the parent document into iframes so that any - * content in the iframe will be styled as if it was inline in the parent - * document. - * - *

- * For example, you might have this CSS rule: - * - * #content .highlighted { background-color: yellow; } - * - * And this DOM structure: - * - *

- * '; - assertSanitizedHtml(xssHtml, safeHtml); - - // FRAME (frames have the same sorts of XSS problems as iframes): - // Browser support: [IE7.0|IE6.0|NS8.1-IE] [NS8.1-G|FF2.0] [O9.02] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // TABLE (who would have thought tables were XSS targets... except me, of - // course): - // Browser support: [IE6.0|NS8.1-IE] [O9.02] - safeHtml = isIE9() ? '
' : '
'; - xssHtml = ''; - // TODO(danesh): Investigate why this is different for IE9. - assertSanitizedHtml(xssHtml, safeHtml); - - // TD (just like above, TD's are vulnerable to BACKGROUNDs containing - // JavaScript XSS vectors): - // Browser support: [IE6.0|NS8.1-IE] [O9.02] - // NOTE(user): original lacked tbody tags - safeHtml = '
'; - xssHtml = '
'; - assertSanitizedHtml(xssHtml, safeHtml); - - // TD (just like above, TD's are vulnerable to BACKGROUNDs containing - // JavaScript XSS vectors): - // Browser support: [IE6.0|NS8.1-IE] [O9.02] - safeHtml = '
'; - xssHtml = '
'; - assertSanitizedHtml(xssHtml, safeHtml); - - // DIV background-image plus extra characters. I built a quick XSS fuzzer to - // detect any erroneous characters that are allowed after the open parenthesis - // but before the JavaScript directive in IE and Netscape 8.1 in secure site - // mode. These are in decimal but you can include hex and add padding of - // course. (Any of the following chars can be used: 1-32, 34, 39, 160, - // 8192-8.13, 12288, 65279): - // Browser support: [IE6.0|NS8.1-IE] - safeHtml = '
'; - xssHtml = '
'; - assertSanitizedHtml(xssHtml, safeHtml); - - // DIV expression - a variant of this was effective against a real world - // cross site scripting filter using a newline between the colon and - // "expression": - // Browser support: [IE7.0|IE6.0|NS8.1-IE] - safeHtml = '
'; - xssHtml = '
'; - assertSanitizedHtml(xssHtml, safeHtml); - - // STYLE tags with broken up JavaScript for XSS (this XSS at times sends IE - // into an infinite loop of alerts): - // Browser support: [IE6.0|NS8.1-IE] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // STYLE attribute using a comment to break up expression (Thanks to Roman - // Ivanov for this one): - // Browser support: [IE7.0|IE6.0|NS8.1-IE] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // Anonymous HTML with STYLE attribute (IE6.0 and Netscape 8.1+ in IE - // rendering engine mode don't really care if the HTML tag you build exists - // or not, as long as it starts with an open angle bracket and a letter): - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // IMG STYLE with expression (this is really a hybrid of the above XSS - // vectors, but it really does show how hard STYLE tags can be to parse apart, - // like above this can send IE into a loop): - // Browser support: [IE7.0|IE6.0|NS8.1-IE] - safeHtml = isIE9() ? 'undefined' : 'exp/*'; - xssHtml = 'exp/*'; - assertSanitizedHtml(xssHtml, safeHtml); - - // STYLE tag (Older versions of Netscape only): - // Browser support: [NS4] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // STYLE tag using background-image: - // Browser support: [IE6.0|NS8.1-IE] - safeHtml = isIE9() ? 'undefined' : ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // BASE tag. Works in IE and Netscape 8.1 in safe mode. You need the // to - // comment out the next characters so you won't get a JavaScript error and - // your XSS tag will render. Also, this relies on the fact that the website - // uses dynamically placed images like "images/image.jpg" rather than full - // paths. If the path includes a leading forward slash like - // "/images/image.jpg" you can remove one slash from this vector (as long as - // there are two to begin the comment this will work): - // Browser support: [IE6.0|NS8.1-IE] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // OBJECT tag (if they allow objects, you can also inject virus payloads to - // infect the users, etc. and same with the APPLET tag). The linked file is - // actually an HTML file that can contain your XSS: - // Browser support: [O9.02] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // Using an EMBED tag you can embed a Flash movie that contains XSS. Click - // here for a demo. If you add the attributes allowScriptAccess="never" and - // allownetworking="internal" it can mitigate this risk (thank you to Jonathan - // Vanasco for the info).: - // Browser support: [IE7.0|IE6.0|NS8.1-IE] [NS8.1-G|FF2.0] [O9.02] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // You can EMBED SVG which can contain your XSS vector. This example only - // works in Firefox, but it's better than the above vector in Firefox because - // it does not require the user to have Flash turned on or installed. Thanks - // to nEUrOO for this one. - // Browser support: [IE7.0|IE6.0|NS8.1-IE] [NS8.1-G|FF2.0] [O9.02] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // XML namespace. The htc file must be located on the same server as your XSS - // vector: - // Browser support: [IE7.0|IE6.0|NS8.1-IE] - safeHtml = 'XSS'; - xssHtml = '' + - '' + - 'XSS' + - ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // XML data island with CDATA obfuscation (this XSS attack works only in IE - // and Netscape 8.1 in IE rendering engine mode) - vector found by Sec Consult - // while auditing Yahoo: - // Browser support: [IE6.0|NS8.1-IE] - safeHtml = isIE9() ? '' : - ']]>' + - ''; - xssHtml = '' + - ']]>' + - ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // HTML+TIME in XML. This is how Grey Magic hacked Hotmail and Yahoo!. This - // only works in Internet Explorer and Netscape 8.1 in IE rendering engine - // mode and remember that you need to be between HTML and BODY tags for this - // to work: - // Browser support: [IE7.0|IE6.0|NS8.1-IE] - safeHtml = ''; - xssHtml = '' + - '' + - '' + - '' + - ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // IMG Embedded commands - this works when the webpage where this is injected - // (like a web-board) is behind password protection and that password - // protection works with other commands on the same domain. This can be used - // to delete users, add users (if the user who visits the page is an - // administrator), send credentials elsewhere, etc.... This is one of the - // lesser used but more useful XSS vectors: - // Browser support: [IE7.0|IE6.0|NS8.1-IE] [NS8.1-G|FF2.0] [O9.02] - safeHtml = ''; - xssHtml = ''; - assertSanitizedHtml(xssHtml, safeHtml); - - // This was tested in IE, your mileage may vary. For performing XSS on sites - // that allow "'; - var expected = ''; - // TODO(pelizzi): use unblockTag once it's available - delete goog.html.sanitizer.TagBlacklist['TEMPLATE']; - var builder = new goog.html.sanitizer.HtmlSanitizer.Builder(); - goog.html.sanitizer.unsafe.alsoAllowTags(just, builder, ['TEMPLATE']); - assertSanitizedHtml(input, expected, builder.build()); - goog.html.sanitizer.TagBlacklist['TEMPLATE'] = true; -} - - -function testOnlyAllowEmptyAttrList() { - var input = '

b

' + - 'c'; - var expected = '

b

c'; - assertSanitizedHtml( - input, expected, new goog.html.sanitizer.HtmlSanitizer.Builder() - .onlyAllowAttributes([]) - .build()); -} - - -function testOnlyAllowUnWhitelistedAttr() { - assertThrows(function() { - new goog.html.sanitizer.HtmlSanitizer.Builder().onlyAllowAttributes( - ['alt', 'zzz']); - }); -} - - -function testOnlyAllowAttributeWildCard() { - var input = - '
yep
'; - var expected = '
yep
'; - assertSanitizedHtml( - input, expected, - new goog.html.sanitizer.HtmlSanitizer.Builder() - .onlyAllowAttributes([{tagName: '*', attributeName: 'alt'}]) - .build()); -} - - -function testOnlyAllowAttributeLabelForA() { - var input = 'fff'; - var expected = 'fff'; - assertSanitizedHtml( - input, expected, new goog.html.sanitizer.HtmlSanitizer.Builder() - .onlyAllowAttributes([{ - tagName: '*', - attributeName: 'label', - policy: function(value, hints) { - if (hints.tagName !== 'a') { - return null; - } - return value; - } - }]) - .build()); -} - - -function testOnlyAllowAttributePolicy() { - var input = 'yesno'; - var expected = 'yes'; - assertSanitizedHtml( - input, expected, new goog.html.sanitizer.HtmlSanitizer.Builder() - .onlyAllowAttributes([{ - tagName: '*', - attributeName: 'alt', - policy: function(value, hints) { - assertEquals(hints.attributeName, 'alt'); - return value === 'yes' ? value : null; - } - }]) - .build()); -} - - -function testOnlyAllowAttributePolicyPipe1() { - var input = 'b'; - var expected = 'b'; - assertSanitizedHtml( - input, expected, new goog.html.sanitizer.HtmlSanitizer.Builder() - .onlyAllowAttributes([{ - tagName: 'a', - attributeName: 'target', - policy: function(value, hints) { - assertEquals(hints.attributeName, 'target'); - return '_blank'; - } - }]) - .build()); -} - - -function testOnlyAllowAttributePolicyPipe2() { - var input = 'b'; - var expected = 'b'; - assertSanitizedHtml( - input, expected, new goog.html.sanitizer.HtmlSanitizer.Builder() - .onlyAllowAttributes([{ - tagName: 'a', - attributeName: 'target', - policy: function(value, hints) { - assertEquals(hints.attributeName, 'target'); - return 'nope'; - } - }]) - .build()); -} - - -function testOnlyAllowAttributeSpecificPolicyThrows() { - assertThrows(function() { - new goog.html.sanitizer.HtmlSanitizer.Builder().onlyAllowAttributes([ - {tagName: 'img', attributeName: 'src', policy: goog.functions.identity} - ]); - }); -} - - -function testOnlyAllowAttributeGenericPolicyThrows() { - assertThrows(function() { - new goog.html.sanitizer.HtmlSanitizer.Builder().onlyAllowAttributes([{ - tagName: '*', - attributeName: 'target', - policy: goog.functions.identity - }]); - }); -} - - -function testOnlyAllowAttributeRefineThrows() { - var builder = - new goog.html.sanitizer.HtmlSanitizer.Builder() - .onlyAllowAttributes( - ['aria-checked', {tagName: 'LINK', attributeName: 'HREF'}]) - .onlyAllowAttributes(['aria-checked']); - assertThrows(function() { - builder.onlyAllowAttributes(['alt']); - }); -} - - -function testUrlWithCredentials() { - if (isIE8() || isIE9()) { - return; - } - // IE has trouble getting and setting URL attributes with credentials. Both - // HTMLSanitizer and assertHtmlMatches are affected by the bug, hence the use - // of plain string matching. - var url = 'http://foo:bar@example.com'; - var input = '
' + - '
'; - var expectedIE = '
'; - var sanitizer = - new goog.html.sanitizer.HtmlSanitizer.Builder() - .withCustomNetworkRequestUrlPolicy(goog.html.SafeUrl.sanitize) - .allowCssStyles() - .build(); - if (goog.userAgent.EDGE_OR_IE) { - assertEquals( - expectedIE, goog.html.SafeHtml.unwrap(sanitizer.sanitize(input))); - } else { - assertSanitizedHtml(input, input, sanitizer); - } -} diff --git a/third_party/closure/goog/html/sanitizer/noclobber.js b/third_party/closure/goog/html/sanitizer/noclobber.js new file mode 100644 index 0000000000000..02355f7738cd8 --- /dev/null +++ b/third_party/closure/goog/html/sanitizer/noclobber.js @@ -0,0 +1,466 @@ +// Copyright 2017 The Closure Library Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS-IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @fileoverview Utility DOM functions resistant to DOM clobbering. Clobbering + * resistance is offered as a best-effort feature -- it is not available on + * older browsers such as IE <10, Chrome <43, etc. In some cases, we can at + * least detect clobbering attempts and abort. Note that this is not intended to + * be a general-purpose library -- it is only used by the HTML sanitizer to + * accept and sanitize clobbered input. If your projects needs to protect + * against clobbered content, consider using the HTML sanitizer and configuring + * it to defuse clobbering by prefixing all element ids and names in the + * output. + * @supported Unless specified in the method documentation, IE 10 and newer. + */ + +goog.module('goog.html.sanitizer.noclobber'); +goog.module.declareLegacyNamespace(); + +var NodeType = goog.require('goog.dom.NodeType'); +var googAsserts = goog.require('goog.asserts'); +var userAgentProduct = goog.require('goog.userAgent.product'); + +/** + * Note about browser support: + * - IE 8 and 9 don't have DOM prototypes. There is no simple way of saving + * the methods and accessors for a clobber-safe call. + * - Chrome <43 doesn't have attributes on DOM prototypes, so there is no way of + * making clobber-safe calls for attribute descriptors. + * - IE 8 and 9 don't even have Node and HTMLElement, so there is no + * straightforward way of checking if the result was clobbered for many of the + * methods. + * - IE 8 and 9 have alternate names for getPropertyValue/setProperty in + * CSSStyleDeclaration. + * For simplicity, we don't support IE 8 and 9 for anything but the CSS methods + * which already had IE8 and IE9 support. Chrome 41 must still be supported. + */ + +/** + * Shorthand for `Object.getOwnPropertyDescriptor(...).get` to improve + * readability during initialization of `Methods`. + * @param {string} className + * @param {string} property + * @return {?Function} + */ +function getterOrNull(className, property) { + var ctor = goog.global[className]; + if (!ctor || !ctor.prototype) { + return null; + } + var descriptor = Object.getOwnPropertyDescriptor(ctor.prototype, property); + return (descriptor && descriptor.get) || null; +} + +/** + * Shorthand for `DOMInterface.prototype.method` to improve readability + * during initialization of `Methods`. + * @param {string} className + * @param {string} method + * @return {?Function} + */ +function prototypeMethodOrNull(className, method) { + var ctor = goog.global[className]; + return (ctor && ctor.prototype && ctor.prototype[method]) || null; +} + +// Functions we use to avoid looking up the prototypes and the descriptors +// multiple times. +/** @const @enum {?Function} */ +var Methods = { + ATTRIBUTES_GETTER: getterOrNull('Element', 'attributes') || + // Edge and IE10 define this Element property on Node instead of + // Element. + getterOrNull('Node', 'attributes'), + HAS_ATTRIBUTE: prototypeMethodOrNull('Element', 'hasAttribute'), + GET_ATTRIBUTE: prototypeMethodOrNull('Element', 'getAttribute'), + SET_ATTRIBUTE: prototypeMethodOrNull('Element', 'setAttribute'), + REMOVE_ATTRIBUTE: prototypeMethodOrNull('Element', 'removeAttribute'), + INNER_HTML_GETTER: getterOrNull('Element', 'innerHTML') || + // IE 10 defines this Element property on HTMLElement. + getterOrNull('HTMLElement', 'innerHTML'), + GET_ELEMENTS_BY_TAG_NAME: + prototypeMethodOrNull('Element', 'getElementsByTagName'), + MATCHES: prototypeMethodOrNull('Element', 'matches') || + prototypeMethodOrNull('Element', 'msMatchesSelector'), + NODE_NAME_GETTER: getterOrNull('Node', 'nodeName'), + NODE_TYPE_GETTER: getterOrNull('Node', 'nodeType'), + PARENT_NODE_GETTER: getterOrNull('Node', 'parentNode'), + CHILD_NODES_GETTER: getterOrNull('Node', 'childNodes'), + APPEND_CHILD: prototypeMethodOrNull('Node', 'appendChild'), + STYLE_GETTER: getterOrNull('HTMLElement', 'style') || + // Safari 10 defines the property on Element instead of + // HTMLElement. + getterOrNull('Element', 'style'), + SHEET_GETTER: getterOrNull('HTMLStyleElement', 'sheet'), + GET_PROPERTY_VALUE: + prototypeMethodOrNull('CSSStyleDeclaration', 'getPropertyValue'), + SET_PROPERTY: prototypeMethodOrNull('CSSStyleDeclaration', 'setProperty') +}; + +/** + * Calls the provided DOM property descriptor and returns its result. If the + * descriptor is not available, use fallbackPropertyName to get the property + * value in a clobber-vulnerable way, and use fallbackTest to check if the + * property was clobbered, throwing an exception if so. + * @param {?Function} fn + * @param {*} object + * @param {string} fallbackPropertyName + * @param {function(*):boolean} fallbackTest + * @return {?} + */ +function genericPropertyGet(fn, object, fallbackPropertyName, fallbackTest) { + if (fn) { + return fn.apply(object); + } + var propertyValue = object[fallbackPropertyName]; + if (!fallbackTest(propertyValue)) { + throw new Error('Clobbering detected'); + } + return propertyValue; +} + +/** + * Calls the provided DOM prototype method and returns its result. If the + * method is not available, use fallbackMethodName to call the method in a + * clobber-vulnerable way, and use fallbackTest to check if the + * method was clobbered, throwing an exception if so. + * @param {?Function} fn + * @param {*} object + * @param {string} fallbackMethodName + * @param {!Array<*>} args + * @return {?} + */ +function genericMethodCall(fn, object, fallbackMethodName, args) { + if (fn) { + return fn.apply(object, args); + } + // IE8 and IE9 will return 'object' for + // CSSStyleDeclaration.(get|set)Attribute, so we can't use typeof. + if (userAgentProduct.IE && document.documentMode < 10) { + if (!object[fallbackMethodName].call) { + throw new Error('IE Clobbering detected'); + } + } else if (typeof object[fallbackMethodName] != 'function') { + throw new Error('Clobbering detected'); + } + return object[fallbackMethodName].apply(object, args); +} + +/** + * Returns an element's attributes without falling prey to things like + *
. Equivalent to + * `node.attributes`. + * @param {!Element} element + * @return {!NamedNodeMap} + */ +function getElementAttributes(element) { + return genericPropertyGet( + Methods.ATTRIBUTES_GETTER, element, 'attributes', function(attributes) { + return attributes instanceof NamedNodeMap; + }); +} + +/** + * Returns whether an element has a specific attribute, without falling prey to + * things like
. + * Equivalent to {@code element.hasAttribute("foo")}. + * @param {!Element} element + * @param {string} attrName + * @return {boolean} + */ +function hasElementAttribute(element, attrName) { + return genericMethodCall( + Methods.HAS_ATTRIBUTE, element, 'hasAttribute', [attrName]); +} + +/** + * Returns a specific attribute from an element without falling prey to + * things like
. + * Equivalent to {@code element.getAttribute("foo")}. + * @param {!Element} element + * @param {string} attrName + * @return {?string} + */ +function getElementAttribute(element, attrName) { + // Older browsers might return empty string instead of null to follow the + // DOM 3 Core Specification. + return genericMethodCall( + Methods.GET_ATTRIBUTE, element, 'getAttribute', [attrName]) || + null; +} + +/** + * Sets an element's attributes without falling prey to things like + *
. Equivalent to {@code + * element.setAttribute("foo", "bar")}. + * @param {!Element} element + * @param {string} name + * @param {string} value + */ +function setElementAttribute(element, name, value) { + try { + genericMethodCall( + Methods.SET_ATTRIBUTE, element, 'setAttribute', [name, value]); + } catch (e) { + // IE throws an exception if the src attribute contains HTTP credentials. + // However the attribute gets set anyway. + if (e.message.indexOf('A security problem occurred') != -1) { + return; + } + throw e; + } +} + +/** + * Deletes a specific attribute from an element without falling prey to + * things like
. + * Equivalent to {@code element.removeAttribute("foo")}. + * @param {!Element} element + * @param {string} attrName + */ +function removeElementAttribute(element, attrName) { + genericMethodCall( + Methods.REMOVE_ATTRIBUTE, element, 'removeAttribute', [attrName]); +} + +/** + * Returns a node's innerHTML property value without falling prey to things like + *
. Equivalent to + * `element.innerHTML`. + * @param {!Element} element + * @return {string} + */ +function getElementInnerHTML(element) { + return genericPropertyGet( + Methods.INNER_HTML_GETTER, element, 'innerHTML', function(html) { + return typeof html == 'string'; + }); +} + +/** + * Returns an element's style without falling prey to things like + *
. + * @param {!Element} element + * @return {!CSSStyleDeclaration} + */ +function getElementStyle(element) { + assertHTMLElement(element); + return genericPropertyGet( + Methods.STYLE_GETTER, element, 'style', function(style) { + return style instanceof CSSStyleDeclaration; + }); +} + +/** + * Asserts that the Element is an HTMLElement, or throws an exception. + * @param {!Element} element + */ +function assertHTMLElement(element) { + if (googAsserts.ENABLE_ASSERTS && !(element instanceof HTMLElement)) { + throw new Error('Not an HTMLElement'); + } +} + +/** + * Get the children of a specific tag matching the provided tag name without + * falling prey to things like
. + * Equivalent to {@code element.getElementsByTagName("foo")}. + * @param {!Element} element + * @param {string} name + * @return {!Array} + */ +function getElementsByTagName(element, name) { + return Array.from(genericMethodCall( + Methods.GET_ELEMENTS_BY_TAG_NAME, element, 'getElementsByTagName', + [name])); +} + +/** + * Returns an element's style without falling prey to things like + *
. + * @param {!Element} element + * @return {!CSSStyleSheet} + */ +function getElementStyleSheet(element) { + assertHTMLElement(element); + return genericPropertyGet( + Methods.SHEET_GETTER, element, 'sheet', function(sheet) { + return sheet instanceof CSSStyleSheet; + }); +} + +/** + * Returns true if the element would be selected by the provided selector, + * without falling prey to things like
. + * Equivalent to {@code element.matches("foo")}. + * @param {!Element} element + * @param {string} selector + * @return {boolean} + */ +function elementMatches(element, selector) { + return genericMethodCall( + Methods.MATCHES, element, + element.matches ? 'matches' : 'msMatchesSelector', [selector]); +} + +/** + * Asserts that a Node is an Element, without falling prey to things like + *
. + * @param {!Node} node + * @return {!Element} + */ +function assertNodeIsElement(node) { + if (googAsserts.ENABLE_ASSERTS && !isNodeElement(node)) { + googAsserts.fail( + 'Expected Node of type Element but got Node of type %s', + getNodeType(node)); + } + return /** @type {!Element} */ (node); +} + +/** + * Returns whether the node is an Element, without falling prey to things like + *
. + * @param {!Node} node + * @return {boolean} + */ +function isNodeElement(node) { + return getNodeType(node) == NodeType.ELEMENT; +} + +/** + * Returns a node's nodeName without falling prey to things like + *
. + * @param {!Node} node + * @return {string} + */ +function getNodeName(node) { + return genericPropertyGet( + Methods.NODE_NAME_GETTER, node, 'nodeName', function(name) { + return typeof name == 'string'; + }); +} + +/** + * Returns a node's nodeType without falling prey to things like + * `
`. + * @param {!Node} node + * @return {number} + */ +function getNodeType(node) { + return genericPropertyGet( + Methods.NODE_TYPE_GETTER, node, 'nodeType', function(type) { + return typeof type == 'number'; + }); +} + +/** + * Returns a node's parentNode without falling prey to things like + *
. + * @param {!Node} node + * @return {?Node} + */ +function getParentNode(node) { + return genericPropertyGet( + Methods.PARENT_NODE_GETTER, node, 'parentNode', function(parentNode) { + // We need to ensure that parentNode is returning the actual parent node + // and not a child node that happens to have a name of "parentNode". + // We check that the node returned by parentNode is itself not named + // "parentNode" - this could happen legitimately but on IE we have no + // better means of avoiding the pitfall. + return !( + parentNode && typeof parentNode.name == 'string' && + parentNode.name && parentNode.name.toLowerCase() == 'parentnode'); + }); +} + +/** + * Returns the value of node.childNodes without falling prey to things like + *
. + * @param {!Node} node + * @return {!NodeList} + */ +function getChildNodes(node) { + return genericPropertyGet( + Methods.CHILD_NODES_GETTER, node, 'childNodes', function(childNodes) { + return childNodes instanceof NodeList; + }); +} + +/** + * Appends a child to a node without falling prey to things like + *
. + * @param {!Node} parent + * @param {!Node} child + * @return {!Node} + */ +function appendNodeChild(parent, child) { + return genericMethodCall( + Methods.APPEND_CHILD, parent, 'appendChild', [child]); +} + +/** + * Provides a way cross-browser way to get a CSS value from a CSS declaration. + * @param {!CSSStyleDeclaration} cssStyle A CSS style object. + * @param {string} propName A property name. + * @return {string} Value of the property as parsed by the browser. + * @supported IE8 and newer. + */ +function getCssPropertyValue(cssStyle, propName) { + return genericMethodCall( + Methods.GET_PROPERTY_VALUE, cssStyle, + cssStyle.getPropertyValue ? 'getPropertyValue' : 'getAttribute', + [propName]) || + ''; +} + +/** + * Provides a cross-browser way to set a CSS value on a CSS declaration. + * @param {!CSSStyleDeclaration} cssStyle A CSS style object. + * @param {string} propName A property name. + * @param {string} sanitizedValue Sanitized value of the property to be set + * on the CSS style object. + * @supported IE8 and newer. + */ +function setCssProperty(cssStyle, propName, sanitizedValue) { + genericMethodCall( + Methods.SET_PROPERTY, cssStyle, + cssStyle.setProperty ? 'setProperty' : 'setAttribute', + [propName, sanitizedValue]); +} + +exports = { + getElementAttributes: getElementAttributes, + hasElementAttribute: hasElementAttribute, + getElementAttribute: getElementAttribute, + setElementAttribute: setElementAttribute, + removeElementAttribute: removeElementAttribute, + getElementInnerHTML: getElementInnerHTML, + getElementStyle: getElementStyle, + getElementsByTagName: getElementsByTagName, + getElementStyleSheet: getElementStyleSheet, + elementMatches: elementMatches, + assertNodeIsElement: assertNodeIsElement, + isNodeElement: isNodeElement, + getNodeName: getNodeName, + getNodeType: getNodeType, + getParentNode: getParentNode, + getChildNodes: getChildNodes, + appendNodeChild: appendNodeChild, + getCssPropertyValue: getCssPropertyValue, + setCssProperty: setCssProperty, + /** @package */ + Methods: Methods, +}; diff --git a/third_party/closure/goog/html/sanitizer/safedomtreeprocessor.js b/third_party/closure/goog/html/sanitizer/safedomtreeprocessor.js new file mode 100644 index 0000000000000..da650f30089c9 --- /dev/null +++ b/third_party/closure/goog/html/sanitizer/safedomtreeprocessor.js @@ -0,0 +1,337 @@ +// Copyright 2017 The Closure Library Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS-IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +/** + * @fileoverview A base class to safely parse and transform an HTML string + * using an inert DOM, which avoids executing scripts and loading images. Note: + * this class does *not* guarantee that the output does not contain scripts and + * images that eventually execute once the output is inserted into an active DOM + * document. If any subclass claims to produce SafeHtml output, it must be + * reviewed separately. + * @supported IE 10+, Chrome 26+, Firefox 22+, Safari 7.1+, Opera 15+ + */ + +goog.module('goog.html.sanitizer.SafeDomTreeProcessor'); +goog.module.declareLegacyNamespace(); + +var Const = goog.require('goog.string.Const'); +var ElementWeakMap = goog.require('goog.html.sanitizer.ElementWeakMap'); +var NodeType = goog.require('goog.dom.NodeType'); +var TagName = goog.require('goog.dom.TagName'); +var googDom = goog.require('goog.dom'); +var googLog = goog.require('goog.log'); +var noclobber = goog.require('goog.html.sanitizer.noclobber'); +var safe = goog.require('goog.dom.safe'); +var uncheckedconversions = goog.require('goog.html.uncheckedconversions'); +var userAgent = goog.require('goog.userAgent'); + +/** @const {?googLog.Logger} */ +var logger = googLog.getLogger('goog.html.sanitizer.SafeDomTreeProcessor'); + +/** + * Whether the HTML sanitizer is supported. For now mainly exclude + * IE9 or below, for which we know the sanitizer is insecure or broken. + * @const {boolean} + */ +var SAFE_PARSING_SUPPORTED = + !userAgent.IE || userAgent.isDocumentModeOrHigher(10); + +/** + * Whether the template tag is supported. + * @const {boolean} + */ +var HTML_SANITIZER_TEMPLATE_SUPPORTED = + !userAgent.IE || document.documentMode == null; + +/** + * Parses a string of unsanitized HTML and provides an iterator over the + * resulting DOM tree nodes. The parsing operation is inert (that is, + * it does not cause execution of any active content or cause the browser to + * issue any requests). The returned iterator is guaranteed to iterate over a + * parent element before iterating over any of its children. + * @param {string} html + * @return {!TreeWalker} + */ +function getDomTreeWalker(html) { + var iteratorParent; + var safeHtml = + uncheckedconversions.safeHtmlFromStringKnownToSatisfyTypeContract( + Const.from('Never attached to DOM.'), html); + var templateElement = document.createElement('template'); + if (HTML_SANITIZER_TEMPLATE_SUPPORTED && 'content' in templateElement) { + safe.unsafeSetInnerHtmlDoNotUseOrElse(templateElement, safeHtml); + iteratorParent = templateElement.content; + } else { + // In browsers where