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 5 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
11 changes: 11 additions & 0 deletions browser/resources/extensions/js_override/pdf/viewport.js
Original file line number Diff line number Diff line change
@@ -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/. */

<include src="../../../../../../chrome/browser/resources/pdf/viewport.js">

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
];
29 changes: 29 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,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
],
Expand Down
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
22 changes: 22 additions & 0 deletions chromium_src/components/zoom/page_zoom_constants.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* 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 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 zoom