Commit 05f7b76b authored by Emily Stark's avatar Emily Stark Committed by Commit Bot

Simplified domains: undo transparency when showing full URL

In the simplified domain field trials, the path, scheme, and
optionally subdomains get faded to transparent when the user interacts
with the page or after the user hovers and exits the mouse. But there
are various ways that it's possible to transition from this state
(path, scheme, subdomains faded out) to showing the full URL. However,
the method that shows the full URL wasn't applying any color changes,
only changing the display area/offset. This could lead to some
situations where the full URL is scrolled into view, but some parts of
it were still transparent (see bug for repro). To fix this,
ShowFullURL() now resets the text color and applies emphasis by
calling EmphasizeURLComponents(). This ensures that all components of
the URL are not just scrolled into the display area but also colored
properly and not transparent.

Bug: 1106478
Change-Id: Ifc57b33c8e6604764ca004a7035c382465711b67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2305031
Commit-Queue: Emily Stark <estark@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789691}
parent 7a1a3bdc
......@@ -2431,6 +2431,15 @@ void OmniboxViewViews::ShowFullURL() {
elide_after_interaction_animation_->Stop();
ApplyCaretVisibility();
FitToLocalBounds();
// Previous animations or elisions might have faded the path and/or subdomains
// to transparent, so reset their color now that they should be visible.
ApplyColor(GetOmniboxColor(GetThemeProvider(),
OmniboxPart::LOCATION_BAR_TEXT_DIMMED),
gfx::Range(0, GetText().size()));
UpdateTextStyle(GetText(), model()->CurrentTextIsURL(),
model()->client()->GetSchemeClassifier());
GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL);
}
......
......@@ -2505,10 +2505,32 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
kSimplifiedDomainDisplayUrlHostnameAndScheme,
kSimplifiedDomainDisplayUrlPath, ShouldElideToRegistrableDomain()));
// Now focus and blur the omnibox. After blur, the path should fade out again
// after another user interaction.
// After focus, the URL should be fully unelided.
omnibox_view()->OnFocus();
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, gfx::Range(0, kSimplifiedDomainDisplayUrl.size())));
EXPECT_NE(SK_ColorTRANSPARENT,
omnibox_view()->GetLatestColorForRange(
gfx::Range(0, omnibox_view()->GetText().size())));
EXPECT_EQ(gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrlHostnameAndScheme.size()),
omnibox_view()->emphasis_range());
// After blur, the URL should return to the same state as page load: only
// scheme and trivial subdomains elided.
omnibox_view()->OnBlur();
ASSERT_NO_FATAL_FAILURE(ExpectUnelidedFromSimplifiedDomain(
render_text, gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrl.size())));
EXPECT_NE(SK_ColorTRANSPARENT,
omnibox_view()->GetLatestColorForRange(
gfx::Range(0, omnibox_view()->GetText().size())));
EXPECT_EQ(gfx::Range(kSimplifiedDomainDisplayUrlScheme.size(),
kSimplifiedDomainDisplayUrlHostnameAndScheme.size()),
omnibox_view()->emphasis_range());
// After a post-blur user interaction, the URL should animate to the
// simplified domain.
omnibox_view()->DidGetUserInteraction(
blink::WebInputEvent::Type::kGestureScrollBegin);
elide_animation =
......
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