cef/patch/patches/views_1749_2102_3330.patch

757 lines
32 KiB
Diff

diff --git ui/base/models/menu_model.h ui/base/models/menu_model.h
index f1f8f33165a4a..8b07817c654e8 100644
--- ui/base/models/menu_model.h
+++ ui/base/models/menu_model.h
@@ -15,8 +15,11 @@
#include "ui/base/models/menu_separator_types.h"
#include "ui/gfx/native_widget_types.h"
+#include "third_party/skia/include/core/SkColor.h"
+
namespace gfx {
class FontList;
+class Point;
}
namespace ui {
@@ -147,6 +150,27 @@ class COMPONENT_EXPORT(UI_BASE) MenuModel
// |event_flags| is a bit mask of ui::EventFlags.
virtual void ActivatedAt(size_t index, int event_flags);
+ // Called when the user moves the mouse outside the menu and over the owning
+ // window.
+ virtual void MouseOutsideMenu(const gfx::Point& screen_point) {}
+
+ // Called on unhandled open/close submenu keyboard commands. |is_rtl| will be
+ // true if the menu is displaying a right-to-left language.
+ virtual void UnhandledOpenSubmenu(bool is_rtl) {}
+ virtual void UnhandledCloseSubmenu(bool is_rtl) {}
+
+ // Override the text/background color of a given menu item dependent on the
+ // |index| and its |is_hovered| state. |is_minor| will be true for accelerator
+ // text. Returns true if it chooses to override the color.
+ virtual bool GetTextColor(size_t index,
+ bool is_minor,
+ bool is_hovered,
+ SkColor* override_color) const { return false; }
+ virtual bool GetBackgroundColor(size_t index,
+ bool is_hovered,
+ SkColor* override_color) const
+ { return false; }
+
// Called when the menu is about to be shown.
virtual void MenuWillShow() {}
diff --git ui/gfx/render_text.cc ui/gfx/render_text.cc
index 67fbf128ea158..230a2adb0af05 100644
--- ui/gfx/render_text.cc
+++ ui/gfx/render_text.cc
@@ -671,6 +671,14 @@ void RenderText::SetWhitespaceElision(absl::optional<bool> whitespace_elision) {
}
}
+void RenderText::SetDrawStringsFlags(int flags) {
+ if (draw_strings_flags_ == flags)
+ return;
+ draw_strings_flags_ = flags;
+ cached_bounds_and_offset_valid_ = false;
+ OnTextAttributeChanged();
+}
+
void RenderText::SetDisplayRect(const Rect& r) {
if (r != display_rect_) {
display_rect_ = r;
@@ -2000,6 +2008,19 @@ void RenderText::OnTextAttributeChanged() {
layout_text_up_to_date_ = false;
+ if (draw_strings_flags_ != 0) {
+ // Compute layout size with the mnemonic character underlined since it might
+ // be larger than with the underline hidden.
+ int char_pos = -1;
+ int char_span = 0;
+ layout_text_ =
+ gfx::LocateAndRemoveAcceleratorChar(layout_text_, &char_pos, &char_span);
+ if (char_pos != -1) {
+ gfx::Range range(char_pos, char_pos + char_span);
+ styles_[TEXT_STYLE_UNDERLINE].ApplyValue(true, range);
+ }
+ }
+
OnLayoutTextAttributeChanged(true);
}
diff --git ui/gfx/render_text.h ui/gfx/render_text.h
index 5d9aaef31ecea..a6b47cd468270 100644
--- ui/gfx/render_text.h
+++ ui/gfx/render_text.h
@@ -347,6 +347,10 @@ class GFX_EXPORT RenderText {
return whitespace_elision_;
}
+ // Get or set the flags that control display of accelerator characters.
+ void SetDrawStringsFlags(int flags);
+ int draw_strings_flags() const { return draw_strings_flags_; }
+
const Rect& display_rect() const { return display_rect_; }
void SetDisplayRect(const Rect& r);
@@ -1050,6 +1054,8 @@ class GFX_EXPORT RenderText {
// Tell whether or not the |layout_text_| needs an update or is up to date.
mutable bool layout_text_up_to_date_ = false;
+
+ int draw_strings_flags_ = 0;
};
} // namespace gfx
diff --git ui/views/animation/ink_drop_host_view.h ui/views/animation/ink_drop_host_view.h
index ab4ee48e6ecbf..448219fd2e3ee 100644
--- ui/views/animation/ink_drop_host_view.h
+++ ui/views/animation/ink_drop_host_view.h
@@ -175,6 +175,8 @@ class VIEWS_EXPORT InkDropHost {
View* host_view() { return host_view_; }
const View* host_view() const { return host_view_; }
+ InkDropMode ink_drop_mode() const { return ink_drop_mode_; }
+
private:
friend class test::InkDropHostTestApi;
diff --git ui/views/controls/button/label_button.cc ui/views/controls/button/label_button.cc
index c9c780e772b69..706e95fb47b47 100644
--- ui/views/controls/button/label_button.cc
+++ ui/views/controls/button/label_button.cc
@@ -512,6 +512,12 @@ void LabelButton::OnThemeChanged() {
SchedulePaint();
}
+void LabelButton::SetFontList(const gfx::FontList& font_list) {
+ cached_normal_font_list_ = font_list;
+ cached_default_button_font_list_ = font_list;
+ label_->SetFontList(cached_normal_font_list_);
+}
+
void LabelButton::StateChanged(ButtonState old_state) {
Button::StateChanged(old_state);
ResetLabelEnabledColor();
diff --git ui/views/controls/button/label_button.h ui/views/controls/button/label_button.h
index 4004c670ba7f6..5d7062efed7c2 100644
--- ui/views/controls/button/label_button.h
+++ ui/views/controls/button/label_button.h
@@ -133,6 +133,9 @@ class VIEWS_EXPORT LabelButton : public Button, public NativeThemeDelegate {
ui::NativeTheme::State GetForegroundThemeState(
ui::NativeTheme::ExtraParams* params) const override;
+ // Sets the font list used by this button.
+ void SetFontList(const gfx::FontList& font_list);
+
protected:
ImageView* image() const { return image_; }
Label* label() const { return label_; }
diff --git ui/views/controls/label.cc ui/views/controls/label.cc
index d7bbcd9496f13..f5a6ac2e40397 100644
--- ui/views/controls/label.cc
+++ ui/views/controls/label.cc
@@ -52,12 +52,29 @@ enum LabelPropertyKey {
kLabelLineHeight,
kLabelObscured,
kLabelAllowCharacterBreak,
+ kLabelDrawStringsFlags,
};
bool IsOpaque(SkColor color) {
return SkColorGetA(color) == SK_AlphaOPAQUE;
}
+// Strips accelerator character prefixes in |text| if needed, based on |flags|.
+// Returns a range in |text| to underline or Range::InvalidRange() if
+// underlining is not needed.
+gfx::Range StripAcceleratorChars(int flags, std::u16string* text) {
+ if (flags & (gfx::Canvas::SHOW_PREFIX | gfx::Canvas::HIDE_PREFIX)) {
+ int char_pos = -1;
+ int char_span = 0;
+ *text = gfx::LocateAndRemoveAcceleratorChar(*text, &char_pos, &char_span);
+ if ((flags & gfx::Canvas::SHOW_PREFIX) && char_pos != -1) {
+ return gfx::Range(static_cast<size_t>(char_pos),
+ static_cast<size_t>(char_pos + char_span));
+ }
+ }
+ return gfx::Range::InvalidRange();
+}
+
} // namespace
namespace views {
@@ -443,6 +460,15 @@ void Label::SetElideBehavior(gfx::ElideBehavior elide_behavior) {
OnPropertyChanged(&elide_behavior_, kPropertyEffectsPreferredSizeChanged);
}
+void Label::SetDrawStringsFlags(int flags) {
+ if (draw_strings_flags_ == flags)
+ return;
+ draw_strings_flags_ = flags;
+ full_text_->SetDrawStringsFlags(draw_strings_flags_);
+ OnPropertyChanged(&full_text_ + kLabelDrawStringsFlags,
+ kPropertyEffectsPreferredSizeChanged);
+}
+
std::u16string Label::GetTooltipText() const {
return tooltip_text_;
}
@@ -747,6 +773,16 @@ std::unique_ptr<gfx::RenderText> Label::CreateRenderText() const {
render_text->SelectRange(stored_selection_range_);
}
+ if (draw_strings_flags_ != 0) {
+ auto text_str = GetText();
+ gfx::Range range = StripAcceleratorChars(draw_strings_flags_, &text_str);
+ render_text->SetText(text_str);
+ if (range.IsValid()) {
+ render_text->SetDisplayRect(bounds());
+ render_text->ApplyStyle(gfx::TEXT_STYLE_UNDERLINE, true, range);
+ }
+ }
+
return render_text;
}
diff --git ui/views/controls/label.h ui/views/controls/label.h
index b856a1cb83b4f..9551454399d8a 100644
--- ui/views/controls/label.h
+++ ui/views/controls/label.h
@@ -236,6 +236,10 @@ class VIEWS_EXPORT Label : public View,
gfx::ElideBehavior GetElideBehavior() const;
void SetElideBehavior(gfx::ElideBehavior elide_behavior);
+ // Get or set the flags that control display of accelerator characters.
+ void SetDrawStringsFlags(int flags);
+ int GetDrawStringsFlags() const { return draw_strings_flags_; }
+
// Gets/Sets the tooltip text. Default behavior for a label (single-line) is
// to show the full text if it is wider than its bounds. Calling this
// overrides the default behavior and lets you set a custom tooltip. To
@@ -495,6 +499,7 @@ class VIEWS_EXPORT Label : public View,
int max_width_ = 0;
// This is used in single-line mode.
int max_width_single_line_ = 0;
+ int draw_strings_flags_ = 0;
std::unique_ptr<SelectionController> selection_controller_;
diff --git ui/views/controls/menu/menu_controller.cc ui/views/controls/menu/menu_controller.cc
index 9202c2a1fa6d1..956cb370882a7 100644
--- ui/views/controls/menu/menu_controller.cc
+++ ui/views/controls/menu/menu_controller.cc
@@ -474,7 +474,8 @@ void MenuController::Run(Widget* parent,
MenuAnchorPosition position,
bool context_menu,
bool is_nested_drag,
- gfx::NativeView native_view_for_gestures) {
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget parent_widget) {
exit_type_ = ExitType::kNone;
possible_drag_ = false;
drag_in_progress_ = false;
@@ -521,6 +522,7 @@ void MenuController::Run(Widget* parent,
owner_->AddObserver(this);
native_view_for_gestures_ = native_view_for_gestures;
+ parent_widget_ = parent_widget;
// Only create a MenuPreTargetHandler for non-nested menus. Nested menus
// will use the existing one.
@@ -2198,6 +2200,7 @@ void MenuController::OpenMenuImpl(MenuItemView* item, bool show) {
params.do_capture = do_capture;
params.native_view_for_gestures = native_view_for_gestures_;
params.owned_window_anchor = anchor;
+ params.parent_widget = parent_widget_;
if (item->GetParentMenuItem()) {
params.context = state_.item->GetWidget();
@@ -2884,8 +2887,13 @@ MenuItemView* MenuController::FindInitialSelectableMenuItem(
void MenuController::OpenSubmenuChangeSelectionIfCan() {
MenuItemView* item = pending_state_.item;
- if (!item->HasSubmenu() || !item->GetEnabled())
+ if (!item->HasSubmenu() || !item->GetEnabled() || !item->GetParentMenuItem()) {
+ MenuItemView* submenu_item =
+ item->GetParentMenuItem() ? item->GetParentMenuItem() : item;
+ submenu_item->GetDelegate()->OnUnhandledOpenSubmenu(submenu_item,
+ base::i18n::IsRTL());
return;
+ }
MenuItemView* to_select = nullptr;
if (!item->GetSubmenu()->GetMenuItems().empty())
to_select = FindInitialSelectableMenuItem(item, INCREMENT_SELECTION_DOWN);
@@ -2904,8 +2912,10 @@ void MenuController::OpenSubmenuChangeSelectionIfCan() {
void MenuController::CloseSubmenu() {
MenuItemView* item = state_.item;
DCHECK(item);
- if (!item->GetParentMenuItem())
+ if (!item->GetParentMenuItem()) {
+ item->GetDelegate()->OnUnhandledCloseSubmenu(item, base::i18n::IsRTL());
return;
+ }
if (item->SubmenuIsShowing())
SetSelection(item, SELECTION_UPDATE_IMMEDIATELY);
else if (item->GetParentMenuItem()->GetParentMenuItem())
diff --git ui/views/controls/menu/menu_controller.h ui/views/controls/menu/menu_controller.h
index da5848241cb5b..05a7f9f0e4932 100644
--- ui/views/controls/menu/menu_controller.h
+++ ui/views/controls/menu/menu_controller.h
@@ -105,7 +105,9 @@ class VIEWS_EXPORT MenuController
MenuAnchorPosition position,
bool context_menu,
bool is_nested_drag,
- gfx::NativeView native_view_for_gestures = nullptr);
+ gfx::NativeView native_view_for_gestures = nullptr,
+ gfx::AcceleratedWidget parent_widget =
+ gfx::kNullAcceleratedWidget);
bool for_drop() const { return for_drop_; }
@@ -711,6 +713,8 @@ class VIEWS_EXPORT MenuController
// RunType::SEND_GESTURE_EVENTS_TO_OWNER is set.
gfx::NativeView native_view_for_gestures_ = nullptr;
+ gfx::AcceleratedWidget parent_widget_ = gfx::kNullAcceleratedWidget;
+
// Indicates a possible drag operation.
bool possible_drag_ = false;
diff --git ui/views/controls/menu/menu_delegate.h ui/views/controls/menu/menu_delegate.h
index b8fa1c116ebcd..015f15ed72385 100644
--- ui/views/controls/menu/menu_delegate.h
+++ ui/views/controls/menu/menu_delegate.h
@@ -73,6 +73,22 @@ class VIEWS_EXPORT MenuDelegate {
virtual const gfx::FontList* GetLabelFontList(int id) const;
virtual absl::optional<SkColor> GetLabelColor(int id) const;
+ // Override the text color of a given menu item dependent on the |command_id|
+ // and its |is_hovered| state. |is_minor| will be true for accelerator text.
+ // Returns true if it chooses to override the color.
+ virtual bool GetTextColor(int command_id,
+ bool is_minor,
+ bool is_hovered,
+ SkColor* override_color) const { return false; }
+
+ // Override the background color of a given menu item dependent on the
+ // |command_id| and its |is_hovered| state. Returns true if it chooses to
+ // override the color.
+ virtual bool GetBackgroundColor(int command_id,
+ bool is_hovered,
+ SkColor* override_color) const
+ { return false; }
+
// The tooltip shown for the menu item. This is invoked when the user
// hovers over the item, and no tooltip text has been set for that item.
virtual std::u16string GetTooltipText(int id,
@@ -201,6 +217,11 @@ class VIEWS_EXPORT MenuDelegate {
bool* has_mnemonics,
MenuButton** button);
+ // Called on unhandled open/close submenu keyboard commands. |is_rtl| will be
+ // true if the menu is displaying a right-to-left language.
+ virtual void OnUnhandledOpenSubmenu(MenuItemView* menu, bool is_rtl) {}
+ virtual void OnUnhandledCloseSubmenu(MenuItemView* menu, bool is_rtl) {}
+
// Returns the max width menus can grow to be.
virtual int GetMaxWidthForMenu(MenuItemView* menu);
diff --git ui/views/controls/menu/menu_host.cc ui/views/controls/menu/menu_host.cc
index 693ef7fa66575..c3a1e70e8ea72 100644
--- ui/views/controls/menu/menu_host.cc
+++ ui/views/controls/menu/menu_host.cc
@@ -144,6 +144,8 @@ void MenuHost::InitMenuHost(const InitParams& init_params) {
: gfx::kNullNativeWindow;
params.bounds = init_params.bounds;
+ params.parent_widget = init_params.parent_widget;
+
#if defined(USE_AURA)
// TODO(msisov): remove kMenutype once positioning of anchored windows
// finally migrates to a new path.
@@ -155,7 +157,8 @@ void MenuHost::InitMenuHost(const InitParams& init_params) {
// If MenuHost has no parent widget, it needs to be marked
// Activatable, so that calling Show in ShowMenuHost will
// get keyboard focus.
- if (init_params.parent == nullptr)
+ if (init_params.parent == nullptr &&
+ init_params.parent_widget == gfx::kNullAcceleratedWidget)
params.activatable = Widget::InitParams::Activatable::kYes;
#if BUILDFLAG(IS_WIN)
diff --git ui/views/controls/menu/menu_host.h ui/views/controls/menu/menu_host.h
index ff34179c3b7fe..3d257e06e3fbb 100644
--- ui/views/controls/menu/menu_host.h
+++ ui/views/controls/menu/menu_host.h
@@ -54,6 +54,8 @@ class MenuHost : public Widget, public WidgetObserver {
// Additional information that helps to position anchored windows in such
// backends as Wayland.
ui::OwnedWindowAnchor owned_window_anchor;
+
+ gfx::AcceleratedWidget parent_widget = gfx::kNullAcceleratedWidget;
};
explicit MenuHost(SubmenuView* submenu);
diff --git ui/views/controls/menu/menu_item_view.cc ui/views/controls/menu/menu_item_view.cc
index c2433154425be..af00acb2bd5b5 100644
--- ui/views/controls/menu/menu_item_view.cc
+++ ui/views/controls/menu/menu_item_view.cc
@@ -1095,6 +1095,15 @@ void MenuItemView::PaintBackground(gfx::Canvas* canvas,
spilling_rect.set_y(spilling_rect.y() - corner_radius_);
spilling_rect.set_height(spilling_rect.height() + corner_radius_);
canvas->DrawRoundRect(spilling_rect, corner_radius_, flags);
+ return;
+ }
+
+ MenuDelegate *delegate = GetDelegate();
+ SkColor override_color;
+ if (delegate && delegate->GetBackgroundColor(GetCommand(),
+ paint_as_selected,
+ &override_color)) {
+ canvas->DrawColor(override_color);
} else if (paint_as_selected) {
gfx::Rect item_bounds = GetLocalBounds();
if (type_ == Type::kActionableSubMenu) {
@@ -1161,6 +1170,13 @@ void MenuItemView::PaintMinorIconAndText(gfx::Canvas* canvas, SkColor color) {
}
SkColor MenuItemView::GetTextColor(bool minor, bool paint_as_selected) const {
+ SkColor text_color;
+ const MenuDelegate *delegate = GetDelegate();
+ if (delegate && delegate->GetTextColor(GetCommand(), minor, paint_as_selected,
+ &text_color)) {
+ return text_color;
+ }
+
style::TextContext context =
GetMenuController() && GetMenuController()->use_ash_system_ui_layout()
? style::CONTEXT_TOUCH_MENU
diff --git ui/views/controls/menu/menu_model_adapter.cc ui/views/controls/menu/menu_model_adapter.cc
index 71385398057f6..9bf3f69b1cfd6 100644
--- ui/views/controls/menu/menu_model_adapter.cc
+++ ui/views/controls/menu/menu_model_adapter.cc
@@ -4,6 +4,7 @@
#include "ui/views/controls/menu/menu_model_adapter.h"
+#include <limits>
#include <list>
#include <memory>
#include <utility>
@@ -243,6 +244,76 @@ bool MenuModelAdapter::IsItemChecked(int id) const {
return false;
}
+MenuItemView* MenuModelAdapter::GetSiblingMenu(MenuItemView* menu,
+ const gfx::Point& screen_point,
+ MenuAnchorPosition* anchor,
+ bool* has_mnemonics,
+ MenuButton** button) {
+ // Look up the menu model for this menu.
+ const std::map<MenuItemView*, ui::MenuModel*>::const_iterator map_iterator =
+ menu_map_.find(menu);
+ if (map_iterator != menu_map_.end()) {
+ map_iterator->second->MouseOutsideMenu(screen_point);
+ return nullptr;
+ }
+
+ NOTREACHED();
+ return nullptr;
+}
+
+void MenuModelAdapter::OnUnhandledOpenSubmenu(MenuItemView* menu,
+ bool is_rtl) {
+ // Look up the menu model for this menu.
+ const std::map<MenuItemView*, ui::MenuModel*>::const_iterator map_iterator =
+ menu_map_.find(menu);
+ if (map_iterator != menu_map_.end()) {
+ map_iterator->second->UnhandledOpenSubmenu(is_rtl);
+ return;
+ }
+
+ NOTREACHED();
+}
+
+void MenuModelAdapter::OnUnhandledCloseSubmenu(MenuItemView* menu,
+ bool is_rtl) {
+ // Look up the menu model for this menu.
+ const std::map<MenuItemView*, ui::MenuModel*>::const_iterator map_iterator =
+ menu_map_.find(menu);
+ if (map_iterator != menu_map_.end()) {
+ map_iterator->second->UnhandledCloseSubmenu(is_rtl);
+ return;
+ }
+
+ NOTREACHED();
+}
+
+bool MenuModelAdapter::GetTextColor(int command_id,
+ bool is_minor,
+ bool is_hovered,
+ SkColor* override_color) const {
+ ui::MenuModel* model = menu_model_;
+ size_t index = 0;
+ if (ui::MenuModel::GetModelAndIndexForCommandId(command_id, &model, &index))
+ return model->GetTextColor(index, is_minor, is_hovered, override_color);
+
+ // Return the default color.
+ return menu_model_->GetBackgroundColor(std::numeric_limits<size_t>::max(),
+ is_hovered, override_color);
+}
+
+bool MenuModelAdapter::GetBackgroundColor(int command_id,
+ bool is_hovered,
+ SkColor* override_color) const {
+ ui::MenuModel* model = menu_model_;
+ size_t index = 0;
+ if (ui::MenuModel::GetModelAndIndexForCommandId(command_id, &model, &index))
+ return model->GetBackgroundColor(index, is_hovered, override_color);
+
+ // Return the default color.
+ return menu_model_->GetBackgroundColor(std::numeric_limits<size_t>::max(),
+ is_hovered, override_color);
+}
+
void MenuModelAdapter::WillShowMenu(MenuItemView* menu) {
// Look up the menu model for this menu.
const std::map<MenuItemView*, ui::MenuModel*>::const_iterator map_iterator =
diff --git ui/views/controls/menu/menu_model_adapter.h ui/views/controls/menu/menu_model_adapter.h
index 5795a5b0e9eb7..025d8fc107c5f 100644
--- ui/views/controls/menu/menu_model_adapter.h
+++ ui/views/controls/menu/menu_model_adapter.h
@@ -88,6 +88,20 @@ class VIEWS_EXPORT MenuModelAdapter : public MenuDelegate,
bool IsCommandEnabled(int id) const override;
bool IsCommandVisible(int id) const override;
bool IsItemChecked(int id) const override;
+ MenuItemView* GetSiblingMenu(MenuItemView* menu,
+ const gfx::Point& screen_point,
+ MenuAnchorPosition* anchor,
+ bool* has_mnemonics,
+ MenuButton** button) override;
+ void OnUnhandledOpenSubmenu(MenuItemView* menu, bool is_rtl) override;
+ void OnUnhandledCloseSubmenu(MenuItemView* menu, bool is_rtl) override;
+ bool GetTextColor(int command_id,
+ bool is_minor,
+ bool is_hovered,
+ SkColor* override_color) const override;
+ bool GetBackgroundColor(int command_id,
+ bool is_hovered,
+ SkColor* override_color) const override;
void WillShowMenu(MenuItemView* menu) override;
void WillHideMenu(MenuItemView* menu) override;
void OnMenuClosed(MenuItemView* menu) override;
diff --git ui/views/controls/menu/menu_runner.cc ui/views/controls/menu/menu_runner.cc
index 5f931d0f55510..876f9a6a464e9 100644
--- ui/views/controls/menu/menu_runner.cc
+++ ui/views/controls/menu/menu_runner.cc
@@ -34,7 +34,8 @@ void MenuRunner::RunMenuAt(Widget* parent,
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
ui::MenuSourceType source_type,
- gfx::NativeView native_view_for_gestures) {
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget parent_widget) {
// Do not attempt to show the menu if the application is currently shutting
// down. MenuDelegate::OnMenuClosed would not be called.
if (ViewsDelegate::GetInstance() &&
@@ -80,7 +81,7 @@ void MenuRunner::RunMenuAt(Widget* parent,
}
impl_->RunMenuAt(parent, button_controller, bounds, anchor, run_types_,
- native_view_for_gestures);
+ native_view_for_gestures, parent_widget);
}
bool MenuRunner::IsRunning() const {
diff --git ui/views/controls/menu/menu_runner.h ui/views/controls/menu/menu_runner.h
index 797c2c0d90b64..f36fe5f19166d 100644
--- ui/views/controls/menu/menu_runner.h
+++ ui/views/controls/menu/menu_runner.h
@@ -146,7 +146,9 @@ class VIEWS_EXPORT MenuRunner {
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
ui::MenuSourceType source_type,
- gfx::NativeView native_view_for_gestures = nullptr);
+ gfx::NativeView native_view_for_gestures = nullptr,
+ gfx::AcceleratedWidget parent_widget =
+ gfx::kNullAcceleratedWidget);
// Returns true if we're in a nested run loop running the menu.
bool IsRunning() const;
diff --git ui/views/controls/menu/menu_runner_impl.cc ui/views/controls/menu/menu_runner_impl.cc
index 067f30cd0e44c..4628a22821443 100644
--- ui/views/controls/menu/menu_runner_impl.cc
+++ ui/views/controls/menu/menu_runner_impl.cc
@@ -119,7 +119,8 @@ void MenuRunnerImpl::RunMenuAt(Widget* parent,
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
int32_t run_types,
- gfx::NativeView native_view_for_gestures) {
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget parent_widget) {
closing_event_time_ = base::TimeTicks();
if (running_) {
// Ignore requests to show the menu while it's already showing. MenuItemView
@@ -184,7 +185,7 @@ void MenuRunnerImpl::RunMenuAt(Widget* parent,
controller->Run(parent, button_controller, menu_, bounds, anchor,
(run_types & MenuRunner::CONTEXT_MENU) != 0,
(run_types & MenuRunner::NESTED_DRAG) != 0,
- native_view_for_gestures);
+ native_view_for_gestures, parent_widget);
}
void MenuRunnerImpl::Cancel() {
diff --git ui/views/controls/menu/menu_runner_impl.h ui/views/controls/menu/menu_runner_impl.h
index 3fd1c7b5c4d2a..9a03e50cc9eee 100644
--- ui/views/controls/menu/menu_runner_impl.h
+++ ui/views/controls/menu/menu_runner_impl.h
@@ -47,7 +47,8 @@ class VIEWS_EXPORT MenuRunnerImpl : public MenuRunnerImplInterface,
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
int32_t run_types,
- gfx::NativeView native_view_for_gestures) override;
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget parent_widget) override;
void Cancel() override;
base::TimeTicks GetClosingEventTime() const override;
diff --git ui/views/controls/menu/menu_runner_impl_adapter.cc ui/views/controls/menu/menu_runner_impl_adapter.cc
index 3cead46aa1450..64157a7149ea2 100644
--- ui/views/controls/menu/menu_runner_impl_adapter.cc
+++ ui/views/controls/menu/menu_runner_impl_adapter.cc
@@ -34,9 +34,10 @@ void MenuRunnerImplAdapter::RunMenuAt(
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
int32_t types,
- gfx::NativeView native_view_for_gestures) {
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget parent_widget) {
impl_->RunMenuAt(parent, button_controller, bounds, anchor, types,
- native_view_for_gestures);
+ native_view_for_gestures, parent_widget);
}
void MenuRunnerImplAdapter::Cancel() {
diff --git ui/views/controls/menu/menu_runner_impl_adapter.h ui/views/controls/menu/menu_runner_impl_adapter.h
index 87b0622eb7891..f677d1a7f4cc6 100644
--- ui/views/controls/menu/menu_runner_impl_adapter.h
+++ ui/views/controls/menu/menu_runner_impl_adapter.h
@@ -38,7 +38,8 @@ class VIEWS_EXPORT MenuRunnerImplAdapter : public MenuRunnerImplInterface {
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
int32_t types,
- gfx::NativeView native_view_for_gestures) override;
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget parent_widget) override;
void Cancel() override;
base::TimeTicks GetClosingEventTime() const override;
diff --git ui/views/controls/menu/menu_runner_impl_cocoa.h ui/views/controls/menu/menu_runner_impl_cocoa.h
index 162640a8ba448..6cd869b5c2191 100644
--- ui/views/controls/menu/menu_runner_impl_cocoa.h
+++ ui/views/controls/menu/menu_runner_impl_cocoa.h
@@ -37,7 +37,8 @@ class VIEWS_EXPORT MenuRunnerImplCocoa : public MenuRunnerImplInterface {
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
int32_t run_types,
- gfx::NativeView native_view_for_gestures) override;
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget parent_widget) override;
void Cancel() override;
base::TimeTicks GetClosingEventTime() const override;
diff --git ui/views/controls/menu/menu_runner_impl_cocoa.mm ui/views/controls/menu/menu_runner_impl_cocoa.mm
index 542b2856967e2..df7e88c91f13e 100644
--- ui/views/controls/menu/menu_runner_impl_cocoa.mm
+++ ui/views/controls/menu/menu_runner_impl_cocoa.mm
@@ -516,7 +516,8 @@ void MenuRunnerImplCocoa::RunMenuAt(Widget* parent,
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
int32_t run_types,
- gfx::NativeView native_view_for_gestures) {
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget /*parent_widget*/) {
DCHECK(!IsRunning());
DCHECK(parent);
closing_event_time_ = base::TimeTicks();
diff --git ui/views/controls/menu/menu_runner_impl_interface.h ui/views/controls/menu/menu_runner_impl_interface.h
index 5246bbf6f143b..d722e2a014ea2 100644
--- ui/views/controls/menu/menu_runner_impl_interface.h
+++ ui/views/controls/menu/menu_runner_impl_interface.h
@@ -40,7 +40,9 @@ class MenuRunnerImplInterface {
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
int32_t run_types,
- gfx::NativeView native_view_for_gestures) = 0;
+ gfx::NativeView native_view_for_gestures,
+ gfx::AcceleratedWidget parent_widget =
+ gfx::kNullAcceleratedWidget) = 0;
// Hides and cancels the menu.
virtual void Cancel() = 0;
diff --git ui/views/controls/menu/menu_scroll_view_container.cc ui/views/controls/menu/menu_scroll_view_container.cc
index 5f5da1f46e59b..38b0a525a8652 100644
--- ui/views/controls/menu/menu_scroll_view_container.cc
+++ ui/views/controls/menu/menu_scroll_view_container.cc
@@ -259,6 +259,11 @@ MenuScrollViewContainer::MenuScrollViewContainer(SubmenuView* content_view)
scroll_down_button_ = background_view_->AddChildView(
std::make_unique<MenuScrollButton>(content_view, false));
+ SkColor override_color;
+ MenuDelegate* delegate = content_view_->GetMenuItem()->GetDelegate();
+ if (delegate && delegate->GetBackgroundColor(-1, false, &override_color))
+ SetBackground(views::CreateSolidBackground(override_color));
+
arrow_ = BubbleBorderTypeFromAnchor(
content_view_->GetMenuItem()->GetMenuController()->GetAnchorPosition());
diff --git ui/views/test/ui_controls_factory_desktop_aura_ozone.cc ui/views/test/ui_controls_factory_desktop_aura_ozone.cc
index 3be783bf139be..ccbd77c2a2797 100644
--- ui/views/test/ui_controls_factory_desktop_aura_ozone.cc
+++ ui/views/test/ui_controls_factory_desktop_aura_ozone.cc
@@ -16,6 +16,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
#include "ui/aura/test/aura_test_utils.h"
@@ -100,9 +101,11 @@ class UIControlsDesktopOzone : public UIControlsAura {
aura::test::QueryLatestMousePositionRequestInHost(host);
host->ConvertPixelsToDIP(&root_current_location);
+#if !BUILDFLAG(ENABLE_CEF)
auto* screen = views::test::TestDesktopScreenOzone::GetInstance();
DCHECK_EQ(screen, display::Screen::GetScreen());
screen->set_cursor_screen_point(gfx::Point(screen_x, screen_y));
+#endif
bool moved_cursor = false;
#if !BUILDFLAG(IS_CHROMEOS_LACROS)
diff --git ui/views/view.h ui/views/view.h
index 5546d26fc701c..2a9797943b9f2 100644
--- ui/views/view.h
+++ ui/views/view.h
@@ -22,6 +22,7 @@
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/strings/string_piece.h"
+#include "base/supports_user_data.h"
#include "build/build_config.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkPath.h"
@@ -272,7 +273,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
public ui::EventTarget,
public ui::EventHandler,
public ui::PropertyHandler,
- public ui::metadata::MetaDataProvider {
+ public ui::metadata::MetaDataProvider,
+ public base::SupportsUserData {
public:
using Views = std::vector<View*>;