Skip to content

Commit

Permalink
Label::CalculatePreferredSize() marked as final (#20767)
Browse files Browse the repository at this point in the history
This function is now marked as `final`, however there is another entry
in the overload set that can be used in its place for the override in
`BraveVPNStatusLabel`.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/bf2f84a8c4f27e399e05bf4730a29152f6a8b0b6

commit bf2f84a8c4f27e399e05bf4730a29152f6a8b0b6
Author: weidongliu <liuwd8@gmail.com>
Date:   Mon Oct 30 15:59:03 2023 +0000

    views: Mark CalculatePreferredSize() of views::Label as final

    Views::Label now has two functions to calculate the preferred size. This
    can cause some unexpected errors. CalculatePreferredSize() is now
    expected to be deprecated. Therefore, mark it as final to prevent
    overrided by subclasses.

    Bug: 1346889
  • Loading branch information
cdesouza-chromium authored and mkarolin committed Nov 28, 2023
1 parent d7faaca commit dbdb923
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions browser/ui/views/toolbar/brave_vpn_status_label.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ void BraveVPNStatusLabel::OnConnectionStateChanged(ConnectionState state) {
UpdateState();
}

gfx::Size BraveVPNStatusLabel::CalculatePreferredSize() const {
auto size = views::Label::CalculatePreferredSize();
gfx::Size BraveVPNStatusLabel::CalculatePreferredSize(
const views::SizeBounds& available_size) const {
auto size = views::Label::CalculatePreferredSize(available_size);
if (longest_state_string_id_ == -1)
return size;
auto text =
Expand Down
3 changes: 2 additions & 1 deletion browser/ui/views/toolbar/brave_vpn_status_label.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class BraveVPNStatusLabel : public views::Label,
BraveVPNStatusLabel(const BraveVPNStatusLabel&) = delete;
BraveVPNStatusLabel& operator=(const BraveVPNStatusLabel&) = delete;

gfx::Size CalculatePreferredSize() const override;
gfx::Size CalculatePreferredSize(
const views::SizeBounds& available_size) const override;

private:
// brave_vpn::BraveVPNServiceObserver overrides:
Expand Down

0 comments on commit dbdb923

Please sign in to comment.