New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 854255 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Last visit 15 days ago
Closed: Sep 12
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

Caption button glyph color does not take IDR_THEME_WINDOW_CONTROL_BACKGROUND into account

Project Member Reported by pkasting@chromium.org, Jun 19 2018

Issue description

Install https://chrome.google.com/webstore/detail/into-the-mist/mgihmkgobaljfehcadcckdggpeojaadh .  Deactivate the window.  Notice that the caption button glyphs turn black despite the frame image and caption button background color not changing.

Maybe the theme is specifying a different inactive frame color and we're keying off that?  I wonder if we need to be smarter somehow here about knowing what color is "really" appearing under the caption button glyph.
 
Labels: -Pri-2 Pri-3
Summary: Caption button glyph color does not take IDR_THEME_WINDOW_CONTROL_BACKGROUND into account (was: Caption button glyph color chosen poorly for inactive window)
kylixrd@ looked at this a bit.  It looks like the theme claims it has a darkish active frame color and a light inactive frame color, even though in reality the frame color is always light.  COLOR_BUTTON_BACKGROUND is fully-transparent, so the glyph is computed against these reported colors; thus the change from white active to black inactive.

Amusingly, if the theme reported more accurately that both active and inactive frames were light, we'd get unreadable caption glyphs all the time.

The issue here, AFAICT, is that the theme has a dark IDR_THEME_WINDOW_CONTROL_BACKGROUND, but there's nothing in the glyph color code that takes this into account.  I think the only real foolproof thing to do here is basically, when the colors change, actually render the caption button background into a buffer (i.e. draw the frame color, then the button background, then the window control background), then use color_utils:BuildLumaHistogram() or some other sampling code to compute whether this is dark or light, and pick the contrasting glyph color; then cache the result, since this is an expensive operation.
Note: color_utils::CalculateKMeanColorOfBitmap() can give you the "dominant color" of an SkBitmap. groby@ thinks picking a contrasting color to this would give better results than the luma histogram route for more types of images.  Computing this is expensive, so we'd want to do it only during theme load.

OTOH maybe we don't need to try this hard because people don't use complicated patterned images for IDR_THEME_WINDOW_CONTROL_BACKGROUND.
Cc: msw@chromium.org
https://chrome.google.com/webstore/detail/marc-ecko/opjonmehjfmkejjifhhknofdnacklmjk is another theme that behaves badly, maybe due to this.

An example of computing the K-mean color of a bitmap during theme load is in https://chromium-review.googlesource.com/c/chromium/src/+/1152517 .
Cc: bsep@chromium.org
Owner: rameier@chromium.org
Project Member

Comment 5 by bugdroid1@chromium.org, Sep 12

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2e300ead1caefdeb60afd77073d114b08768ab88

commit 2e300ead1caefdeb60afd77073d114b08768ab88
Author: Ryan Meier <rameier@chromium.org>
Date: Wed Sep 12 15:40:58 2018

Make the Windows Caption Button color contrast with its background.

BrowserThemePack now calculates expected average background colors for control buttons, based on frame color, button background color, and a window control background image (as applicable).  Windows10CaptionButton then uses these calculated colors to determine what color to draw the button foregrounds, ensuring that there is sufficient contrast between the background and the foreground.

Additionally, the theme's Caption Button BG image now appears to draw contiguously behind all of the caption buttons.

Bug:  854255 
Change-Id: I4adacd4fb066b840476fcf74036b2c2d524e1899
Reviewed-on: https://chromium-review.googlesource.com/1182412
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Bret Sepulveda <bsep@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Commit-Queue: Ryan Meier <rameier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590692}
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/themes/browser_theme_pack.cc
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/themes/browser_theme_pack.h
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/themes/browser_theme_pack_unittest.cc
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/themes/theme_properties.h
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/ui/BUILD.gn
[add] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/ui/frame/OWNERS
[add] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/ui/frame/window_frame_util.cc
[add] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/ui/frame/window_frame_util.h
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/ui/views/frame/windows_10_caption_button.cc
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/browser/ui/views/frame/windows_10_caption_button.h
[add] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/test/data/extensions/theme_test_captionbutton_buttoncolor/manifest.json
[add] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/test/data/extensions/theme_test_captionbutton_buttonimage/images/control_button_bg.png
[add] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/test/data/extensions/theme_test_captionbutton_buttonimage/manifest.json
[add] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/test/data/extensions/theme_test_captionbutton_framecolor/manifest.json
[modify] https://crrev.com/2e300ead1caefdeb60afd77073d114b08768ab88/chrome/test/data/extensions/theme_testinherittextcolor_withincog/manifest.json

Status: Fixed (was: Assigned)
Cc: robliao@chromium.org pkasting@chromium.org
 Issue 887564  has been merged into this issue.

Sign in to add a comment