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

Conversation

fow5040
Copy link
Contributor

@fow5040 fow5040 commented Nov 27, 2019

Fix brave/brave-browser#6943

Submitter Checklist:

Test Plan:

  1. Verify you can set Zoom level in brave://settings to 133% and 140%
  2. Open a PDF
  3. Verify you can use Zoom level 133% and 140% (icon shows in omnibar)
  4. Try to print the page
  5. Print preview will come up
  6. Verify you can zoom to 133% and 140%
    • Zoom controls are on the left side (- and +)
    • To check the zoom value, you need to right click the preview and pick Inspect
    • Once the debugger comes up, go to the console
    • In the console, type in window.viewer.viewport_.internalZoom_
    • Zoom % value should show

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@bsclifton
Copy link
Member

Very nice! I think we can do this without patches (we have a mechanism that overrides the files at the GN level). Let me see if I can re-work your PR... 😄

@fow5040
Copy link
Contributor Author

fow5040 commented Nov 27, 2019

Ahh, thank you, got it! Just for my reference, is it the subclass/override method listed in the patching chromium wiki, or something else entirely?

@bsclifton
Copy link
Member

bsclifton commented Nov 27, 2019

@fow5040 I thought it would be a slam dunk, but it's actually a little trickier...

That wiki entry is exactly what would work for the C/C++ ones 😄I made an edit which does that here: e3b534c

The JavaScript ones are a bit tougher; we do have a template system in which you can define a "behavior" which would then (at runtime) replace the array. I have this working... but only if I change the array to be readonly=false. Here's the settings override JavaScript we have (which gets ran on Polymer pages):
https://github.com/brave/brave-core/blob/master/browser/resources/settings/brave_settings_overrides.js

My edit (so far) looks like this:

diff --git a/browser/resources/settings/brave_settings_overrides.js b/browser/resources/settings/brave_settings_overrides.js
index c55966d30..7a4ab6f2d 100644
--- a/browser/resources/settings/brave_settings_overrides.js
+++ b/browser/resources/settings/brave_settings_overrides.js
@@ -103,8 +103,43 @@ const BraveClearSettingsMenuHighlightBehavior = {
   }
 }

