Revert "Fix width of status bubbles"
This reverts commit 03d9d9e6e9
.
Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=936144#c20
Original change's description:
> Fix width of status bubbles
>
> Status bubbles for short URLs now match the width of the URL
>
> Tested by mousing over various links to make the status bubble appear.
>
> Bug: 936144
> Change-Id: Ia6e4735a84e4d02f560b860b93e6dbc2066ff63e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529187
> Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
> Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#645300}
TBR=ellyjones@chromium.org,tsrwebgl@gmail.com
Change-Id: I09ffe33585a9303a000109a66b742a5e716abbbc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 936144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1544162
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#645423}
This commit is contained in:

committed by
Commit Bot

parent
dac67c0f24
commit
f44babc7de
1
AUTHORS
1
AUTHORS
@ -297,7 +297,6 @@ Georgy Buranov <gburanov@gmail.com>
|
||||
Gergely Nagy <ngg@ngg.hu>
|
||||
Getulio Sánchez <valentin2507@gmail.com>
|
||||
Gideon Pyzer <gjpyzer@gmail.com>
|
||||
Giovanni Panaro <tsrwebgl@gmail.com>
|
||||
Girish Kumar M <mck.giri@samsung.com>
|
||||
Gitanshu Mehndiratta <g.mehndiratt@samsung.com>
|
||||
Giuseppe Iuculano <giuseppe@iuculano.it>
|
||||
|
@ -721,14 +721,6 @@ void StatusBubbleViews::SetBounds(int x, int y, int w, int h) {
|
||||
AvoidMouse(last_mouse_moved_location_);
|
||||
}
|
||||
|
||||
int StatusBubbleViews::GetWidthForURL(const base::string16& url_string) {
|
||||
// Get the width of the elided url
|
||||
int elided_url_width = gfx::GetStringWidth(url_string, GetFont());
|
||||
// Add proper paddings
|
||||
return elided_url_width + (kShadowThickness * 2) + kTextPositionX +
|
||||
kTextHorizPadding + 1;
|
||||
}
|
||||
|
||||
void StatusBubbleViews::SetStatus(const base::string16& status_text) {
|
||||
if (size_.IsEmpty())
|
||||
return; // We have no bounds, don't attempt to show the popup.
|
||||
@ -768,6 +760,12 @@ void StatusBubbleViews::SetURL(const GURL& url) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset expansion state only when bubble is completely hidden.
|
||||
if (view_->state() == StatusView::BUBBLE_HIDDEN) {
|
||||
is_expanded_ = false;
|
||||
SetBubbleWidth(GetStandardStatusBubbleWidth());
|
||||
}
|
||||
|
||||
// Set Elided Text corresponding to the GURL object.
|
||||
int text_width = static_cast<int>(size_.width() - (kShadowThickness * 2) -
|
||||
kTextPositionX - kTextHorizPadding - 1);
|
||||
@ -778,28 +776,8 @@ void StatusBubbleViews::SetURL(const GURL& url) {
|
||||
// correctly.
|
||||
url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_);
|
||||
|
||||
// Get the width of the URL if the bubble width is the maximum size.
|
||||
base::string16 full_size_elided_url =
|
||||
url_formatter::ElideUrl(url, GetFont(), GetMaxStatusBubbleWidth());
|
||||
int url_width = GetWidthForURL(full_size_elided_url);
|
||||
|
||||
// Get the width for the url if it is unexpanded.
|
||||
int unexpanded_width = std::min(url_width, GetStandardStatusBubbleWidth());
|
||||
|
||||
// Reset expansion state only when bubble is completely hidden.
|
||||
if (view_->state() == StatusView::BUBBLE_HIDDEN) {
|
||||
is_expanded_ = false;
|
||||
url_text_ = url_formatter::ElideUrl(url, GetFont(), unexpanded_width);
|
||||
SetBubbleWidth(unexpanded_width);
|
||||
}
|
||||
|
||||
if (IsFrameVisible()) {
|
||||
// If bubble is not expanded & not empty, make it fit properly in the
|
||||
// unexpanded bubble
|
||||
if (!is_expanded_ & !url.is_empty()) {
|
||||
url_text_ = url_formatter::ElideUrl(url, GetFont(), unexpanded_width);
|
||||
SetBubbleWidth(unexpanded_width);
|
||||
}
|
||||
view_->SetText(url_text_, true);
|
||||
|
||||
CancelExpandTimer();
|
||||
|
||||
@ -815,7 +793,6 @@ void StatusBubbleViews::SetURL(const GURL& url) {
|
||||
expand_timer_factory_.GetWeakPtr()),
|
||||
base::TimeDelta::FromMilliseconds(kExpandHoverDelayMS));
|
||||
}
|
||||
view_->SetText(url_text_, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -960,11 +937,15 @@ bool StatusBubbleViews::IsFrameMaximized() {
|
||||
void StatusBubbleViews::ExpandBubble() {
|
||||
// Elide URL to maximum possible size, then check actual length (it may
|
||||
// still be too long to fit) before expanding bubble.
|
||||
url_text_ =
|
||||
url_formatter::ElideUrl(url_, GetFont(), GetMaxStatusBubbleWidth());
|
||||
int max_status_bubble_width = GetMaxStatusBubbleWidth();
|
||||
const gfx::FontList font_list;
|
||||
url_text_ = url_formatter::ElideUrl(url_, font_list, max_status_bubble_width);
|
||||
int expanded_bubble_width =
|
||||
std::max(GetStandardStatusBubbleWidth(),
|
||||
std::min(GetWidthForURL(url_text_), GetMaxStatusBubbleWidth()));
|
||||
std::min(gfx::GetStringWidth(url_text_, font_list) +
|
||||
(kShadowThickness * 2) + kTextPositionX +
|
||||
kTextHorizPadding + 1,
|
||||
max_status_bubble_width));
|
||||
is_expanded_ = true;
|
||||
expand_view_->StartExpansion(url_text_, size_.width(), expanded_bubble_width);
|
||||
}
|
||||
|
@ -58,9 +58,6 @@ class StatusBubbleViews : public StatusBubble {
|
||||
// Set bubble to new width.
|
||||
void SetBubbleWidth(int width);
|
||||
|
||||
// Gets the width that a bubble should be for a given string
|
||||
int GetWidthForURL(const base::string16& url_string);
|
||||
|
||||
// Overridden from StatusBubble:
|
||||
void SetStatus(const base::string16& status) override;
|
||||
void SetURL(const GURL& url) override;
|
||||
|
Reference in New Issue
Block a user