Commit 5b3e9042 authored by Emily Stark's avatar Emily Stark Committed by Commit Bot

Simplified domain: Further kill the edit bump

The previous CL in this chain reveals trivial subdomain and scheme
when the URL is unelided on hover. This CL adds a hover animation to
the omnibox even before the user interacts with the page (in the
hide-on-interaction field trial). This allows the user to hover over
the omnibox to bring back the scheme and trivial subdomain even before
the URL has been elided to the simplified domain, thereby minimizing
the potential of having an edit bump before interacting the page as
well as after.

The main change is that we need to create the hover animation
earlier. Previously, we were creating it once the user interacts with
the page; now we create it on page load. Each elide/unelide operation
decides whether to use the full URL, partially elided URL (just scheme
and trivial subdomain hidden), or simplified domain based on whether
the user has interacted with the page yet or not.

Bug: 1101486
Change-Id: Id747929df56becadc34f0cb7a581494f4d90df5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2291310
Commit-Queue: Emily Stark <estark@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788837}
parent 52334214
...@@ -461,7 +461,7 @@ void OmniboxViewViews::EmphasizeURLComponents() { ...@@ -461,7 +461,7 @@ void OmniboxViewViews::EmphasizeURLComponents() {
// show just the simplified domain until the user specifically interacts // show just the simplified domain until the user specifically interacts
// with the omnibox by hovering over it. // with the omnibox by hovering over it.
if (IsURLEligibleForSimplifiedDomainEliding()) { if (IsURLEligibleForSimplifiedDomainEliding()) {
ElideToSimplifiedDomain(); ElideURL();
} else { } else {
// If the text isn't eligible to be elided to a simplified domain, then // If the text isn't eligible to be elided to a simplified domain, then
// ensure that as much of it is visible as will fit. // ensure that as much of it is visible as will fit.
...@@ -700,11 +700,7 @@ void OmniboxViewViews::OnThemeChanged() { ...@@ -700,11 +700,7 @@ void OmniboxViewViews::OnThemeChanged() {
set_placeholder_text_color(dimmed_text_color); set_placeholder_text_color(dimmed_text_color);
if (!model()->ShouldPreventElision() && if (!model()->ShouldPreventElision() &&
OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover() && OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover()) {
!OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction()) {
// When reveal-on-hover is enabled but not hide-on-interaction, create
// the hover elision animation now. When hide-on-interaction is enabled,
// the hover animation is created after the user interacts with each page.
hover_elide_or_unelide_animation_ = hover_elide_or_unelide_animation_ =
std::make_unique<ElideAnimation>(this, GetRenderText()); std::make_unique<ElideAnimation>(this, GetRenderText());
} }
...@@ -1166,11 +1162,22 @@ void OmniboxViewViews::OnMouseMoved(const ui::MouseEvent& event) { ...@@ -1166,11 +1162,22 @@ void OmniboxViewViews::OnMouseMoved(const ui::MouseEvent& event) {
if (starting_color == gfx::kPlaceholderColor) if (starting_color == gfx::kPlaceholderColor)
starting_color = SK_ColorTRANSPARENT; starting_color = SK_ColorTRANSPARENT;
hover_elide_or_unelide_animation_->Stop(); hover_elide_or_unelide_animation_->Stop();
std::vector<gfx::Range> ranges_surrounding_simplified_domain; // Figure out where we are uneliding from so that the hover animation can
GetSimplifiedDomainBounds(&ranges_surrounding_simplified_domain); // fade the surrounding text in. If the user has already interacted with the
// page, then we elided to the simplified domain and that is what we are
// uneliding from now. Otherwise, only the scheme and possibly a trivial
// subdomain have been elided and those components now need to be faded in.
std::vector<gfx::Range> ranges_to_fade_in;
if (elide_after_interaction_animation_ ||
!OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction()) {
GetSimplifiedDomainBounds(&ranges_to_fade_in);
} else {
url::Component host = GetHostComponentAfterTrivialSubdomain();
ranges_to_fade_in.emplace_back(0, host.begin);
}
hover_elide_or_unelide_animation_->Start( hover_elide_or_unelide_animation_->Start(
unelide_bounds, OmniboxFieldTrial::UnelideURLOnHoverThresholdMs(), unelide_bounds, OmniboxFieldTrial::UnelideURLOnHoverThresholdMs(),
ranges_surrounding_simplified_domain, starting_color, ranges_to_fade_in, starting_color,
GetOmniboxColor(GetThemeProvider(), GetOmniboxColor(GetThemeProvider(),
OmniboxPart::LOCATION_BAR_TEXT_DIMMED)); OmniboxPart::LOCATION_BAR_TEXT_DIMMED));
} }
...@@ -1192,23 +1199,23 @@ void OmniboxViewViews::OnMouseExited(const ui::MouseEvent& event) { ...@@ -1192,23 +1199,23 @@ void OmniboxViewViews::OnMouseExited(const ui::MouseEvent& event) {
// when their mouse exits the omnibox area. The elision animation is the // when their mouse exits the omnibox area. The elision animation is the
// reverse of the unelision animation: we shrink the URL from both sides while // reverse of the unelision animation: we shrink the URL from both sides while
// shifting the text to the leading edge. // shifting the text to the leading edge.
DCHECK(hover_elide_or_unelide_animation_);
// When hide-on-interaction is enabled, we don't want to elide or unelide SkColor starting_color =
// until there's user interaction with the page. In this variation, hover_elide_or_unelide_animation_->IsAnimating()
// |hover_elide_or_unelide_animation_| is created in DidGetUserInteraction() ? hover_elide_or_unelide_animation_->GetCurrentColor()
// so its existence signals that user interaction has taken place already. : GetOmniboxColor(GetThemeProvider(),
if (hover_elide_or_unelide_animation_) { OmniboxPart::LOCATION_BAR_TEXT_DIMMED);
SkColor starting_color = hover_elide_or_unelide_animation_->Stop();
hover_elide_or_unelide_animation_->IsAnimating() // Elisions don't take display offset into account (see
? hover_elide_or_unelide_animation_->GetCurrentColor() // https://crbug.com/1099078), so the RenderText must be in NO_ELIDE mode to
: GetOmniboxColor(GetThemeProvider(), // avoid over-eliding when some of the text is not visible due to display
OmniboxPart::LOCATION_BAR_TEXT_DIMMED); // offset.
hover_elide_or_unelide_animation_->Stop(); GetRenderText()->SetElideBehavior(gfx::NO_ELIDE);
// Elisions don't take display offset into account (see // Figure out where to elide to. If the user has already interacted with the
// https://crbug.com/1099078), so the RenderText must be in NO_ELIDE mode to // page or reveal-on-interaction is disabled, then elide to the simplified
// avoid over-eliding when some of the text is not visible due to display // domain; otherwise just hide the scheme and trivial subdomain (if any).
// offset. if (elide_after_interaction_animation_ ||
GetRenderText()->SetElideBehavior(gfx::NO_ELIDE); !OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction()) {
std::vector<gfx::Range> ranges_surrounding_simplified_domain; std::vector<gfx::Range> ranges_surrounding_simplified_domain;
gfx::Range simplified_domain = gfx::Range simplified_domain =
GetSimplifiedDomainBounds(&ranges_surrounding_simplified_domain); GetSimplifiedDomainBounds(&ranges_surrounding_simplified_domain);
...@@ -1216,6 +1223,13 @@ void OmniboxViewViews::OnMouseExited(const ui::MouseEvent& event) { ...@@ -1216,6 +1223,13 @@ void OmniboxViewViews::OnMouseExited(const ui::MouseEvent& event) {
simplified_domain, 0 /* delay_ms */, simplified_domain, 0 /* delay_ms */,
ranges_surrounding_simplified_domain, starting_color, ranges_surrounding_simplified_domain, starting_color,
SK_ColorTRANSPARENT); SK_ColorTRANSPARENT);
} else {
base::string16 text = GetText();
url::Component host = GetHostComponentAfterTrivialSubdomain();
hover_elide_or_unelide_animation_->Start(
gfx::Range(host.begin, text.size()), 0 /* delay_ms */,
std::vector<gfx::Range>{gfx::Range(0, host.begin)}, starting_color,
SK_ColorTRANSPARENT);
} }
} }
...@@ -1548,7 +1562,7 @@ void OmniboxViewViews::OnFocus() { ...@@ -1548,7 +1562,7 @@ void OmniboxViewViews::OnFocus() {
saved_selection_for_focus_change_.clear(); saved_selection_for_focus_change_.clear();
} }
UnelideFromSimplifiedDomain(); ShowFullURL();
GetRenderText()->SetElideBehavior(gfx::NO_ELIDE); GetRenderText()->SetElideBehavior(gfx::NO_ELIDE);
// Focus changes can affect the visibility of any keyword hint. // Focus changes can affect the visibility of any keyword hint.
...@@ -1673,7 +1687,7 @@ void OmniboxViewViews::OnBlur() { ...@@ -1673,7 +1687,7 @@ void OmniboxViewViews::OnBlur() {
std::make_unique<OmniboxViewViews::ElideAnimation>(this, std::make_unique<OmniboxViewViews::ElideAnimation>(this,
GetRenderText()); GetRenderText());
if (IsURLEligibleForSimplifiedDomainEliding()) { if (IsURLEligibleForSimplifiedDomainEliding()) {
ElideToSimplifiedDomain(); ElideURL();
} else { } else {
// If the text isn't eligible to be elided to a simplified domain, then // If the text isn't eligible to be elided to a simplified domain, then
// ensure that as much of it is visible as will fit. // ensure that as much of it is visible as will fit.
...@@ -1734,7 +1748,7 @@ void OmniboxViewViews::DidFinishNavigation( ...@@ -1734,7 +1748,7 @@ void OmniboxViewViews::DidFinishNavigation(
if (IsURLEligibleForSimplifiedDomainEliding() && if (IsURLEligibleForSimplifiedDomainEliding() &&
elide_after_interaction_animation_ && elide_after_interaction_animation_ &&
!elide_after_interaction_animation_->IsAnimating()) { !elide_after_interaction_animation_->IsAnimating()) {
ElideToSimplifiedDomain(); ElideURL();
} }
return; return;
} }
...@@ -1750,6 +1764,11 @@ void OmniboxViewViews::DidGetUserInteraction( ...@@ -1750,6 +1764,11 @@ void OmniboxViewViews::DidGetUserInteraction(
return; return;
} }
// If there's already a hover animation running, just let it run as we will
// end up at the same place.
if (hover_elide_or_unelide_animation_->IsAnimating())
return;
// This method runs when the user interacts with the page, such as scrolling // This method runs when the user interacts with the page, such as scrolling
// or typing. In the hide-on-interaction field trial, the URL is shown until // or typing. In the hide-on-interaction field trial, the URL is shown until
// user interaction, at which point it's animated to a simplified version of // user interaction, at which point it's animated to a simplified version of
...@@ -1774,14 +1793,6 @@ void OmniboxViewViews::DidGetUserInteraction( ...@@ -1774,14 +1793,6 @@ void OmniboxViewViews::DidGetUserInteraction(
OmniboxPart::LOCATION_BAR_TEXT_DIMMED), OmniboxPart::LOCATION_BAR_TEXT_DIMMED),
SK_ColorTRANSPARENT); SK_ColorTRANSPARENT);
} }
// Now that the URL is being elided, create the animation to bring it back on
// hover (if enabled via field trial), if it hasn't already been created on an
// earlier call to this method.
if (OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover() &&
!hover_elide_or_unelide_animation_) {
hover_elide_or_unelide_animation_ =
std::make_unique<ElideAnimation>(this, GetRenderText());
}
} }
base::string16 OmniboxViewViews::GetSelectionClipboardText() const { base::string16 OmniboxViewViews::GetSelectionClipboardText() const {
...@@ -2231,8 +2242,7 @@ gfx::Range OmniboxViewViews::GetSimplifiedDomainBounds( ...@@ -2231,8 +2242,7 @@ gfx::Range OmniboxViewViews::GetSimplifiedDomainBounds(
base::string16 text = GetText(); base::string16 text = GetText();
url::Component host = GetHostComponentAfterTrivialSubdomain(); url::Component host = GetHostComponentAfterTrivialSubdomain();
if (ranges_surrounding_simplified_domain) { if (ranges_surrounding_simplified_domain) {
ranges_surrounding_simplified_domain->push_back( ranges_surrounding_simplified_domain->emplace_back(host.end(), text.size());
gfx::Range(host.end(), text.size()));
} }
if (!OmniboxFieldTrial::ShouldElideToRegistrableDomain()) { if (!OmniboxFieldTrial::ShouldElideToRegistrableDomain()) {
...@@ -2257,8 +2267,8 @@ gfx::Range OmniboxViewViews::GetSimplifiedDomainBounds( ...@@ -2257,8 +2267,8 @@ gfx::Range OmniboxViewViews::GetSimplifiedDomainBounds(
text.find(base::ASCIIToUTF16(simplified_domain)); text.find(base::ASCIIToUTF16(simplified_domain));
DCHECK_NE(simplified_domain_pos, std::string::npos); DCHECK_NE(simplified_domain_pos, std::string::npos);
if (ranges_surrounding_simplified_domain) { if (ranges_surrounding_simplified_domain) {
ranges_surrounding_simplified_domain->push_back( ranges_surrounding_simplified_domain->emplace_back(0,
gfx::Range(0, simplified_domain_pos)); simplified_domain_pos);
} }
return gfx::Range(simplified_domain_pos, host.end()); return gfx::Range(simplified_domain_pos, host.end());
} }
...@@ -2287,13 +2297,15 @@ void OmniboxViewViews::ResetToHideOnInteraction() { ...@@ -2287,13 +2297,15 @@ void OmniboxViewViews::ResetToHideOnInteraction() {
model()->ShouldPreventElision()) { model()->ShouldPreventElision()) {
return; return;
} }
// Delete the animations; they'll get recreated in DidGetUserInteraction(). // Delete the interaction animation; it'll get recreated in
// This prevents us from running any animations until the user interacts with // DidGetUserInteraction(). Recreate the hover animation now because the user
// the page. // can hover over the URL before interacting with the page to reveal the
hover_elide_or_unelide_animation_.reset(); // scheme and trivial subdomain (if any).
elide_after_interaction_animation_.reset(); elide_after_interaction_animation_.reset();
hover_elide_or_unelide_animation_ =
std::make_unique<OmniboxViewViews::ElideAnimation>(this, GetRenderText());
if (IsURLEligibleForSimplifiedDomainEliding()) if (IsURLEligibleForSimplifiedDomainEliding())
UnelideFromSimplifiedDomain(); ShowFullURLWithoutSchemeAndTrivialSubdomain();
} }
void OmniboxViewViews::OnShouldPreventElisionChanged() { void OmniboxViewViews::OnShouldPreventElisionChanged() {
...@@ -2306,7 +2318,7 @@ void OmniboxViewViews::OnShouldPreventElisionChanged() { ...@@ -2306,7 +2318,7 @@ void OmniboxViewViews::OnShouldPreventElisionChanged() {
hover_elide_or_unelide_animation_.reset(); hover_elide_or_unelide_animation_.reset();
elide_after_interaction_animation_.reset(); elide_after_interaction_animation_.reset();
if (IsURLEligibleForSimplifiedDomainEliding()) if (IsURLEligibleForSimplifiedDomainEliding())
UnelideFromSimplifiedDomain(); ShowFullURL();
return; return;
} }
if (OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction()) { if (OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction()) {
...@@ -2315,19 +2327,16 @@ void OmniboxViewViews::OnShouldPreventElisionChanged() { ...@@ -2315,19 +2327,16 @@ void OmniboxViewViews::OnShouldPreventElisionChanged() {
ResetToHideOnInteraction(); ResetToHideOnInteraction();
} else if (OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover()) { } else if (OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover()) {
if (IsURLEligibleForSimplifiedDomainEliding()) { if (IsURLEligibleForSimplifiedDomainEliding()) {
ElideToSimplifiedDomain(); ElideURL();
} }
hover_elide_or_unelide_animation_ = hover_elide_or_unelide_animation_ =
std::make_unique<ElideAnimation>(this, GetRenderText()); std::make_unique<ElideAnimation>(this, GetRenderText());
} }
} }
void OmniboxViewViews::ElideToSimplifiedDomain() { void OmniboxViewViews::ElideURL() {
if (!OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction() && DCHECK(OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction() ||
!OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover()) { OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover());
return;
}
DCHECK(IsURLEligibleForSimplifiedDomainEliding()); DCHECK(IsURLEligibleForSimplifiedDomainEliding());
// The simplified domain string must be a substring of the current display // The simplified domain string must be a substring of the current display
...@@ -2370,7 +2379,7 @@ void OmniboxViewViews::ElideToSimplifiedDomain() { ...@@ -2370,7 +2379,7 @@ void OmniboxViewViews::ElideToSimplifiedDomain() {
(simplified_domain_rect.x() - old_bounds.x())); (simplified_domain_rect.x() - old_bounds.x()));
} }
void OmniboxViewViews::UnelideFromSimplifiedDomain() { void OmniboxViewViews::ShowFullURL() {
if (!OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction() && if (!OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction() &&
!OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover()) { !OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover()) {
return; return;
...@@ -2385,6 +2394,66 @@ void OmniboxViewViews::UnelideFromSimplifiedDomain() { ...@@ -2385,6 +2394,66 @@ void OmniboxViewViews::UnelideFromSimplifiedDomain() {
GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL); GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL);
} }
void OmniboxViewViews::ShowFullURLWithoutSchemeAndTrivialSubdomain() {
DCHECK(IsURLEligibleForSimplifiedDomainEliding());
DCHECK(OmniboxFieldTrial::ShouldHidePathQueryRefOnInteraction() ||
OmniboxFieldTrial::ShouldRevealPathQueryRefOnHover());
DCHECK(!model()->ShouldPreventElision());
// First show the full URL, then figure out what to elide.
ShowFullURL();
if (!IsURLEligibleForSimplifiedDomainEliding() ||
model()->ShouldPreventElision()) {
return;
}
// TODO(https://crbug.com/1099078): currently, we cannot set the elide
// behavior to anything other than NO_ELIDE when the display offset is 0, i.e.
// when we are not hiding the scheme and trivial subdomain. This is because
// RenderText does not take display offset into account when eliding, so it
// will over-elide by however much text is scrolled out of the display area.
GetRenderText()->SetElideBehavior(gfx::NO_ELIDE);
GetRenderText()->SetDisplayOffset(0);
const gfx::Rect& current_display_rect = GetRenderText()->display_rect();
// If the scheme and trivial subdomain should be elided, then we want to set
// the display offset to where the hostname after the trivial subdomain (if
// any) begins, relative to the current display rect.
base::string16 text = GetText();
url::Component host = GetHostComponentAfterTrivialSubdomain();
gfx::Rect display_url_bounds;
for (const auto& rect : GetRenderText()->GetSubstringBounds(
gfx::Range(host.begin, text.size()))) {
display_url_bounds.Union(rect);
}
display_url_bounds.set_height(current_display_rect.height());
display_url_bounds.set_y(current_display_rect.y());
// Set the scheme and trivial subdomain to transparent. This isn't necessary
// to hide this portion of the text because it will be scrolled out of
// visibility anyway when we set the display offset below. However, if the
// user subsequently hovers over the URL to bring back the scheme and trivial
// subdomain, the hover animation assumes that the hidden text starts from
// transparent and fades it back in.
ApplyColor(SK_ColorTRANSPARENT, gfx::Range(0, host.begin));
// Before setting the display offset, set the display rect to the portion of
// the URL that won't be elided, or leave it at the local bounds, whichever is
// smaller. The display offset is capped at 0 if the text doesn't overflow the
// display rect, so we must fit the display rect to the text so that we can
// then set the display offset to scroll the scheme and trivial subdomain out
// of visibility.
GetRenderText()->SetDisplayRect(
gfx::Rect(current_display_rect.x(), display_url_bounds.y(),
display_url_bounds.width(), display_url_bounds.height()));
GetRenderText()->SetDisplayOffset(
-1 * (display_url_bounds.x() - current_display_rect.x()));
}
url::Component OmniboxViewViews::GetHostComponentAfterTrivialSubdomain() { url::Component OmniboxViewViews::GetHostComponentAfterTrivialSubdomain() {
url::Component host; url::Component host;
url::Component unused_scheme; url::Component unused_scheme;
......
...@@ -173,6 +173,9 @@ class OmniboxViewViews : public OmniboxView, ...@@ -173,6 +173,9 @@ class OmniboxViewViews : public OmniboxView,
FRIEND_TEST_ALL_PREFIXES( FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest, OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
UserInteractionAndHover); UserInteractionAndHover);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
SchemeAndTrivialSubdomainElision);
FRIEND_TEST_ALL_PREFIXES( FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest, OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
HideOnInteractionAfterFocusAndBlur); HideOnInteractionAfterFocusAndBlur);
...@@ -447,16 +450,27 @@ class OmniboxViewViews : public OmniboxView, ...@@ -447,16 +450,27 @@ class OmniboxViewViews : public OmniboxView,
// display. // display.
void OnShouldPreventElisionChanged(); void OnShouldPreventElisionChanged();
// Elides or unelides to a simplified version of the URL. Callers should // The methods below elide to or unelide from a simplified version of the URL.
// ensure that the URL is valid before calling. // Callers should ensure that the URL is valid before calling.
// //
// These methods do not animate, but rather immediately elide/unelide. These // These methods do not animate, but rather immediately elide/unelide. These
// methods are used when we don't want to draw the user's attention to the URL // methods are used when we don't want to draw the user's attention to the URL
// simplification -- for example, if the URL is already simplified and the // simplification -- for example, if the URL is already simplified and the
// user performs a same-document navigation, we want to keep the URL // user performs a same-document navigation, we want to keep the URL
// simplified without it appearing to be a change from the user's perspective. // simplified without it appearing to be a change from the user's perspective.
void ElideToSimplifiedDomain();
void UnelideFromSimplifiedDomain(); // Elides the URL to a simplified version of the domain. This will be the
// registrable domain if OmniboxFieldTrial::ShouldElideToRegistrableDomain()
// is true; otherwise it is the hostname with trivial subdomains ("www.")
// elided. The scheme, path, and other components of the URL are hidden.
void ElideURL();
// Show the full URL, including scheme, all subdomains, and path.
void ShowFullURL();
// Shows the full URL and then elides http/https schemes and the
// "www." subdomain (if present) by setting the display rect to the width of
// the remaining URL and then setting the display offset to scroll the scheme
// and trivial subdomain offscreen.
void ShowFullURLWithoutSchemeAndTrivialSubdomain();
// Parses GetText() as a URL, trims trivial subdomains from it (if any and if // Parses GetText() as a URL, trims trivial subdomains from it (if any and if
// applicable), and returns the result. // applicable), and returns the result.
...@@ -483,26 +497,19 @@ class OmniboxViewViews : public OmniboxView, ...@@ -483,26 +497,19 @@ class OmniboxViewViews : public OmniboxView,
// //
// These animations are used by different field trials as described below. // These animations are used by different field trials as described below.
// When ShouldRevealPathQueryRefOnHover() is enabled but not // This animation is used to unelide or elide the URL
// ShouldHidePathQueryRefOnInteraction(), then the URL is elided in // when the mouse hovers or exits the omnibox. The URL will unelide to the
// EmphasizeUrlComponents() and |hover_elide_or_unelide_animation_| is created // full URL or a partially elided version (with scheme and trivial subdomains
// in OnThemeChanged(). This animation is used to unelide or elide the URL // elided) depending on whether the user has interacted with the page yet
// when the mouse hovers or exits the omnibox. // (when reveal-on-interaction is enabled).
std::unique_ptr<ElideAnimation> hover_elide_or_unelide_animation_; std::unique_ptr<ElideAnimation> hover_elide_or_unelide_animation_;
// When ShouldHidePathQueryRefOnInteraction() is enabled, we don't // When ShouldHidePathQueryRefOnInteraction() is enabled, when a
// create any animations until the user interacts with the page. When a
// navigation finishes, we unelide the URL if it was a full cross-document // navigation finishes, we unelide the URL if it was a full cross-document
// navigation. Once the user interacts with the page, we create and run // navigation. Once the user interacts with the page, we create and run
// |elide_after_interaction_animation_| to elide the URL. If // |elide_after_interaction_animation_| to elide the URL. After the first user
// ShouldRevealPathQueryRefOnHover() is also enabled, we defer the creation of // interaction, |elide_after_interaction_animation_| doesn't run again until
// |hover_elide_or_unelide_animation_| until the user interacts with the page // it's re-created after the next navigation. There are 2 separate animations
// as well, since we don't want to do any hover animations until the URL has // (one for after-interaction and one hovering) so that the state of the
// been elided after user interaction. After the first user interaction,
// |elide_after_interaction_animation_| doesn't run again until it's
// re-created after the next navigation, and
// |hover_elide_or_unelide_animation_| behaves as described above for the rest
// of the navigation. There are 2 separate animations (one for
// after-interaction and one hovering) so that the state of the
// after-interaction animation can be queried to know when the user has or has // after-interaction animation can be queried to know when the user has or has
// not already interacted with the page. // not already interacted with the page.
std::unique_ptr<ElideAnimation> elide_after_interaction_animation_; std::unique_ptr<ElideAnimation> elide_after_interaction_animation_;
......
...@@ -255,6 +255,8 @@ const base::string16 kSimplifiedDomainDisplayUrlSubdomain = ...@@ -255,6 +255,8 @@ const base::string16 kSimplifiedDomainDisplayUrlSubdomain =
base::ASCIIToUTF16("foo."); base::ASCIIToUTF16("foo.");
const base::string16 kSimplifiedDomainDisplayUrlPath = const base::string16 kSimplifiedDomainDisplayUrlPath =
base::ASCIIToUTF16("/bar"); base::ASCIIToUTF16("/bar");
const base::string16 kSimplifiedDomainDisplayUrlScheme =
base::ASCIIToUTF16("https://");
class OmniboxViewViewsTest : public OmniboxViewViewsTestBase { class OmniboxViewViewsTest : public OmniboxViewViewsTestBase {
public: public:
...@@ -1451,16 +1453,17 @@ void ExpectElidedToSimplifiedDomain(gfx::RenderText* render_text, ...@@ -1451,16 +1453,17 @@ void ExpectElidedToSimplifiedDomain(gfx::RenderText* render_text,
} }
// Checks that |render_text|'s current display rect and offset displays all of // Checks that |render_text|'s current display rect and offset displays all of
// |display_url|. // |display_url|, starting at the leading edge.
void ExpectUnelidedFromSimplifiedDomain(gfx::RenderText* render_text, void ExpectUnelidedFromSimplifiedDomain(gfx::RenderText* render_text,
const base::string16& display_url) { const gfx::Range& display_url) {
gfx::Rect unelided_rect; gfx::Rect unelided_rect;
for (const auto& rect : for (const auto& rect : render_text->GetSubstringBounds(display_url)) {
render_text->GetSubstringBounds(gfx::Range(0, display_url.size()))) {
unelided_rect.Union(rect); unelided_rect.Union(rect);
} }
EXPECT_TRUE(render_text->display_rect().Contains(unelided_rect)); EXPECT_TRUE(render_text->display_rect().Contains(unelided_rect));
EXPECT_EQ(0, render_text->GetUpdatedDisplayOffset().x()); // |display_url| should be at the leading edge of |render_text|'s display
// rect.
EXPECT_EQ(unelided_rect.x(), render_text->display_rect().x());
} }
// Returns true if |render_text|'s current display rect and offset display at // Returns true if |render_text|'s current display rect and offset display at
...@@ -1531,7 +1534,8 @@ TEST_F(OmniboxViewViewsNoSimplifiedDomainTest, UrlNotSimplifiedByDefault) { ...@@ -1531,7 +1534,8 @@ TEST_F(OmniboxViewViewsNoSimplifiedDomainTest, UrlNotSimplifiedByDefault) {
SetUpSimplifiedDomainTest(); SetUpSimplifiedDomainTest();
omnibox_view()->EmphasizeURLComponents(); omnibox_view()->EmphasizeURLComponents();
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), kSimplifiedDomainDisplayUrl)); omnibox_view()->GetRenderText(),
gfx::Range(0, kSimplifiedDomainDisplayUrl.size())));
} }
class OmniboxViewViewsRevealOnHoverTest class OmniboxViewViewsRevealOnHoverTest
...@@ -1602,7 +1606,7 @@ TEST_P(OmniboxViewViewsRevealOnHoverTest, HoverAndExit) { ...@@ -1602,7 +1606,7 @@ TEST_P(OmniboxViewViewsRevealOnHoverTest, HoverAndExit) {
hover_animation_as_element->Step(base::TimeTicks() + hover_animation_as_element->Step(base::TimeTicks() +
base::TimeDelta::FromSeconds(1)); base::TimeDelta::FromSeconds(1));
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, kSimplifiedDomainDisplayUrl)); render_text, gfx::Range(0, kSimplifiedDomainDisplayUrl.size())));
EXPECT_FALSE(hover_animation->IsAnimating()); EXPECT_FALSE(hover_animation->IsAnimating());
EXPECT_FALSE(IsPathTransparent(omnibox_view(), kSimplifiedDomainDisplayUrl, EXPECT_FALSE(IsPathTransparent(omnibox_view(), kSimplifiedDomainDisplayUrl,
kSimplifiedDomainDisplayUrlHostnameAndScheme)); kSimplifiedDomainDisplayUrlHostnameAndScheme));
...@@ -1674,7 +1678,9 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest, ...@@ -1674,7 +1678,9 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
navigation.set_is_same_document(false); navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), kSimplifiedDomainDisplayUrl)); omnibox_view()->GetRenderText(),
gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
// Simulate a user interaction and check that the fade-out animation runs. // Simulate a user interaction and check that the fade-out animation runs.
omnibox_view()->DidGetUserInteraction( omnibox_view()->DidGetUserInteraction(
...@@ -1721,14 +1727,126 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest, ...@@ -1721,14 +1727,126 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
unelide_as_element->SetStartTime(base::TimeTicks()); unelide_as_element->SetStartTime(base::TimeTicks());
// Assume that the extended hover time + fade-in time is less than 2 seconds. // Assume that the extended hover time + fade-in time is less than 2 seconds.
unelide_as_element->Step(base::TimeTicks() + base::TimeDelta::FromSeconds(2)); unelide_as_element->Step(base::TimeTicks() + base::TimeDelta::FromSeconds(2));
// The hover should bring back the full URL, including scheme and trivial
// subdomains.
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), kSimplifiedDomainDisplayUrl)); omnibox_view()->GetRenderText(),
gfx::Range(0, kSimplifiedDomainDisplayUrl.size())));
EXPECT_FALSE(IsPathTransparent(omnibox_view(), kSimplifiedDomainDisplayUrl, EXPECT_FALSE(IsPathTransparent(omnibox_view(), kSimplifiedDomainDisplayUrl,
kSimplifiedDomainDisplayUrlHostnameAndScheme)); kSimplifiedDomainDisplayUrlHostnameAndScheme));
EXPECT_FALSE(IsSubdomainTransparent( EXPECT_FALSE(IsSubdomainTransparent(
omnibox_view(), kSimplifiedDomainDisplayUrlSubdomainAndScheme)); omnibox_view(), kSimplifiedDomainDisplayUrlSubdomainAndScheme));
} }
// Tests scheme and trivial subdomain elision when simplified domain field
// trials are enabled.
TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
SchemeAndTrivialSubdomainElision) {
// Use custom setup code instead of SetUpSimplifiedDomainTest() to use a URL
// with a "www." prefix (a trivial subdomain).
const base::string16 kFullUrl =
base::ASCIIToUTF16("https://www.example.test/foo");
constexpr size_t kSchemeAndSubdomainSize = 12; // "https://www."
location_bar_model()->set_url(GURL("https://www.example.test/foo"));
location_bar_model()->set_url_for_display(kFullUrl);
omnibox_view()->model()->ResetDisplayTexts();
omnibox_view()->RevertAll();
omnibox_view()->OnThemeChanged();
gfx::RenderText* render_text = omnibox_view()->GetRenderText();
content::MockNavigationHandle navigation;
navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(),
gfx::Range(kSchemeAndSubdomainSize, kFullUrl.size())));
EXPECT_EQ(SK_ColorTRANSPARENT, omnibox_view()->GetLatestColorForRange(
gfx::Range(0, kSchemeAndSubdomainSize)));
// Hovering before user interaction should bring back the scheme and trivial
// subdomain.
omnibox_view()->OnMouseMoved(CreateMouseEvent(ui::ET_MOUSE_MOVED, {0, 0}));
OmniboxViewViews::ElideAnimation* unelide_animation =
omnibox_view()->GetHoverElideOrUnelideAnimationForTesting();
ASSERT_TRUE(unelide_animation);
EXPECT_TRUE(unelide_animation->IsAnimating());
gfx::AnimationContainerElement* unelide_as_element =
static_cast<gfx::AnimationContainerElement*>(
unelide_animation->GetAnimationForTesting());
unelide_as_element->SetStartTime(base::TimeTicks());
unelide_as_element->Step(base::TimeTicks() + base::TimeDelta::FromSeconds(2));
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), gfx::Range(0, kFullUrl.size())));
EXPECT_NE(SK_ColorTRANSPARENT, omnibox_view()->GetLatestColorForRange(
gfx::Range(0, kSchemeAndSubdomainSize)));
// After mousing out, the scheme should fade out again.
omnibox_view()->OnMouseExited(CreateMouseEvent(ui::ET_MOUSE_MOVED, {0, 0}));
OmniboxViewViews::ElideAnimation* elide_animation =
omnibox_view()->GetHoverElideOrUnelideAnimationForTesting();
ASSERT_TRUE(elide_animation);
EXPECT_TRUE(elide_animation->IsAnimating());
gfx::AnimationContainerElement* elide_as_element =
static_cast<gfx::AnimationContainerElement*>(
elide_animation->GetAnimationForTesting());
elide_as_element->SetStartTime(base::TimeTicks());
elide_as_element->Step(base::TimeTicks() + base::TimeDelta::FromSeconds(2));
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(),
gfx::Range(kSchemeAndSubdomainSize, kSimplifiedDomainDisplayUrl.size())));
EXPECT_EQ(SK_ColorTRANSPARENT, omnibox_view()->GetLatestColorForRange(
gfx::Range(0, kSchemeAndSubdomainSize)));
// Simulate a user interaction and check that the URL gets elided to the
// simplified domain.
omnibox_view()->DidGetUserInteraction(
blink::WebInputEvent::Type::kGestureScrollBegin);
elide_animation =
omnibox_view()->GetElideAfterInteractionAnimationForTesting();
EXPECT_TRUE(elide_animation->IsAnimating());
elide_as_element = static_cast<gfx::AnimationContainerElement*>(
elide_animation->GetAnimationForTesting());
elide_as_element->SetStartTime(base::TimeTicks());
elide_as_element->Step(base::TimeTicks() + base::TimeDelta::FromSeconds(2));
ASSERT_NO_FATAL_FAILURE(ExpectElidedToSimplifiedDomain(
render_text, base::ASCIIToUTF16("https://www."),
base::ASCIIToUTF16("www."),
base::ASCIIToUTF16("https://www.example.test"),
base::ASCIIToUTF16("/foo"), ShouldElideToRegistrableDomain()));
// Do another hover and check that the URL gets unelided to the full URL.
omnibox_view()->OnMouseMoved(CreateMouseEvent(ui::ET_MOUSE_MOVED, {0, 0}));
elide_animation = omnibox_view()->GetHoverElideOrUnelideAnimationForTesting();
ASSERT_TRUE(unelide_animation);
EXPECT_TRUE(unelide_animation->IsAnimating());
unelide_as_element = static_cast<gfx::AnimationContainerElement*>(
unelide_animation->GetAnimationForTesting());
unelide_as_element->SetStartTime(base::TimeTicks());
unelide_as_element->Step(base::TimeTicks() + base::TimeDelta::FromSeconds(2));
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), gfx::Range(0, kFullUrl.size())));
EXPECT_NE(SK_ColorTRANSPARENT, omnibox_view()->GetLatestColorForRange(
gfx::Range(0, kSchemeAndSubdomainSize)));
// And after another mouse exit, the URL should go back to the simplified
// domain.
omnibox_view()->OnMouseExited(CreateMouseEvent(ui::ET_MOUSE_MOVED, {0, 0}));
elide_animation = omnibox_view()->GetHoverElideOrUnelideAnimationForTesting();
ASSERT_TRUE(elide_animation);
EXPECT_TRUE(elide_animation->IsAnimating());
elide_as_element = static_cast<gfx::AnimationContainerElement*>(
elide_animation->GetAnimationForTesting());
elide_as_element->SetStartTime(base::TimeTicks());
elide_as_element->Step(base::TimeTicks() + base::TimeDelta::FromSeconds(2));
ASSERT_NO_FATAL_FAILURE(ExpectElidedToSimplifiedDomain(
render_text, base::ASCIIToUTF16("https://www."),
base::ASCIIToUTF16("www."),
base::ASCIIToUTF16("https://www.example.test"),
base::ASCIIToUTF16("/foo"), ShouldElideToRegistrableDomain()));
EXPECT_EQ(SK_ColorTRANSPARENT, omnibox_view()->GetLatestColorForRange(
gfx::Range(0, kSchemeAndSubdomainSize)));
}
class OmniboxViewViewsHideOnInteractionTest class OmniboxViewViewsHideOnInteractionTest
: public OmniboxViewViewsTest, : public OmniboxViewViewsTest,
public ::testing::WithParamInterface<bool> { public ::testing::WithParamInterface<bool> {
...@@ -1780,7 +1898,7 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, AlwaysShowFullURLs) { ...@@ -1780,7 +1898,7 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, AlwaysShowFullURLs) {
omnibox_view()->OnTabChanged(web_contents.get()); omnibox_view()->OnTabChanged(web_contents.get());
EXPECT_EQ(kFullUrl, omnibox_view()->GetText()); EXPECT_EQ(kFullUrl, omnibox_view()->GetText());
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), kFullUrl)); omnibox_view()->GetRenderText(), gfx::Range(0, kFullUrl.size())));
// When the Always Show Full URLs pref is enabled, the omnibox view won't // When the Always Show Full URLs pref is enabled, the omnibox view won't
// observe user interactions and elide the URL. // observe user interactions and elide the URL.
...@@ -1885,7 +2003,9 @@ TEST_P(OmniboxViewViewsRevealOnHoverAndMaybeHideOnInteractionTest, ...@@ -1885,7 +2003,9 @@ TEST_P(OmniboxViewViewsRevealOnHoverAndMaybeHideOnInteractionTest,
EXPECT_EQ(base::ASCIIToUTF16("https://www.example.test/foo"), EXPECT_EQ(base::ASCIIToUTF16("https://www.example.test/foo"),
omnibox_view()->GetText()); omnibox_view()->GetText());
if (IsHideOnInteractionEnabled()) { if (IsHideOnInteractionEnabled()) {
ExpectUnelidedFromSimplifiedDomain(render_text, omnibox_view()->GetText()); ExpectUnelidedFromSimplifiedDomain(
render_text,
gfx::Range(std::string("https://www.").size(), kFullUrl.size()));
// Simulate a user interaction and check the fade-out animation. // Simulate a user interaction and check the fade-out animation.
omnibox_view()->DidGetUserInteraction( omnibox_view()->DidGetUserInteraction(
blink::WebInputEvent::Type::kGestureScrollBegin); blink::WebInputEvent::Type::kGestureScrollBegin);
...@@ -1897,12 +2017,12 @@ TEST_P(OmniboxViewViewsRevealOnHoverAndMaybeHideOnInteractionTest, ...@@ -1897,12 +2017,12 @@ TEST_P(OmniboxViewViewsRevealOnHoverAndMaybeHideOnInteractionTest,
// Even though kElideToRegistrableDomain is disabled, we expect to be elided // Even though kElideToRegistrableDomain is disabled, we expect to be elided
// to the registrable domain because the www subdomain is considered // to the registrable domain because the www subdomain is considered
// trivial. // trivial.
ExpectElidedToSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectElidedToSimplifiedDomain(
render_text, base::ASCIIToUTF16("https://www."), render_text, base::ASCIIToUTF16("https://www."),
base::ASCIIToUTF16("www."), base::ASCIIToUTF16("www."),
base::ASCIIToUTF16("https://www.example.test"), base::ASCIIToUTF16("https://www.example.test"),
base::ASCIIToUTF16("/foo"), base::ASCIIToUTF16("/foo"),
true /* should elide to registrable domain */); true /* should elide to registrable domain */));
} }
// Simulate a hover event and check the elide/unelide animations. This // Simulate a hover event and check the elide/unelide animations. This
// should happen the same regardless of whether hide-on-interaction is // should happen the same regardless of whether hide-on-interaction is
...@@ -1928,7 +2048,9 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest, ...@@ -1928,7 +2048,9 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
navigation.set_is_same_document(false); navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), kSimplifiedDomainDisplayUrl)); omnibox_view()->GetRenderText(),
gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
// Simulate a user interaction and check that the fade-out animation runs. // Simulate a user interaction and check that the fade-out animation runs.
omnibox_view()->DidGetUserInteraction( omnibox_view()->DidGetUserInteraction(
...@@ -1959,13 +2081,17 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest, ...@@ -1959,13 +2081,17 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
navigation.set_is_same_document(false); navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), kSimplifiedDomainDisplayUrl)); omnibox_view()->GetRenderText(),
gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
// After a navigation, the URL should not be elided to the simplified domain, // After a navigation, the URL should not be elided to the simplified domain,
// and the display rect (including vertical and horizontal position) should be // and the display rect (including vertical and horizontal position) should be
// unchanged. // unchanged.
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
omnibox_view()->GetRenderText(), kSimplifiedDomainDisplayUrl)); omnibox_view()->GetRenderText(),
gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
EXPECT_EQ(original_display_rect, render_text->display_rect()); EXPECT_EQ(original_display_rect, render_text->display_rect());
// Simulate a user interaction to elide to simplified domain and advance // Simulate a user interaction to elide to simplified domain and advance
...@@ -2011,7 +2137,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, SameDocNavigations) { ...@@ -2011,7 +2137,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, SameDocNavigations) {
navigation.set_is_same_document(false); navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, kSimplifiedDomainDisplayUrl)); render_text, gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
} }
// On a same-document navigation before the URL has been simplified, the URL // On a same-document navigation before the URL has been simplified, the URL
...@@ -2021,7 +2148,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, SameDocNavigations) { ...@@ -2021,7 +2148,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, SameDocNavigations) {
navigation.set_is_same_document(true); navigation.set_is_same_document(true);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, kSimplifiedDomainDisplayUrl)); render_text, gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
OmniboxViewViews::ElideAnimation* elide_animation = OmniboxViewViews::ElideAnimation* elide_animation =
omnibox_view()->GetElideAfterInteractionAnimationForTesting(); omnibox_view()->GetElideAfterInteractionAnimationForTesting();
EXPECT_FALSE(elide_animation); EXPECT_FALSE(elide_animation);
...@@ -2042,7 +2170,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, SameDocNavigations) { ...@@ -2042,7 +2170,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, SameDocNavigations) {
navigation.set_is_same_document(false); navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, kSimplifiedDomainDisplayUrl)); render_text, gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
OmniboxViewViews::ElideAnimation* elide_animation = OmniboxViewViews::ElideAnimation* elide_animation =
omnibox_view()->GetElideAfterInteractionAnimationForTesting(); omnibox_view()->GetElideAfterInteractionAnimationForTesting();
EXPECT_FALSE(elide_animation); EXPECT_FALSE(elide_animation);
...@@ -2098,7 +2227,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, ...@@ -2098,7 +2227,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest,
navigation.set_is_same_document(false); navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, kSimplifiedDomainDisplayUrl)); render_text, gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
// Simulate a user interaction to begin animating to the simplified domain. // Simulate a user interaction to begin animating to the simplified domain.
omnibox_view()->DidGetUserInteraction( omnibox_view()->DidGetUserInteraction(
...@@ -2160,7 +2290,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, UserInteractionDuringAnimation) { ...@@ -2160,7 +2290,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, UserInteractionDuringAnimation) {
navigation.set_is_same_document(false); navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, kSimplifiedDomainDisplayUrl)); render_text, gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
// Simulate a user interaction to begin animating to the simplified domain. // Simulate a user interaction to begin animating to the simplified domain.
omnibox_view()->DidGetUserInteraction( omnibox_view()->DidGetUserInteraction(
...@@ -2216,7 +2347,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, SubframeNavigations) { ...@@ -2216,7 +2347,8 @@ TEST_P(OmniboxViewViewsHideOnInteractionTest, SubframeNavigations) {
navigation.set_is_same_document(false); navigation.set_is_same_document(false);
omnibox_view()->DidFinishNavigation(&navigation); omnibox_view()->DidFinishNavigation(&navigation);
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain( ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, kSimplifiedDomainDisplayUrl)); render_text, gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
} }
// Simulate a user interaction to elide to the simplified domain, and advance // Simulate a user interaction to elide to the simplified domain, and advance
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment