-
Notifications
You must be signed in to change notification settings - Fork 887
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
Add horizontal margin to LocationBar, centering on Toolbar where possible #454
Conversation
85c2df1
to
4361221
Compare
4361221
to
a62f253
Compare
@@ -1,15 +0,0 @@ | |||
diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These pref keys are being whitelisted from the javascript settingsPrivate
API. Moved from patch to override, anything extra need testing?
@@ -6,7 +6,7 @@ | |||
<link rel="import" href="../settings_shared_css.html"> | |||
<link rel="import" href="../settings_vars_css.html"> | |||
|
|||
<dom-module id="settings-brave-appearance-page"> | |||
<dom-module id="settings-brave-appearance-theme"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes since we want to insert items to two separate places within the chromium list
} | ||
next_element_x += GetLayoutConstant(TOOLBAR_STANDARD_SPACING); | ||
|
||
next_element_x += element_padding; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we now always want element_padding
distance between all items, even LocationBar, instead of GetLayoutConstant(TOOLBAR_STANDARD_SPACING)
for the spacing to the left of LocationBar
a62f253
to
90fe311
Compare
(toolbar_width / 2); | ||
// Can't shim more than we have space for, so restrict to margin size | ||
// or in the case of moving-right, 25% of the space since we want to avoid | ||
// touching browser actions where possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't understand this comment about why right-side moving is restricted to 25% of margin.
There are always gap between location bar and browser action area because browser actions has it's internal padding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to prevent the gap being larger on the left side than the right side, reducing the extra margin (the gap that does not include the left padding on the browser actions area). Whilst we aim to center the LocationBar as much as possible, a more important priority is to not be in the situation where there is some gap on the left, and no gap on the right, due to the proximity of the brave actions bar and the browser actions bar.
Of course, when there is no extra margin (either user-configurable or because the window is too narrow), then we are ok with no extra gap on either side.
Without shim-right restriction (moves right, towards center):
With 100% shim-right restriction (not allowed a smaller gap on right than left):
With 25% shim-right restriction (can move right towards center, but not more than 25% of the right-margin):
(Apologies for the discrepancy of the bookmark button position, some screenshots were taken before this moved!)
However, we still allow shim-left to 0% of the margin, moving all margin to the right:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation! I thought location bar view should be center on toolbar always.
90fe311
to
ea12792
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a couple of minor comments
|
||
const PrefsUtil::TypedPrefMap& BravePrefsUtil::GetWhitelistedKeys() { | ||
// Static cache, similar to parent class | ||
static PrefsUtil::TypedPrefMap* s_brave_whitelist = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want s_brave_whitelist
in a std::unique_ptr
or something like that? Or does it not matter for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in PM - followed parent class pattern of using static variable that hangs around for the whole browser process life, seems ok since this is a global whitelist.
…ible Can be disabled via user preference under Appearance section of settings page. Takes the opportunity to create a Brave whitelist for the settingsPrivate javascript API without adding items through patching chromium directly. This is achieved via subclassing `extensions::PrefsUtil`. Whilst a target margin is determined according to window's width and a maximum LocationBar width, such as 3%, 5%, 7% or more consider we determined that it's a nicer effect if the LocationBar is centered on the Toolbar, and not within the space between items on the left and right side of the Toolbar, which can be varying widths, especially with many extensions. Therefore space is allocated from the right margin to the left in order to 'shim' the center point of the LocationBar towards the center point of the Toolbar. Similarly space can also be allocated from the left margin to the right for the same purpose, but not so much that it encroaches more than 25% in to the right margin, so not to get too close to extension Browser Actions. BookmarkButton is then anchored to the floating LocationBar. LocationBar max width is 1080px which is calculated from Brave 0.23's 900px width and increased with appropriate space for the Brave Actions.
ea12792
to
5ac363f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM2!
const auto chromium_prefs = PrefsUtil::GetWhitelistedKeys(); | ||
s_brave_whitelist->insert(chromium_prefs.begin(), chromium_prefs.end()); | ||
// Add Brave values to the whitelist | ||
#if !defined(OS_CHROMEOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this define can be removed
(toolbar_width / 2); | ||
// Can't shim more than we have space for, so restrict to margin size | ||
// or in the case of moving-right, 25% of the space since we want to avoid | ||
// touching browser actions where possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation! I thought location bar view should be center on toolbar always.
Add horizontal margin to LocationBar, centering on Toolbar where possible
0.55.x d27d1db |
Also, anchor BookmarkButton to floating LocationBar
Fix brave/brave-browser#791
Whilst a target margin is determined according to window's width and a maximum LocationBar width, such as 3%, 5%, 7% or more consider we determined that it's a nicer effect if the LocationBar is centered on the Toolbar, and not within the space between items on the left and right side of the Toolbar, which can be varying widths, especially with many extensions. Therefore space is allocated from the right margin to the left in order to 'shim' the center point of the LocationBar towards the center point of the Toolbar. Similarly space can also be allocated from the left margin to the right for the same purpose, but not so much that it encroaches more than 25% in to the right margin, so not to get too close to extension Browser Actions.
LocationBar max width is 1080px which is calculated from Brave 0.23's 900px width and increased with appropriate space for the Brave Actions.
Note that I experimented with 3 algorithms for calculating how much space to allocate on each side before settling on the following. These explorations are documented here: https://projects.invisionapp.com/boards/GD3PV3FKN4V/
Screenshots
With 4 extensions
Without extensions
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist: