Index: chrome/browser/ui/libgtkui/gtk_util.cc |
diff --git a/chrome/browser/ui/libgtkui/gtk_util.cc b/chrome/browser/ui/libgtkui/gtk_util.cc |
index 6b83e386e6f109608d19937329ffc16bbd265078..aab971785907c7b330a0fd56d43f49e7cde63823 100644 |
--- a/chrome/browser/ui/libgtkui/gtk_util.cc |
+++ b/chrome/browser/ui/libgtkui/gtk_util.cc |
@@ -19,6 +19,7 @@ |
#include "ui/base/accelerators/accelerator.h" |
#include "ui/events/event_constants.h" |
#include "ui/events/keycodes/keyboard_code_conversion_x.h" |
+#include "ui/gfx/color_utils.h" |
#include "ui/gfx/geometry/size.h" |
namespace { |
@@ -52,6 +53,52 @@ void CommonInitFromCommandLine(const base::CommandLine& command_line, |
namespace libgtkui { |
+// Theme colors returned by GetSystemColor(). |
+const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); |
+const SkColor kURLTextColor = SkColorSetRGB(0x0b, 0x80, 0x43); |
+ |
+SkColor NormalURLColor(SkColor foreground) { |
+ color_utils::HSL fg_hsl, hue_hsl; |
+ color_utils::SkColorToHSL(foreground, &fg_hsl); |
+ color_utils::SkColorToHSL(kURLTextColor, &hue_hsl); |
+ |
+ // Only allow colors that have a fair amount of saturation in them (color vs |
+ // white). This means that our output color will always be fairly green. |
+ double s = std::max(0.5, fg_hsl.s); |
+ |
+ // Make sure the luminance is at least as bright as the |kURLTextColor| green |
+ // would be if we were to use that. |
+ double l; |
+ if (fg_hsl.l < hue_hsl.l) |
+ l = hue_hsl.l; |
+ else |
+ l = (fg_hsl.l + hue_hsl.l) / 2; |
+ |
+ color_utils::HSL output = {hue_hsl.h, s, l}; |
+ return color_utils::HSLToSkColor(output, 255); |
+} |
+ |
+SkColor SelectedURLColor(SkColor foreground, SkColor background) { |
+ color_utils::HSL fg_hsl, bg_hsl, hue_hsl; |
+ color_utils::SkColorToHSL(foreground, &fg_hsl); |
+ color_utils::SkColorToHSL(background, &bg_hsl); |
+ color_utils::SkColorToHSL(kURLTextColor, &hue_hsl); |
+ |
+ // The saturation of the text should be opposite of the background, clamped |
+ // to 0.2-0.8. We make sure it's greater than 0.2 so there's some color, but |
+ // less than 0.8 so it's not the oversaturated neon-color. |
+ double opposite_s = 1 - bg_hsl.s; |
+ double s = std::max(0.2, std::min(0.8, opposite_s)); |
+ |
+ // The luminance should match the luminance of the foreground text. Again, |
+ // we clamp so as to have at some amount of color (green) in the text. |
+ double opposite_l = fg_hsl.l; |
+ double l = std::max(0.1, std::min(0.9, opposite_l)); |
+ |
+ color_utils::HSL output = {hue_hsl.h, s, l}; |
+ return color_utils::HSLToSkColor(output, 255); |
+} |
+ |
void GtkInitFromCommandLine(const base::CommandLine& command_line) { |
CommonInitFromCommandLine(command_line, gtk_init); |
} |