Skip to content

Commit

Permalink
WebUI: Post Polymer2 removal cleanups.
Browse files Browse the repository at this point in the history
 - Move remaining (still used) Bash/Python scripts from v1_0/ to v3_0/
 - Delete now unused tools/polymer/generate_gn.py
 - Delete unnecessary 'polymer_version' parameter from generate_gn.sh
 - Update README.chromium
 - Delete ui/webui/resources/html/polymer.html,
   ui/webui/resources/js/polymer_config.js and remove from the binary.

Bug: 965770
Change-Id: Ib56d1ed2b9b97e36c8476fe3a6accbd8d96b3ed7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3866451
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1041394}
  • Loading branch information
freshp86 authored and Chromium LUCI CQ committed Aug 31, 2022
1 parent aca98c0 commit 5e6d79b
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 161 deletions.
30 changes: 9 additions & 21 deletions third_party/polymer/README.chromium
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Name: Polymer
Short Name: polymer
URL: http://www.polymer-project.org
Version: 1.9.1
Revision: (see v1_0/components_summary.txt)
URL: https://polymer-library.polymer-project.org
Version: 3.2.0
Revision: N/A
License: BSD
License File: LICENSE.polymer
Security Critical: no

Description:
This directory contains a copy of the Polymer framework and some elements from
the Polymer elements catalog (https://elements.polymer-project.org/). See
v1_0/components_summary.txt for a full list of components.
v3_0/package.json for a full list of components.

The source git repositories can be found at:
https://github.com/Polymer/polymer
Expand All @@ -26,37 +26,25 @@ becomes smaller and better over time.
technologies called the Polymer.

Local Modifications:
- Applied modifications that can be found in v1_0/chromium.patch.
- Applied modifications that can be found in v3_0/chromium.patch.
- All inline JavaScript blocks are extracted from Polymer HTML elements to
external JS files. This version of the Polymer is used in a web UI, where CSP
forbids an execution of inline scripts. The extraction was made with the help of
the Crisper tool (https://github.com/PolymerLabs/crisper).
- Removed executable bit from some files.
- Resolved encoding issues.
- Replaced CRLF line endings with LF line endings in text files.
- Removed files that are not needed by Chromium, see v1_0/rsync_exclude.txt.
- Removed files that are not needed by Chromium, see v3_0/rsync_exclude.txt.
- Re-implemented <paper-ripple> using Web Animations API (which, as of
2/21/2017 does not work in Safari or IE). This is a complete fork from
Polymer's <paper-ripple>.
- Removed CSS properties that are not needed in Chromium using
css_strip_prefixes.py script.
- Bundled and minified Polymer 2 with minify_polymer.py, since Polymer 2 repo
does not distribute minified files (unlike Polymer 1).
- Note that the Polymer 2 bundle does not include dir-mixin.html which is
- Bundled and minified Polymer 3 with minify_polymer.py, since Polymer 3 repo
does not distribute minified files.
- Note that the Polymer 3 bundle does not include dir-mixin.js which is
responsible for polyfylling :dir() CSS rules, because it causes a performance
regression (and it is unnecessary), see crbug.com/899603 for more context.

To restore a content of the 'components-chromium' directory from scratch, run
./v1_0/reproduce.sh on a Linux machine.

Note on Bower:
The directory can be updated by running "bower update". A new component can be
installed by running "bower install -S PolymerElements/<component>#version".
Be sure to add the .bower.json file to the repository as it includes the
revision information of the polymer component.
Also be sure that you listed all the added packages in bower.json.

Polymer 3 notes
Polymer 3 resides under v3_0/, and uses NPM instead of Bower. To restore the
contents of the 'components-chromium' directory from scratch, run
./v3_0/reproduce.sh on a Linux machine.
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,13 @@
dirs=$(find components-chromium -type d | grep -v 'components-chromium/polymer')

gn_files=''
polymer_version=$1

if [ "$polymer_version" -eq 3 ];
then
file_extension="js";
else
file_extension="html";
fi

for dir in $dirs; do
files=$(\ls $dir/*.$file_extension 2>/dev/null)
files=$(\ls $dir/*.js 2>/dev/null)
if [ "$files" ]; then
echo "Analyzing $dir"
gn_file="$dir/BUILD.gn"
if [ "$polymer_version" -eq 3 ];
then
content=$(../../../tools/polymer/generate_gn_v3.py $files);
else
content=$(../../../tools/polymer/generate_gn.py $files);
fi
content=$(../../../tools/polymer/generate_gn_v3.py $files);
if [ "$content" ]; then
echo "Writing $gn_file"
echo "$content" > "$gn_file"
Expand All @@ -40,10 +27,6 @@ done

# Copy components-chromium/polymer BUILD.gn file manually, since it is not
# auto-generated by generate_gn_v3.py.
if [ "$polymer_version" -eq 3 ];
then
cp ./BUILD_polymer.gn "components-chromium/polymer/BUILD.gn"
fi

cp ./BUILD_polymer.gn "components-chromium/polymer/BUILD.gn"

git cl format $gn_files
6 changes: 3 additions & 3 deletions third_party/polymer/v3_0/reproduce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ if [[ ! -z "${new}${deleted}" ]]; then
fi

echo 'Stripping unnecessary prefixed CSS rules...'
python ../v1_0/css_strip_prefixes.py --file_extension=js
python css_strip_prefixes.py --file_extension=js

echo 'Generating -rgb versions of --google-* vars in paper-style/colors.js...'
python ../v1_0/rgbify_hex_vars.py --filter-prefix=google --replace \
python rgbify_hex_vars.py --filter-prefix=google --replace \
components-chromium/paper-styles/color.js

# TODO create components summary

echo 'Creating GN files for interfaces and externs...'
../v1_0/generate_gn.sh 3 # polymer_version=3
./generate_gn.sh
File renamed without changes.
86 changes: 0 additions & 86 deletions tools/polymer/generate_gn.py

This file was deleted.

16 changes: 5 additions & 11 deletions ui/webui/resources/html/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import("//build/config/chromeos/ui_mode.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

include_polymer = !is_android && !is_ios

generate_grd("build_grdp") {
grd_prefix = "webui_html"
out_grd = "$target_gen_dir/resources.grdp"
Expand Down Expand Up @@ -36,15 +34,11 @@ generate_grd("build_grdp") {
]
}

if (include_polymer) {
input_files += [ "polymer.html" ]

if (is_chromeos_ash) {
input_files += [
"i18n_behavior.html",
"web_ui_listener_behavior.html",
]
}
if (is_chromeos_ash) {
input_files += [
"i18n_behavior.html",
"web_ui_listener_behavior.html",
]
}
input_files_base_dir = rebase_path(".", "//")
}
2 changes: 0 additions & 2 deletions ui/webui/resources/html/polymer.html

This file was deleted.

1 change: 0 additions & 1 deletion ui/webui/resources/js/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ preprocess_if_expr("preprocess_src") {
"i18n_template_no_process.js",
"list_property_update_behavior.js",
"parse_html_subset.js",
"polymer_config.js",
"promise_resolver.js",
"web_ui_listener_behavior.js",
]
Expand Down
17 changes: 0 additions & 17 deletions ui/webui/resources/js/polymer_config.js

This file was deleted.

0 comments on commit 5e6d79b

Please sign in to comment.