Commit 9125a821 authored by estade's avatar estade Committed by Commit bot

[MD] fix bookmark bar/URL bar drag image color for OTR mode.

Do this by using textfield colors instead of label default colors. The change to
pre-MD and non-OTR should be extremely minimal (text that's \#222 becomes
\#000). The same colors are used regardless of the drag source (bookmark bar or
location bar), and this just matches the location bar instead of the bookmark
bar. Either way it's hard to notice a difference anywhere except MD OTR mode.

Also support systems without translucency better. We don't need a text shadow
but we do need a background (and border) on these systems.

BUG=581239

Review URL: https://codereview.chromium.org/1633793003

Cr-Commit-Position: refs/heads/master@{#371544}
parent 5897360a
...@@ -14,7 +14,10 @@ ...@@ -14,7 +14,10 @@
#include "ui/gfx/geometry/vector2d.h" #include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/resources/grit/ui_resources.h" #include "ui/resources/grit/ui_resources.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/drag_utils.h" #include "ui/views/drag_utils.h"
#include "ui/views/resources/grit/views_resources.h" #include "ui/views/resources/grit/views_resources.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -49,13 +52,17 @@ void SetDragImage(const GURL& url, ...@@ -49,13 +52,17 @@ void SetDragImage(const GURL& url,
button.SetTextSubpixelRenderingEnabled(false); button.SetTextSubpixelRenderingEnabled(false);
const ui::NativeTheme* theme = widget->GetNativeTheme(); const ui::NativeTheme* theme = widget->GetNativeTheme();
button.SetTextColor(views::Button::STATE_NORMAL, button.SetTextColor(views::Button::STATE_NORMAL,
theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor)); theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor));
gfx::ShadowValues shadows(
10, SkColor bg_color = theme->GetSystemColor(
gfx::ShadowValue(gfx::Vector2d(0, 0), 1.0f, ui::NativeTheme::kColorId_TextfieldDefaultBackground);
theme->GetSystemColor( if (widget->IsTranslucentWindowOpacitySupported()) {
ui::NativeTheme::kColorId_LabelBackgroundColor))); button.SetTextShadows(gfx::ShadowValues(
button.SetTextShadows(shadows); 10, gfx::ShadowValue(gfx::Vector2d(0, 0), 1.0f, bg_color)));
} else {
button.set_background(views::Background::CreateSolidBackground(bg_color));
button.SetBorder(button.CreateDefaultBorder());
}
button.SetMaxSize(gfx::Size(kLinkDragImageMaxWidth, 0)); button.SetMaxSize(gfx::Size(kLinkDragImageMaxWidth, 0));
if (icon.isNull()) { if (icon.isNull()) {
button.SetImage(views::Button::STATE_NORMAL, button.SetImage(views::Button::STATE_NORMAL,
......
...@@ -14,9 +14,6 @@ namespace { ...@@ -14,9 +14,6 @@ namespace {
float GetDeviceScaleForNativeView(views::Widget* widget) { float GetDeviceScaleForNativeView(views::Widget* widget) {
float device_scale = 1.0f; float device_scale = 1.0f;
// The following code should work on other platforms as well. But we do not
// yet care about device scale factor on other platforms. So to keep drag and
// drop behavior on other platforms un-touched, we wrap this in the #if guard.
if (widget && widget->GetNativeView()) { if (widget && widget->GetNativeView()) {
gfx::NativeView view = widget->GetNativeView(); gfx::NativeView view = widget->GetNativeView();
gfx::Display display = gfx::Screen::GetScreenFor(view)-> gfx::Display display = gfx::Screen::GetScreenFor(view)->
......
...@@ -209,13 +209,12 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, ...@@ -209,13 +209,12 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
WidgetDelegate* delegate; WidgetDelegate* delegate;
bool child; bool child;
// If TRANSLUCENT_WINDOW, the widget may be fully or partially transparent. // If TRANSLUCENT_WINDOW, the widget may be fully or partially transparent.
// Translucent windows may not always be supported. Use
// IsTranslucentWindowOpacitySupported to determine if translucent windows
// are supported.
// If OPAQUE_WINDOW, we can perform optimizations based on the widget being // If OPAQUE_WINDOW, we can perform optimizations based on the widget being
// fully opaque. Defaults to TRANSLUCENT_WINDOW if // fully opaque.
// ViewsDelegate::UseTransparentWindows(). Defaults to OPAQUE_WINDOW for // Default is based on ViewsDelegate::GetOpacityForInitParams(). Defaults
// non-window widgets. // to OPAQUE_WINDOW for non-window widgets.
// Translucent windows may not always be supported. Use
// IsTranslucentWindowOpacitySupported to determine whether they are.
WindowOpacity opacity; WindowOpacity opacity;
bool accept_events; bool accept_events;
Activatable activatable; Activatable activatable;
......
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