Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated zoom constants and pages to resolve issue #6943 #4092

Merged
merged 6 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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