+const BraveAddZoomLevelsBehavior = {
+  ready: function() {
+    console.log('BSC]] START ', this.pageZoomLevels_)
+    this.pageZoomLevels_Handler = function(levels) {
+      this._setPageZoomLevels_(levels);
+    }
+
+    this.pageZoomLevels_ = [
+        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,
+      ]
+    console.log('BSC]] END')
+  }
+}
+
 // Polymer Component Behavior injection (like superclasses)
 BravePatching.RegisterPolymerComponentBehaviors({
+  'settings-appearance-page': [
+    BraveAddZoomLevelsBehavior
+  ],
   'settings-clear-browsing-data-dialog': [
     BraveClearBrowsingDataOnExitBehavior
   ],

@bsclifton
Copy link
Member

Here we go- second one fixed and working 😄 589db3f

The last one I was talking through how to make the fix with @bridiver. It'll be the hardest, as we don't have any examples (currently)

@fow5040
Copy link
Contributor Author

fow5040 commented Nov 28, 2019

Got it! Thanks for updating this thread with examples, will keep it in mind for any potential future contributions. :)

@bsclifton
Copy link
Member

You're very welcome! Thanks for taking the time to fix this, it's greatly appreciated 😄

We try to be more careful about patching (as you saw in the guide) to help keep rebases (when new Chromium versions come out) much easier. Will help with this last example (it's a little trickier) then we can accept this! 😎

This fix would be a great one to upstream, honestly- I could help you push it to Chromium if you were interested. Let me know 😄

@bsclifton bsclifton requested a review from simonhong November 28, 2019 07:32
@fow5040
Copy link
Contributor Author

fow5040 commented Nov 28, 2019

Absolutely - will keep these changes in mind (including the fancy viewport .js overrides). If you think it'd be a valuable change to merge with Chromium I'd be happy to put it there as well!

As far as I'm concerned I just did a little bit of digging and some minor tweaking, but always happy to push it if it'll be useful to the user base at large.

Thanks again for all the guidance 🙌

@bsclifton
Copy link
Member

bsclifton commented Nov 28, 2019

@fow5040 with the help of @simonhong I was able to solve the last one 😄 No more patches! Please take a look; you should be able to pull this PR down now and verify it works for you

BTW - I added a test plan that covers the 3 areas called out in the source

@bridiver this is now ready for review 😄👍

@bsclifton
Copy link
Member

bsclifton commented Nov 28, 2019

and whoops; a little too quick there on my part (doh). I loaded up print preview and noticed this error:

[20247:775:1128/003811.688271:ERROR:CONSOLE(6)] "Uncaught SyntaxError: Cannot use import statement outside a module", source: chrome://print/pdf/viewport.js (6)
[20247:775:1128/003811.799828:ERROR:CONSOLE(187)] "Uncaught (in promise) ReferenceError: Viewport is not defined", source: chrome://print/pdf/pdf_viewer.js (187)

It doesn't appear that the pre-processing is happening for this file (the import should be getting replaced with the actual content)

@bsclifton
Copy link
Member

Fix found! Thanks @simonhong

OK - @bridiver, this is ready for review 😄

@simonhong simonhong force-pushed the add-extra-static-zoom-levels branch from f88e7e1 to e25def3 Compare November 28, 2019 21:51
@bsclifton bsclifton force-pushed the add-extra-static-zoom-levels branch from bdb64f2 to 41776c0 Compare December 2, 2019 05:36
@bsclifton bsclifton added this to the 1.3.x - Nightly milestone Dec 2, 2019
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Tested on macOS

@bsclifton bsclifton force-pushed the add-extra-static-zoom-levels branch from 66afaf1 to 165e4cf Compare December 2, 2019 23:09
@bsclifton bsclifton merged commit 88c7229 into brave:master Dec 2, 2019
@bsclifton
Copy link
Member

and merged! Thanks for the PR, @fow5040 😄

@fow5040 fow5040 deleted the add-extra-static-zoom-levels branch December 3, 2019 02:35
mkarolin added a commit that referenced this pull request Mar 2, 2020
…evels"

Reason for revert: this change has been upstreamed:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

This reverts commit 88c7229, reversing
changes made to 01f83c7.
mkarolin added a commit that referenced this pull request Mar 2, 2020
#4092 was reverted in a separate
commit because it is now in Chromium:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

The only difference upstream is 2 additional zoom values we had in
Brave.

This readds those values (4 / 3.0 and 7 / 5.0).
mkarolin added a commit that referenced this pull request Mar 4, 2020
…evels"

Reason for revert: this change has been upstreamed:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

This reverts commit 88c7229, reversing
changes made to 01f83c7.
mkarolin added a commit that referenced this pull request Mar 4, 2020
#4092 was reverted in a separate
commit because it is now in Chromium:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

The only difference upstream is 2 additional zoom values we had in
Brave.

This readds those values (4 / 3.0 and 7 / 5.0).
mkarolin added a commit that referenced this pull request Mar 12, 2020
…evels"

Reason for revert: this change has been upstreamed:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

This reverts commit 88c7229, reversing
changes made to 01f83c7.
mkarolin added a commit that referenced this pull request Mar 12, 2020
#4092 was reverted in a separate
commit because it is now in Chromium:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

The only difference upstream is 2 additional zoom values we had in
Brave.

This readds those values (4 / 3.0 and 7 / 5.0).
mkarolin added a commit that referenced this pull request Mar 17, 2020
…evels"

Reason for revert: this change has been upstreamed:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

This reverts commit 88c7229, reversing
changes made to 01f83c7.
mkarolin added a commit that referenced this pull request Mar 17, 2020
#4092 was reverted in a separate
commit because it is now in Chromium:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

The only difference upstream is 2 additional zoom values we had in
Brave.

This readds those values (4 / 3.0 and 7 / 5.0).
mkarolin added a commit that referenced this pull request Mar 19, 2020
…evels"

Reason for revert: this change has been upstreamed:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

This reverts commit 88c7229, reversing
changes made to 01f83c7.
mkarolin added a commit that referenced this pull request Mar 19, 2020
#4092 was reverted in a separate
commit because it is now in Chromium:
https://chromium.googlesource.com/chromium/src/+/08b57c09851e2bdcb39ea70e46707f3bab6a0a4a

The only difference upstream is 2 additional zoom values we had in
Brave.

This readds those values (4 / 3.0 and 7 / 5.0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more zoom levels, like 133%
4 participants