diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 00000000..346f9888 --- /dev/null +++ b/.bazelrc @@ -0,0 +1 @@ +build --strategy=Closure=worker diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..7a61a332 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +* text=auto whitespace=blank-at-eol,tab-in-indent,trailing-space,tabwidth=2 + +*.bat text eol=crlf +*.sh text eol=lf diff --git a/.gitignore b/.gitignore index e2c7c1a4..726beb74 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ private/ node_modules/ node_modules/**/build/ node_modules/.bin/ +yarn.lock # coverage/etc scratch/ @@ -67,6 +68,8 @@ build-gen/ build-bin/ build-test/ +bazel-* + # ============================================================================== # WTF # ============================================================================== diff --git a/.gitmodules b/.gitmodules index edca41f3..9cf820da 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,24 +1,9 @@ -[submodule "third_party/closure-compiler"] - path = third_party/closure-compiler - url = https://github.com/benvanik/google-closure-compiler-bin.git -[submodule "third_party/closure-templates"] - path = third_party/closure-templates - url = https://github.com/benvanik/google-closure-templates-bin.git -[submodule "third_party/closure-stylesheets"] - path = third_party/closure-stylesheets - url = https://github.com/benvanik/google-closure-stylesheets-bin.git -[submodule "third_party/anvil-build"] - path = third_party/anvil-build - url = https://github.com/google/anvil-build.git [submodule "third_party/closure-linter"] path = third_party/closure-linter url = https://github.com/knutwalker/google-closure-linter.git [submodule "third_party/normalize.css"] path = third_party/normalize.css url = https://github.com/necolas/normalize.css.git -[submodule "third_party/closure-library"] - path = third_party/closure-library - url = https://github.com/google/closure-library.git [submodule "third_party/firefox-addon-sdk"] path = third_party/firefox-addon-sdk url = https://github.com/mozilla/addon-sdk.git diff --git a/BUILD b/BUILD new file mode 100644 index 00000000..35a3d979 --- /dev/null +++ b/BUILD @@ -0,0 +1,59 @@ +# Description: +# Javascript and C++ instrumentation-based profiling tools. +# https://github.com/google/tracing-framework + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # BSD 3-clause + +exports_files(["LICENSE"]) + +# Restricts most packages to use by WTF only. +# Selective rules we wish to support to external users are set to +# //visibility:public. +package_group( + name = "internal", + packages = [ + "//addons/...", + "//app/...", + "//assets/...", + "//bin/...", + "//bindings/...", + "//extensions/...", + "//externs/...", + "//src/...", + "//test/...", + "//third_party/...", + ], +) + +# Exported for nodejs rules. +filegroup( + name = "node_modules", + srcs = glob(["node_modules/**/*"]), +) + +# Debug; all runtime checks, verbose logging, and debug symbols. +# +# $ bazel build -c dbg ... +config_setting( + name = "dbg", + values = {"compilation_mode": "dbg"}, +) + +# Fast build; some runtime checks, detailed logging, and debug symbols. +# This is the default and will likely be what you want to use unless profiling. +# +# $ bazel build -c fastbuild ... +config_setting( + name = "fastbuild", + values = {"compilation_mode": "fastbuild"}, +) + +# Optimized; no runtime checks and terse logging. +# +# $ bazel build -c opt ... +config_setting( + name = "opt", + values = {"compilation_mode": "opt"}, +) diff --git a/BUILD.anvil b/BUILD.anvil deleted file mode 100644 index 85f9e077..00000000 --- a/BUILD.anvil +++ /dev/null @@ -1,673 +0,0 @@ -# Copyright 2012 Google Inc. All Rights Reserved. - -__author__ = 'benvanik@google.com (Ben Vanik)' - - -# Master anvil-build BUILD file for wtf - - -# ------------------------------------------------------------------------------ -# Third Party -# ------------------------------------------------------------------------------ - -JS_COMPILER_JAR='third_party:closure_compiler_jar' -SOY_COMPILER_JAR='third_party:closure_templates_jar' -GSS_COMPILER_JAR='third_party:closure_stylesheets_jar' -file_set( - name='all_externs', - srcs=glob('externs/**/*.js')) - - -# ------------------------------------------------------------------------------ -# CSS -# ------------------------------------------------------------------------------ - -file_set( - name='all_less', - srcs=glob('src/**/*.less')) - - -# ------------------------------------------------------------------------------ -# Soy Templates -# ------------------------------------------------------------------------------ - -closure_soy_library( - name='wtf_ui_soy_js', - srcs=glob('src/wtf/ui/**/*.soy'), - compiler_jar=SOY_COMPILER_JAR) -closure_soy_library( - name='wtf_hud_soy_js', - srcs=glob('src/wtf/hud/**/*.soy'), - deps=':wtf_ui_soy_js', - compiler_jar=SOY_COMPILER_JAR) -closure_soy_library( - name='wtf_app_soy_js', - srcs=glob('src/wtf/app/**/*.soy'), - deps=':wtf_ui_soy_js', - compiler_jar=SOY_COMPILER_JAR) -closure_soy_library( - name='wtf_replay_soy_js', - srcs=glob('src/wtf/replay/**/*.soy'), - deps=':wtf_ui_soy_js', - compiler_jar=SOY_COMPILER_JAR) - -file_set( - name='all_soy_js', - srcs=[ - ':wtf_ui_soy_js', - ':wtf_hud_soy_js', - ':wtf_app_soy_js', - ':wtf_replay_soy_js', - ]) - - -# ------------------------------------------------------------------------------ -# JavaScript -# ------------------------------------------------------------------------------ - -# wtf src/ -file_set( - name='wtf_src_js', - srcs=glob('src/**/*.js')) - -# third_party js -file_set( - name='third_party_js', - srcs=[ - 'third_party/d3/colorbrewer.js', - ]) - -# Testing support files -file_set( - name='testing_files', - srcs=[ - 'node_modules/mocha/mocha.js', - 'node_modules/mocha/mocha.css', - 'node_modules/chai/chai.js', - ]) - -SHARED_JS_FLAGS=[ - '--summary_detail_level=3', - '--define=goog.DEBUG=false', - '--define=goog.asserts.ENABLE_ASSERTS=false', - '--create_source_map=%outname%.map', - '--source_map_format=V3', - ] - -RELEASE_JS_FLAGS=[ - '--use_types_for_optimization', - #'--collapse_variable_declarations', - #'--collapse_anonymous_functions', - #'--collapse_properties', - #'--disambiguate_properties', - # rewrites things to be smaller but likely not better - # http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/FunctionRewriter.java - #'--rewrite_function_expressions=false', - # slow - may want disabled - #'--devirtualize_prototype_methods', - #'--devirtualize_prototype_methods=false', - ] - -# deps.js only -closure_js_library( - name='wtf_js_deps', - out='wtf_js', - mode='DEPS', - entry_points=[ - 'wtf.app.exports', - 'wtf.db.exports', - 'wtf.hud.exports', - 'wtf.remote.exports', - 'wtf.replay.graphics.exports', - 'wtf.replay.timeTravel.exports', - 'wtf.trace.exports', - ], - srcs=[ - 'third_party:all_closure_js', - ':third_party_js', - ':wtf_src_js', - ':all_soy_js', - ], - compiler_jar=JS_COMPILER_JAR) - - -# ------------------------------------------------------------------------------ -# JavaScript : trace_web -# ------------------------------------------------------------------------------ - -less_css_library( - name='wtf_trace_web_styles_debug', - srcs=['src/wtf/hud/hud.less', ':all_less'], - include_paths=['src',], - compiler_flags=[]) -less_css_library( - name='wtf_trace_web_styles_release_unminified', - srcs=['src/wtf/hud/hud.less', ':all_less'], - include_paths=['src',], - compiler_flags=['']) -closure_gss_library( - name='wtf_trace_web_styles_release', - mode='COMPILED', - srcs=':wtf_trace_web_styles_release_unminified', - compiler_jar=GSS_COMPILER_JAR, - compiler_flags=[ - '--css-renaming-prefix', 'wtf_', - '--no-eliminate-dead-styles', - '--allow-unrecognized-functions', - ]) - -WTF_TRACE_WEB_SRCS=[ - ':third_party_js', - ':wtf_src_js', - ':wtf_ui_soy_js', - ':wtf_hud_soy_js', - ] - -# All uncompiled JS -file_set( - name='all_trace_web_uncompiled_js', - srcs=[ - 'third_party:all_closure_js', - 'third_party:closure_uncompiled_js', - ] + WTF_TRACE_WEB_SRCS) - -# All compiled JS -file_set( - name='all_trace_web_compiled_js', - srcs=[ - 'third_party:all_closure_js', - ':wtf_trace_web_styles_release', - ] + WTF_TRACE_WEB_SRCS) - -WTF_TRACE_WEB_ENTRY_POINTS=[ - 'wtf.addon', - 'wtf.trace.exports', - 'wtf.hud.exports', - 'wtf.remote.exports', - ] - -WTF_TRACE_WEB_JS_FLAGS=[ - '--language_in=ECMASCRIPT5_STRICT', - '--define=wtf.hud.exports.ENABLE_EXPORTS=true', - '--define=wtf.remote.exports.ENABLE_EXPORTS=true', - '--define=wtf.trace.exports.ENABLE_EXPORTS=true', - '--output_wrapper="if(!this.wtf){(function(){%output%}).call(this);}"', - ] -# wtf_trace_web_js_compiled_debug js -closure_js_library( - name='wtf_trace_web_js_compiled_debug_head', - deps_out='wtf_trace_web_js', - mode='ADVANCED', - pretty_print=True, - entry_points=WTF_TRACE_WEB_ENTRY_POINTS, - srcs=':all_trace_web_uncompiled_js', - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + - WTF_TRACE_WEB_JS_FLAGS + [ - '--debug', - '--create_name_map_files', - ]) -# wtf_trace_web_js_compiled js -closure_js_library( - name='wtf_trace_web_js_compiled_head', - deps_out='wtf_trace_web_js', - mode='ADVANCED', - entry_points=WTF_TRACE_WEB_ENTRY_POINTS, - srcs=':all_trace_web_compiled_js', - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + RELEASE_JS_FLAGS + - WTF_TRACE_WEB_JS_FLAGS + [ - ]) - -# TODO(benvanik): test in IE -STYLES_WRAPPER=''.join([ - "if(this.window && !window.wtf_styles){window.wtf_styles=1;", - "var style = document.createElement('style');", - "style.innerHTML = '%output%';", - "(document.documentElement || document.head).appendChild(style);", - ";}\n"]) -# wtf_trace_web_js_compiled_debug -embed_files( - name='wtf_trace_web_styles_debug_js', - srcs=[':wtf_trace_web_styles_debug'], - wrapper=STYLES_WRAPPER, - replace_chars=[['\n', '\\n'], ['\'', '\\\'']]) -concat_files( - name='wtf_trace_web_js_compiled_debug', - out='wtf_trace_web_js_compiled_debug.js', - srcs=[ - ':wtf_trace_web_js_compiled_debug_head', - ':wtf_trace_web_styles_debug_js', - 'assets:hud_icons', - ], - src_exclude_filter='*-deps.js') -# wtf_trace_web_js_compiled -embed_files( - name='wtf_trace_web_styles_release_js', - srcs=[':wtf_trace_web_styles_release'], - wrapper=STYLES_WRAPPER, - replace_chars=[['\n', '\\n'], ['\'', '\\\'']], - src_exclude_filter='*.js') -concat_files( - name='wtf_trace_web_js_compiled', - out='wtf_trace_web_js_compiled.js', - srcs=[ - ':wtf_trace_web_js_compiled_head', - ':wtf_trace_web_styles_release_js', - 'assets:hud_icons', - ], - src_exclude_filter='*-deps.js') - -file_set( - name='wtf_trace_web_debug', - srcs=[ - ':testing_files', - ':wtf_trace_web_js_compiled_debug', - ':wtf_trace_web_styles_debug', - ]) -file_set( - name='wtf_trace_web_release', - srcs=[ - ':wtf_trace_web_js_compiled', - ], - src_exclude_filter='*-deps.js') - - -# ------------------------------------------------------------------------------ -# JavaScript : trace_min -# ------------------------------------------------------------------------------ - -WTF_TRACE_MIN_SRCS=[ - ':third_party_js', - ':wtf_src_js', - ] - -# All uncompiled JS -file_set( - name='all_trace_min_uncompiled_js', - srcs=[ - 'third_party:all_closure_js', - 'third_party:closure_uncompiled_js', - ] + WTF_TRACE_MIN_SRCS) - -# All compiled JS -file_set( - name='all_trace_min_compiled_js', - srcs=[ - 'third_party:all_closure_js', - ] + WTF_TRACE_MIN_SRCS) - -WTF_TRACE_MIN_ENTRY_POINTS=[ - 'wtf.trace.exports', - ] - -WTF_TRACE_MIN_JS_FLAGS=[ - '--language_in=ECMASCRIPT5_STRICT', - '--define=wtf.MIN_BUILD=true', - '--define=wtf.trace.exports.ENABLE_EXPORTS=true', - '--output_wrapper="if(!this.wtf){(function(){%output%}).call(this);}"', - ] -# wtf_trace_min_js_compiled_debug js -closure_js_library( - name='wtf_trace_min_js_compiled_debug', - deps_out='wtf_trace_min_js', - mode='ADVANCED', - pretty_print=True, - entry_points=WTF_TRACE_MIN_ENTRY_POINTS, - srcs=':all_trace_min_uncompiled_js', - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + - WTF_TRACE_MIN_JS_FLAGS + [ - '--debug', - '--create_name_map_files', - ]) -# wtf_trace_min_js_compiled js -closure_js_library( - name='wtf_trace_min_js_compiled', - deps_out='wtf_trace_min_js', - mode='ADVANCED', - entry_points=WTF_TRACE_MIN_ENTRY_POINTS, - srcs=':all_trace_min_compiled_js', - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + RELEASE_JS_FLAGS + - WTF_TRACE_MIN_JS_FLAGS + [ - ]) - -file_set( - name='wtf_trace_min_debug', - srcs=[ - ':testing_files', - ':wtf_trace_min_js_compiled_debug', - ]) -file_set( - name='wtf_trace_min_release', - srcs=[ - ':wtf_trace_min_js_compiled', - ], - src_exclude_filter='*-deps.js') - - -# ------------------------------------------------------------------------------ -# JavaScript : trace_prod -# ------------------------------------------------------------------------------ - -WTF_TRACE_PROD_JS_FLAGS=[ - '--language_in=ECMASCRIPT5_STRICT', - '--define=wtf.MIN_BUILD=true', - '--define=wtf.PROD_BUILD=true', - '--define=wtf.trace.exports.ENABLE_EXPORTS=true', - '--output_wrapper="if(!this.wtf){(function(){%output%}).call(this);}"', - ] -# wtf_trace_prod_js_compiled_debug js -closure_js_library( - name='wtf_trace_prod_js_compiled_debug', - deps_out='wtf_trace_prod_js', - mode='ADVANCED', - pretty_print=True, - entry_points=WTF_TRACE_MIN_ENTRY_POINTS, - srcs=':all_trace_min_uncompiled_js', - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + - WTF_TRACE_PROD_JS_FLAGS + [ - '--debug', - '--create_name_map_files', - ]) -# wtf_trace_prod_js_compiled js -closure_js_library( - name='wtf_trace_prod_js_compiled', - deps_out='wtf_trace_prod_js', - mode='ADVANCED', - entry_points=WTF_TRACE_MIN_ENTRY_POINTS, - srcs=':all_trace_min_compiled_js', - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + RELEASE_JS_FLAGS + - WTF_TRACE_PROD_JS_FLAGS + [ - ]) - -file_set( - name='wtf_trace_prod_debug', - srcs=[ - ':wtf_trace_prod_js_compiled_debug', - ]) -file_set( - name='wtf_trace_prod_release', - srcs=[ - ':wtf_trace_prod_js_compiled', - ], - src_exclude_filter='*-deps.js') - - -# ------------------------------------------------------------------------------ -# JavaScript : node -# ------------------------------------------------------------------------------ - -closure_js_library( - name='wtf_node_js_compiled', - deps_out='wtf_node_js', - # TODO(benvanik): fix exports so ADVANCED can be used - mode='SIMPLE', - pretty_print=True, - entry_points=[ - 'wtf.db.exports', - 'wtf.db.node', - 'wtf.replay.graphics.Step', - 'wtf.trace.exports', - 'wtf.trace.node', - ], - srcs=[ - 'third_party:all_closure_js', - ':third_party_js', - ':wtf_src_js', - ], - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + RELEASE_JS_FLAGS + [ - '--language_in=ECMASCRIPT5_STRICT', - '--define=goog.DEBUG=false', - '--define=goog.asserts.ENABLE_ASSERTS=false', - '--define=wtf.NODE=true', - '--define=wtf.db.exports.ENABLE_EXPORTS=true', - '--define=wtf.trace.exports.ENABLE_EXPORTS=true', - '--output_wrapper="module.exports = (function(exports){%output%;return this.wtf;}).call(global); delete global.wtf;"', - ]) - -file_set( - name='wtf_node_release', - srcs=[ - ':wtf_node_js_compiled', - ], - src_exclude_filter='*-deps.js') - - -# ------------------------------------------------------------------------------ -# JavaScript : app -# ------------------------------------------------------------------------------ -# TODO(benvanik): move to app/BUILD? - -WTF_UI_SRCS=[ - ':third_party_js', - ':wtf_src_js', - ':wtf_ui_soy_js', - ':wtf_app_soy_js', - ':wtf_replay_soy_js', - ] - -# All uncompiled JS -file_set( - name='all_ui_uncompiled_js', - srcs=[ - 'third_party:all_closure_js', - 'third_party:closure_uncompiled_js', - 'app:debug_js_srcs', - ] + WTF_UI_SRCS) - -# All compiled JS -file_set( - name='all_ui_compiled_js', - srcs=[ - 'third_party:all_closure_js', - 'app:release_js_srcs', - ] + WTF_UI_SRCS) - -WTF_UI_ENTRY_POINTS=[ - 'wtf.app.exports', - 'wtf.db.exports', - 'wtf.replay.graphics.exports', - 'wtf.replay.timeTravel.exports', - ] - -WTF_UI_JS_FLAGS=[ - # Safari has issues with 'use strict'. - '--language_in=ECMASCRIPT5', - ] - -# wtf_ui_js_uncompiled -closure_js_library( - name='wtf_ui_js_uncompiled', - deps_out='wtf_ui_js', - mode='UNCOMPILED', - entry_points=WTF_UI_ENTRY_POINTS, - srcs=':all_ui_uncompiled_js', - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + WTF_UI_JS_FLAGS + [ - ], - wrap_with_global='this', - file_list_out='wtf_ui_js.list') - -# wtf_ui_js_compiled -closure_js_library( - name='wtf_ui_js_compiled', - deps_out='wtf_ui_js', - mode='ADVANCED', - #pretty_print=True, - entry_points=WTF_UI_ENTRY_POINTS, - srcs=':all_ui_compiled_js', - externs=[':all_externs'], - compiler_jar=JS_COMPILER_JAR, - compiler_flags=SHARED_JS_FLAGS + RELEASE_JS_FLAGS + WTF_UI_JS_FLAGS + [ - #'--debug', - '--define=wtf.app.exports.ENABLE_EXPORTS=true', - '--define=wtf.db.exports.ENABLE_EXPORTS=true', - '--define=wtf.replay.graphics.exports.ENABLE_EXPORTS=true', - '--define=wtf.replay.timeTravel.exports.ENABLE_EXPORTS=true', - ], - wrap_with_global='window') - -less_css_library( - name='wtf_ui_styles_debug', - srcs=['src/wtf/app/app.less', ':all_less'], - include_paths=['src',], - compiler_flags=[]) -less_css_library( - name='wtf_ui_styles_release', - srcs=['src/wtf/app/app.less', ':all_less'], - include_paths=['src',], - compiler_flags=['--compress']) - - -# ------------------------------------------------------------------------------ -# JS linting -# ------------------------------------------------------------------------------ - -CLOSURE_LINTER_PATH='third_party/closure-linter/' - -file_set( - name='lint_src', - srcs=[':wtf_src_js'], - src_exclude_filter='filterparser.js|eventbuffers_test.js|benchmark.js') - -closure_js_fixstyle( - name='all_js_fixstyle', - namespaces=['goog', 'wtf',], - srcs=[':lint_src'], - linter_path=CLOSURE_LINTER_PATH) - -closure_js_lint( - name='all_js_lint', - namespaces=['goog', 'wtf',], - srcs=[':lint_src'], - linter_path=CLOSURE_LINTER_PATH) - - -# ------------------------------------------------------------------------------ -# Testing -# ------------------------------------------------------------------------------ - -TEST_REQUIRES=[ - ('node module', 'mocha@1.4.2'), - ('node module', 'chai@1.2.0'), - ] - -file_set( - name='test_external', - deps=[':fast'], - requires=TEST_REQUIRES) - -shell_execute( - name='wtf_js_test', - srcs=glob('src/**/*_test.js'), - deps=[':fast'], - command=[ - 'node_modules/mocha/bin/mocha', - '--ui', 'tdd', - '--reporter', 'dot', - '--require', 'src/wtf/bootstrap/mocha.js', - ], - requires=TEST_REQUIRES) - - -# ------------------------------------------------------------------------------ -# Target rules -# ------------------------------------------------------------------------------ - -file_set( - name='setup', - requires=[ - ('node', '>=0.6.14'), - ] + TEST_REQUIRES) - -file_set( - name='lint', - deps=':all_js_lint') - -file_set( - name='fixstyle', - deps=':all_js_fixstyle') - -file_set( - name='fast', - deps=[ - ':testing_files', - ':wtf_js_deps', - ':wtf_trace_web_styles_debug', - 'app:fast', - ]) - -file_set( - name='deps', - srcs=[ - ':wtf_js_deps', - ]) - -file_set( - name='test', - deps=[':wtf_js_test']) - -file_set( - name='debug', - srcs=[ - ':testing_files', - ':deps', - ':wtf_trace_web_debug', - 'app:debug', - ]) - -archive_files( - name='wtf-trace-web-api', - srcs=[ - ':wtf_trace_web_release', - ] + glob('shims/*.*')) - -archive_files( - name='wtf-app', - srcs=[ - 'app:release', - ]) - -file_set( - name='injector', - srcs=[ - 'extensions/wtf-injector-chrome:wtf-injector-chrome', - 'extensions/wtf-injector-firefox:wtf-injector-firefox', - ]) - -file_set( - name='release', - srcs=[ - ':deps', - ':wtf_trace_web_release', - ':wtf_trace_min_release', - ':wtf_node_release', - 'app:release', - ':wtf-trace-web-api', - ':wtf-app', - ':injector', - ], - src_exclude_filter='*-deps.js', - deps=[ - #':all_js_lint', - ]) - -file_set( - name='gh-pages', - srcs=[ - ':wtf_trace_web_release', - 'app:app_files' - ]) diff --git a/LICENSE b/LICENSE index 989d02e4..3bd62820 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2012, Google Inc. +Copyright 2017, Google Inc. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index bf0388e9..d9df771a 100644 --- a/README.md +++ b/README.md @@ -26,27 +26,33 @@ See [building](https://github.com/google/tracing-framework/blob/master/docs/buil ## Quickstart -Just want the extension as fast as possible? +For more information and other build options, see [building](https://github.com/google/tracing-framework/blob/master/docs/building.md). + +### Setup ```bash -umask 0022 -git clone https://github.com/google/tracing-framework.git -cd tracing-framework/ -./scripts/setup.sh # or setup.bat on Windows -source wtfrc && deployext -# At chrome://extensions load unpacked extension from -# build-bin/wtf-injector-chrome +$ git clone --recursive https://github.com/google/tracing-framework.git && cd tracing-framework/ +$ bazel run @yarn//:yarn ``` -If you pull new changes, just redeploy: +### Chrome Extension + +This builds and copies the unpacked extension to +`bazel-bin/extensions/wtf-injector-chrome/wtf-injector-chrome_pkg`, which can +then be loaded from chrome://extensions. ```bash -git pull && git submodule update -deployext -# Reload from chrome://extensions +$ bazel build -c opt //extensions/wtf-injector-chrome ``` -For more information and other build options, see [building](https://github.com/google/tracing-framework/blob/master/docs/building.md). +### Embedded Tracing Library + +This produces `bazel-bin/bindings/js/wtf_trace_web_js_compiled.js`, which can be +copied and included via script tags on any page. + +```bash +$ bazel build -c opt //bindings/js:wtf_trace_web_js +``` ## License diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 00000000..ca5f08cb --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,27 @@ +workspace(name = "tracing_framework") + +http_archive( + name = "io_bazel_rules_closure", + strip_prefix = "rules_closure-0.4.2", + sha256 = "25f5399f18d8bf9ce435f85c6bbf671ec4820bc4396b3022cc5dc4bc66303609", + urls = [ + "http://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.4.2.tar.gz", + "https://github.com/bazelbuild/rules_closure/archive/0.4.2.tar.gz", + ], +) + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") + +closure_repositories() + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "build_bazel_rules_nodejs", + remote = "https://github.com/bazelbuild/rules_nodejs.git", + tag = "0.1.6", +) + +load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") + +node_repositories(package_json = ["//:package.json"]) diff --git a/anvil.bat b/anvil.bat deleted file mode 100644 index 1912edfc..00000000 --- a/anvil.bat +++ /dev/null @@ -1,3 +0,0 @@ -@ECHO OFF - -third_party\anvil-build\anvil-local.bat %* diff --git a/app/BUILD b/app/BUILD new file mode 100644 index 00000000..8b4d204d --- /dev/null +++ b/app/BUILD @@ -0,0 +1,82 @@ +# Description: +# WTF Javascript app UI. + +package(default_visibility = ["//:internal"]) + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_css_binary") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") +load("//builddefs:config.bzl", "SHARED_CSS_FLAGS") +load("//builddefs:config.bzl", "SHARED_JS_FLAGS") +load("//builddefs:packaging_rules.bzl", "pkg_zip") + +filegroup( + name = "icons", + srcs = glob(["icons/**"]), +) + +closure_js_binary( + name = "wtf_ui_js_compiled", + defs = SHARED_JS_FLAGS + [ + "--define=wtf.app.exports.ENABLE_EXPORTS=true", + "--define=wtf.db.exports.ENABLE_EXPORTS=true", + "--define=wtf.replay.graphics.exports.ENABLE_EXPORTS=true", + "--define=wtf.replay.timeTravel.exports.ENABLE_EXPORTS=true", + ], + dependency_mode = "STRICT", + entry_points = [ + "wtf.app.exports", + "wtf.db.exports", + "wtf.replay.graphics.exports", + "wtf.replay.timeTravel.exports", + ], + language = "ECMASCRIPT5_STRICT", + output_wrapper = "(function(){%output%}).call(window)", + deps = [ + "//src/wtf/addon", + "//src/wtf/app", + "//src/wtf/db", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_css_binary( + name = "wtf_ui_styles", + defs = SHARED_CSS_FLAGS, + renaming = False, + deps = ["//src/wtf/app:app_styles"], +) + +filegroup( + name = "app", + srcs = select({ + "//:dbg": [ + # TODO(benvanik): exploded mode. + "maindisplay-debug.html", + "scripts/debug-prefix.js", + "scripts/debug-postfix-maindisplay.js", + "//third_party/d3:min", + ":wtf_ui_styles", + ], + "//:fastbuild": [ + ":wtf_ui_js_compiled", + "maindisplay-debug.html", + ":wtf_ui_styles", + ":icons", + "//third_party/d3:min", + ], + "//:opt": [ + ":wtf_ui_js_compiled", + ":icons", + "maindisplay.html", + "scripts/release-maindisplay.js", + "//third_party/d3:min", + ":wtf_ui_styles", + ], + }), +) + +pkg_zip( + name = "wtf-app", + srcs = [":app",], +) diff --git a/app/BUILD.anvil b/app/BUILD.anvil deleted file mode 100644 index 3914440b..00000000 --- a/app/BUILD.anvil +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2012 Google Inc. All Rights Reserved. - -__author__ = 'benvanik@google.com (Ben Vanik)' - - -# Chrome app release output - - -# ------------------------------------------------------------------------------ -# JavaScript -# ------------------------------------------------------------------------------ - -file_set( - name='shared_js_srcs', - srcs=[ - # soy - ]) - -file_set( - name='debug_js_srcs', - srcs=[ - ':shared_js_srcs', - ]) -file_set( - name='release_js_srcs', - srcs=[ - ':shared_js_srcs', - ]) - -file_set( - name='third_party_js', - srcs=[ - '../third_party/d3:min', - ]) - - -# ------------------------------------------------------------------------------ -# Modes -# ------------------------------------------------------------------------------ - -file_set( - name='exploded', - srcs=[ - '../third_party:all_closure_js', - '..:wtf_src_js', - '..:all_soy_js', - '..:deps', - '..:wtf_ui_styles_debug', - 'maindisplay-debug.html', - 'scripts/debug-prefix.js', - 'scripts/debug-postfix-maindisplay.js', - ':third_party_js', - ]) - -file_set( - name='debug', - srcs=[ - '..:wtf_ui_js_uncompiled', - '..:wtf_ui_styles_debug', - 'maindisplay-debug.html', - ':third_party_js', - ]) - -file_set( - name='release', - srcs=[ - '..:wtf_ui_js_compiled', - '..:wtf_ui_styles_release', - 'maindisplay.html', - 'scripts/release-maindisplay.js', - ':third_party_js', - ] + glob('icons/**/*'), - src_exclude_filter='*-deps.js') - -file_set( - name='fast', - srcs=[ - '..:wtf_ui_styles_debug', - ]) - -file_set( - name='app_files', - srcs=[ - 'maindisplay.html', - 'scripts/release-maindisplay.js', - - ':third_party_js', - - # This is bad - should prefix this. - '..:wtf_ui_styles_release', - '..:wtf_ui_js_compiled', - ] + glob('icons/**/*'), - src_exclude_filter='*-deps.js') diff --git a/app/graphicsreplay.html b/app/graphicsreplay.html index fdeb5763..059d6889 100644 --- a/app/graphicsreplay.html +++ b/app/graphicsreplay.html @@ -3,8 +3,8 @@ WTF Graphics Replay - - + +
diff --git a/app/maindisplay-debug.html b/app/maindisplay-debug.html index db5dc076..585a06b8 100644 --- a/app/maindisplay-debug.html +++ b/app/maindisplay-debug.html @@ -5,7 +5,7 @@ - + diff --git a/app/maindisplay.html b/app/maindisplay.html index b9a0772d..2060aa06 100644 --- a/app/maindisplay.html +++ b/app/maindisplay.html @@ -3,8 +3,8 @@ Web Tracing Framework - - + + diff --git a/assets/BUILD b/assets/BUILD new file mode 100644 index 00000000..c68e2c9e --- /dev/null +++ b/assets/BUILD @@ -0,0 +1,21 @@ +# Description: +# Assets such as icons and images. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:file_rules.bzl", "concat_files", "embed_files") + +ICON_WRAPPER = "".join([ + "wtf.ui.icons.setIconData(", + "'/%path%', ", + "'data:image/png;base64,%output%'", + ");\n", +]) + +embed_files( + name = "hud_icons", + srcs = glob(["icons/**/*.png"]), + out = "hud_icons.js", + encoding = "base64", + wrapper = ICON_WRAPPER, +) diff --git a/assets/BUILD.anvil b/assets/BUILD.anvil deleted file mode 100644 index 36f3e6d4..00000000 --- a/assets/BUILD.anvil +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2012 Google Inc. All Rights Reserved. - -__author__ = 'benvanik@google.com (Ben Vanik)' - - -# Assets rules. -# These are used to build javascript code with embedded data assets. - - -ICON_WRAPPER=''.join([ - "wtf.ui.icons.setIconData(", - "'/assets/%path%', ", - "'data:image/png;base64,%output%'", - ");\n" - ]) - - -# ------------------------------------------------------------------------------ -# HUD -# ------------------------------------------------------------------------------ - -embed_files( - name='hud_icons', - srcs=[ - ] + glob('icons/*.png'), - wrapper=ICON_WRAPPER, - encoding='base64', - replace_chars=[['\n', '\\n'], ['\'', '\\\'']]) diff --git a/assets/store/tile-small.png b/assets/store/tile-small.png index 4171bbb0..939c6a55 100644 Binary files a/assets/store/tile-small.png and b/assets/store/tile-small.png differ diff --git a/bindings/js/BUILD b/bindings/js/BUILD new file mode 100644 index 00000000..02c747a2 --- /dev/null +++ b/bindings/js/BUILD @@ -0,0 +1,206 @@ +# Description: +# WTF Javascript bindings. + +package(default_visibility = ["//:internal"]) + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_css_binary") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_deps") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") +load("//builddefs:config.bzl", "SHARED_CSS_FLAGS") +load("//builddefs:config.bzl", "SHARED_JS_FLAGS") +load("//builddefs:file_rules.bzl", "concat_files", "embed_files") +load("//builddefs:packaging_rules.bzl", "pkg_zip") + +# ------------------------------------------------------------------------------ +# JavaScript +# ------------------------------------------------------------------------------ + +# third_party js +filegroup( + name = "third_party_js", + srcs = [ + "//third_party/d3:colorbrewer", + ], +) + +# ------------------------------------------------------------------------------ +# JavaScript : node +# ------------------------------------------------------------------------------ + +closure_js_binary( + name = "wtf_node_js_compiled", + compilation_level = "ADVANCED", + defs = SHARED_JS_FLAGS + [ + "--define=goog.DEBUG=false", + "--define=goog.asserts.ENABLE_ASSERTS=false", + "--define=wtf.NODE=true", + "--define=wtf.db.exports.ENABLE_EXPORTS=true", + "--define=wtf.trace.exports.ENABLE_EXPORTS=true", + ], + dependency_mode = "STRICT", + entry_points = [ + "wtf.db.exports", + "wtf.db.node", + "wtf.trace.exports", + "wtf.trace.node", + ], + language = "ECMASCRIPT5_STRICT", + output_wrapper = "module.exports = (function(exports){%output%;return this.wtf;}).call(global); delete global.wtf;", + deps = [ + "//src/wtf/db:node", + "//src/wtf/trace:node", + "@io_bazel_rules_closure//closure/library", + ], +) + +# ------------------------------------------------------------------------------ +# JavaScript : web (minimal) +# ------------------------------------------------------------------------------ + +closure_js_binary( + name = "wtf_trace_min_js_compiled", + compilation_level = "ADVANCED", + defs = SHARED_JS_FLAGS + [ + "--define=wtf.MIN_BUILD=true", + "--define=wtf.trace.exports.ENABLE_EXPORTS=true", + ], + dependency_mode = "STRICT", + entry_points = [ + "wtf.trace.exports", + ], + language = "ECMASCRIPT5_STRICT", + output_wrapper = "if(!this.wtf){(function(){%output%}).call(this);}", + deps = [ + "//src/wtf/trace", + "@io_bazel_rules_closure//closure/library", + ], +) + +# ------------------------------------------------------------------------------ +# JavaScript : web (minimal with prod flag) +# ------------------------------------------------------------------------------ + +closure_js_binary( + name = "wtf_trace_prod_js_compiled", + compilation_level = "ADVANCED", + defs = SHARED_JS_FLAGS + [ + "--define=wtf.MIN_BUILD=true", + "--define=wtf.PROD_BUILD=true", + "--define=wtf.trace.exports.ENABLE_EXPORTS=true", + ], + dependency_mode = "STRICT", + entry_points = [ + "wtf.trace.exports", + ], + language = "ECMASCRIPT5_STRICT", + output_wrapper = "if(!this.wtf){(function(){%output%}).call(this);}", + deps = [ + "//src/wtf/trace", + "@io_bazel_rules_closure//closure/library", + ], +) + +# ------------------------------------------------------------------------------ +# JavaScript : web (with HUD) +# ------------------------------------------------------------------------------ + +WTF_TRACE_WEB_JS_DEPS = [ + "//src/wtf/addon", + "//src/wtf/hud", + "//src/wtf/remote", + "//src/wtf/trace", + "@io_bazel_rules_closure//closure/library", +] + +closure_js_deps( + name = "wtf_trace_web_js_uncompiled", + deps = WTF_TRACE_WEB_JS_DEPS, +) + +closure_js_binary( + name = "wtf_trace_web_js_compiled_head", + css = ":wtf_trace_web_css_compiled", + defs = SHARED_JS_FLAGS + [ + "--define=wtf.hud.exports.ENABLE_EXPORTS=true", + "--define=wtf.remote.exports.ENABLE_EXPORTS=true", + "--define=wtf.trace.exports.ENABLE_EXPORTS=true", + ], + dependency_mode = "STRICT", + entry_points = [ + "wtf.addon", + "wtf.hud.exports", + "wtf.remote.exports", + "wtf.trace.exports", + ], + language = "ECMASCRIPT5_STRICT", + output_wrapper = "if(!this.wtf){(function(){%output%}).call(this);}", + deps = WTF_TRACE_WEB_JS_DEPS, +) + +closure_css_binary( + name = "wtf_trace_web_css_compiled", + defs = SHARED_CSS_FLAGS, + renaming = False, + deps = ["//src/wtf/hud:hud_styles"], +) + +STYLES_WRAPPER = "".join([ + "if(this.window && !window.wtf_styles){window.wtf_styles=1;\n", + "var style = document.createElement('style');\n", + "style.innerHTML = '%output%';\n", + "(document.documentElement || document.head).appendChild(style);\n", + "}\n", +]) + +embed_files( + name = "wtf_trace_web_css_compiled_js", + srcs = [":wtf_trace_web_css_compiled.css"], + out = "wtf_trace_web_css_compiled.js", + wrapper = STYLES_WRAPPER, +) + +concat_files( + name = "wtf_trace_web_js_compiled", + parts = [ + # Order matters; JS must go first. + ":wtf_trace_web_js_compiled_head.js", + ":wtf_trace_web_css_compiled_js", + "//assets:hud_icons", + ], + out = "wtf_trace_web_js_compiled.js", +) + +pkg_zip( + name = "wtf-trace-web-api", + srcs = [ + ":wtf_trace_web_js_compiled", + "wtf-trace-closure.js", + "wtf-trace-disabled.js", + "wtf-trace.js", + ], + path_mapping = { + "bindings/js/wtf-trace-closure.js": "shims/wtf-trace-closure.js", + "bindings/js/wtf-trace-disabled.js": "shims/wtf-trace-disabled.js", + "bindings/js/wtf-trace.js": "shims/wtf-trace.js", + "bindings/js/wtf_trace_web_js_compiled.js": "wtf_trace_web_js_compiled.js", + }, +) + +filegroup( + name = "js", + srcs = select({ + "//:dbg": [ + # TODO(benvanik): exploded. + ":wtf_trace_web_css_compiled", + ":wtf_trace_web_js_uncompiled", + ], + "//:fastbuild": [ + ":wtf_trace_web_js_compiled", + ], + "//:opt": [ + ":wtf_trace_web_js_compiled", + ], + }), + visibility = ["//visibility:public"], +) diff --git a/shims/wtf-trace-closure.js b/bindings/js/wtf-trace-closure.js similarity index 100% rename from shims/wtf-trace-closure.js rename to bindings/js/wtf-trace-closure.js diff --git a/shims/wtf-trace-disabled.js b/bindings/js/wtf-trace-disabled.js similarity index 100% rename from shims/wtf-trace-disabled.js rename to bindings/js/wtf-trace-disabled.js diff --git a/shims/wtf-trace.js b/bindings/js/wtf-trace.js similarity index 100% rename from shims/wtf-trace.js rename to bindings/js/wtf-trace.js diff --git a/builddefs/BUILD b/builddefs/BUILD new file mode 100644 index 00000000..b1133829 --- /dev/null +++ b/builddefs/BUILD @@ -0,0 +1,30 @@ +# Description: +# Bazel macros, rules, and defines. + +package(default_visibility = ["//:internal"]) + +load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") + +# Used by the file_rules.bzl:concat_files rule. +sh_binary( + name = "concat_files", + srcs = ["concat_files.sh"], +) + +# Used by the file_rules.bzl:embed_files rule. +py_binary( + name = "embed_files", + srcs = ["embed_files.py"], +) + +# Used by the file_rules.bzl:strip_comments rule. +py_binary( + name = "strip_comments", + srcs = ["strip_comments.py"], +) + +# Used by the less_rules.bzl:less_css_library rule. +nodejs_binary( + name = "lessc", + entry_point = "less/bin/lessc", +) diff --git a/builddefs/concat_files.sh b/builddefs/concat_files.sh new file mode 100755 index 00000000..72da64a3 --- /dev/null +++ b/builddefs/concat_files.sh @@ -0,0 +1,4 @@ +#!/bin/bash +out=$1 +shift +cat $* > $out diff --git a/builddefs/config.bzl b/builddefs/config.bzl new file mode 100644 index 00000000..8192dcac --- /dev/null +++ b/builddefs/config.bzl @@ -0,0 +1,62 @@ +# Description: +# Common configuration options. + +COMMON_JS_SUPPRESSIONS = [ + # TODO(benvanik): somehow make all our code typed correctly ;) + "JSC_UNKNOWN_EXPR_TYPE", + + # TODO(benvanik): go replace naked Object with !Object or ?Object. + "JSC_IMPLICITLY_NULLABLE_JSDOC", + + # goog.result deprecated in favor of goog.Promise. + "JSC_DEPRECATED_CLASS_REASON", + "JSC_DEPRECATED_PROP_REASON", +] + +SHARED_CSS_FLAGS = [ + "--allow-unrecognized-functions", +] + select({ + "//:dbg": [ + "--preserve-comments", + "--pretty-print", + ], + "//:fastbuild": [ + "--preserve-comments", + "--pretty-print", + ], + "//:opt": [ + #"--css-renaming-prefix=wtf_", + ], +}) + +SHARED_JS_FLAGS = [ + "--summary_detail_level=3", + "--create_source_map=%outname%.map", + "--source_map_format=V3", + "--define=goog.soy.REQUIRE_STRICT_AUTOESCAPE=false", +] + select({ + "//:dbg": [ + "--compilation_level=WHITESPACE_ONLY", + "--define=goog.DEBUG=true", + "--define=goog.asserts.ENABLE_ASSERTS=true", + ], + "//:fastbuild": [ + "--compilation_level=SIMPLE", + "--define=goog.DEBUG=true", + "--define=goog.asserts.ENABLE_ASSERTS=true", + ], + "//:opt": [ + "--compilation_level=ADVANCED", + "--use_types_for_optimization", + #"--collapse_variable_declarations", + #"--collapse_anonymous_functions", + #"--collapse_properties", + #"--disambiguate_properties", + # rewrites things to be smaller but likely not better + # http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/FunctionRewriter.java + #"--rewrite_function_expressions=false", + # slow - may want disabled + #"--devirtualize_prototype_methods", + #"--devirtualize_prototype_methods=false", + ], +}) diff --git a/builddefs/embed_files.py b/builddefs/embed_files.py new file mode 100644 index 00000000..69afdddb --- /dev/null +++ b/builddefs/embed_files.py @@ -0,0 +1,36 @@ +import base64 +import os +import sys + +def main(argv): + encoding = argv[1] + template_path = argv[2] + out_path = argv[3] + src_path = argv[4] + + with open(src_path, "r") as file: + src_str = file.read() + + if encoding == 'base64': + src_str = base64.b64encode(src_str) + else: + src_str = src_str.replace('\n', '\\n') + src_str = src_str.replace('\'', '\\\'') + + sanitized_src_path = src_path + sanitized_src_str = src_str + + with open(template_path, "r") as file: + template_str = file.read() + + out_str = template_str + out_str = out_str.replace('%output%', sanitized_src_str) + out_str = out_str.replace('%path%', sanitized_src_path) + + with open(out_path, "w") as file: + file.write(out_str) + + return 0 + +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff --git a/builddefs/file_rules.bzl b/builddefs/file_rules.bzl new file mode 100644 index 00000000..85fd0cc9 --- /dev/null +++ b/builddefs/file_rules.bzl @@ -0,0 +1,118 @@ +# Description: +# Rules for file manipulation. + + +def _concat_files_impl(ctx): + ctx.actions.run( + inputs = ctx.files.parts, + outputs = [ctx.outputs.out], + arguments = [ + ctx.outputs.out.path, + ] + [f.path for f in ctx.files.parts], + progress_message = "Concating into %s" % (ctx.outputs.out.short_path), + executable = ctx.executable._concat_tool, + ) + +concat_files = rule( + implementation = _concat_files_impl, + attrs = { + "parts": attr.label_list(allow_files = True), + "out": attr.output(mandatory = True), + "_concat_tool": attr.label( + executable = True, + cfg = "host", + allow_files = True, + default = Label("//builddefs:concat_files"), + ), + }, +) + + +def _embed_files_impl(ctx): + # Write template string to a file as that's what expand_template wants. + template_file = ctx.actions.declare_file(ctx.label.name + "_template") + ctx.actions.write( + output = template_file, + content = ctx.attr.wrapper, + ) + + # Convert and template each file. + templated_src_files = [] + for src_file in ctx.files.srcs: + # Prepare temporary output file. + templated_src_file = ctx.actions.declare_file(src_file.short_path + ".templated") + templated_src_files.append(templated_src_file) + + # Issue conversion command. + ctx.actions.run( + inputs = [template_file, src_file], + outputs = [templated_src_file], + arguments = [ + ctx.attr.encoding, + template_file.path, + templated_src_file.path, + src_file.path, + ], + progress_message = "Embedding %s" % (src_file.short_path), + executable = ctx.executable._embed_tool, + ) + + # Concat all files together. + ctx.actions.run( + inputs = templated_src_files, + outputs = [ctx.outputs.out], + arguments = [ + ctx.outputs.out.path, + ] + [f.path for f in templated_src_files], + progress_message = "Concating into %s" % (ctx.outputs.out.short_path), + executable = ctx.executable._concat_tool, + ) + +embed_files = rule( + implementation = _embed_files_impl, + attrs = { + "srcs": attr.label_list(allow_files = True), + "wrapper": attr.string(default = "%output%"), + "encoding": attr.string(default = "utf8"), + "out": attr.output(mandatory = True), + "_embed_tool": attr.label( + executable = True, + cfg = "host", + allow_files = True, + default = Label("//builddefs:embed_files"), + ), + "_concat_tool": attr.label( + executable = True, + cfg = "host", + allow_files = True, + default = Label("//builddefs:concat_files"), + ), + }, +) + + +def _strip_comments_impl(ctx): + ctx.actions.run( + inputs = ctx.files.srcs, + outputs = [ctx.outputs.out], + arguments = [ + ctx.files.srcs[0].path, + ctx.outputs.out.path, + ], + progress_message = "Stripping comments from %s" % (ctx.outputs.out.short_path), + executable = ctx.executable._strip_comments_tool, + ) + +strip_comments = rule( + implementation = _strip_comments_impl, + attrs = { + "srcs": attr.label_list(allow_files = True), + "out": attr.output(mandatory = True), + "_strip_comments_tool": attr.label( + executable = True, + cfg = "host", + allow_files = True, + default = Label("//builddefs:strip_comments"), + ), + }, +) diff --git a/builddefs/less_rules.bzl b/builddefs/less_rules.bzl new file mode 100644 index 00000000..051e7eee --- /dev/null +++ b/builddefs/less_rules.bzl @@ -0,0 +1,93 @@ +# Description: +# Rules for building LESS CSS libraries. + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_css_library") + + +def _unfurl(deps, provider=""): + """Returns deps as well as deps exported by parent rules.""" + res = [] + for dep in deps: + if not provider or hasattr(dep, provider): + res.append(dep) + if hasattr(dep, "exports"): + for edep in dep.exports: + if not provider or hasattr(edep, provider): + res.append(edep) + return res + + +def _collect_less_deps(deps): + """Aggregates transitive LESS source files from unfurled deps.""" + srcs = [] + for dep in deps: + srcs += getattr(dep.less_css_library, "srcs", []) + srcs += getattr(dep.less_css_library, "main_srcs", []) + srcs += getattr(dep.less_css_library, "transitive_srcs", []) + return srcs + + +def _less_css_library(ctx): + deps = _unfurl(ctx.attr.deps, provider="less_css_library") + less_deps = _collect_less_deps(deps) + less_deps.extend(ctx.files.srcs) + + common_less_args = [] + include_paths = ["."] + if ctx.attr.includes: + include_paths.extend(ctx.attr.includes) + common_less_args.append("--include-path=" + ":".join(include_paths)) + if ctx.attr.defs: + common_less_args.extend(ctx.attr.defs) + + # Translate each .less into a .css individually. + css_files = [] + for src in ctx.files.main_srcs: + css_file = ctx.actions.declare_file(src.short_path[:-5] + ".css") + css_files.append(css_file) + ctx.actions.run( + outputs = [css_file], + inputs = [src] + less_deps, + executable = ctx.executable._compiler, + arguments = common_less_args + [ + src.path, + css_file.path, + ], + mnemonic = "LessCompile", + progress_message = "Translating LESS to CSS: %s" % (src.short_path), + ) + + return struct( + files = depset(css_files), + less_css_library = struct( + srcs = ctx.files.srcs, + main_srcs = ctx.files.main_srcs, + transitive_srcs = less_deps, + ), + closure_css_library = struct( + srcs = css_files, + deps = deps, + data = ctx.attr.srcs, + orientation = ctx.attr.orientation, + ), + ) + +less_css_library = rule( + implementation = _less_css_library, + attrs = { + "main_srcs": attr.label_list(allow_files=FileType([".css", ".less"])), + "srcs": attr.label_list(allow_files=FileType([".css", ".less"])), + "deps": attr.label_list(providers=["less_css_library"]), + "includes": attr.string_list(), + "defs": attr.string_list(), + "orientation": attr.string(default="LTR"), + "_compiler": attr.label( + default = Label("//builddefs:lessc"), + allow_files = True, + cfg = "host", + executable = True, + ), + }, + #outputs = {"out": "%{name}.css"}, +) + diff --git a/builddefs/packaging_rules.bzl b/builddefs/packaging_rules.bzl new file mode 100644 index 00000000..9cde56e9 --- /dev/null +++ b/builddefs/packaging_rules.bzl @@ -0,0 +1,66 @@ +# Description: +# Rules for packaging build outputs. + + +def _pkg_zip_impl(ctx): + # Copy all files into the staging directory. + staging_dir = ctx.attr.name + "_pkg" + staged_files = [] + for src_file in ctx.files.srcs: + # Remap path, if desired. + original_path = src_file.short_path + staged_path = original_path + for (prefix, replacement) in ctx.attr.path_mapping.items(): + if staged_path.startswith(prefix): + staged_path = staged_path.replace(prefix, replacement) + staged_path = "/".join([staging_dir, staged_path]) + + # Copy to staging path. + staged_file = ctx.actions.declare_file(staged_path) + staged_files.append(staged_file) + ctx.actions.run_shell( + inputs = [src_file], + outputs = [staged_file], + command = "cp $1 $2", + arguments = [ + src_file.path, + staged_file.path, + ], + progress_message = "Staging %s" % (src_file.short_path), + ) + + # Zip all of the files in the staging dir. + staged_file_paths = [] + staged_base_path = "/".join([ctx.label.package, staging_dir]) + "/" + for staged_file in staged_files: + relative_path = staged_file.short_path.replace(staged_base_path, "") + staged_file_paths.append("/".join([relative_path])) + ctx.actions.run_shell( + inputs = staged_files, + outputs = [ctx.outputs.out], + command = "\n".join([ + "ROOT_PATH=`pwd`", + "cd %s" % ("/".join([ctx.outputs.out.dirname, staging_dir])), + "zip -rqD $ROOT_PATH/%s %s" % ( + ctx.outputs.out.path, + " ".join(staged_file_paths), + ), + "cd -", + ]), + progress_message = "Zipping package %s" % (ctx.outputs.out.short_path), + ) + + return struct( + files = depset([ctx.outputs.out]), + ) + +pkg_zip = rule( + implementation = _pkg_zip_impl, + attrs = { + "srcs": attr.label_list(allow_files = True), + "path_mapping": attr.string_dict(), + }, + outputs = { + "out": "%{name}.zip", + }, +) diff --git a/builddefs/strip_comments.py b/builddefs/strip_comments.py new file mode 100644 index 00000000..7fe1e9a0 --- /dev/null +++ b/builddefs/strip_comments.py @@ -0,0 +1,30 @@ +import os +import re +import sys + +def main(argv): + src_path = argv[1] + out_path = argv[2] + + with open(src_path, "r") as file: + src_str = file.read() + + # Code from Markus Jarderot, posted to stackoverflow + def replacer(match): + s = match.group(0) + if s.startswith('/'): + return "" + else: + return s + pattern = re.compile( + r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', + re.DOTALL | re.MULTILINE) + out_str = re.sub(pattern, replacer, src_str) + + with open(out_path, "w") as file: + file.write(out_str) + + return 0 + +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff --git a/extensions/wtf-injector-chrome/BUILD b/extensions/wtf-injector-chrome/BUILD new file mode 100644 index 00000000..984c4946 --- /dev/null +++ b/extensions/wtf-injector-chrome/BUILD @@ -0,0 +1,64 @@ +# Description: +# WTF Chrome Extension. + +package(default_visibility = ["//:internal"]) + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_css_binary") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_deps") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") +load("//builddefs:config.bzl", "SHARED_CSS_FLAGS") +load("//builddefs:config.bzl", "SHARED_JS_FLAGS") +load("//builddefs:file_rules.bzl", "concat_files", "embed_files", "strip_comments") +load("//builddefs:less_rules.bzl", "less_css_library") +load("//builddefs:packaging_rules.bzl", "pkg_zip") + +# CWS hates comments in extension manifests - strip them all. +strip_comments( + name = "stripped_manifest", + srcs = ["manifest.template.json"], + out = "manifest.json", +) + +less_css_library( + name = "popup_styles", + includes = ["src"], + main_srcs = ["popup.less"], + deps = [ + "//src/wtf/ui/styles", + ], +) + +filegroup( + name = "extension_files", + srcs = [ + "//app", + "//bindings/js", + ":stripped_manifest", + ":popup_styles", + "background.js", + "debugger.js", + "extension.js", + "injectedtab.js", + "options.js", + "popup.html", + "popup.js", + "tracer.js", + "uri.js", + "wtf-call-tracing.js", + "wtf-injector.js", + "wtf-process.js", + ] + glob([ + "assets/icons/*.png", + "third_party/*.js", + ]), +) + +pkg_zip( + name = "wtf-injector-chrome", + srcs = [":extension_files"], + path_mapping = { + "bindings/js/": "", + "extensions/wtf-injector-chrome/": "", + }, +) diff --git a/extensions/wtf-injector-chrome/BUILD.anvil b/extensions/wtf-injector-chrome/BUILD.anvil deleted file mode 100644 index d62be660..00000000 --- a/extensions/wtf-injector-chrome/BUILD.anvil +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2012 Google Inc. All Rights Reserved. - -__author__ = 'benvanik@google.com (Ben Vanik)' - - -# Chrome injector extension release output - - -# ------------------------------------------------------------------------------ -# Extension -# ------------------------------------------------------------------------------ - -# CWS hates comments in extension manifests - strip them all -strip_comments( - name='stripped_manifest', - srcs=['manifest.json']) - -# Files relating to the injected tracing code -file_set( - name='tracing_files', - srcs=[ - '../..:wtf_trace_web_js_compiled', - ]) - -file_set( - name='all_less', - srcs=glob('../../src/**/*.less')) -less_css_library( - name='popup_styles', - srcs=['popup.less', ':all_less'], - include_paths=['src',], - compiler_flags=[ - #'--compress' - ]) - -file_set( - name='extension_files', - srcs=[ - ':stripped_manifest', - ':tracing_files', - ':popup_styles', - 'background.js', - 'debugger.js', - 'extension.js', - 'injectedtab.js', - 'options.js', - 'popup.html', - 'popup.js', - 'tracer.js', - 'uri.js', - 'wtf-call-tracing.js', - 'wtf-injector.js', - 'wtf-process.js', - ] + - glob('assets/scripts/*.js') + - glob('assets/icons/*.png') + - glob('third_party/*.js'), - src_exclude_filter='*-deps.js') - -file_set( - name='app_files', - srcs=['../../app:app_files'], - src_exclude_filter='manifest.json') - -file_set( - name='combined_files', - srcs=[ - ':extension_files', - ':app_files' - ]) - -copy_files( - name='deploy', - srcs=[':combined_files'], - out='../../wtf-injector-chrome/', - flatten_paths=['extensions/wtf-injector-chrome/']) - -archive_files( - name='wtf-injector-chrome', - srcs=':combined_files', - flatten_paths=['extensions/wtf-injector-chrome/']) diff --git a/extensions/wtf-injector-chrome/injectedtab.js b/extensions/wtf-injector-chrome/injectedtab.js index d78bc457..358b6711 100644 --- a/extensions/wtf-injector-chrome/injectedtab.js +++ b/extensions/wtf-injector-chrome/injectedtab.js @@ -69,7 +69,9 @@ var InjectedTab = function(extension, tab, pageStatus, pageOptions, port) { */ this.debugger_ = null; - if (pageStatus == PageStatus.WHITELISTED && + // Chrome debugger support is disabled until it's updated. + if (false && + pageStatus == PageStatus.WHITELISTED && pageOptions['wtf.trace.provider.chromeDebug'] !== false) { var timelineEnabled = pageOptions['wtf.trace.provider.chromeDebug.timeline'] !== false; diff --git a/extensions/wtf-injector-chrome/manifest.json b/extensions/wtf-injector-chrome/manifest.template.json similarity index 99% rename from extensions/wtf-injector-chrome/manifest.json rename to extensions/wtf-injector-chrome/manifest.template.json index dd64f68a..a69fc4e1 100644 --- a/extensions/wtf-injector-chrome/manifest.json +++ b/extensions/wtf-injector-chrome/manifest.template.json @@ -4,7 +4,7 @@ // These can be copy/pasted directly between them. // --------------------------------------------------------------------------- "manifest_version": 2, - "version": "2015.7.15.1", + "version": "2017.10.20.1", "minimum_chrome_version": "23", "homepage_url": "https://github.com/google/tracing-framework", diff --git a/extensions/wtf-injector-chrome/popup.html b/extensions/wtf-injector-chrome/popup.html index 113d78dd..6de7214b 100644 --- a/extensions/wtf-injector-chrome/popup.html +++ b/extensions/wtf-injector-chrome/popup.html @@ -2,7 +2,7 @@ - + diff --git a/extensions/wtf-injector-firefox/package.json b/extensions/wtf-injector-firefox/package.json index 52bc6043..ab34d0c7 100644 --- a/extensions/wtf-injector-firefox/package.json +++ b/extensions/wtf-injector-firefox/package.json @@ -2,7 +2,7 @@ "name": "web-tracing-framework", "fullName": "Web Tracing Framework", "id": "jid1-AdSGhlstK2V5ig", - "version": "2015.7.15.1", + "version": "2017.10.20.1", "description": "Rich tools for instrumenting, analyzing, and visualizing web apps. Make your app jank-free at 60fps!", "author": "benvanik@google.com", "license": "BSD" diff --git a/externs/BUILD b/externs/BUILD new file mode 100644 index 00000000..fb746320 --- /dev/null +++ b/externs/BUILD @@ -0,0 +1,16 @@ +# Description: +# Externs for browser/node/etc APIs. + +package(default_visibility = ["//:internal"]) + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "externs", + srcs = [ + "analytics.js", + "chrome.js", + "drive.js", + "node.js", + ], +) diff --git a/externs/chrome.js b/externs/chrome.js index 13dc98c6..98dfc5fe 100644 --- a/externs/chrome.js +++ b/externs/chrome.js @@ -13,14 +13,6 @@ */ -/** - * @typedef {{ - * addListener: function(!Function), - * removeListener: function(!Function) - * }} - */ -var ChromeEvent; - // var chrome; @@ -61,6 +53,10 @@ chrome.app.runtime.onLaunched; var ChromeAppWindow; +/** @type {!ChromeAppWindow} */ +chrome.app.window; + + /** * @param {string} url * @param {!Object} options diff --git a/externs/node.js b/externs/node.js index 3c224bdd..5ee02406 100644 --- a/externs/node.js +++ b/externs/node.js @@ -112,7 +112,7 @@ Buffer.byteLength = function(value) {}; /** - * @return {string} + * @override */ Buffer.prototype.toString = function() {}; diff --git a/lint.sh b/lint.sh new file mode 100755 index 00000000..dfa909ea --- /dev/null +++ b/lint.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find -name 'BUILD' -print0 | xargs -0 buildifier diff --git a/package.json b/package.json index b50aecde..457ec228 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tracing-framework", - "version": "2015.7.15-1", + "version": "2017.10.20-1", "description": "Web Tracing Framework instrumentation and analysis library.", "keywords": [ "javascript", @@ -20,23 +20,23 @@ }, "scripts": {}, "dependencies": { - "falafel": "0.1.4", - "mkdirp": "0.3.5", - "optimist": "0.3.5", - "ws": "0.4.25", - "string-hash": "~1.1.0", - "temporary": "0.0.7" + "falafel": "2.1.0", + "mkdirp": "0.5.1", + "optimist": "0.6.1", + "ws": "3.2.0", + "string-hash": "~1.1.3", + "temporary": "0.0.8" }, "devDependencies": { - "benchmark": "1.0.0", - "chai": "1.2.0", - "less": "1.4.2", - "mocha": "1.4.2", - "pegjs": "~0.7.0", - "wd": "0.0.32" + "benchmark": "2.1.4", + "chai": "4.1.2", + "less": "2.7.2", + "mocha": "3.5.3", + "pegjs": "~0.10.0", + "wd": "1.4.1" }, "optionalDependencies": { - "microtime": "2.1.2" + "microtime": "2.1.6" }, "files": [ "build-out/wtf_node_js_compiled.js", diff --git a/scripts/prepare-publish.sh b/scripts/prepare-publish.sh index 2023745d..99442edf 100755 --- a/scripts/prepare-publish.sh +++ b/scripts/prepare-publish.sh @@ -15,12 +15,22 @@ if [ ! -d ".git" ]; then exit 1 fi +GIT_USERNAME=`git config user.name` +GIT_USEREMAIL=`git config user.email` + # ============================================================================= # Build everything # ============================================================================= echo "Building everything..." -./third_party/anvil-build/anvil-local.sh build :fast :debug :release +bazel build -c opt \ + //app \ + //app:wtf-app \ + //bindings/js \ + //bindings/js:wtf_trace_min_js_compiled \ + //bindings/js:wtf_node_js_compiled \ + //bindings/js:wtf-trace-web-api \ + //extensions/wtf-injector-chrome echo "" # ============================================================================= @@ -28,24 +38,19 @@ echo "" # ============================================================================= echo "Building extensions..." -# Chrome. -rm -rf build-bin/wtf-injector-chrome -./third_party/anvil-build/anvil-local.sh deploy -o build-bin/ extensions/wtf-injector-chrome:deploy -./third_party/anvil-build/anvil-local.sh deploy -o build-bin/ :injector - # Firefox. -rm -rf build-bin/wtf-injector-firefox -./third_party/anvil-build/anvil-local.sh deploy -o build-bin/ extensions/wtf-injector-firefox:deploy -cd third_party/firefox-addon-sdk/ -source bin/activate -cd ../.. -cd build-bin/wtf-injector-firefox/ -cfx xpi \ - --update-link https://tracing-framework.appspot.com/CURRENT/web-tracing-framework.xpi \ - --update-url https://tracing-framework.appspot.com/CURRENT/web-tracing-framework.update.rdf -cd ../.. -mv build-bin/wtf-injector-firefox/web-tracing-framework.xpi build-bin/extensions/ -mv build-bin/wtf-injector-firefox/web-tracing-framework.update.rdf build-bin/extensions/ +# rm -rf build-bin/wtf-injector-firefox +# ./third_party/anvil-build/anvil-local.sh deploy -o build-bin/ extensions/wtf-injector-firefox:deploy +# cd third_party/firefox-addon-sdk/ +# source bin/activate +# cd ../.. +# cd build-bin/wtf-injector-firefox/ +# cfx xpi \ +# --update-link https://tracing-framework.appspot.com/CURRENT/web-tracing-framework.xpi \ +# --update-url https://tracing-framework.appspot.com/CURRENT/web-tracing-framework.update.rdf +# cd ../.. +# mv build-bin/wtf-injector-firefox/web-tracing-framework.xpi build-bin/extensions/ +# mv build-bin/wtf-injector-firefox/web-tracing-framework.update.rdf build-bin/extensions/ echo "" # ============================================================================= @@ -53,28 +58,55 @@ echo "" # ============================================================================= echo "Building gh-pages..." -# Clean first. -rm -rf build-bin/gh-pages/ +# Ensure we have a sibling tracking-framework-gh-pages checkout. +SELF_DIR=$PWD +GH_PAGES=$PWD/../tracing-framework-gh-pages +if [ ! -d "$GH_PAGES" ]; then + # Not found - create and clone. + echo "Creating tracing-framework-gh-pages..." + git clone git@github.com:google/tracing-framework.git $GH_PAGES + cd $GH_PAGES + git checkout gh-pages +else + # Reset hard to the current version. + echo "Resetting tracing-framework-gh-pages..." + cd $GH_PAGES + git reset --hard + git pull + git merge origin/gh-pages +fi +cd $SELF_DIR + +# Reset existing bin dir. +if [ -d "$GH_PAGES/bin" ]; then + rm -rf $GH_PAGES/bin/ +fi -./third_party/anvil-build/anvil-local.sh deploy -o build-bin/gh-pages/ :release +# Copy binaries from build results and source tree. +mkdir -p $GH_PAGES/bin +cp bazel-bin/app/wtf-app.zip $GH_PAGES/bin/ +unzip -q bazel-bin/app/wtf-app.zip -d $GH_PAGES/bin/ +cp bazel-bin/bindings/js/wtf-trace-web-api.zip $GH_PAGES/bin/ +cp bazel-bin/bindings/js/wtf_trace_min_js_compiled.js $GH_PAGES/bin/ +cp bazel-bin/bindings/js/wtf_trace_web_js_compiled.js $GH_PAGES/bin/ +cp bazel-bin/bindings/js/wtf_node_js_compiled.js $GH_PAGES/bin/ -# Copy around extension files. -cp build-bin/extensions/web-tracing-framework.* build-bin/gh-pages/extensions/ -rm -rf build-bin/gh-pages/extensions/wtf-injector-firefox/ -mv build-bin/gh-pages/extensions/wtf-injector-chrome/wtf-injector-chrome.zip build-bin/gh-pages/extensions/ -rmdir build-bin/gh-pages/extensions/wtf-injector-chrome/ +# Copy extensions from build results. +mkdir $GH_PAGES/bin/extensions +cp bazel-bin/extensions/wtf-injector-chrome/wtf-injector-chrome.zip $GH_PAGES/bin/extensions/ +# cp bazel-bin/extensions/web-tracing-framework.* $GH_PAGES/extensions/ echo "" # ============================================================================= # Done! # ============================================================================= echo "gh-pages:" -echo " build-bin/gh-pages/" +echo " $GH_PAGES/" echo "Chrome extension:" -echo " build-bin/extensions/wtf-injector-chrome/wtf-injector-chrome.zip" -echo "Firefox extension:" -echo " build-bin/extensions/web-tracing-framework.xpi <-- zip" -echo " build-bin/extensions/web-tracing-framework.update.rdf <-- update RDF" +echo " bazel-bin/extensions/wtf-injector-chrome/wtf-injector-chrome.zip" +# echo "Firefox extension:" +# echo " build-bin/extensions/web-tracing-framework.xpi <-- zip" +# echo " build-bin/extensions/web-tracing-framework.update.rdf <-- update RDF" echo "" echo "Ready for npm publish and ./scripts/update-gh-pages.sh" echo "" diff --git a/scripts/update-third-party.sh b/scripts/publish-gh-pages.sh similarity index 52% rename from scripts/update-third-party.sh rename to scripts/publish-gh-pages.sh index a1654b0f..d827029c 100755 --- a/scripts/update-third-party.sh +++ b/scripts/publish-gh-pages.sh @@ -3,8 +3,11 @@ # Copyright 2012 Google Inc. All Rights Reserved. # This script is only to be used by contributors. -# It will attempt to pull the latest versions of third party code and binaries. -# Before running one should be in a git branch with no pending changes. +# This will build everything, check out the latest tracing-framework gh-pages +# branch, update the bin/ path, and prepare a commit. + +# Break on error. +set -e # This must currently run from the root of the repo # TODO(benvanik): make this runnable from anywhere (find git directory?) @@ -13,33 +16,35 @@ if [ ! -d ".git" ]; then exit 1 fi +echo "" # ============================================================================= -# Node modules +# Look for sibling path or create # ============================================================================= -npm install +GH_PAGES=$PWD/../tracing-framework-gh-pages +if [ ! -d "$GH_PAGES" ]; then + # Not found. + echo "Run prepare-publish.sh first to create gh-pages repo" + exit 1 +fi +cd $GH_PAGES # ============================================================================= -# Git submodules +# Stage all changes # ============================================================================= -echo "Updating git modules..." - -# TODO(benvanik): update each module -SUBMODULES=( anvil-build closure-compiler closure-library closure-linter closure-stylesheets closure-templates ) -cd third_party -for m in ${SUBMODULES[@]} -do - echo "-> third_party/$m" - cd $m - git checkout master - git pull origin master - git merge origin/master - cd .. -done -cd .. -for m in ${SUBMODULES[@]} -do - git add third_party/$m -done +echo "Staging changes..." + +git add --all bin/ +git commit -m "Updating bin/ to the latest version." echo "" +# ============================================================================= +# Push! +# ============================================================================= +echo "Pushing changes..." + +git push origin gh-pages + +echo "" + +cd - diff --git a/scripts/setup.bat b/scripts/setup.bat deleted file mode 100644 index 25b620e3..00000000 --- a/scripts/setup.bat +++ /dev/null @@ -1,54 +0,0 @@ -@ECHO OFF - -REM Copyright 2012 Google Inc. All Rights Reserved. -REM -REM wtf Windows setup script -REM -REM This script will install all dependencies to the system (that it can). -REM The dependencies are all local. -REM -REM Requires: -REM - Git 1.7.5+ -REM - Python 2.7+ -REM - Python easy_install: http://pypi.python.org/pypi/setuptools -REM - node.js v0.6.10+ (containing npm) - -ECHO. -REM ============================================================================ -REM Check for Python/node/etc -REM ============================================================================ -ECHO Checking for dependencies... - -REM TODO(benvanik): check python/node versions - -ECHO WARNING: you need to make sure you have Python 2.6+ and node 0.8.4+! -ECHO WARNING: attempting to install pip - install it yourself if it fails! - -easy_install pip - -ECHO. -REM ============================================================================ -REM Git submodules -REM ============================================================================ -ECHO Fetching submodules... - -git submodule init -git submodule update - -ECHO. -REM ============================================================================ -REM Node modules -REM ============================================================================ -ECHO Installing node modules... - -npm install - -ECHO. -REM ============================================================================ -REM Anvil init -REM ============================================================================ -ECHO Setting up anvil-build environment... - -third_party\anvil-build\setup-local.bat - -ECHO. diff --git a/scripts/setup.sh b/scripts/setup.sh deleted file mode 100755 index fa71fbc9..00000000 --- a/scripts/setup.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash - -# Copyright 2012 Google Inc. All Rights Reserved. - -# wtf unix setup script - -# This script will install all dependencies. Everything is local, no need to -# run as root. -# -# Requires: -# - All: -# - Git 1.7.5+ -# - Python 2.6+ -# - Python pip -# - node.js v0.8.0+ (containing npm) - -# Ensure running as root (or on Cygwin, where it doesn't matter) -if [ "$(id -u)" -eq 0 ]; then - if [ ! -e "/Cygwin.bat" ]; then - echo "This script should not be run as root!" - echo "Run without sudo!" - exit 1 - fi -fi - -# This must currently run from the root of the repo -# TODO(benvanik): make this runnable from anywhere (find git directory?) -if [ ! -d ".git" ]; then - echo "This script must be run from the root of the repository (the folder containing .git)" - exit 1 -fi - -# ============================================================================== -# Check for Python/node/etc -# ============================================================================== -echo "Checking for dependencies..." - -echo "- Python 2.6+:" -if [ ! -e "$(which python)" ]; then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "! Python not found or not in PATH - at least version 2.6 is required !" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - exit 1 -fi -PYTHON_CHECK=`python -c 'import sys; print(sys.version_info >= (2, 6) and "1" or "0")'` -PYTHON_VERSION=`python -c 'import sys; print(sys.version_info[:])'` -if [ "$PYTHON_CHECK" = "0" ]; then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "! Python is out of date - at least version 2.6 is required !" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Your version: $PYTHON_VERSION" - exit 1 -fi -echo " path: $(which python)" -echo " version: $PYTHON_VERSION" -echo "" -echo "- Python pip:" -if [ ! -e "$(which pip)" ]; then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "! pip not found or not in PATH !" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Attemping to install via the system package manager..." - if [ "$(which easy_install)" ]; then - # Anything with easy_install (on OS X by default) - sudo easy_install pip - elif [ "$(which apt-get 2>/dev/null)" ]; then - # Linux (Ubuntu) - sudo apt-get install python-pip - elif [ "$(which port 2>/dev/null)" ]; then - # OS X (MacPorts) - sudo port selfupdate - sudo port install pip - else - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "! No supported package manager found! !" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " If on OS X ensure you install MacPorts (port) and run again" - echo " Or, manually install these packages:" - echo " pip" - exit 1 - fi -fi -echo " path: $(which pip)" -echo "" -echo "- node.js 0.8.0+:" -if [ ! -e "$(which node)" ]; then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "! node.js not found or not in PATH - at least version 0.8.0 is required !" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Grab the latest version from: http://nodejs.org/#download" - exit 1 -fi -NODE_CHECK=`node -e "var v = process.version.split('v')[1].split('.'); console.log(v[0] > 0 || v[1] > 8 || v[2] >= 0)"` -NODE_VERSION=`node -e "console.log(process.version)"` -if [ "$NODE_CHECK" = "false" ]; then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "! node.js is out of date - at least version 0.8.0 is required !" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Your version: $NODE_VERSION" - echo "Grab the latest version from: http://nodejs.org/#download" - exit 1 -fi -echo " path: $(which node)" -echo " version: $NODE_VERSION" - -echo "" -# ============================================================================== -# Git submodules -# ============================================================================== -echo "Fetching submodules..." - -git submodule init -git submodule update - -# On cygwin disable the filemode setting to prevent all the spurious +x diffs. -# This cannot be set globally as git resets it each repo. -if [ -e "/Cygwin.bat" ]; then - git config core.filemode false - git submodule foreach git config core.filemode false -fi - -# Add an ignored gitignore to closure-linter, as the repo is missing one that -# ignores .pyc files. -echo '.gitignore' > third_party/closure-linter/.gitignore -echo '*.pyc' >> third_party/closure-linter/.gitignore - -echo "" -# ============================================================================= -# Node modules -# ============================================================================= -echo "Installing node modules..." - -npm install - -echo "" -# ============================================================================= -# Anvil init -# ============================================================================= -echo "Setting up anvil-build environment..." - -third_party/anvil-build/setup-local.sh - -echo "" diff --git a/scripts/update-gh-pages.sh b/scripts/update-gh-pages.sh deleted file mode 100755 index 674533cf..00000000 --- a/scripts/update-gh-pages.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -# Copyright 2012 Google Inc. All Rights Reserved. - -# This script is only to be used by contributors. -# This will build everything, check out the latest tracing-framework gh-pages -# branch, update the bin/ path, and prepare a commit. - -# Break on error. -set -e - -# This must currently run from the root of the repo -# TODO(benvanik): make this runnable from anywhere (find git directory?) -if [ ! -d ".git" ]; then - echo "This script must be run from the root of the repository (the folder containing .git)" - exit 1 -fi - -GIT_USERNAME=`git config user.name` -GIT_USEREMAIL=`git config user.email` - -# ============================================================================= -# Build everything -# ============================================================================= -echo "Building everything..." - -./scripts/prepare-publish.sh -SRC_PATH=$PWD/build-bin/gh-pages/ - -echo "" -# ============================================================================= -# Look for sibling path or create -# ============================================================================= - -cd .. -if [ ! -d "tracing-framework-gh-pages" ]; then - # Not found - create and clone - echo "Creating tracing-framework-gh-pages..." - git clone git@github.com:google/tracing-framework.git tracing-framework-gh-pages - cd tracing-framework-gh-pages - git checkout gh-pages -else - # Reset hard to the current version - echo "Resetting tracing-framework-gh-pages..." - cd tracing-framework-gh-pages - git reset --hard - git pull - git merge origin/gh-pages -fi - -# Be sure to reset username/email to the owner of the source repo -git config user.name "$GIT_USERNAME" -git config user.email "$GIT_USEREMAIL" - -echo "" -# ============================================================================= -# Copy bin/ -# ============================================================================= -echo "Updating bin/..." - -# Delete all the old contents and recreate -if [ -d "bin" ]; then - rm -rf bin/ -fi -mkdir bin - -# Copy bin contents -cp -R $SRC_PATH/* bin/ - -echo "" -# ============================================================================= -# Stage all changes -# ============================================================================= -echo "Staging changes..." - -git add --all bin/ -git commit -m "Updating bin/ to the latest version." - -echo "" -# ============================================================================= -# Push! -# ============================================================================= -echo "Pushing changes..." - -git push origin gh-pages - -echo "" - diff --git a/scripts/update-version.sh b/scripts/update-version.sh index 7184ef21..b47c8e8e 100755 --- a/scripts/update-version.sh +++ b/scripts/update-version.sh @@ -52,13 +52,13 @@ sed -i.bak \ package.json rm package.json.bak -echo "-> extensions/wtf-injector-chrome/manifest.json" +echo "-> extensions/wtf-injector-chrome/manifest.template.json" # __"version": "2012.12.17.1", manifest_string="$ver_major.$ver_minor.$ver_patch.$ver_tag" sed -i.bak \ "s/^\ \ \"version\": \".*\",$/\ \ \"version\": \"$manifest_string\",/" \ - extensions/wtf-injector-chrome/manifest.json -rm extensions/wtf-injector-chrome/manifest.json.bak + extensions/wtf-injector-chrome/manifest.template.json +rm extensions/wtf-injector-chrome/manifest.template.json.bak echo "-> extensions/wtf-injector-firefox/package.json" # __"version": "2012.12.17.1", @@ -93,6 +93,6 @@ echo "Committing changes..." git commit -o -m "Updating version to $ver_string." \ package.json \ - extensions/wtf-injector-chrome/manifest.json \ + extensions/wtf-injector-chrome/manifest.template.json \ extensions/wtf-injector-firefox/package.json \ src/wtf/version.js diff --git a/src/BUILD b/src/BUILD new file mode 100644 index 00000000..c1024820 --- /dev/null +++ b/src/BUILD @@ -0,0 +1,9 @@ +# Description: +# WTF source code for both the tracing library and visualizers. + +package(default_visibility = ["//:internal"]) + +filegroup( + name = "all_files", + srcs = glob(["**/*.js"]), +) diff --git a/src/wtf/BUILD b/src/wtf/BUILD new file mode 100644 index 00000000..8d737f29 --- /dev/null +++ b/src/wtf/BUILD @@ -0,0 +1,19 @@ +# Description: +# Shared macros and versioning rules. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "wtf", + srcs = [ + "version.js", + "wtf.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//externs", + ], +) diff --git a/src/wtf/addon/BUILD b/src/wtf/addon/BUILD new file mode 100644 index 00000000..5593c5c0 --- /dev/null +++ b/src/wtf/addon/BUILD @@ -0,0 +1,23 @@ +# Description: +# Add-on API. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "addon", + srcs = [ + "addon.js", + "appaddon.js", + "manifest.js", + "registry.js", + "traceaddon.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf/events:eventemitter", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/app/BUILD b/src/wtf/app/BUILD new file mode 100644 index 00000000..27183f65 --- /dev/null +++ b/src/wtf/app/BUILD @@ -0,0 +1,135 @@ +# Description: +# Main application source code. +# HTML and assets live under //app/. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("//builddefs:less_rules.bzl", "less_css_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_template_library") + +closure_js_library( + name = "app", + srcs = [ + "addonmanager.js", + "app.js", + "documentview.js", + "exports.js", + "framepainter.js", + "granularity.js", + "graphics/canvaspanel.js", + "healthdialog.js", + "helpdialog.js", + "loader.js", + "maindisplay.js", + "markpainter.js", + "nav/heatmappainter.js", + "nav/navbar.js", + "nav/statsbox.js", + "nav/timelinepainter.js", + "query/querypanel.js", + "query/querytablesource.js", + "selection.js", + "selectionpainter.js", + "splashdialog.js", + "statusbar.js", + "tabbar.js", + "tabpanel.js", + "toolbar.js", + "tracks/statisticstablesource.js", + "tracks/timerangepainter.js", + "tracks/trackinfobar.js", + "tracks/trackspanel.js", + "tracks/zonepainter.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":app_templates", + "//src/wtf", + "//src/wtf/addon", + "//src/wtf/data", + "//src/wtf/db", + "//src/wtf/db:unit", + "//src/wtf/doc", + "//src/wtf/events", + "//src/wtf/events:eventemitter", + "//src/wtf/io", + "//src/wtf/io/cff", + "//src/wtf/ipc", + "//src/wtf/math", + "//src/wtf/pal", + "//src/wtf/replay/graphics", + "//src/wtf/replay/graphics/ui", + "//src/wtf/replay/timetravel", + "//src/wtf/timing", + "//src/wtf/ui:color", + "//src/wtf/ui:control", + "//src/wtf/ui:dialog", + "//src/wtf/ui:errordialog", + "//src/wtf/ui:gridpainter", + "//src/wtf/ui:progressdialog", + "//src/wtf/ui:rangepainter", + "//src/wtf/ui:rulerpainter", + "//src/wtf/ui:searchcontrol", + "//src/wtf/ui:settingsdialog", + "//src/wtf/ui:timepainter", + "//src/wtf/ui:tooltip", + "//src/wtf/ui:virtualtable", + "//src/wtf/ui:zoom", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_template_library( + name = "app_templates", + srcs = [ + "documentview.soy", + "graphics/canvaspanel.soy", + "healthdialog.soy", + "helpdialog.soy", + "maindisplay.soy", + "nav/navbar.soy", + "nav/statsbox.soy", + "query/querypanel.soy", + "splashdialog.soy", + "statusbar.soy", + "tabbar.soy", + "toolbar.soy", + "tracks/trackinfobar.soy", + "tracks/trackspanel.soy", + ], +) + +less_css_library( + name = "app_styles", + srcs = [ + "documentview.less", + "graphics/canvaspanel.less", + "graphics/graphics.less", + "healthdialog.less", + "helpdialog.less", + "maindisplay.less", + "nav/nav.less", + "nav/navbar.less", + "nav/statsbox.less", + "query/query.less", + "query/querypanel.less", + "splashdialog.less", + "statusbar.less", + "tabbar.less", + "toolbar.less", + "tracks/trackinfobar.less", + "tracks/tracks.less", + "tracks/trackspanel.less", + ], + includes = ["src"], + main_srcs = ["app.less"], + deps = [ + "//src/wtf/replay/graphics/ui:graphics_styles", + "//src/wtf/replay/timetravel:timetravel_styles", + "//src/wtf/ui:ui_styles", + "//src/wtf/ui/styles", + ], +) diff --git a/src/wtf/app/addonmanager.js b/src/wtf/app/addonmanager.js index c94d451b..f03685aa 100644 --- a/src/wtf/app/addonmanager.js +++ b/src/wtf/app/addonmanager.js @@ -18,7 +18,6 @@ goog.require('goog.Disposable'); goog.require('goog.Uri'); goog.require('goog.asserts'); goog.require('goog.dom'); -goog.require('goog.dom.TagName'); goog.require('goog.dom.classes'); goog.require('goog.style'); goog.require('wtf.addon'); @@ -61,7 +60,7 @@ wtf.app.AddonManager = function(documentView) { * @type {!Element} * @private */ - this.addonsEl_ = dom.createElement(goog.dom.TagName.DIV); + this.addonsEl_ = dom.createElement('div'); this.addonsEl_.id = 'wtfAppAddons'; dom.getDocument().body.appendChild(this.addonsEl_); @@ -124,13 +123,13 @@ wtf.app.AddonManager.prototype.loadAddon = function(addon) { // Create iframe container. var iframe = /** @type {!HTMLIFrameElement} */ ( - dom.createElement(goog.dom.TagName.IFRAME)); + dom.createElement('iframe')); this.addonsEl_.appendChild(iframe); // Set base. var idoc = iframe.contentDocument; var baseUri = goog.Uri.resolve(window.location.href, manifest.getUrl()); - var baseEl = idoc.createElement(goog.dom.TagName.BASE); + var baseEl = idoc.createElement('base'); baseEl.href = baseUri.toString(); idoc.head.appendChild(baseEl); @@ -141,7 +140,7 @@ wtf.app.AddonManager.prototype.loadAddon = function(addon) { // Add scripts. for (var n = 0; n < info.scripts.length; n++) { - var script = idoc.createElement(goog.dom.TagName.SCRIPT); + var script = idoc.createElement('script'); script.src = info.scripts[n]; idoc.body.appendChild(script); } @@ -183,7 +182,7 @@ wtf.app.AddonManager.prototype.setupAddonApi_ = function( function createTabPanel(path, name, options, callback) { tabbar.addPanel(new wtf.app.AddonTabPanel( addon, documentView, path, name, options, callback)); - }; + } }; @@ -267,7 +266,7 @@ wtf.app.AddonTabPanel.Callback; * @override */ wtf.app.AddonTabPanel.prototype.createDom = function(dom) { - var el = dom.createElement(goog.dom.TagName.DIV); + var el = dom.createElement('div'); goog.dom.classes.add(el, goog.getCssName('appUiTabPanel')); return el; }; @@ -287,13 +286,13 @@ wtf.app.AddonTabPanel.prototype.setupIframe_ = function() { // renamed CSS. Better would be to insert a default stylesheet with some // common styles (buttons/etc). var iframe = /** @type {!HTMLIFrameElement} */ ( - this.getDom().createElement(goog.dom.TagName.IFRAME)); + this.getDom().createElement('iframe')); this.getRootElement().appendChild(iframe); // Set base. var idoc = iframe.contentDocument; var baseUri = goog.Uri.resolve(window.location.href, manifest.getUrl()); - var baseEl = idoc.createElement(goog.dom.TagName.BASE); + var baseEl = idoc.createElement('base'); baseEl.href = baseUri.toString(); idoc.head.appendChild(baseEl); @@ -306,7 +305,7 @@ wtf.app.AddonTabPanel.prototype.setupIframe_ = function() { // Add scripts. var scripts = this.options_['scripts'] || []; for (var n = 0; n < scripts.length; n++) { - var script = idoc.createElement(goog.dom.TagName.SCRIPT); + var script = idoc.createElement('script'); script.src = scripts[n]; idoc.body.appendChild(script); } @@ -314,7 +313,7 @@ wtf.app.AddonTabPanel.prototype.setupIframe_ = function() { // Add stylesheets. var stylesheets = this.options_['stylesheets'] || []; for (var n = 0; n < stylesheets.length; n++) { - var link = idoc.createElement(goog.dom.TagName.LINK); + var link = idoc.createElement('link'); link.rel = 'stylesheet'; link.href = stylesheets[n]; link.type = 'text/css'; diff --git a/src/wtf/app/documentview.js b/src/wtf/app/documentview.js index 9e77d18b..51fef9a9 100644 --- a/src/wtf/app/documentview.js +++ b/src/wtf/app/documentview.js @@ -581,7 +581,7 @@ wtf.app.DocumentView.prototype.saveLocalTrace_ = function() { self.getDom()); }; xhr.send(); - }; + } }; diff --git a/src/wtf/app/framepainter.js b/src/wtf/app/framepainter.js index 01fcb346..4e56c827 100644 --- a/src/wtf/app/framepainter.js +++ b/src/wtf/app/framepainter.js @@ -237,7 +237,7 @@ wtf.app.FramePainter.prototype.getInfoStringInternal = * @param {number} x X coordinate, relative to canvas. * @param {number} y Y coordinate, relative to canvas. * @param {!goog.math.Rect} bounds Draw bounds. - * @return {wtf.db.Frame|Array.} Frame or an array + * @return {!wtf.db.Frame|!Array.} Frame or an array * containing the two frames on either side of the time. * @private */ diff --git a/src/wtf/app/granularity.js b/src/wtf/app/granularity.js index 7304bb18..351013a4 100644 --- a/src/wtf/app/granularity.js +++ b/src/wtf/app/granularity.js @@ -27,10 +27,11 @@ wtf.app.Granularity = { CENTISECOND: 10, /** ms */ MILLISECOND: 1, - - // TODO(benvanik): make this a setting on the summary index instead? - /** - * The finest granularity to work with. - */ - FINEST: 100 }; + +// TODO(benvanik): make this a setting on the summary index instead? +/** + * The finest granularity to work with. + * @const {wtf.app.Granularity} + */ +wtf.app.Granularity.FINEST = wtf.app.Granularity.DECISECOND; diff --git a/src/wtf/app/helpdialog.soy b/src/wtf/app/helpdialog.soy index 2257f0ef..408aa899 100644 --- a/src/wtf/app/helpdialog.soy +++ b/src/wtf/app/helpdialog.soy @@ -21,7 +21,7 @@ * @param system_key System command key string (like 'ctrl'). * @param is_chrome_extension Whether this is running in the Chrome extension. */ -{template .control} +{template .control autoescape="deprecated-contextual"}
diff --git a/src/wtf/app/loader.js b/src/wtf/app/loader.js index 53e1cdbe..f16103cd 100644 --- a/src/wtf/app/loader.js +++ b/src/wtf/app/loader.js @@ -189,6 +189,7 @@ wtf.app.Loader.prototype.requestLocalOpenDialog = function( opt_selectCallback.call(opt_scope); } _gaq.push(['_trackEvent', 'app', 'open_local_files']); + goog.asserts.assert(inputElement.files); this.loadFiles(inputElement.files); }, false, this); inputElement.click(); @@ -269,7 +270,7 @@ wtf.app.Loader.prototype.requestDriveOpenDialog = function( } this.loadDataSources_(sourceInfos); - }; + } }, this); }; @@ -277,7 +278,7 @@ wtf.app.Loader.prototype.requestDriveOpenDialog = function( /** * Begins loading a set of HTML5 File objects. * These can be from the filesystem, dragged in, etc. - * @param {!Array.} files File objects. + * @param {!Array.|!FileList} files File objects. */ wtf.app.Loader.prototype.loadFiles = function(files) { var sourceInfos = []; @@ -439,7 +440,7 @@ wtf.app.Loader.prototype.loadSucceeded_ = function(doc, entries, opt_title) { wtf.timing.setTimeout(50, function() { documentView.zoomToFit(); }, this); - }; + } }; diff --git a/src/wtf/app/maindisplay.js b/src/wtf/app/maindisplay.js index 714489b9..5123204e 100644 --- a/src/wtf/app/maindisplay.js +++ b/src/wtf/app/maindisplay.js @@ -193,13 +193,13 @@ wtf.app.MainDisplay.prototype.createDom = function(dom) { wtf.app.MainDisplay.prototype.setupDragDropLoading_ = function() { var doc = this.getDom().getDocument(); var eh = this.getHandler(); - eh.listen(doc.body, goog.events.EventType.DRAGENTER, function(e) { + eh.listenWithScope(doc.body, goog.events.EventType.DRAGENTER, function(e) { e.preventDefault(); }, false, this); - eh.listen(doc.body, goog.events.EventType.DRAGOVER, function(e) { + eh.listenWithScope(doc.body, goog.events.EventType.DRAGOVER, function(e) { e.preventDefault(); }, false, this); - eh.listen(doc.body, goog.events.EventType.DROP, function(e) { + eh.listenWithScope(doc.body, goog.events.EventType.DROP, function(e) { var browserEvent = e.getBrowserEvent(); if (browserEvent.dataTransfer && browserEvent.dataTransfer.files && browserEvent.dataTransfer.files.length) { diff --git a/src/wtf/app/query/querypanel.js b/src/wtf/app/query/querypanel.js index 94f1ed6d..c244bc1e 100644 --- a/src/wtf/app/query/querypanel.js +++ b/src/wtf/app/query/querypanel.js @@ -72,7 +72,8 @@ wtf.app.query.QueryPanel = function(documentView) { */ this.zoneSelect_ = this.getChildElement(goog.getCssName('zoneSelect')); this.updateZoneList_(); - this.getHandler().listen(this.zoneSelect_, goog.events.EventType.CHANGE, + this.getHandler().listenWithScope( + this.zoneSelect_, goog.events.EventType.CHANGE, this.reissueQuery_, false, this); /** diff --git a/src/wtf/app/splashdialog.soy b/src/wtf/app/splashdialog.soy index e22f8865..a70f4724 100644 --- a/src/wtf/app/splashdialog.soy +++ b/src/wtf/app/splashdialog.soy @@ -21,7 +21,7 @@ * @param system_key System command key string (like 'ctrl'). * @param show_drive Whether to show the open from drive button. */ -{template .control} +{template .control autoescape="deprecated-contextual"}

Web Tracing Framework

diff --git a/src/wtf/app/statusbar.soy b/src/wtf/app/statusbar.soy index 9b1bcfd2..d23654e9 100644 --- a/src/wtf/app/statusbar.soy +++ b/src/wtf/app/statusbar.soy @@ -18,7 +18,7 @@ * Root control UI. * @param system_key System command key string (like 'ctrl'). */ -{template .control} +{template .control autoescape="deprecated-contextual"}
} + * @type {!Object.} * @private */ this.panelsByPath_ = {}; @@ -114,7 +114,7 @@ wtf.app.Tabbar.prototype.addPanel = function(panel) { dom.appendChild( this.getChildElement(goog.getCssName('kTabHeaderTabs')), tabElement); - this.getHandler().listen( + this.getHandler().listenWithScope( tabElement, goog.events.EventType.CLICK, function(e) { @@ -281,8 +281,7 @@ wtf.app.Tabbar.prototype.getTabForPanel_ = function(panel) { /** - * Handles sizing/layout. - * This is called by the document view when the control size changes. + * @override */ wtf.app.Tabbar.prototype.layout = function() { if (this.selectedTab_) { diff --git a/src/wtf/app/toolbar.soy b/src/wtf/app/toolbar.soy index 54841290..208795ba 100644 --- a/src/wtf/app/toolbar.soy +++ b/src/wtf/app/toolbar.soy @@ -18,7 +18,7 @@ * Root control UI. * @param system_key System command key string (like 'ctrl'). */ -{template .control} +{template .control autoescape="deprecated-contextual"}
diff --git a/src/wtf/app/tracks/trackspanel.js b/src/wtf/app/tracks/trackspanel.js index e6494e93..2d8e7bea 100644 --- a/src/wtf/app/tracks/trackspanel.js +++ b/src/wtf/app/tracks/trackspanel.js @@ -293,7 +293,7 @@ wtf.app.tracks.TracksPanel.prototype.setupKeyboardShortcuts_ = function() { commandManager.execute('goto_frame', this, null, newFrame); } } - }; + } keyboardScope.addShortcut('z', function() { moveFrames(-1, true); }, this); diff --git a/src/wtf/data/BUILD b/src/wtf/data/BUILD new file mode 100644 index 00000000..d3b01cb5 --- /dev/null +++ b/src/wtf/data/BUILD @@ -0,0 +1,25 @@ +# Description: +# Event data types. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "data", + srcs = [ + "contextinfo.js", + "eventclass.js", + "eventflag.js", + "formats.js", + "variable.js", + "webidl.js", + "zonetype.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/data/contextinfo.js b/src/wtf/data/contextinfo.js index bf675e8f..7a3ca206 100644 --- a/src/wtf/data/contextinfo.js +++ b/src/wtf/data/contextinfo.js @@ -77,8 +77,7 @@ wtf.data.ContextInfo.prototype.serialize = goog.abstractMethod; /** - * Gets a human-readable version of the context info. - * @return {string} String version. + * @override */ wtf.data.ContextInfo.prototype.toString = goog.abstractMethod; diff --git a/src/wtf/db/BUILD b/src/wtf/db/BUILD new file mode 100644 index 00000000..2ca6c9d1 --- /dev/null +++ b/src/wtf/db/BUILD @@ -0,0 +1,73 @@ +# Description: +# Trace database loading and querying. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "db", + srcs = [ + "database.js", + "datasource.js", + "datasourceinfo.js", + "db.js", + "eventindex.js", + "eventiterator.js", + "eventlist.js", + "eventstatistics.js", + "eventstruct.js", + "eventtype.js", + "eventtypebuilder.js", + "eventtypetable.js", + "exports.js", + "filter.js", + "filterparser.js", + "frame.js", + "framelist.js", + "healthinfo.js", + "mark.js", + "marklist.js", + "queryresult.js", + "sources/callsdatasource.js", + "sources/chunkeddatasource.js", + "sources/cpuprofiledatasource.js", + "timerange.js", + "timerangelist.js", + "zone.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":unit", + "//src/wtf", + "//src/wtf/data", + "//src/wtf/events:eventemitter", + "//src/wtf/io", + "//src/wtf/io/cff", + "//src/wtf/pal", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "node", + srcs = ["node.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":db", + "//src/wtf/pal", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "unit", + srcs = ["unit.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/db/eventiterator.js b/src/wtf/db/eventiterator.js index 735b7f74..3d5fbdd4 100644 --- a/src/wtf/db/eventiterator.js +++ b/src/wtf/db/eventiterator.js @@ -607,7 +607,7 @@ wtf.db.EventIterator.prototype.buildArgumentString_ = function( // TODO(benvanik): better handling of objects/other types? s.push(value); } - }; + } }; diff --git a/src/wtf/db/eventtype.js b/src/wtf/db/eventtype.js index 02dd60a5..1724028f 100644 --- a/src/wtf/db/eventtype.js +++ b/src/wtf/db/eventtype.js @@ -106,8 +106,7 @@ wtf.db.EventType.LegacyParseFunction; /** - * Gets a pretty-formatted name for the event. - * @return {string} Pretty-formatted name. + * @override */ wtf.db.EventType.prototype.toString = function() { return this.name; diff --git a/src/wtf/db/filter.js b/src/wtf/db/filter.js index 15ea3750..81a6c0ba 100644 --- a/src/wtf/db/filter.js +++ b/src/wtf/db/filter.js @@ -203,8 +203,7 @@ wtf.db.Filter.prototype.setFromString = function(value) { /** - * Gets a string representing this filter. - * @return {string} Filter string. May be the empty string. + * @override */ wtf.db.Filter.prototype.toString = function() { return this.sourceString_; @@ -368,9 +367,9 @@ wtf.db.Filter.prototype.generateArgumentFilter_ = function(expr) { } else { return findArgumentName(access.base); } - }; + } return findArgumentName(exprValue.value); - }; + } function stringifyExpressionValue(exprValue) { switch (exprValue.type) { case 'number': @@ -397,7 +396,7 @@ wtf.db.Filter.prototype.generateArgumentFilter_ = function(expr) { default: throw new Error('Unknown expression value type: ' + exprValue.type); } - }; + } function stringifyReferenceAccess(access) { if (goog.isString(access)) { if (access[0] == '@') { @@ -423,7 +422,7 @@ wtf.db.Filter.prototype.generateArgumentFilter_ = function(expr) { '"' + access.name + '"' : access.name; return stringifyReferenceAccess(access.base) + '[' + name + ']'; } - }; + } }; diff --git a/src/wtf/db/healthinfo.js b/src/wtf/db/healthinfo.js index dd33b8f4..d2e1dc53 100644 --- a/src/wtf/db/healthinfo.js +++ b/src/wtf/db/healthinfo.js @@ -416,8 +416,7 @@ wtf.db.HealthWarning.prototype.getLink = function() { /** - * Gets a human-readable string for this warning. - * @return {string} Warning string. + * @override */ wtf.db.HealthWarning.prototype.toString = function() { return this.title_ + ' (' + this.suggestion_ + ')'; diff --git a/src/wtf/db/queryresult.js b/src/wtf/db/queryresult.js index 3667af7a..1f943046 100644 --- a/src/wtf/db/queryresult.js +++ b/src/wtf/db/queryresult.js @@ -151,7 +151,7 @@ wtf.db.QueryResult.prototype.dump = function(format) { /** * Dumps the results into a blob formatted by RFC 4180 (CSV). - * @return {string?} Results. + * @return {string} Results. * @private */ wtf.db.QueryResult.prototype.dumpCsv_ = function() { diff --git a/src/wtf/db/sources/callsdatasource.js b/src/wtf/db/sources/callsdatasource.js index 2c9dc3b2..aa1afae0 100644 --- a/src/wtf/db/sources/callsdatasource.js +++ b/src/wtf/db/sources/callsdatasource.js @@ -64,7 +64,7 @@ wtf.db.sources.CallsDataSource = function(db, sourceInfo, transport) { /** * All received blob parts. * They'll be stitched up at the end. - * @type {!Array.} + * @type {!Array.} * @private */ this.blobParts_ = []; diff --git a/src/wtf/db/sources/cpuprofiledatasource.js b/src/wtf/db/sources/cpuprofiledatasource.js index 8ff69cce..5b56db62 100644 --- a/src/wtf/db/sources/cpuprofiledatasource.js +++ b/src/wtf/db/sources/cpuprofiledatasource.js @@ -60,7 +60,7 @@ wtf.db.sources.CpuProfileDataSource = function(db, sourceInfo, transport) { /** * All received blob parts. * They'll be stitched up at the end. - * @type {!Array.} + * @type {!Array.} * @private */ this.blobParts_ = []; diff --git a/src/wtf/db/zone.js b/src/wtf/db/zone.js index 31825760..cd4c60f9 100644 --- a/src/wtf/db/zone.js +++ b/src/wtf/db/zone.js @@ -139,8 +139,7 @@ wtf.db.Zone.prototype.resetInfo = function(name, type, location) { /** - * Gets a string representation of the zone. - * @return {string} String representation of the zone. + * @override */ wtf.db.Zone.prototype.toString = function() { return this.name_; @@ -265,7 +264,7 @@ wtf.db.Zone.prototype.getSharedIndex = function(eventNames) { * Queries the zone. * Throws errors if the expression could not be parsed. * @param {string} expr Query string. - * @return {wtf.db.QueryResult} Result. + * @return {!wtf.db.QueryResult} Result. */ wtf.db.Zone.prototype.query = function(expr) { var startTime = wtf.now(); diff --git a/src/wtf/doc/BUILD b/src/wtf/doc/BUILD new file mode 100644 index 00000000..c90610cb --- /dev/null +++ b/src/wtf/doc/BUILD @@ -0,0 +1,26 @@ +# Description: +# Abstract loaded trace document. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "doc", + srcs = [ + "comment.js", + "commentscope.js", + "document.js", + "profile.js", + "profilescope.js", + "view.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "//src/wtf/db", + "//src/wtf/events:eventemitter", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/events/BUILD b/src/wtf/events/BUILD new file mode 100644 index 00000000..ba74f604 --- /dev/null +++ b/src/wtf/events/BUILD @@ -0,0 +1,37 @@ +# Description: +# Eventing and common app event types. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "events", + srcs = [ + "commandmanager.js", + "events.js", + "keyboard.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":eventemitter", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "eventemitter", + srcs = [ + "eventemitter.js", + "eventfullist.js", + "eventfulmap.js", + "eventtype.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/events/keyboard.js b/src/wtf/events/keyboard.js index 8130e1e8..c3994879 100644 --- a/src/wtf/events/keyboard.js +++ b/src/wtf/events/keyboard.js @@ -315,7 +315,7 @@ wtf.events.KeyboardScope.prototype.addCommandShortcut = function( if (commandManager) { commandManager.execute(commandName, this, null); } - }; + } this.listeners_.push([shortcut, callback, this]); if (this.enabled_) { this.keyboard_.addShortcut_(shortcut, callback, this); diff --git a/src/wtf/hud/BUILD b/src/wtf/hud/BUILD new file mode 100644 index 00000000..3aa8db5c --- /dev/null +++ b/src/wtf/hud/BUILD @@ -0,0 +1,54 @@ +# Description: +# Browser tracing HUD. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("//builddefs:less_rules.bzl", "less_css_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_template_library") + +closure_js_library( + name = "hud", + srcs = [ + "exports.js", + "hud.js", + "livegraph.js", + "overlay.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":overlay_template", + "//src/wtf/addon", + "//src/wtf/events", + "//src/wtf/io", + "//src/wtf/ipc", + "//src/wtf/trace", + "//src/wtf/trace:util", + "//src/wtf/ui:control", + "//src/wtf/ui:errordialog", + "//src/wtf/ui:icons", + "//src/wtf/ui:settingsdialog", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) + +less_css_library( + name = "hud_styles", + srcs = [ + "livegraph.less", + "overlay.less", + ], + includes = ["src"], + main_srcs = ["hud.less"], + deps = [ + "//src/wtf/ui:ui_styles", + "//src/wtf/ui/styles", + ], +) + +closure_js_template_library( + name = "overlay_template", + srcs = ["overlay.soy"], +) diff --git a/src/wtf/hud/hud.js b/src/wtf/hud/hud.js index 43e0cace..a80d446f 100644 --- a/src/wtf/hud/hud.js +++ b/src/wtf/hud/hud.js @@ -57,7 +57,8 @@ wtf.hud.prepare = function(opt_options, opt_parentElement) { var provider = providers[n]; var buttons = provider.getHudButtons(); for (var m = 0; m < buttons.length; m++) { - wtf.hud.buttons_.push(buttons[m]); + wtf.hud.buttons_.push( + /** @type {!wtf.hud.Overlay.ButtonInfo} */ (buttons[m])); } } diff --git a/src/wtf/hud/overlay.less b/src/wtf/hud/overlay.less index 2c3a4484..3b09684e 100644 --- a/src/wtf/hud/overlay.less +++ b/src/wtf/hud/overlay.less @@ -9,6 +9,8 @@ * @author benvanik@google.com (Ben Vanik) */ + @import "wtf/ui/styles/css3.less"; + .hudOuter { position: fixed; height: 40px; @@ -52,12 +54,7 @@ border-left: 1px solid #C1C1C1; text-align: center; color: #444; - background-color: #f5f5f5; - background-image: -webkit-linear-gradient(top,#f5f5f5,#f1f1f1); - background-image: -moz-linear-gradient(top,#f5f5f5,#f1f1f1); - background-image: -ms-linear-gradient(top,#f5f5f5,#f1f1f1); - background-image: -o-linear-gradient(top,#f5f5f5,#f1f1f1); - background-image: linear-gradient(top,#f5f5f5,#f1f1f1); + .backgroundGradient(#f5f5f5, #f1f1f1); -webkit-transition: all 0.218s; -moz-transition: all 0.218s; @@ -66,25 +63,13 @@ } .hudButton:hover { color: #222; - background-color: #f8f8f8; - background-image: -webkit-linear-gradient(top,#f8f8f8,#f1f1f1); - background-image: -moz-linear-gradient(top,#f8f8f8,#f1f1f1); - background-image: -ms-linear-gradient(top,#f8f8f8,#f1f1f1); - background-image: -o-linear-gradient(top,#f8f8f8,#f1f1f1); - background-image: linear-gradient(top,#f8f8f8,#f1f1f1); - -webkit-box-shadow: inset 0px 1px 2px rgba(0,0,0,0.2); - box-shadow: inset 0px 1px 2px rgba(0,0,0,0.2); + .backgroundGradient(#f8f8f8 ,#f1f1f1); + .insetBoxShadow(0px, 1px, 2px, rgba(0,0,0,0.2)); } .hudButton:active { color: #333; - background-color: #f6f6f6; - background-image: -webkit-linear-gradient(top,#f6f6f6,#f1f1f1); - background-image: -moz-linear-gradient(top,#f6f6f6,#f1f1f1); - background-image: -ms-linear-gradient(top,#f6f6f6,#f1f1f1); - background-image: -o-linear-gradient(top,#f6f6f6,#f1f1f1); - background-image: linear-gradient(top,#f6f6f6,#f1f1f1); - -webkit-box-shadow: inset 0px 1px 3px rgba(0,0,0,0.4); - box-shadow: inset 0px 1px 3px rgba(0,0,0,0.4); + .backgroundGradient(#f6f6f6, #f1f1f1); + .insetBoxShadow(0px, 1px, 3px, rgba(0,0,0,0.4)); } .hudButton img { position: relative; diff --git a/src/wtf/io/BUILD b/src/wtf/io/BUILD new file mode 100644 index 00000000..52e96839 --- /dev/null +++ b/src/wtf/io/BUILD @@ -0,0 +1,41 @@ +# Description: +# IO subsystem for basic IO operations and the WTF file formats. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "io", + srcs = [ + "blob.js", + "buffer.js", + "bufferview.js", + "drive.js", + "eventtype.js", + "io.js", + "readtransport.js", + # TODO(benvanik): figure out if I lost this code. + #"streaminghttpwritestream.js", + "stringtable.js", + "writetransport.js", + "transports/blobreadtransport.js", + "transports/blobwritetransport.js", + "transports/filereadtransport.js", + "transports/filewritetransport.js", + "transports/memoryreadtransport.js", + "transports/memorywritetransport.js", + "transports/nullwritetransport.js", + "transports/xhrreadtransport.js", + "transports/xhrwritetransport.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "//src/wtf/events:eventemitter", + "//src/wtf/pal", + "//src/wtf/timing", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/io/cff/BUILD b/src/wtf/io/cff/BUILD new file mode 100644 index 00000000..54547d6f --- /dev/null +++ b/src/wtf/io/cff/BUILD @@ -0,0 +1,40 @@ +# Description: +# WTF chunked file format reading/writing. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "cff", + srcs = [ + "binarystreamsource.js", + "binarystreamtarget.js", + "chunk.js", + "chunks/eventdatachunk.js", + "chunks/fileheaderchunk.js", + "chunktype.js", + "jsonstreamsource.js", + "jsonstreamtarget.js", + "part.js", + "parts/binaryeventbufferpart.js", + "parts/fileheaderpart.js", + "parts/jsoneventbufferpart.js", + "parts/legacyeventbufferpart.js", + "parts/resourcepart.js", + "parts/stringtablepart.js", + "parttype.js", + "streambase.js", + "streamsource.js", + "streamtarget.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "//src/wtf/data", + "//src/wtf/events:eventemitter", + "//src/wtf/io", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/io/drive.js b/src/wtf/io/drive.js index 34aa948a..f7ec24e6 100644 --- a/src/wtf/io/drive.js +++ b/src/wtf/io/drive.js @@ -215,7 +215,7 @@ wtf.io.drive.showFilePicker = function(options) { }); } goog.result.wait(wtf.io.drive.filePickerLoadResult_, show); - }; + } function show() { var mimeTypes = [ @@ -253,7 +253,7 @@ wtf.io.drive.showFilePicker = function(options) { } var builtPicker = picker.build(); builtPicker.setVisible(true); - }; + } return result; }; @@ -309,7 +309,7 @@ wtf.io.drive.queryFile = function(fileId) { }); } goog.result.wait(wtf.io.drive.downloadFileLoadResult_, getMetadata); - }; + } function getMetadata() { var token = gapi.auth.getToken(); @@ -343,7 +343,7 @@ wtf.io.drive.queryFile = function(fileId) { result.setError(); }; xhr.send(null); - }; + } return result; }; @@ -379,7 +379,7 @@ wtf.io.drive.downloadFile = function(driveFile) { }); } goog.result.wait(wtf.io.drive.downloadFileLoadResult_, download); - }; + } function download() { var token = gapi.auth.getToken(); @@ -402,7 +402,7 @@ wtf.io.drive.downloadFile = function(driveFile) { // We don't send here, as we let the caller do it. // xhr.send(null); result.setValue(xhr); - }; + } return result; }; diff --git a/src/wtf/io/transports/blobwritetransport.js b/src/wtf/io/transports/blobwritetransport.js index ea7bfd4f..ba533874 100644 --- a/src/wtf/io/transports/blobwritetransport.js +++ b/src/wtf/io/transports/blobwritetransport.js @@ -71,7 +71,7 @@ wtf.io.transports.BlobWriteTransport.prototype.disposeInternal = function() { wtf.io.transports.BlobWriteTransport.prototype.write = function(data) { if (wtf.io.Blob.isBlob(data)) { // Blobs are immutable, so store off our input. - this.blobParts_.push(data); + this.blobParts_.push(/** @type {!wtf.io.Blob} */ (data)); } else { // Wrap in a blob. This allows the browser to page the data out if needed. this.blobParts_.push(wtf.io.Blob.create([data])); diff --git a/src/wtf/ipc/BUILD b/src/wtf/ipc/BUILD new file mode 100644 index 00000000..bf31e82d --- /dev/null +++ b/src/wtf/ipc/BUILD @@ -0,0 +1,24 @@ +# Description: +# IPC utilities for communicating with remote code (like the extension). + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "ipc", + srcs = [ + "channel.js", + "ipc.js", + "messagechannel.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf/events:eventemitter", + "//src/wtf/timing", + "//src/wtf/trace:util", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/math/BUILD b/src/wtf/math/BUILD new file mode 100644 index 00000000..c64ce571 --- /dev/null +++ b/src/wtf/math/BUILD @@ -0,0 +1,16 @@ +# Description: +# Math utilities. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "math", + srcs = [ + "math.js", + "mersennetwister.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, +) diff --git a/src/wtf/pal/BUILD b/src/wtf/pal/BUILD new file mode 100644 index 00000000..f66a2118 --- /dev/null +++ b/src/wtf/pal/BUILD @@ -0,0 +1,23 @@ +# Description: +# Platform abstraction layer for supporting browser and non-browser runtimes. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "pal", + srcs = [ + "browserplatform.js", + "chromeplatform.js", + "iplatform.js", + "nodeplatform.js", + "pal.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/pal/browserplatform.js b/src/wtf/pal/browserplatform.js index 4ad8e71c..5ac201a9 100644 --- a/src/wtf/pal/browserplatform.js +++ b/src/wtf/pal/browserplatform.js @@ -14,7 +14,6 @@ goog.provide('wtf.pal.BrowserPlatform'); goog.require('goog.dom'); -goog.require('goog.dom.TagName'); goog.require('goog.events.EventType'); goog.require('goog.fs'); goog.require('wtf.pal.IPlatform'); @@ -95,7 +94,7 @@ wtf.pal.BrowserPlatform.prototype.downloadBlob_ = function(filename, blob) { // Download file. Wow. var doc = goog.dom.getDocument(); - var a = doc.createElement(goog.dom.TagName.A); + var a = doc.createElement('a'); a['download'] = filename; a.href = goog.fs.createObjectUrl(blob); var e = doc.createEvent('MouseEvents'); diff --git a/src/wtf/remote/BUILD b/src/wtf/remote/BUILD new file mode 100644 index 00000000..715e98f9 --- /dev/null +++ b/src/wtf/remote/BUILD @@ -0,0 +1,24 @@ +# Description: +# Remote tracing support. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "remote", + srcs = [ + "client.js", + "exports.js", + "remote.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf/data", + "//src/wtf/events", + "//src/wtf/io", + "//src/wtf/trace", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/replay/graphics/BUILD b/src/wtf/replay/graphics/BUILD new file mode 100644 index 00000000..b84cdef0 --- /dev/null +++ b/src/wtf/replay/graphics/BUILD @@ -0,0 +1,61 @@ +# Description: +# Graphics replay. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "graphics", + srcs = [ + "exports.js", + "graphics.js", + "session.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":graphics_library", + "//src/wtf", + "//src/wtf/db", + "//src/wtf/events", + "//src/wtf/events:eventemitter", + "//src/wtf/replay/graphics/ui", + "//src/wtf/timing", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "graphics_library", + srcs = [ + "contextpool.js", + "drawcallvisualizer.js", + "experiment.js", + "extensionmanager.js", + "frameoverdrawvisualizer.js", + "frametimevisualizer.js", + "highlightvisualizer.js", + "offscreensurface.js", + "overdrawsurface.js", + "overdrawvisualizer.js", + "playback.js", + "program.js", + "replayframe.js", + "skipcallsvisualizer.js", + "step.js", + "visualizer.js", + "webglstate.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "//src/wtf/db", + "//src/wtf/events", + "//src/wtf/events:eventemitter", + "//src/wtf/timing", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/replay/graphics/contextpool.js b/src/wtf/replay/graphics/contextpool.js index 2fee5c10..0f518f32 100644 --- a/src/wtf/replay/graphics/contextpool.js +++ b/src/wtf/replay/graphics/contextpool.js @@ -128,7 +128,8 @@ wtf.replay.graphics.ContextPool.prototype.getContext = } else { // Create a new context. var newCanvas = this.dom_.createElement(goog.dom.TagName.CANVAS); - retrievedContext = newCanvas.getContext(contextType, opt_attributes); + retrievedContext = /** @type {WebGLRenderingContext} */ ( + newCanvas.getContext(contextType, opt_attributes)); // If context type is unsupported, return null. if (!retrievedContext) { diff --git a/src/wtf/replay/graphics/highlightvisualizer.js b/src/wtf/replay/graphics/highlightvisualizer.js index 9b6ec7df..a4d87919 100644 --- a/src/wtf/replay/graphics/highlightvisualizer.js +++ b/src/wtf/replay/graphics/highlightvisualizer.js @@ -41,10 +41,7 @@ goog.inherits(wtf.replay.graphics.HighlightVisualizer, /** - * Returns whether the visualization for a target substep is stored. - * @param {number} targetSubStepIndex Target substep. - * @return {boolean} Whether the visualization is stored for a target substep. - * @protected + * @override */ wtf.replay.graphics.HighlightVisualizer.prototype.visualizationStored = function(targetSubStepIndex) { diff --git a/src/wtf/replay/graphics/offscreensurface.js b/src/wtf/replay/graphics/offscreensurface.js index a61ef26f..370cd897 100644 --- a/src/wtf/replay/graphics/offscreensurface.js +++ b/src/wtf/replay/graphics/offscreensurface.js @@ -121,9 +121,9 @@ wtf.replay.graphics.OffscreenSurface = function(gl, width, height, opt_args) { * Internal texture. Used as a render target for this.framebuffer_. * Used by drawTexture and captureTexture. * @type {WebGLTexture} - * @private + * @protected */ - this.texture_ = null; + this.texture = null; /** * Renderbuffer used for depth/stencil information in the framebuffer. @@ -159,9 +159,9 @@ wtf.replay.graphics.OffscreenSurface = function(gl, width, height, opt_args) { /** * A buffer containing vertex positions arranged in a square. * @type {WebGLBuffer} - * @private + * @protected */ - this.squareVertexPositionBuffer_ = null; + this.squareVertexPositionBuffer = null; /** * A buffer containing texture coordinates arranged for a square. @@ -198,10 +198,10 @@ wtf.replay.graphics.OffscreenSurface.prototype.clearWebGLObjects = function() { var gl = this.context; gl.deleteFramebuffer(this.framebuffer_); - gl.deleteTexture(this.texture_); + gl.deleteTexture(this.texture); gl.deleteProgram(this.drawTextureProgram_); gl.deleteRenderbuffer(this.depthStencilBuffer_); - gl.deleteBuffer(this.squareVertexPositionBuffer_); + gl.deleteBuffer(this.squareVertexPositionBuffer); gl.deleteBuffer(this.squareTextureCoordBuffer_); }; @@ -234,8 +234,8 @@ wtf.replay.graphics.OffscreenSurface.prototype.initialize = function() { gl.bindFramebuffer(goog.webgl.FRAMEBUFFER, this.framebuffer_); // Create the texture and set it as a render target for the framebuffer. - this.texture_ = gl.createTexture(); - gl.bindTexture(goog.webgl.TEXTURE_2D, this.texture_); + this.texture = gl.createTexture(); + gl.bindTexture(goog.webgl.TEXTURE_2D, this.texture); gl.texParameteri(goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_MAG_FILTER, goog.webgl.LINEAR); gl.texParameteri(goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_MIN_FILTER, @@ -247,7 +247,7 @@ wtf.replay.graphics.OffscreenSurface.prototype.initialize = function() { gl.texImage2D(goog.webgl.TEXTURE_2D, 0, goog.webgl.RGBA, this.width, this.height, 0, goog.webgl.RGBA, goog.webgl.UNSIGNED_BYTE, null); gl.framebufferTexture2D(goog.webgl.FRAMEBUFFER, - goog.webgl.COLOR_ATTACHMENT0, goog.webgl.TEXTURE_2D, this.texture_, 0); + goog.webgl.COLOR_ATTACHMENT0, goog.webgl.TEXTURE_2D, this.texture, 0); // Set renderbuffer attachment and storage formats. if (this.depth_ && this.stencil_) { @@ -309,8 +309,8 @@ wtf.replay.graphics.OffscreenSurface.prototype.initialize = function() { gl.deleteShader(drawTextureFragmentShader); // Setup attributes aVertexPosition and aTextureCoord. - this.squareVertexPositionBuffer_ = gl.createBuffer(); - gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.squareVertexPositionBuffer_); + this.squareVertexPositionBuffer = gl.createBuffer(); + gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.squareVertexPositionBuffer); var vertices = [ -1.0, -1.0, 1.0, -1.0, @@ -399,7 +399,7 @@ wtf.replay.graphics.OffscreenSurface.prototype.resize = function( this.webGLState.backup(); - gl.bindTexture(goog.webgl.TEXTURE_2D, this.texture_); + gl.bindTexture(goog.webgl.TEXTURE_2D, this.texture); gl.texImage2D(goog.webgl.TEXTURE_2D, 0, goog.webgl.RGBA, this.width, this.height, 0, goog.webgl.RGBA, goog.webgl.UNSIGNED_BYTE, null); @@ -432,7 +432,7 @@ wtf.replay.graphics.OffscreenSurface.prototype.captureTexture = function() { var originalTextureBinding = /** @type {!WebGLTexture} */ ( gl.getParameter(goog.webgl.TEXTURE_BINDING_2D)); - gl.bindTexture(goog.webgl.TEXTURE_2D, this.texture_); + gl.bindTexture(goog.webgl.TEXTURE_2D, this.texture); var alpha = this.contextAttributes_['alpha']; var format = alpha ? goog.webgl.RGBA : goog.webgl.RGB; gl.copyTexImage2D(goog.webgl.TEXTURE_2D, 0, format, 0, 0, @@ -478,7 +478,7 @@ wtf.replay.graphics.OffscreenSurface.prototype.clear = function(opt_color) { wtf.replay.graphics.OffscreenSurface.prototype.drawTexture = function( opt_blend) { this.ensureInitialized(); - this.drawTextureInternal(this.texture_, this.drawTextureProgram_, opt_blend); + this.drawTextureInternal(this.texture, this.drawTextureProgram_, opt_blend); }; @@ -510,7 +510,7 @@ wtf.replay.graphics.OffscreenSurface.prototype.drawTextureInternal = function( // Update vertex attrib settings. var vertexAttribLocation = gl.getAttribLocation(program, 'aVertexPosition'); - gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.squareVertexPositionBuffer_); + gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.squareVertexPositionBuffer); gl.enableVertexAttribArray(vertexAttribLocation); gl.vertexAttribPointer(vertexAttribLocation, 2, goog.webgl.FLOAT, false, 0, 0); diff --git a/src/wtf/replay/graphics/overdrawsurface.js b/src/wtf/replay/graphics/overdrawsurface.js index b4ccc1c0..ab0d9bb4 100644 --- a/src/wtf/replay/graphics/overdrawsurface.js +++ b/src/wtf/replay/graphics/overdrawsurface.js @@ -118,9 +118,7 @@ wtf.replay.graphics.OverdrawSurface.prototype.getThresholdDrawColor = /** - * Creates framebuffer, texture, drawTextureProgram, and buffers. - * @return {boolean} Whether initialization succeeded. - * @protected + * @override */ wtf.replay.graphics.OverdrawSurface.prototype.initialize = function() { if (!goog.base(this, 'initialize')) { @@ -222,7 +220,7 @@ wtf.replay.graphics.OverdrawSurface.prototype.initialize = function() { wtf.replay.graphics.OffscreenSurface.prototype.drawOverdraw = function( opt_blend) { this.ensureInitialized(); - this.drawTextureInternal(this.texture_, this.drawOverdrawProgram_, opt_blend); + this.drawTextureInternal(this.texture, this.drawOverdrawProgram_, opt_blend); }; @@ -248,7 +246,7 @@ wtf.replay.graphics.OffscreenSurface.prototype.drawQuad = function() { // Update vertex attrib settings. var vertexAttribLocation = gl.getAttribLocation(this.drawQuadProgram_, 'aVertexPosition'); - gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.squareVertexPositionBuffer_); + gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.squareVertexPositionBuffer); gl.enableVertexAttribArray(vertexAttribLocation); gl.vertexAttribPointer(vertexAttribLocation, 2, goog.webgl.FLOAT, false, 0, 0); diff --git a/src/wtf/replay/graphics/program.js b/src/wtf/replay/graphics/program.js index 952d5660..162223ab 100644 --- a/src/wtf/replay/graphics/program.js +++ b/src/wtf/replay/graphics/program.js @@ -171,7 +171,7 @@ wtf.replay.graphics.Program.prototype.deleteVariants = function() { /** * Returns the original program. - * @return {WebGLProgram} + * @return {!WebGLProgram} */ wtf.replay.graphics.Program.prototype.getOriginalProgram = function() { return this.originalProgram_; diff --git a/src/wtf/replay/graphics/skipcallsvisualizer.js b/src/wtf/replay/graphics/skipcallsvisualizer.js index dea30596..728d420f 100644 --- a/src/wtf/replay/graphics/skipcallsvisualizer.js +++ b/src/wtf/replay/graphics/skipcallsvisualizer.js @@ -132,8 +132,7 @@ wtf.replay.graphics.SkipCallsVisualizer.prototype.getState = function() { /** - * Sets playback-affecting state. - * @param {wtf.replay.graphics.Visualizer.State} state The new state. + * @override */ wtf.replay.graphics.SkipCallsVisualizer.prototype.setState = function(state) { for (var i = 0; i < this.skippedProgramHandles_.length; ++i) { diff --git a/src/wtf/replay/graphics/ui/BUILD b/src/wtf/replay/graphics/ui/BUILD new file mode 100644 index 00000000..aefd2f7c --- /dev/null +++ b/src/wtf/replay/graphics/ui/BUILD @@ -0,0 +1,76 @@ +# Description: +# Graphics replay UI. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("//builddefs:less_rules.bzl", "less_css_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_template_library") + +closure_js_library( + name = "ui", + srcs = [ + "argumentsdialog.js", + "canvasarea.js", + "contextbox.js", + "eventnavigator.js", + "eventnavigatorsource.js", + "eventnavigatortoolbar.js", + "graphicspanel.js", + "graphicstoolbar.js", + "rangeseeker.js", + "replayframepainter.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":ui_templates", + "//src/wtf/db", + "//src/wtf/events", + "//src/wtf/events:eventemitter", + "//src/wtf/math", + "//src/wtf/replay/graphics:graphics_library", + "//src/wtf/timing", + "//src/wtf/ui:control", + "//src/wtf/ui:dialog", + "//src/wtf/ui:errordialog", + "//src/wtf/ui:searchcontrol", + "//src/wtf/ui:tooltip", + "//src/wtf/ui:virtualtable", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_template_library( + name = "ui_templates", + srcs = [ + "argumentsdialog.soy", + "canvasarea.soy", + "contextbox.soy", + "eventnavigator.soy", + "eventnavigatortoolbar.soy", + "graphicspanel.soy", + "graphicstoolbar.soy", + "rangeseeker.soy", + ], +) + +less_css_library( + name = "graphics_styles", + srcs = [ + "argumentsdialog.less", + "canvasarea.less", + "contextbox.less", + "eventnavigator.less", + "eventnavigatortoolbar.less", + "graphicspanel.less", + "graphicstoolbar.less", + "rangeseeker.less", + ], + includes = ["src"], + main_srcs = ["graphics.less"], + deps = [ + "//src/wtf/ui:ui_styles", + "//src/wtf/ui/styles", + ], +) diff --git a/src/wtf/replay/graphics/ui/argumentsdialog.js b/src/wtf/replay/graphics/ui/argumentsdialog.js index 27081267..0777b532 100644 --- a/src/wtf/replay/graphics/ui/argumentsdialog.js +++ b/src/wtf/replay/graphics/ui/argumentsdialog.js @@ -121,9 +121,9 @@ wtf.replay.graphics.ui.ArgumentsDialog.prototype.createForm_ = function() { // Save the new arguments when either the update button is clicked or Enter // is hit. - eventHandler.listen(saveButton, goog.events.EventType.CLICK, + eventHandler.listenWithScope(saveButton, goog.events.EventType.CLICK, saveFunction, false, this); - eventHandler.listen(form, goog.events.EventType.SUBMIT, + eventHandler.listenWithScope(form, goog.events.EventType.SUBMIT, saveFunction, false, this); // Create label/input pair elements based on the type of value. @@ -138,7 +138,7 @@ wtf.replay.graphics.ui.ArgumentsDialog.prototype.createForm_ = function() { // Create the reset arguments button. var resetArgumentsElement = domHelper.getElementByClass( goog.getCssName('resetArgumentsButton')); - eventHandler.listen(resetArgumentsElement, + eventHandler.listenWithScope(resetArgumentsElement, goog.events.EventType.CLICK, function() { this.resetArguments_(); }, false, this); @@ -146,7 +146,7 @@ wtf.replay.graphics.ui.ArgumentsDialog.prototype.createForm_ = function() { // Create the cancel button. var cancelButton = domHelper.getElementByClass( goog.getCssName('cancelButton'), this.getRootElement()); - eventHandler.listen(cancelButton, + eventHandler.listenWithScope(cancelButton, goog.events.EventType.CLICK, function() { this.close(); }, false, this); diff --git a/src/wtf/replay/graphics/ui/canvasarea.js b/src/wtf/replay/graphics/ui/canvasarea.js index e50d9743..1a54d9a4 100644 --- a/src/wtf/replay/graphics/ui/canvasarea.js +++ b/src/wtf/replay/graphics/ui/canvasarea.js @@ -301,7 +301,7 @@ wtf.replay.graphics.ui.CanvasesArea.prototype.removeContext_ = function( /** - * Lays out the area where the canvases are displayed. + * @override */ wtf.replay.graphics.ui.CanvasesArea.prototype.layout = function() { if (this.resizeCanvasesToFit_) { diff --git a/src/wtf/replay/graphics/ui/eventnavigator.js b/src/wtf/replay/graphics/ui/eventnavigator.js index 1bc3ba89..0b344efa 100644 --- a/src/wtf/replay/graphics/ui/eventnavigator.js +++ b/src/wtf/replay/graphics/ui/eventnavigator.js @@ -107,7 +107,7 @@ wtf.replay.graphics.ui.EventNavigator.prototype.setReady = function() { /** - * Changes the layout of elements to fit the container. + * @override */ wtf.replay.graphics.ui.EventNavigator.prototype.layout = function() { this.table_.layout(); diff --git a/src/wtf/replay/graphics/ui/eventnavigatorsource.js b/src/wtf/replay/graphics/ui/eventnavigatorsource.js index 366f8497..b68c1e15 100644 --- a/src/wtf/replay/graphics/ui/eventnavigatorsource.js +++ b/src/wtf/replay/graphics/ui/eventnavigatorsource.js @@ -662,7 +662,7 @@ wtf.replay.graphics.ui.EventNavigatorTableSource.prototype.playbackToCurrent_ = * Gets the context handle of the given event. * This is slow and should be used sparingly. * @param {!wtf.db.EventIterator} it Iterator. - * @return {string?} Context handle, if any. + * @return {string} Context handle, if any. * @private */ wtf.replay.graphics.ui.EventNavigatorTableSource.prototype.getContextOfEvent_ = diff --git a/src/wtf/replay/graphics/ui/eventnavigatortoolbar.js b/src/wtf/replay/graphics/ui/eventnavigatortoolbar.js index 6822d8ab..27b85e8b 100644 --- a/src/wtf/replay/graphics/ui/eventnavigatortoolbar.js +++ b/src/wtf/replay/graphics/ui/eventnavigatortoolbar.js @@ -224,23 +224,23 @@ wtf.replay.graphics.ui.EventNavigatorToolbar.prototype.setReady = function() { // Handle button clicks. var eh = this.getHandler(); - eh.listen( + eh.listenWithScope( this.firstCallButton_, goog.events.EventType.CLICK, this.firstCallHandler_, false, this); - eh.listen( + eh.listenWithScope( this.previousDrawCallButton_, goog.events.EventType.CLICK, this.previousDrawCallHandler_, false, this); - eh.listen( + eh.listenWithScope( this.nextDrawCallButton_, goog.events.EventType.CLICK, this.nextDrawCallHandler_, false, this); - eh.listen( + eh.listenWithScope( this.lastCallButton_, goog.events.EventType.CLICK, this.lastCallHandler_, false, this); - eh.listen( + eh.listenWithScope( this.toggleOverdrawButton_, goog.events.EventType.CLICK, this.toggleOverdrawHandler_, false, this); diff --git a/src/wtf/replay/graphics/ui/graphicspanel.js b/src/wtf/replay/graphics/ui/graphicspanel.js index 98b3aa51..2d026a6a 100644 --- a/src/wtf/replay/graphics/ui/graphicspanel.js +++ b/src/wtf/replay/graphics/ui/graphicspanel.js @@ -66,7 +66,7 @@ wtf.replay.graphics.ui.GraphicsPanel = function( * @private */ this.viewportSizeMonitor_ = wtf.events.acquireViewportSizeMonitor(); - this.getHandler().listen( + this.getHandler().listenWithScope( this.viewportSizeMonitor_, goog.events.EventType.RESIZE, this.layout, false, this); @@ -138,7 +138,7 @@ wtf.replay.graphics.ui.GraphicsPanel = function( */ this.toggleResizeCanvasesButton_ = this.getChildElement( goog.getCssName('resizeCanvasesToFitButton')); - this.getHandler().listen( + this.getHandler().listenWithScope( this.toggleResizeCanvasesButton_, goog.events.EventType.CLICK, this.toggleResizeCanvases_, false, this); diff --git a/src/wtf/replay/graphics/ui/graphicstoolbar.js b/src/wtf/replay/graphics/ui/graphicstoolbar.js index 6c8297fc..b945e90a 100644 --- a/src/wtf/replay/graphics/ui/graphicstoolbar.js +++ b/src/wtf/replay/graphics/ui/graphicstoolbar.js @@ -153,23 +153,23 @@ wtf.replay.graphics.ui.GraphicsToolbar.prototype.setReady_ = // Handle button clicks. var eh = this.getHandler(); - eh.listen( + eh.listenWithScope( this.resetButton_, goog.events.EventType.CLICK, this.resetClickHandler_, false, this); - eh.listen( + eh.listenWithScope( this.backButton_, goog.events.EventType.CLICK, this.backClickHandler_, false, this); - eh.listen( + eh.listenWithScope( this.playButton_, goog.events.EventType.CLICK, this.playClickHandler_, false, this); - eh.listen( + eh.listenWithScope( this.forwardButton_, goog.events.EventType.CLICK, this.forwardClickHandler_, false, this); - eh.listen( + eh.listenWithScope( this.resetVisualizersButton_, goog.events.EventType.CLICK, this.resetVisualizersClickHandler_, false, this); diff --git a/src/wtf/replay/graphics/ui/rangeseeker.js b/src/wtf/replay/graphics/ui/rangeseeker.js index 9fc1a0f8..cd77ffae 100644 --- a/src/wtf/replay/graphics/ui/rangeseeker.js +++ b/src/wtf/replay/graphics/ui/rangeseeker.js @@ -197,7 +197,7 @@ wtf.replay.graphics.ui.RangeSeeker.prototype.createValueDisplayer_ = valueDisplayer.type = 'text'; // Update the seeker if displayer changes. - this.getHandler().listen(valueDisplayer, + this.getHandler().listenWithScope(valueDisplayer, goog.events.EventType.CHANGE, function() { var newValue = goog.string.parseInt(valueDisplayer.value); diff --git a/src/wtf/replay/graphics/ui/replayframepainter.js b/src/wtf/replay/graphics/ui/replayframepainter.js index 160d522c..4e476d6d 100644 --- a/src/wtf/replay/graphics/ui/replayframepainter.js +++ b/src/wtf/replay/graphics/ui/replayframepainter.js @@ -13,6 +13,7 @@ goog.provide('wtf.replay.graphics.ui.ReplayFramePainter'); +goog.require('goog.asserts'); goog.require('goog.dom.classes'); goog.require('wtf.events'); goog.require('wtf.math'); @@ -318,6 +319,7 @@ wtf.replay.graphics.ui.ReplayFramePainter.prototype.repaintInternal = function( var experiment, frames, frame; // Draw a colored bar graph for the currently selected experiment. + goog.asserts.assert(this.selectedExperiment_ !== null); experiment = experiments[this.selectedExperiment_]; if (experiment && experiment.getFrames()) { frames = experiment.getFrames(); diff --git a/src/wtf/replay/timetravel/BUILD b/src/wtf/replay/timetravel/BUILD new file mode 100644 index 00000000..a6130367 --- /dev/null +++ b/src/wtf/replay/timetravel/BUILD @@ -0,0 +1,54 @@ +# Description: +# Time-travel replay. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("//builddefs:less_rules.bzl", "less_css_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_template_library") + +closure_js_library( + name = "timetravel", + srcs = [ + "controller.js", + "exports.js", + "replaysession.js", + "timetravel.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":controller_template", + "//src/wtf", + "//src/wtf/data", + "//src/wtf/db", + "//src/wtf/events:eventemitter", + "//src/wtf/io", + "//src/wtf/io/cff", + "//src/wtf/math", + "//src/wtf/ui:control", + "//src/wtf/ui:dialog", + "//src/wtf/ui:errordialog", + "//src/wtf/ui:progressdialog", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_template_library( + name = "controller_template", + srcs = ["controller.soy"], +) + +less_css_library( + name = "timetravel_styles", + srcs = [ + "controller.less", + ], + includes = ["src"], + main_srcs = ["timetravel.less"], + deps = [ + "//src/wtf/ui:ui_styles", + "//src/wtf/ui/styles", + ], +) diff --git a/src/wtf/replay/timetravel/replaysession.js b/src/wtf/replay/timetravel/replaysession.js index 8c4731b7..cf0b9662 100644 --- a/src/wtf/replay/timetravel/replaysession.js +++ b/src/wtf/replay/timetravel/replaysession.js @@ -290,7 +290,7 @@ wtf.replay.timeTravel.ReplaySession.prototype.neuterPageEvents_ = function() { e.preventDefault(); e.stopPropagation(); return false; - }; + } for (var eventName in allEventTypes) { pageGlobal.addEventListener(eventName, eventDisabler, true); } diff --git a/src/wtf/timing/BUILD b/src/wtf/timing/BUILD new file mode 100644 index 00000000..10a5ec21 --- /dev/null +++ b/src/wtf/timing/BUILD @@ -0,0 +1,24 @@ +# Description: +# Timers and time queries. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "timing", + srcs = [ + "browserinterval.js", + "handle.js", + "renderinterval.js", + "rendertimer.js", + "timing.js", + "util.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/timing/util.js b/src/wtf/timing/util.js index 0fa296ee..c7881b27 100644 --- a/src/wtf/timing/util.js +++ b/src/wtf/timing/util.js @@ -87,10 +87,11 @@ wtf.timing.util.getRequestAnimationFrame = function(opt_enableFallback) { * @param {Function} callback Callback to issue on tick. * @return {number} Cancellation handle. */ - return function(callback) { + function setTimeoutShim(callback) { return setTimeout.call( goog.global, callback, 1000 / wtf.timing.util.FRAMERATE); - }; + } + return setTimeoutShim; } return null; @@ -128,9 +129,10 @@ wtf.timing.util.getCancelAnimationFrame = * @param {number} id The result of a previous {@code requestAnimationFrame} * call. */ - return function(id) { + function clearTimeoutShim(id) { clearTimeout(id); - }; + } + return clearTimeoutShim; } return null; diff --git a/src/wtf/trace/BUILD b/src/wtf/trace/BUILD new file mode 100644 index 00000000..eb7c3124 --- /dev/null +++ b/src/wtf/trace/BUILD @@ -0,0 +1,82 @@ +# Description: +# Tracing support. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "trace", + srcs = [ + "builtinevents.js", + "eventregistry.js", + "events.js", + "eventsessioncontext.js", + "eventtarget.js", + "eventtype.js", + "eventtypebuilder.js", + "exports.js", + "flow.js", + "instrument.js", + "prepare.js", + "provider.js", + "scope.js", + "session.js", + "trace.js", + "tracemanager.js", + "zone.js", + + # TODO(benvanik): conditional on build type? + "providers/chromedebugprovider.js", + "providers/consoleprovider.js", + "providers/domprovider.js", + "providers/firefoxdebugprovider.js", + "providers/imageprovider.js", + "providers/providers.js", + "providers/replayprovider.js", + "providers/timingprovider.js", + "providers/webglprovider.js", + "providers/websocketprovider.js", + "providers/webworkerprovider.js", + "providers/xhrprovider.js", + "sessions/nullsession.js", + "sessions/snapshottingsession.js", + "sessions/streamingsession.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":util", + "//src/wtf", + "//src/wtf/data", + "//src/wtf/events:eventemitter", + "//src/wtf/io", + "//src/wtf/io/cff", + "//src/wtf/ipc", + "//src/wtf/math", + "//src/wtf/pal", + "//src/wtf/timing", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "node", + srcs = ["node.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":trace", + "//src/wtf", + ], +) + +closure_js_library( + name = "util", + srcs = ["util.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/trace/events.js b/src/wtf/trace/events.js index e812bd49..2f96373e 100644 --- a/src/wtf/trace/events.js +++ b/src/wtf/trace/events.js @@ -13,6 +13,7 @@ goog.provide('wtf.trace.events'); +goog.require('goog.asserts'); goog.require('wtf.data.EventClass'); goog.require('wtf.data.Variable'); goog.require('wtf.trace.EventRegistry'); @@ -24,7 +25,7 @@ goog.require('wtf.trace.EventType'); * @param {string} signature Event signature. * @param {wtf.data.EventClass} eventClass Event class. * @param {number} flags A bitmask of {@see wtf.data.EventFlag} values. - * @return {wtf.trace.EventType} New event type. + * @return {!wtf.trace.EventType} New event type. * @private */ wtf.trace.events.create_ = function(signature, eventClass, flags) { @@ -89,6 +90,7 @@ wtf.trace.events.create_ = function(signature, eventClass, flags) { wtf.trace.events.createInstance = function(signature, opt_flags) { var eventType = wtf.trace.events.create_( signature, wtf.data.EventClass.INSTANCE, opt_flags || 0); + goog.asserts.assert(eventType.append); return eventType.append; }; @@ -129,5 +131,6 @@ wtf.trace.events.createInstance = function(signature, opt_flags) { wtf.trace.events.createScope = function(signature, opt_flags) { var eventType = wtf.trace.events.create_( signature, wtf.data.EventClass.SCOPE, opt_flags || 0); + goog.asserts.assert(eventType.append); return eventType.append; }; diff --git a/src/wtf/trace/eventtype.js b/src/wtf/trace/eventtype.js index 0ecafa23..ad9b26c2 100644 --- a/src/wtf/trace/eventtype.js +++ b/src/wtf/trace/eventtype.js @@ -103,8 +103,7 @@ wtf.trace.EventType.nextEventWireId_ = 1; /** - * Gets a pretty-formatted name for the event. - * @return {string} Pretty-formatted name. + * @override */ wtf.trace.EventType.prototype.toString = function() { return this.name; diff --git a/src/wtf/trace/eventtypebuilder.js b/src/wtf/trace/eventtypebuilder.js index 7f8cd6da..cb93ffa9 100644 --- a/src/wtf/trace/eventtypebuilder.js +++ b/src/wtf/trace/eventtypebuilder.js @@ -46,7 +46,7 @@ goog.inherits(wtf.trace.EventTypeBuilder, wtf.util.FunctionBuilder); * Generates an event tracing function. * @param {!wtf.trace.EventSessionContextType} context Event session context. * @param {!wtf.trace.EventType} eventType Event type. - * @return {Function} Generated function based on class. + * @return {!Function} Generated function based on class. */ wtf.trace.EventTypeBuilder.prototype.generate = function(context, eventType) { var writers = wtf.trace.EventTypeBuilder.WRITERS_; diff --git a/src/wtf/trace/instrument.js b/src/wtf/trace/instrument.js index 49af3706..22ff5760 100644 --- a/src/wtf/trace/instrument.js +++ b/src/wtf/trace/instrument.js @@ -41,7 +41,7 @@ goog.require('wtf.util'); * event type. * @param {(function())=} opt_pre Code to execute before the scope is entered. * This is only called if {@code opt_generator} is not provided. - * @return {Function} The instrumented input value. + * @return {!Function} The instrumented input value. */ wtf.trace.instrument = function(value, signature, opt_namePrefix, opt_generator, opt_pre) { @@ -128,14 +128,14 @@ wtf.trace.instrument = function(value, signature, opt_namePrefix, * @param {Object|!Object.} methodMap A map of translated method names * to method signatures. Only the methods in this map will be * auto-instrumented. - * @return {Function} The instrumented input value. + * @return {!Function} The instrumented input value. */ wtf.trace.instrumentType = function(value, constructorSignature, methodMap) { // Rewrite constructor. This requires changing the entire type, which is why // we return the result. var newValue = wtf.trace.instrument(value, constructorSignature); /** @constructor */ - function tempCtor() {}; + function tempCtor() {} tempCtor.prototype = value.prototype; newValue.superClass_ = value.prototype; newValue.prototype = new tempCtor(); diff --git a/src/wtf/trace/providers/chromedebugprovider.js b/src/wtf/trace/providers/chromedebugprovider.js index 71ae319e..f35cc028 100644 --- a/src/wtf/trace/providers/chromedebugprovider.js +++ b/src/wtf/trace/providers/chromedebugprovider.js @@ -642,7 +642,7 @@ wtf.trace.providers.ChromeDebugProvider.prototype.toggleCapture_ = function() { consoleTimeEnd.call(goog.global.console, syncName); wtf.trace.leaveScope(tracingScope); - }; + } if (!this.isCapturingTracing_) { // Start tracing. diff --git a/src/wtf/trace/providers/webglprovider.js b/src/wtf/trace/providers/webglprovider.js index af6f730c..b20eccd5 100644 --- a/src/wtf/trace/providers/webglprovider.js +++ b/src/wtf/trace/providers/webglprovider.js @@ -350,7 +350,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { getHandle(ctx), ctx.drawingBufferWidth, ctx.drawingBufferHeight); } - }; + } // Stash off functions that let us quickly restore the context prototype // to its original state. @@ -410,7 +410,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { contextRestoreFns.push(function() { target[methodName] = rawFn; }); - }; + } /** * @param {string} signature Event signature. @@ -420,7 +420,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { wrapMethod( WebGLRenderingContext.prototype, 'WebGLRenderingContext', signature, opt_generator); - }; + } function coercePixelTypeToUint8(source) { if (!(source instanceof Uint8Array)) { @@ -433,7 +433,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { } else { return source; } - }; + } /** * Wraps the ANGLEInstancedArrays extension object. @@ -449,7 +449,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { wrapMethod( proto, 'ANGLEInstancedArrays', signature, opt_generator); - }; + } wrapInstancedArraysMethod( 'drawArraysInstancedANGLE(uint32 mode, uint32 first, int32 count, ' + @@ -480,7 +480,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { return leaveScope(scope, fn.apply(this, arguments)); }; }); - }; + } /** * Wraps the OESVertexArrayObject extension object. @@ -496,7 +496,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { wrapMethod( proto, 'OESVertexArrayObject', signature, opt_generator); - }; + } // http://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/ @@ -541,7 +541,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { return leaveScope(scope, fn.apply(this, arguments)); }; }); - }; + } /** * Wraps the WebGLLoseContext extension object. @@ -557,7 +557,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { wrapMethod( proto, 'WebGLLoseContext', signature, opt_generator); - }; + } // http://www.khronos.org/registry/webgl/extensions/WEBGL_lose_context/ @@ -579,7 +579,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { return leaveScope(scope, fn.apply(this, arguments)); }; }); - }; + } /** * Wraps an extension object. @@ -608,7 +608,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { delete proto['__gl_wrapped__']; }); return true; - }; + } switch (name) { case 'ANGLE_instanced_arrays': @@ -637,7 +637,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { default: return true; } - }; + } wrapContextMethod( 'getContextAttributes()'); @@ -861,7 +861,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { return obj; }; }); - }; + } wrapCreateMethod( 'createBuffer', 'buffer'); wrapCreateMethod( @@ -885,7 +885,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { return leaveScope(scope, fn.apply(this, arguments)); }; }); - }; + } wrapDeleteMethod( 'deleteBuffer', 'buffer'); wrapDeleteMethod( @@ -1096,7 +1096,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { return leaveScope(scope, fn.apply(this, arguments)); }; }); - }; + } wrapIsMethod('isBuffer'); wrapIsMethod('isFramebuffer'); wrapIsMethod('isProgram'); @@ -1332,7 +1332,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { }); break; } - }; + } function wrapUniformArrayMethod(name, type, count) { var signature = name + '(uint32 location, ' + type + '[] v)'; wrapContextMethod(signature, function(fn, eventType) { @@ -1342,7 +1342,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { return leaveScope(scope, fn.apply(this, arguments)); }; }); - }; + } function wrapUniformMatrixMethod(name, type, count) { var signature = name + '(uint32 location, uint8 transpose, ' + type + '[] value)'; @@ -1353,7 +1353,7 @@ wtf.trace.providers.WebGLProvider.prototype.injectContextType_ = function() { return leaveScope(scope, fn.apply(this, arguments)); }; }); - }; + } wrapUniformMethod( 'uniform1f', 'float', 1); wrapUniformMethod( diff --git a/src/wtf/trace/providers/websocketprovider.js b/src/wtf/trace/providers/websocketprovider.js index 70c55385..2b8cbb35 100644 --- a/src/wtf/trace/providers/websocketprovider.js +++ b/src/wtf/trace/providers/websocketprovider.js @@ -141,6 +141,7 @@ wtf.trace.providers.WebSocketProvider.prototype.injectWs_ = function() { ProxyWebSocket.prototype['CLOSED'] = 3; // Event tracking. + /** @override */ ProxyWebSocket.prototype.beginTrackingEvent = function(type) { var self = this; var tracker = function(e) { @@ -149,6 +150,7 @@ wtf.trace.providers.WebSocketProvider.prototype.injectWs_ = function() { this.trackers_[type] = tracker; this.handle_.addEventListener(type, tracker, false); }; + /** @override */ ProxyWebSocket.prototype.endTrackingEvent = function(type) { this.handle_.removeEventListener(type, this.trackers_[type], false); delete this.trackers_[type]; @@ -187,7 +189,7 @@ wtf.trace.providers.WebSocketProvider.prototype.injectWs_ = function() { this.handle_[name] = value; } }); - }; + } setupProxyProperty('url', true); setupProxyProperty('readyState'); diff --git a/src/wtf/trace/providers/webworkerprovider.js b/src/wtf/trace/providers/webworkerprovider.js index e1f56831..93888825 100644 --- a/src/wtf/trace/providers/webworkerprovider.js +++ b/src/wtf/trace/providers/webworkerprovider.js @@ -311,7 +311,7 @@ wtf.trace.providers.WebWorkerProvider.prototype.injectBrowserShim_ = var shimScriptUrl = goog.fs.createObjectUrl(shimBlob); return shimScriptUrl; - }; + } /** * Worker shim. @@ -397,6 +397,7 @@ wtf.trace.providers.WebWorkerProvider.prototype.injectBrowserShim_ = goog.inherits(ProxyWorker, wtf.trace.eventtarget.BaseEventTarget); // Event tracking. + /** @override */ ProxyWorker.prototype.beginTrackingEvent = function(type) { var self = this; var tracker = function(e) { @@ -405,6 +406,7 @@ wtf.trace.providers.WebWorkerProvider.prototype.injectBrowserShim_ = this.trackers_[type] = tracker; this.handle_.addEventListener(type, tracker, false); }; + /** @override */ ProxyWorker.prototype.endTrackingEvent = function(type) { this.handle_.removeEventListener(type, this.trackers_[type], false); delete this.trackers_[type]; @@ -645,5 +647,5 @@ wtf.trace.providers.WebWorkerProvider.prototype.injectProxyWorker_ = 'command': command, 'value': opt_value || null }, []); - }; + } }; diff --git a/src/wtf/trace/providers/xhrprovider.js b/src/wtf/trace/providers/xhrprovider.js index b6dc2b32..2afe05ba 100644 --- a/src/wtf/trace/providers/xhrprovider.js +++ b/src/wtf/trace/providers/xhrprovider.js @@ -206,6 +206,7 @@ wtf.trace.providers.XhrProvider.prototype.injectXhr_ = function() { ProxyXMLHttpRequest.prototype['DONE'] = 4; // Event tracking. + /** @override */ ProxyXMLHttpRequest.prototype.beginTrackingEvent = function(type) { var self = this; var tracker = function(e) { @@ -224,6 +225,7 @@ wtf.trace.providers.XhrProvider.prototype.injectXhr_ = function() { this.trackers_[type] = tracker; this.handle_.addEventListener(type, tracker, false); }; + /** @override */ ProxyXMLHttpRequest.prototype.endTrackingEvent = function(type) { this.handle_.removeEventListener(type, this.trackers_[type], false); delete this.trackers_[type]; @@ -262,18 +264,20 @@ wtf.trace.providers.XhrProvider.prototype.injectXhr_ = function() { this.handle_[name] = value; } }); - }; + } setupProxyProperty('readyState'); setupProxyProperty('timeout', true); setupProxyProperty('withCredentials', true); setupProxyProperty('upload'); + /** @override */ ProxyXMLHttpRequest.prototype['setRequestHeader'] = function( header, value) { var props = this.props_; props['headers'][header] = value; return this.handle_.setRequestHeader.apply(this.handle_, arguments); }; + /** @override */ ProxyXMLHttpRequest.prototype['overrideMimeType'] = function(mime) { var props = this.props_; props['overrideMimeType'] = mime; diff --git a/src/wtf/trace/tracemanager.js b/src/wtf/trace/tracemanager.js index 09c6bf0c..320ad6c2 100644 --- a/src/wtf/trace/tracemanager.js +++ b/src/wtf/trace/tracemanager.js @@ -461,7 +461,7 @@ wtf.trace.TraceManager.prototype.requestSnapshots = function( goog.dispose(streamTarget); goog.dispose(transport); callback.call(opt_scope, allBuffers.length ? allBuffers : null); - }; + } // Snapshot self. session.snapshot(streamTarget); @@ -481,7 +481,7 @@ wtf.trace.TraceManager.prototype.requestSnapshots = function( if (!pendingSnapshots) { complete(); } - }; + } for (var n = 0; n < this.listeners_.length; n++) { var requested = this.listeners_[n].requestSnapshots( session, listenerCallback); diff --git a/src/wtf/ui/BUILD b/src/wtf/ui/BUILD new file mode 100644 index 00000000..2aa43a27 --- /dev/null +++ b/src/wtf/ui/BUILD @@ -0,0 +1,246 @@ +# Description: +# Common UI utilities and support. +# App UI lives under //src/wtf/app. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("//builddefs:less_rules.bzl", "less_css_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_template_library") + +# TODO(benvanik): split up. +less_css_library( + name = "ui_styles", + srcs = [ + "dialog.less", + "errordialog.less", + "progressdialog.less", + "settingsdialog.less", + "tooltip.less", + "virtualtable.less", + ], + includes = ["src"], + main_srcs = ["ui.less"], + deps = [ + "//src/wtf/ui/styles", + ], +) + +closure_js_library( + name = "color", + srcs = [ + "color/color.js", + "color/palette.js", + "//third_party/d3:colorbrewer", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "control", + srcs = [ + "control.js", + "painter.js", + "resizablecontrol.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":tooltip", + "//src/wtf/events", + "//src/wtf/events:eventemitter", + "//src/wtf/timing", + "//src/wtf/util", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "dialog", + srcs = [ + "dialog.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":control", + "//src/wtf/events", + "//src/wtf/timing", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "errordialog", + srcs = ["errordialog.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":dialog", + ":errordialog_template", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_template_library( + name = "errordialog_template", + srcs = ["errordialog.soy"], +) + +closure_js_library( + name = "icons", + srcs = ["icons.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "gridpainter", + srcs = ["gridpainter.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":control", + ":timepainter", + "//src/wtf/math", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "progressdialog", + srcs = ["progressdialog.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":dialog", + ":progressdialog_template", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_template_library( + name = "progressdialog_template", + srcs = ["progressdialog.soy"], +) + +closure_js_library( + name = "rangepainter", + srcs = [ + "rangepainter.js", + "rangerenderer.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":control", + ":timepainter", + "//src/wtf/math", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "rulerpainter", + srcs = ["rulerpainter.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":control", + ":timepainter", + "//src/wtf/db:unit", + "//src/wtf/math", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "searchcontrol", + srcs = ["searchcontrol.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":control", + "//src/wtf/events", + "//src/wtf/events:eventemitter", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "settingsdialog", + srcs = ["settingsdialog.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":dialog", + ":settingsdialog_template", + "//src/wtf/trace:util", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_template_library( + name = "settingsdialog_template", + srcs = ["settingsdialog.soy"], +) + +closure_js_library( + name = "timepainter", + srcs = ["timepainter.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":control", + "//src/wtf/db:unit", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "tooltip", + srcs = ["tooltip.js"], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_library( + name = "virtualtable", + srcs = [ + "virtualtable.js", + "virtualtablesource.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + ":control", + ":tooltip", + ":virtualtable_template", + "//src/wtf/events", + "//src/wtf/events:eventemitter", + "//src/wtf/math", + "//src/wtf/timing", + "@io_bazel_rules_closure//closure/library", + ], +) + +closure_js_template_library( + name = "virtualtable_template", + srcs = ["virtualtable.soy"], +) + +closure_js_library( + name = "zoom", + srcs = [ + "zoom/element.js", + "zoom/itarget.js", + "zoom/spring.js", + "zoom/viewport.js", + "zoom/zoom.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf", + "//src/wtf/events", + "//src/wtf/events:eventemitter", + "//src/wtf/timing", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/ui/color/color.js b/src/wtf/ui/color/color.js index 3e1166ba..087035d3 100644 --- a/src/wtf/ui/color/color.js +++ b/src/wtf/ui/color/color.js @@ -79,7 +79,7 @@ wtf.ui.color.RgbColor = function(r, g, b) { /** * Gets the #RRGGBB string. - * @return {string} Value. + * @override */ wtf.ui.color.RgbColor.prototype.toString = function() { return this.string_; diff --git a/src/wtf/ui/control.js b/src/wtf/ui/control.js index 7e8902ed..b332b345 100644 --- a/src/wtf/ui/control.js +++ b/src/wtf/ui/control.js @@ -331,7 +331,7 @@ wtf.ui.Control.prototype.toggleInputEvents_ = function(value) { modifiers |= wtf.ui.ModifierKey.META; } return modifiers; - }; + } eh.listen( canvas, diff --git a/src/wtf/ui/errordialog.js b/src/wtf/ui/errordialog.js index a00fdfa8..3cf85e81 100644 --- a/src/wtf/ui/errordialog.js +++ b/src/wtf/ui/errordialog.js @@ -49,7 +49,7 @@ wtf.ui.ErrorDialog = function(message, detail, opt_dom) { }, body, dom); var eh = this.getHandler(); - eh.listen( + eh.listenWithScope( this.getChildElement(goog.getCssName('buttonClose')), goog.events.EventType.CLICK, function() { this.close(); diff --git a/src/wtf/ui/errordialog.soy b/src/wtf/ui/errordialog.soy index c1afe8b3..a26118f3 100644 --- a/src/wtf/ui/errordialog.soy +++ b/src/wtf/ui/errordialog.soy @@ -19,7 +19,7 @@ * @param message Error message. * @param detail Detailed information. */ -{template .control} +{template .control autoescape="deprecated-contextual"}
diff --git a/src/wtf/ui/settingsdialog.js b/src/wtf/ui/settingsdialog.js index a60a2282..717db78d 100644 --- a/src/wtf/ui/settingsdialog.js +++ b/src/wtf/ui/settingsdialog.js @@ -81,14 +81,14 @@ wtf.ui.SettingsDialog = function(options, title, parentElement, opt_dom) { dom.setTextContent(titleEl, title); var eh = this.getHandler(); - eh.listen( + eh.listenWithScope( this.getChildElement(goog.getCssName('buttonSave')), goog.events.EventType.CLICK, function() { this.saveSettings(); this.close(); }, false, this); - eh.listen( + eh.listenWithScope( this.getChildElement(goog.getCssName('buttonCancel')), goog.events.EventType.CLICK, function() { this.close(); diff --git a/src/wtf/ui/styles/BUILD b/src/wtf/ui/styles/BUILD new file mode 100644 index 00000000..4f0114bc --- /dev/null +++ b/src/wtf/ui/styles/BUILD @@ -0,0 +1,23 @@ +# Description: +# Shared UI styles for reset, compatibility, and kennedy. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:less_rules.bzl", "less_css_library") + +less_css_library( + name = "styles", + srcs = [ + "common.less", + "css3.less", + "kennedy.less", + "reset.less", + ], + includes = [ + ".", + "src", + ], + deps = [ + "//third_party:normalize_css", + ], +) diff --git a/src/wtf/ui/styles/common.less b/src/wtf/ui/styles/common.less index b2aa7bff..9b4d7828 100644 --- a/src/wtf/ui/styles/common.less +++ b/src/wtf/ui/styles/common.less @@ -11,10 +11,10 @@ .fitParent { position: absolute; - left: 0; - right: 0; - top: 0; - bottom: 0; + /* @alternate */ left: 0; + /* @alternate */ right: 0; + /* @alternate */ top: 0; + /* @alternate */ bottom: 0; } .fitParentRelative { position: relative; diff --git a/src/wtf/ui/styles/css3.less b/src/wtf/ui/styles/css3.less index abf07a00..1980acdc 100644 --- a/src/wtf/ui/styles/css3.less +++ b/src/wtf/ui/styles/css3.less @@ -22,15 +22,15 @@ .backgroundGradient(@topColor, @bottomColor) { background-color: @topColor; - background-image: -webkit-linear-gradient(top,@topColor,@bottomColor); - background-image: -moz-linear-gradient(top,@topColor,@bottomColor); - background-image: -ms-linear-gradient(top,@topColor,@bottomColor); - background-image: -o-linear-gradient(top,@topColor,@bottomColor); - background-image: linear-gradient(top,@topColor,@bottomColor); + /* @alternate */ background-image: -webkit-linear-gradient(top,@topColor,@bottomColor); + /* @alternate */ background-image: -moz-linear-gradient(top,@topColor,@bottomColor); + /* @alternate */ background-image: -ms-linear-gradient(top,@topColor,@bottomColor); + /* @alternate */ background-image: -o-linear-gradient(top,@topColor,@bottomColor); + /* @alternate */ background-image: linear-gradient(top,@topColor,@bottomColor); // IE8+: -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorstr=%d, endColorstr=%d)", @topColor, @bottomColor); // IE10: - background-image: -ms-linear-gradient(top,@topColor, @bottomColor); + /* @alternate */ background-image: -ms-linear-gradient(top,@topColor, @bottomColor); } .boxSizing(@sizing: border-box) { diff --git a/src/wtf/ui/styles/kennedy.less b/src/wtf/ui/styles/kennedy.less index 79d53073..6544146f 100644 --- a/src/wtf/ui/styles/kennedy.less +++ b/src/wtf/ui/styles/kennedy.less @@ -9,6 +9,9 @@ * @author benvanik@google.com (Ben Vanik) */ +@import "wtf/ui/styles/reset.less"; +@import "wtf/ui/styles/css3.less"; + .k { font-family: "Arial", "Helvetica", sans-serif; color: #222222; @@ -125,7 +128,6 @@ text-decoration: none; display: inline-block; min-width: 54px; - border: 1px solid #DCDCDC; border: 1px solid rgba(0,0,0,0.1); text-align: center; color: #444; @@ -183,7 +185,6 @@ &.kDisabled, &.kDisabled:hover, &.kDisabled:active { background: none; color: #b8b8b8; - border: 1px solid #f3f3f3; border: 1px solid rgba(0,0,0,0.05); cursor: default; pointer-events: none; @@ -232,12 +233,9 @@ } &.kDisabled, &.kDisabled:hover, &.kDisabled:active { - border: 1px solid #505050; - background-color: #666; - opacity: 0.5; - - border-color: #b0281a; + border: 1px solid #b0281a; background-color: #d14836; + opacity: 0.5; } } @@ -354,7 +352,7 @@ display: inline-block; width: 7px; height: 7px; - background: url('app/icons/arrow_dropdown.svg') center no-repeat; + background: url('icons/arrow_dropdown.svg') center no-repeat; .transition(all, 0.218s); } .kDisabled .kButtonDisclosure { @@ -482,15 +480,15 @@ padding-top:100px; background-clip:padding-box; background-color: rgba(0,0,0,0.2); - -webkit-box-shadow: inset 1px 1px 0px rgba(0,0,0,0.10), - inset 0px -1px 0px rgba(0,0,0,0.07); + .insetBoxShadow2(1px, 1px, 0px, rgba(0,0,0,0.10), + 0px, -1px, 0px, rgba(0,0,0,0.07)); } ::-webkit-scrollbar-thumb:hover { + .insetBoxShadow(1px, 1px, 1px, rgba(0,0,0,0.25)); background-color: rgba(0,0,0,0.4); - -webkit-box-shadow: inset 1px 1px 1px rgba(0,0,0,0.25); } ::-webkit-scrollbar-thumb:active { - -webkit-box-shadow: inset 1px 1px 3px rgba(0,0,0,0.35); + .insetBoxShadow(1px, 1px, 3px, rgba(0,0,0,0.35)); background-color: rgba(0,0,0,0.5); } ::-webkit-scrollbar-thumb:vertical { @@ -507,12 +505,12 @@ } ::-webkit-scrollbar-track:hover { background-color:rgba(0,0,0,0.05); - -webkit-box-shadow: inset 1px 0px 0px rgba(0,0,0,0.10); + .insetBoxShadow(1px, 0px, 0px, rgba(0,0,0,0.10)); } ::-webkit-scrollbar-track:active { background-color:rgba(0,0,0,0.05); - -webkit-box-shadow: inset 1px 0px 0px rgba(0,0,0,0.14), - inset -1px -1px 0px rgba(0,0,0,0.07); + .insetBoxShadow2(1px, 0px, 0px, rgba(0,0,0,0.14), + -1px, -1px, 0px, rgba(0,0,0,0.07)); } .kScrollBarInner::-webkit-scrollbar-track:vertical { border-left: 6px solid transparent; @@ -656,7 +654,7 @@ padding-left: 30px; } .goog-option-selected { - background-image: url('app/icons/checkmark.svg'); + background-image: url('icons/checkmark.svg'); background-position: left center; background-repeat: no-repeat; background-position-x: 5px; @@ -677,11 +675,11 @@ background-size: 20px 10px; background-color: rgba(0,0,0,0.12); - background-image: -webkit-linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); - background-image: -moz-linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); - background-image: -ms-linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); - background-image: -o-linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); - background-image: linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); + /* @alternate */ background-image: -webkit-linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); + /* @alternate */ background-image: -moz-linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); + /* @alternate */ background-image: -ms-linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); + /* @alternate */ background-image: -o-linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); + /* @alternate */ background-image: linear-gradient(315deg, transparent, transparent 33%, rgba(0,0,0,0.12) 33%, rgba(0,0,0,0.12) 66%, transparent 66%, transparent); .animation(kProgressBarAnimation, 0.8s, linear, infinite); } diff --git a/src/wtf/ui/styles/reset.less b/src/wtf/ui/styles/reset.less index 99e13ff8..7be873e8 100644 --- a/src/wtf/ui/styles/reset.less +++ b/src/wtf/ui/styles/reset.less @@ -36,7 +36,7 @@ blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { - content: ''; + /* @alternate */ content: ''; content: none; } @@ -64,4 +64,4 @@ img { display: inline } /** * normalize.css */ -@import (less) "../../../../third_party/normalize.css/normalize.css"; +@import (less) "third_party/normalize.css/normalize.css"; diff --git a/src/wtf/ui/virtualtable.less b/src/wtf/ui/virtualtable.less index 6cf1048d..eef1aadf 100644 --- a/src/wtf/ui/virtualtable.less +++ b/src/wtf/ui/virtualtable.less @@ -52,7 +52,6 @@ .noSelect(); width: 100%; height: 28px; - background-color: red; background-clip:padding-box; background-color: rgba(0,0,0,0.2); .insetBoxShadow2(1px, 1px, 0px, rgba(0,0,0,0.10), diff --git a/src/wtf/ui/zoom/element.js b/src/wtf/ui/zoom/element.js index f64fcdab..fb685f72 100644 --- a/src/wtf/ui/zoom/element.js +++ b/src/wtf/ui/zoom/element.js @@ -83,7 +83,7 @@ wtf.ui.zoom.Element = function(el, zoomTarget) { this.elementOffset_ = goog.style.getPageOffset(this.el); // Relayout as required. - this.listen( + this.listenWithScope( this.viewportSizeMonitor_, goog.events.EventType.RESIZE, function() { diff --git a/src/wtf/util/BUILD b/src/wtf/util/BUILD new file mode 100644 index 00000000..12bb1049 --- /dev/null +++ b/src/wtf/util/BUILD @@ -0,0 +1,22 @@ +# Description: +# Utilities. + +package(default_visibility = ["//:internal"]) + +load("//builddefs:config.bzl", "COMMON_JS_SUPPRESSIONS") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") + +closure_js_library( + name = "util", + srcs = [ + "canvas.js", + "functionbuilder.js", + "options.js", + "util.js", + ], + suppress = COMMON_JS_SUPPRESSIONS, + deps = [ + "//src/wtf/events:eventemitter", + "@io_bazel_rules_closure//closure/library", + ], +) diff --git a/src/wtf/version.js b/src/wtf/version.js index 2c9a2cf3..808e2019 100644 --- a/src/wtf/version.js +++ b/src/wtf/version.js @@ -24,7 +24,7 @@ goog.provide('wtf.version'); */ wtf.version.getValue = function() { // Set via update-version.sh - return 1436947200000; // time + return 1508486400000; // time }; @@ -34,7 +34,7 @@ wtf.version.getValue = function() { */ wtf.version.getCommit = function() { // Set via update-version.sh - return 'b42eb485660d79fd6756d34835427a8b39170227'; // sha + return '9cc0f8b6a4eff974c6aa67d0c6b0fafcb461d714'; // sha }; @@ -45,7 +45,7 @@ wtf.version.getCommit = function() { */ wtf.version.toString = function() { // Set via update-version.sh - return '2015.7.15-1'; // string + return '2017.10.20-1'; // string }; diff --git a/src/wtf/wtf.js b/src/wtf/wtf.js index fbc66295..ac305195 100644 --- a/src/wtf/wtf.js +++ b/src/wtf/wtf.js @@ -215,8 +215,12 @@ wtf.now = (function() { * @return {number} Estimated overhead, in nanoseconds (1/1000 us). */ wtf.computeNowOverhead = function() { - // This is in a function so that v8 can JIT it easier. - // We then run it a few times to try to factor out the JIT time. + /** + * This is in a function so that v8 can JIT it easier. + * We then run it a few times to try to factor out the JIT time. + * @param {number} iterations + * @return {number} + */ function computeInner(iterations) { var dummy = 0; for (var n = 0; n < iterations; n++) { @@ -225,7 +229,7 @@ wtf.computeNowOverhead = function() { dummy += wtf.now(); } return dummy; - }; + } var iterations = 100000; var dummy = 0; diff --git a/test/test-js.html b/test/test-js.html index 2268640c..65b1d409 100644 --- a/test/test-js.html +++ b/test/test-js.html @@ -2,8 +2,8 @@ WTF Test (normal JS) - - + +