-
Notifications
You must be signed in to change notification settings - Fork 877
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
Forward preferred size changes from BraveActionsContainer
#587
Conversation
When a `BraveAction` is added, the size change isn't properly notified to `BraveLocationBarView`. This commit implements `ChildPreferredSizeChanged()` in both `BraveActionsContainer` and `BraveLocationBarView`, and makes sure the action's preferred size is set after calling `AddChildView()`. Fixes brave/brave-browser#1276
if (actions_[id].position_ != ACTION_ANY_POSITION) { | ||
DCHECK(actions_[id].position_ > 0); | ||
AddChildViewAt(actions_[id].view_.get(), actions_[id].position_); | ||
} else { | ||
AddChildView(actions_[id].view_.get()); | ||
} | ||
// we control destruction | ||
actions_[id].view_->set_owned_by_client(); |
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: I think this relocation isn't needed.
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.
Sure, actually I just moved the code calling AddChildView()
so that it happens just after creation. It's just that git diff
shows it the other way around.
@@ -244,3 +246,7 @@ void BraveActionsContainer::OnExtensionActionUpdated( | |||
UpdateActionState(extension_action->extension_id()); | |||
} | |||
// end ExtensionActionAPI::Observer | |||
|
|||
void BraveActionsContainer::ChildPreferredSizeChanged(views::View* child) { | |||
PreferredSizeChanged(); |
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.
Instead of calling PreferredSizeChanged()
, just calling parent()->Layout()
would be more explicit.
With this, we don't need to modify BraveLocationBarView
.
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.
Well, I think it is more clean this way. In the future, we may want to do other things instead of or besides calling Layout()
in BraveLocationBarView::ChildPreferredSizeChanged()
. Or we may have other BraveLocationBarView
's children needing to do that. Also, this code is independent of the BraveActionsContainer
's parent. What do you think?
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.
Ok, I got what you mean.
I assume this problem could be reproduced when action is removed during the runtime. |
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.
As I understand, as long as the extensions do not get unloaded, which they don't, then this is ok. So going to merge and approve.
Forward preferred size changes from `BraveActionsContainer`
Forward preferred size changes from `BraveActionsContainer`
Skipping 12 because it was used for some ad-hoc testing, also 13 == good luck
When a
BraveAction
is added, the size change isn't properly notifiedto
BraveLocationBarView
. This commit implementsChildPreferredSizeChanged()
in bothBraveActionsContainer
andBraveLocationBarView
, and makes sure the action's preferred size isset after calling
AddChildView()
.Fixes brave/brave-browser#1276
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests
) ongit rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist: