[Demo] Animate background colors on url focus change [chromium/src : main]

0 views
Skip to first unread message

Sirisha Kavuluru (Gerrit)

unread,
Oct 1, 2025, 4:51:22 PMOct 1
to Neil Coronado, chromium...@chromium.org, hanxi...@chromium.org, peilinwa...@google.com
Attention needed from Neil Coronado

Sirisha Kavuluru added 1 comment

File chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java
Line 2366, Patchset 4 (Latest): // Set the initial state to ensure the delayed transition animates from the correct starting
// values.
updateBackground(!hasFocus);
updateToolbarAndLocationBarColorForFocusChange(hasFocus ? 0f : 1f);
Sirisha Kavuluru . unresolved

What happens if we dont set this?

Open in Gerrit

Related details

Attention is currently required from:
  • Neil Coronado
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia16b4288b80816ce31237e7614a25e30e4699a29
Gerrit-Change-Number: 6908601
Gerrit-PatchSet: 4
Gerrit-Owner: Neil Coronado <ne...@google.com>
Gerrit-CC: Sirisha Kavuluru <skav...@google.com>
Gerrit-Attention: Neil Coronado <ne...@google.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 20:51:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Neil Coronado (Gerrit)

unread,
Oct 1, 2025, 6:04:28 PMOct 1
to Sirisha Kavuluru, chromium...@chromium.org, hanxi...@chromium.org, peilinwa...@google.com
Attention needed from Sirisha Kavuluru

Neil Coronado added 1 comment

File chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java
Line 2366, Patchset 4 (Latest): // Set the initial state to ensure the delayed transition animates from the correct starting
// values.
updateBackground(!hasFocus);
updateToolbarAndLocationBarColorForFocusChange(hasFocus ? 0f : 1f);
Sirisha Kavuluru . unresolved

What happens if we dont set this?

Neil Coronado

Sync'd offline; I _think_ this we needed to set the correct starting color & corner radius specifically for the NTP (as we swap drawables on NTP), and I was seeing stale starting color in testing.

I also think the `updateBackground` call is unnecessary. Will revisit.

Open in Gerrit

Related details

Attention is currently required from:
  • Sirisha Kavuluru
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia16b4288b80816ce31237e7614a25e30e4699a29
Gerrit-Change-Number: 6908601
Gerrit-PatchSet: 4
Gerrit-Owner: Neil Coronado <ne...@google.com>
Gerrit-CC: Sirisha Kavuluru <skav...@google.com>
Gerrit-Attention: Sirisha Kavuluru <skav...@google.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 22:04:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Sirisha Kavuluru <skav...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Neil Coronado (Gerrit)

unread,
Oct 1, 2025, 6:28:24 PMOct 1
to Sirisha Kavuluru, chromium...@chromium.org, hanxi...@chromium.org, peilinwa...@google.com
Attention needed from Sirisha Kavuluru

Neil Coronado added 1 comment

File chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java
Line 2366, Patchset 4 (Latest): // Set the initial state to ensure the delayed transition animates from the correct starting
// values.
updateBackground(!hasFocus);
updateToolbarAndLocationBarColorForFocusChange(hasFocus ? 0f : 1f);
Sirisha Kavuluru . unresolved

What happens if we dont set this?

Neil Coronado

Sync'd offline; I _think_ this we needed to set the correct starting color & corner radius specifically for the NTP (as we swap drawables on NTP), and I was seeing stale starting color in testing.

I also think the `updateBackground` call is unnecessary. Will revisit.

Neil Coronado

To be more specific, I _think_ that when we unfocus, we:

  • already have the focused-colored location bar drawable
  • switch to NTP drawable
  • run transition
  • observe that since we've already switched to the NTP drawable, we _do not_ change the location bar drawable from the focused-color -> unfocused-color.

So when we would next focus, we would

  • switch to the location bar drawable
  • observe that it's still the (old) focused-color
  • run transition
  • observe that the color does not animate, as it already started at the focused-color.

I'm not sure what the ideal pattern is here. I think it'd be preferable if we could:

  • avoid changing the current properties
  • `#beginDelayedTransition`
  • `#setEndProperties(hasFocus)`

But there's some state that might not be correctly set at the start of the transition. Namely the drawable state & potentially the location bar bounds (if it's not being updated while invisible due to the fakebox showing instead). So we may want to:

  • `#setEndProperties(!hasFocus)`
  • `#beginDelayedTransition`
  • `#setEndProperties(hasFocus)`

Though unclear if some things would still need to be special-cased.

Open in Gerrit

Related details

Attention is currently required from:
  • Sirisha Kavuluru
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia16b4288b80816ce31237e7614a25e30e4699a29
Gerrit-Change-Number: 6908601
Gerrit-PatchSet: 4
Gerrit-Owner: Neil Coronado <ne...@google.com>
Gerrit-CC: Sirisha Kavuluru <skav...@google.com>
Gerrit-Attention: Sirisha Kavuluru <skav...@google.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 22:28:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Sirisha Kavuluru <skav...@google.com>
Comment-In-Reply-To: Neil Coronado <ne...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Neil Coronado (Gerrit)

unread,
Oct 1, 2025, 6:39:11 PMOct 1
to Sirisha Kavuluru, chromium...@chromium.org, hanxi...@chromium.org, peilinwa...@google.com
File chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java
Neil Coronado

Also oops, the `updateBackground(!hasFocus);` is currently required, since when unfocusing, we've already switched to the NTP drawable in `#onUrlFocusChange`.

The NTP drawable doesn't currently change color (instead, with the flag disabled, we interpolate the location bar drawable properties while translating down, then switch to the NTP drawable when the bounds + color + corners matched the NTP drawable).

So it's awkward, but we:
1. switch to NTP drawable in `#onUrlFocusChange` -> `updateBackground(hasFocus);`
2. switch back to the location bar drawable with `updateBackground(!hasFocus);`
3. grab the correct starting color in `#beginDelayedTransition`
4. switch back to the NTP drawable with `updateBackground(hasFocus);`
5. animate the NTP drawable's properties in the transition.

This is also why we need to `#mutate()` the NTP drawable, as we're now changing its state in the transition, which we didn't do before.

It might be cleaner to just move the call from 1. to the animator methods; I don't have a strong opinion yet.

Open in Gerrit

Related details

Attention is currently required from:
  • Sirisha Kavuluru
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia16b4288b80816ce31237e7614a25e30e4699a29
Gerrit-Change-Number: 6908601
Gerrit-PatchSet: 4
Gerrit-Owner: Neil Coronado <ne...@google.com>
Gerrit-CC: Sirisha Kavuluru <skav...@google.com>
Gerrit-Attention: Sirisha Kavuluru <skav...@google.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 22:39:01 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Sirisha Kavuluru (Gerrit)

unread,
4:27 PM (3 hours ago) 4:27 PM
to Neil Coronado, chromium...@chromium.org, hanxi...@chromium.org, peilinwa...@google.com
Attention needed from Neil Coronado

Sirisha Kavuluru added 1 comment

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Sirisha Kavuluru . resolved

Removing from my attention set. Please add me back when ready for review

Open in Gerrit

Related details

Attention is currently required from:
  • Neil Coronado
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ia16b4288b80816ce31237e7614a25e30e4699a29
    Gerrit-Change-Number: 6908601
    Gerrit-PatchSet: 4
    Gerrit-Owner: Neil Coronado <ne...@google.com>
    Gerrit-CC: Sirisha Kavuluru <skav...@google.com>
    Gerrit-Attention: Neil Coronado <ne...@google.com>
    Gerrit-Comment-Date: Mon, 20 Oct 2025 20:27:10 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages