Skip to content

Commit

Permalink
Merge pull request #4092 from fow5040/add-extra-static-zoom-levels
Browse files Browse the repository at this point in the history
Updated zoom constants and pages to resolve issue #6943
  • Loading branch information
bsclifton authored Dec 2, 2019
2 parents 01f83c7 + 165e4cf commit 88c7229
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions browser/resources/extensions/extensions_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<structures>
<structure name="IDR_EXTENSIONS_BRAVE_ITEM_LIST_MORE_ITEMS_JS" file="brave_item_list_more_items.js" type="chrome_html" preprocess="true" />
<structure name="IDR_EXTENSIONS_BRAVE_ITEM_LIST_MORE_ITEMS_HTML" file="brave_item_list_more_items.html" type="chrome_html" preprocess="true" allowexternalscript="true" />
<!-- included in chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc -->
<structure name="IDR_BRAVE_PDF_VIEWPORT_JS" file="js_override/pdf/viewport.js" preprocess="true" type="chrome_html" />
</structures>
<includes>
<include name="IDR_EXTENSIONS_BRAVE_STAMP" file="brave_unpack.stamp" type="BINDATA" />
Expand Down
8 changes: 8 additions & 0 deletions browser/resources/extensions/js_override/pdf/viewport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* 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 src="../../../../../../chrome/browser/resources/pdf/viewport.js">

Viewport.ZOOM_FACTORS = <include src="../../../settings/zoom_factors.json">;
9 changes: 9 additions & 0 deletions browser/resources/settings/brave_settings_overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,17 @@ const BraveClearSettingsMenuHighlightBehavior = {
}
}

const BraveAddZoomLevelsBehavior = {
ready: function() {
this._setPageZoomLevels_(<include src="./zoom_factors.json">)
}
}

// Polymer Component Behavior injection (like superclasses)
BravePatching.RegisterPolymerComponentBehaviors({
'settings-appearance-page': [
BraveAddZoomLevelsBehavior
],
'settings-clear-browsing-data-dialog': [
BraveClearBrowsingDataOnExitBehavior
],
Expand Down
21 changes: 21 additions & 0 deletions browser/resources/settings/zoom_factors.json
Original file line number Diff line number Diff line change
@@ -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
]
Original file line number Diff line number Diff line change
@@ -0,0 +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" // NOLINT
#undef IDR_PDF_VIEWPORT_JS
21 changes: 21 additions & 0 deletions chromium_src/components/zoom/page_zoom_constants.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* 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"

#include "base/stl_util.h"

namespace zoom {

// 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,
3.0, 4.0, 5.0};
const std::size_t kPresetZoomFactorsSize = base::size(kPresetZoomFactors);

} // namespace zoom

0 comments on commit 88c7229

Please sign in to comment.