From 135d7124203a7d176dd2b60a0e3a873d439002ed Mon Sep 17 00:00:00 2001 From: Frank Walsh Date: Wed, 27 Nov 2019 13:41:29 -0500 Subject: [PATCH 1/6] Updated zoom constants and pages to resolve issue #6943 --- patches/chrome-VERSION.patch | 2 +- .../chrome-browser-resources-pdf-viewport.js.patch | 13 +++++++++++++ ...ttings-appearance_page-appearance_page.js.patch | 13 +++++++++++++ .../components-zoom-page_zoom_constants.cc.patch | 14 ++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 patches/chrome-browser-resources-pdf-viewport.js.patch create mode 100644 patches/chrome-browser-resources-settings-appearance_page-appearance_page.js.patch create mode 100644 patches/components-zoom-page_zoom_constants.cc.patch diff --git a/patches/chrome-VERSION.patch b/patches/chrome-VERSION.patch index 376b11aa280a..6c22abe4be9e 100644 --- a/patches/chrome-VERSION.patch +++ b/patches/chrome-VERSION.patch @@ -1,5 +1,5 @@ diff --git a/chrome/VERSION b/chrome/VERSION -index 177739cfcedccfa03e317b6863f3466070a427b7..7262a5d9998a8c7711295d03833c35a23431c7f4 100644 +index 177739cfcedccfa03e317b6863f3466070a427b7..17f62eb039b830bb616921ef2453bf0f55e43a42 100644 --- a/chrome/VERSION +++ b/chrome/VERSION @@ -1,4 +1,4 @@ diff --git a/patches/chrome-browser-resources-pdf-viewport.js.patch b/patches/chrome-browser-resources-pdf-viewport.js.patch new file mode 100644 index 000000000000..dd1f493f4efb --- /dev/null +++ b/patches/chrome-browser-resources-pdf-viewport.js.patch @@ -0,0 +1,13 @@ +diff --git a/chrome/browser/resources/pdf/viewport.js b/chrome/browser/resources/pdf/viewport.js +index 480664c014ce18126a4806a9ac484bed390d68ad..8f4f959091038848466d1130fd1f610035fa5212 100644 +--- a/chrome/browser/resources/pdf/viewport.js ++++ b/chrome/browser/resources/pdf/viewport.js +@@ -1228,7 +1228,7 @@ Viewport.SCROLL_INCREMENT = 40; + * chrome/browser/resources/settings/appearance_page/appearance_page.js + */ + Viewport.ZOOM_FACTORS = [ +- 0.25, 1 / 3, 0.5, 2 / 3, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, ++ 0.25, 1 / 3, 0.5, 2 / 3, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.33, 1.4, 1.5, 1.75, 2, 2.5, 3, + 4, 5 + ]; + diff --git a/patches/chrome-browser-resources-settings-appearance_page-appearance_page.js.patch b/patches/chrome-browser-resources-settings-appearance_page-appearance_page.js.patch new file mode 100644 index 000000000000..da4cb066308c --- /dev/null +++ b/patches/chrome-browser-resources-settings-appearance_page-appearance_page.js.patch @@ -0,0 +1,13 @@ +diff --git a/chrome/browser/resources/settings/appearance_page/appearance_page.js b/chrome/browser/resources/settings/appearance_page/appearance_page.js +index 2551cf3b19168d51dd5a2432eb56871490d11d54..069915b493e46096e546d2c62204094b101b162e 100644 +--- a/chrome/browser/resources/settings/appearance_page/appearance_page.js ++++ b/chrome/browser/resources/settings/appearance_page/appearance_page.js +@@ -82,6 +82,8 @@ Polymer({ + 1, + 11 / 10, + 5 / 4, ++ 4 / 3, ++ 7 / 5, + 3 / 2, + 7 / 4, + 2, diff --git a/patches/components-zoom-page_zoom_constants.cc.patch b/patches/components-zoom-page_zoom_constants.cc.patch new file mode 100644 index 000000000000..60d072844261 --- /dev/null +++ b/patches/components-zoom-page_zoom_constants.cc.patch @@ -0,0 +1,14 @@ +diff --git a/components/zoom/page_zoom_constants.cc b/components/zoom/page_zoom_constants.cc +index 0c9052bd188e9ac0680dc6afe729dcc623442021..e053ad80e7a011b20ee766219e19c27910f35e5a 100644 +--- a/components/zoom/page_zoom_constants.cc ++++ b/components/zoom/page_zoom_constants.cc +@@ -12,7 +12,8 @@ namespace zoom { + // chrome/browser/resources/settings/appearance_page/appearance_page.js. Please + // make sure the three match. + const double kPresetZoomFactors[] = {0.25, 1 / 3.0, 0.5, 2 / 3.0, 0.75, 0.8, +- 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, ++ 0.9, 1.0, 1.1, 1.25, 4 / 3.0, 7 / 5.0, ++ 1.5, 1.75, 2.0, 2.5, + 3.0, 4.0, 5.0}; + const std::size_t kPresetZoomFactorsSize = base::size(kPresetZoomFactors); + From 2261ea091efe15a1493374080a4ce1a79b11206a Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Wed, 27 Nov 2019 15:26:41 -0700 Subject: [PATCH 2/6] Use chromium_src to replace the values used for Zoom Only updates one of the 3 places... (working through the other 2 now) --- .../components/zoom/page_zoom_constants.cc | 21 +++++++++++++++++++ patches/chrome-VERSION.patch | 2 +- ...mponents-zoom-page_zoom_constants.cc.patch | 14 ------------- 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 chromium_src/components/zoom/page_zoom_constants.cc delete mode 100644 patches/components-zoom-page_zoom_constants.cc.patch diff --git a/chromium_src/components/zoom/page_zoom_constants.cc b/chromium_src/components/zoom/page_zoom_constants.cc new file mode 100644 index 000000000000..71cab34e2844 --- /dev/null +++ b/chromium_src/components/zoom/page_zoom_constants.cc @@ -0,0 +1,21 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/zoom/page_zoom_constants.h" + +#include "base/stl_util.h" + +namespace zoom { + +// This list is duplicated in chrome/browser/resources/pdf/viewport.js and in +// chrome/browser/resources/settings/appearance_page/appearance_page.js. Please +// make sure the three match. +const double kPresetZoomFactors[] = {0.25, 1 / 3.0, 0.5, 2 / 3.0, 0.75, 0.8, + 0.9, 1.0, 1.1, 1.25, 4 / 3.0, 7 / 5.0, + 1.5, 1.75, 2.0, 2.5, + 3.0, 4.0, 5.0}; +const std::size_t kPresetZoomFactorsSize = base::size(kPresetZoomFactors); + +} // namespace ui_zoom + diff --git a/patches/chrome-VERSION.patch b/patches/chrome-VERSION.patch index 6c22abe4be9e..376b11aa280a 100644 --- a/patches/chrome-VERSION.patch +++ b/patches/chrome-VERSION.patch @@ -1,5 +1,5 @@ diff --git a/chrome/VERSION b/chrome/VERSION -index 177739cfcedccfa03e317b6863f3466070a427b7..17f62eb039b830bb616921ef2453bf0f55e43a42 100644 +index 177739cfcedccfa03e317b6863f3466070a427b7..7262a5d9998a8c7711295d03833c35a23431c7f4 100644 --- a/chrome/VERSION +++ b/chrome/VERSION @@ -1,4 +1,4 @@ diff --git a/patches/components-zoom-page_zoom_constants.cc.patch b/patches/components-zoom-page_zoom_constants.cc.patch deleted file mode 100644 index 60d072844261..000000000000 --- a/patches/components-zoom-page_zoom_constants.cc.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/components/zoom/page_zoom_constants.cc b/components/zoom/page_zoom_constants.cc -index 0c9052bd188e9ac0680dc6afe729dcc623442021..e053ad80e7a011b20ee766219e19c27910f35e5a 100644 ---- a/components/zoom/page_zoom_constants.cc -+++ b/components/zoom/page_zoom_constants.cc -@@ -12,7 +12,8 @@ namespace zoom { - // chrome/browser/resources/settings/appearance_page/appearance_page.js. Please - // make sure the three match. - const double kPresetZoomFactors[] = {0.25, 1 / 3.0, 0.5, 2 / 3.0, 0.75, 0.8, -- 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, -+ 0.9, 1.0, 1.1, 1.25, 4 / 3.0, 7 / 5.0, -+ 1.5, 1.75, 2.0, 2.5, - 3.0, 4.0, 5.0}; - const std::size_t kPresetZoomFactorsSize = base::size(kPresetZoomFactors); - From 112a41b501ff81215a56d62ba0e6d01388bb244c Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Wed, 27 Nov 2019 15:44:51 -0700 Subject: [PATCH 3/6] Use brave_settings_overrides to replace the values used for Zoom This updates the second of 3 places needing to be changed (working through last one) --- .../settings/brave_settings_overrides.js | 29 +++++++++++++++++++ ...s-appearance_page-appearance_page.js.patch | 13 --------- 2 files changed, 29 insertions(+), 13 deletions(-) delete mode 100644 patches/chrome-browser-resources-settings-appearance_page-appearance_page.js.patch diff --git a/browser/resources/settings/brave_settings_overrides.js b/browser/resources/settings/brave_settings_overrides.js index c55966d300fa..c34f29578fd5 100644 --- a/browser/resources/settings/brave_settings_overrides.js +++ b/browser/resources/settings/brave_settings_overrides.js @@ -103,8 +103,37 @@ const BraveClearSettingsMenuHighlightBehavior = { } } +const BraveAddZoomLevelsBehavior = { + ready: function() { + this._setPageZoomLevels_([ + 1 / 4, + 1 / 3, + 1 / 2, + 2 / 3, + 3 / 4, + 4 / 5, + 9 / 10, + 1, + 11 / 10, + 5 / 4, + 4 / 3, + 7 / 5, + 3 / 2, + 7 / 4, + 2, + 5 / 2, + 3, + 4, + 5, + ]) + } +} + // Polymer Component Behavior injection (like superclasses) BravePatching.RegisterPolymerComponentBehaviors({ + 'settings-appearance-page': [ + BraveAddZoomLevelsBehavior + ], 'settings-clear-browsing-data-dialog': [ BraveClearBrowsingDataOnExitBehavior ], diff --git a/patches/chrome-browser-resources-settings-appearance_page-appearance_page.js.patch b/patches/chrome-browser-resources-settings-appearance_page-appearance_page.js.patch deleted file mode 100644 index da4cb066308c..000000000000 --- a/patches/chrome-browser-resources-settings-appearance_page-appearance_page.js.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/chrome/browser/resources/settings/appearance_page/appearance_page.js b/chrome/browser/resources/settings/appearance_page/appearance_page.js -index 2551cf3b19168d51dd5a2432eb56871490d11d54..069915b493e46096e546d2c62204094b101b162e 100644 ---- a/chrome/browser/resources/settings/appearance_page/appearance_page.js -+++ b/chrome/browser/resources/settings/appearance_page/appearance_page.js -@@ -82,6 +82,8 @@ Polymer({ - 1, - 11 / 10, - 5 / 4, -+ 4 / 3, -+ 7 / 5, - 3 / 2, - 7 / 4, - 2, From 2ddbf8a5f1289e58b90d2b90a2cb5a4865d5824a Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Thu, 28 Nov 2019 15:54:12 +0900 Subject: [PATCH 4/6] Use a mix of chromium_src and grit preprocessing to replace the values used for Zoom in viewport.js For more info, see: https://chromium.googlesource.com/chromium/src.git/+/master/styleguide/web/web.md#preprocessing --- .../resources/extensions/extensions_resources.grd | 2 ++ .../extensions/js_override/pdf/viewport.js | 11 +++++++++++ .../ui/webui/print_preview/print_preview_ui.cc | 7 +++++++ .../chrome-browser-resources-pdf-viewport.js.patch | 13 ------------- 4 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 browser/resources/extensions/js_override/pdf/viewport.js create mode 100644 chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc delete mode 100644 patches/chrome-browser-resources-pdf-viewport.js.patch diff --git a/browser/resources/extensions/extensions_resources.grd b/browser/resources/extensions/extensions_resources.grd index 635841eb014e..a32e7e65d2d0 100644 --- a/browser/resources/extensions/extensions_resources.grd +++ b/browser/resources/extensions/extensions_resources.grd @@ -12,6 +12,8 @@ + + diff --git a/browser/resources/extensions/js_override/pdf/viewport.js b/browser/resources/extensions/js_override/pdf/viewport.js new file mode 100644 index 000000000000..34e2dda4c125 --- /dev/null +++ b/browser/resources/extensions/js_override/pdf/viewport.js @@ -0,0 +1,11 @@ +/* Copyright (c) 2019 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + + + +Viewport.ZOOM_FACTORS = [ + 0.25, 1 / 3, 0.5, 2 / 3, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.33, 1.4, 1.5, 1.75, 2, 2.5, 3, + 4, 5 +]; diff --git a/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc new file mode 100644 index 000000000000..7139c034526e --- /dev/null +++ b/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc @@ -0,0 +1,7 @@ +#include "chrome/grit/component_extension_resources.h" +#include "brave/browser/resources/extensions/grit/brave_extensions_resources.h" + +#undef IDR_PDF_VIEWPORT_JS +#define IDR_PDF_VIEWPORT_JS IDR_BRAVE_PDF_VIEWPORT_JS +#include "../../../../../../../chrome/browser/ui/webui/print_preview/print_preview_ui.cc" +#undef IDR_PDF_VIEWPORT_JS diff --git a/patches/chrome-browser-resources-pdf-viewport.js.patch b/patches/chrome-browser-resources-pdf-viewport.js.patch deleted file mode 100644 index dd1f493f4efb..000000000000 --- a/patches/chrome-browser-resources-pdf-viewport.js.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/chrome/browser/resources/pdf/viewport.js b/chrome/browser/resources/pdf/viewport.js -index 480664c014ce18126a4806a9ac484bed390d68ad..8f4f959091038848466d1130fd1f610035fa5212 100644 ---- a/chrome/browser/resources/pdf/viewport.js -+++ b/chrome/browser/resources/pdf/viewport.js -@@ -1228,7 +1228,7 @@ Viewport.SCROLL_INCREMENT = 40; - * chrome/browser/resources/settings/appearance_page/appearance_page.js - */ - Viewport.ZOOM_FACTORS = [ -- 0.25, 1 / 3, 0.5, 2 / 3, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, -+ 0.25, 1 / 3, 0.5, 2 / 3, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.33, 1.4, 1.5, 1.75, 2, 2.5, 3, - 4, 5 - ]; - From 41776c0567ffc766bc2488d1b9546547587fa92b Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Fri, 29 Nov 2019 08:55:28 +0900 Subject: [PATCH 5/6] Fix lint error --- .../browser/ui/webui/print_preview/print_preview_ui.cc | 7 ++++++- chromium_src/components/zoom/page_zoom_constants.cc | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc index 7139c034526e..efd2b7345868 100644 --- a/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc +++ b/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc @@ -1,7 +1,12 @@ +/* Copyright (c) 2019 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + #include "chrome/grit/component_extension_resources.h" #include "brave/browser/resources/extensions/grit/brave_extensions_resources.h" #undef IDR_PDF_VIEWPORT_JS #define IDR_PDF_VIEWPORT_JS IDR_BRAVE_PDF_VIEWPORT_JS -#include "../../../../../../../chrome/browser/ui/webui/print_preview/print_preview_ui.cc" +#include "../../../../../../../chrome/browser/ui/webui/print_preview/print_preview_ui.cc" // NOLINT #undef IDR_PDF_VIEWPORT_JS diff --git a/chromium_src/components/zoom/page_zoom_constants.cc b/chromium_src/components/zoom/page_zoom_constants.cc index 71cab34e2844..a47f225e13f4 100644 --- a/chromium_src/components/zoom/page_zoom_constants.cc +++ b/chromium_src/components/zoom/page_zoom_constants.cc @@ -1,6 +1,7 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +/* Copyright (c) 2019 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "components/zoom/page_zoom_constants.h" @@ -17,5 +18,5 @@ const double kPresetZoomFactors[] = {0.25, 1 / 3.0, 0.5, 2 / 3.0, 0.75, 0.8, 3.0, 4.0, 5.0}; const std::size_t kPresetZoomFactorsSize = base::size(kPresetZoomFactors); -} // namespace ui_zoom +} // namespace zoom From 165e4cff11eeb7a1f4a5daec4e02f46983701475 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Mon, 2 Dec 2019 16:00:12 -0700 Subject: [PATCH 6/6] Zoom values for both JS files come from one source Cleanup during review with @bridiver --- .../extensions/js_override/pdf/viewport.js | 5 +---- .../settings/brave_settings_overrides.js | 22 +------------------ browser/resources/settings/zoom_factors.json | 21 ++++++++++++++++++ .../components/zoom/page_zoom_constants.cc | 5 ++--- 4 files changed, 25 insertions(+), 28 deletions(-) create mode 100644 browser/resources/settings/zoom_factors.json diff --git a/browser/resources/extensions/js_override/pdf/viewport.js b/browser/resources/extensions/js_override/pdf/viewport.js index 34e2dda4c125..d2894439d0a7 100644 --- a/browser/resources/extensions/js_override/pdf/viewport.js +++ b/browser/resources/extensions/js_override/pdf/viewport.js @@ -5,7 +5,4 @@ -Viewport.ZOOM_FACTORS = [ - 0.25, 1 / 3, 0.5, 2 / 3, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.33, 1.4, 1.5, 1.75, 2, 2.5, 3, - 4, 5 -]; +Viewport.ZOOM_FACTORS = ; diff --git a/browser/resources/settings/brave_settings_overrides.js b/browser/resources/settings/brave_settings_overrides.js index c34f29578fd5..e62ea211fb84 100644 --- a/browser/resources/settings/brave_settings_overrides.js +++ b/browser/resources/settings/brave_settings_overrides.js @@ -105,27 +105,7 @@ const BraveClearSettingsMenuHighlightBehavior = { const BraveAddZoomLevelsBehavior = { ready: function() { - this._setPageZoomLevels_([ - 1 / 4, - 1 / 3, - 1 / 2, - 2 / 3, - 3 / 4, - 4 / 5, - 9 / 10, - 1, - 11 / 10, - 5 / 4, - 4 / 3, - 7 / 5, - 3 / 2, - 7 / 4, - 2, - 5 / 2, - 3, - 4, - 5, - ]) + this._setPageZoomLevels_() } } diff --git a/browser/resources/settings/zoom_factors.json b/browser/resources/settings/zoom_factors.json new file mode 100644 index 000000000000..05de8b17d8da --- /dev/null +++ b/browser/resources/settings/zoom_factors.json @@ -0,0 +1,21 @@ +[ + 0.25, + 1 / 3, + 0.5, + 2 / 3, + 0.75, + 0.8, + 0.9, + 1, + 1.1, + 1.25, + 4 / 3, + 7 / 5, + 1.5, + 1.75, + 2, + 2.5, + 3, + 4, + 5 +] \ No newline at end of file diff --git a/chromium_src/components/zoom/page_zoom_constants.cc b/chromium_src/components/zoom/page_zoom_constants.cc index a47f225e13f4..9155941a6c31 100644 --- a/chromium_src/components/zoom/page_zoom_constants.cc +++ b/chromium_src/components/zoom/page_zoom_constants.cc @@ -9,9 +9,8 @@ namespace zoom { -// This list is duplicated in chrome/browser/resources/pdf/viewport.js and in -// chrome/browser/resources/settings/appearance_page/appearance_page.js. Please -// make sure the three match. +// This list is duplicated in brave/browser/resources/settings/zoom_factors.json +// When changing this list, please make sure that gets updated also. const double kPresetZoomFactors[] = {0.25, 1 / 3.0, 0.5, 2 / 3.0, 0.75, 0.8, 0.9, 1.0, 1.1, 1.25, 4 / 3.0, 7 / 5.0, 1.5, 1.75, 2.0, 2.5,