2023-12-06 21:16:15 +01:00
|
|
|
diff --git chrome/browser/ui/views/toolbar/app_menu.cc chrome/browser/ui/views/toolbar/app_menu.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index 7986c86012518..fa75795aa6c30 100644
|
2023-12-06 21:16:15 +01:00
|
|
|
--- chrome/browser/ui/views/toolbar/app_menu.cc
|
|
|
|
+++ chrome/browser/ui/views/toolbar/app_menu.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1025,7 +1025,9 @@ void AppMenu::RunMenu(views::MenuButtonController* host) {
|
2023-12-06 21:16:15 +01:00
|
|
|
host->button()->GetWidget(), host,
|
|
|
|
host->button()->GetAnchorBoundsInScreen(),
|
|
|
|
views::MenuAnchorPosition::kTopRight, ui::MENU_SOURCE_NONE,
|
2024-01-26 03:12:43 +01:00
|
|
|
- /*native_view_for_gestures=*/gfx::NativeView(), /*corners=*/std::nullopt,
|
2023-12-06 21:16:15 +01:00
|
|
|
+ /*native_view_for_gestures=*/gfx::NativeView(),
|
|
|
|
+ /*parent_widget=*/gfx::kNullAcceleratedWidget,
|
2024-01-26 03:12:43 +01:00
|
|
|
+ /*corners=*/std::nullopt,
|
2023-12-06 21:16:15 +01:00
|
|
|
"Chrome.AppMenu.MenuHostInitToNextFramePresented");
|
|
|
|
}
|
|
|
|
|
2017-02-22 19:05:27 +01:00
|
|
|
diff --git ui/base/models/menu_model.h ui/base/models/menu_model.h
|
2024-02-22 19:36:15 +01:00
|
|
|
index fb795f76d3616..6e36a4c1e29da 100644
|
2017-02-22 19:05:27 +01:00
|
|
|
--- ui/base/models/menu_model.h
|
|
|
|
+++ ui/base/models/menu_model.h
|
2023-04-04 20:00:13 +02:00
|
|
|
@@ -17,8 +17,11 @@
|
|
|
|
#include "ui/color/color_id.h"
|
2020-06-09 19:48:00 +02:00
|
|
|
#include "ui/gfx/native_widget_types.h"
|
|
|
|
|
|
|
|
+#include "third_party/skia/include/core/SkColor.h"
|
|
|
|
+
|
2017-02-22 19:05:27 +01:00
|
|
|
namespace gfx {
|
|
|
|
class FontList;
|
|
|
|
+class Point;
|
|
|
|
}
|
|
|
|
|
2020-06-09 19:48:00 +02:00
|
|
|
namespace ui {
|
2023-08-09 23:17:17 +02:00
|
|
|
@@ -147,6 +150,27 @@ class COMPONENT_EXPORT(UI_BASE) MenuModel
|
2017-02-22 19:05:27 +01:00
|
|
|
// |event_flags| is a bit mask of ui::EventFlags.
|
2022-07-25 19:49:32 +02:00
|
|
|
virtual void ActivatedAt(size_t index, int event_flags);
|
2017-02-22 19:05:27 +01:00
|
|
|
|
|
|
|
+ // 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) {}
|
2017-02-25 06:03:31 +01:00
|
|
|
+
|
|
|
|
+ // Override the text/background color of a given menu item dependent on the
|
2017-03-03 23:37:23 +01:00
|
|
|
+ // |index| and its |is_hovered| state. |is_minor| will be true for accelerator
|
|
|
|
+ // text. Returns true if it chooses to override the color.
|
2022-07-25 19:49:32 +02:00
|
|
|
+ virtual bool GetTextColor(size_t index,
|
2017-03-03 23:37:23 +01:00
|
|
|
+ bool is_minor,
|
2017-02-25 06:03:31 +01:00
|
|
|
+ bool is_hovered,
|
|
|
|
+ SkColor* override_color) const { return false; }
|
2022-07-25 19:49:32 +02:00
|
|
|
+ virtual bool GetBackgroundColor(size_t index,
|
2017-02-25 06:03:31 +01:00
|
|
|
+ bool is_hovered,
|
|
|
|
+ SkColor* override_color) const
|
|
|
|
+ { return false; }
|
2017-02-22 19:05:27 +01:00
|
|
|
+
|
|
|
|
// Called when the menu is about to be shown.
|
|
|
|
virtual void MenuWillShow() {}
|
|
|
|
|
2017-02-24 21:01:42 +01:00
|
|
|
diff --git ui/gfx/render_text.cc ui/gfx/render_text.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index 7437fc1dbf24c..fe19f3e046b1a 100644
|
2017-02-24 21:01:42 +01:00
|
|
|
--- ui/gfx/render_text.cc
|
|
|
|
+++ ui/gfx/render_text.cc
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -696,6 +696,14 @@ void RenderText::SetWhitespaceElision(std::optional<bool> whitespace_elision) {
|
2017-02-24 21:01:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+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;
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -2128,6 +2136,19 @@ void RenderText::OnTextAttributeChanged() {
|
2020-02-10 18:10:17 +01:00
|
|
|
|
|
|
|
layout_text_up_to_date_ = false;
|
2017-02-24 21:01:42 +01:00
|
|
|
|
|
|
|
+ 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_ =
|
2021-01-28 00:13:12 +01:00
|
|
|
+ gfx::LocateAndRemoveAcceleratorChar(layout_text_, &char_pos, &char_span);
|
2017-02-24 21:01:42 +01:00
|
|
|
+ if (char_pos != -1) {
|
|
|
|
+ gfx::Range range(char_pos, char_pos + char_span);
|
2019-02-01 20:40:18 +01:00
|
|
|
+ styles_[TEXT_STYLE_UNDERLINE].ApplyValue(true, range);
|
2017-02-24 21:01:42 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
OnLayoutTextAttributeChanged(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git ui/gfx/render_text.h ui/gfx/render_text.h
|
2024-05-23 03:52:35 +02:00
|
|
|
index c18ec4422d538..e89b7403c5399 100644
|
2017-02-24 21:01:42 +01:00
|
|
|
--- ui/gfx/render_text.h
|
|
|
|
+++ ui/gfx/render_text.h
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -356,6 +356,10 @@ class GFX_EXPORT RenderText {
|
2024-02-22 19:36:15 +01:00
|
|
|
void SetWhitespaceElision(std::optional<bool> elide_whitespace);
|
|
|
|
std::optional<bool> whitespace_elision() const { return whitespace_elision_; }
|
2017-02-24 21:01:42 +01:00
|
|
|
|
|
|
|
+ // 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);
|
|
|
|
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -1087,6 +1091,8 @@ class GFX_EXPORT RenderText {
|
2021-06-04 03:34:56 +02:00
|
|
|
|
2020-03-04 01:29:39 +01:00
|
|
|
// Tell whether or not the |layout_text_| needs an update or is up to date.
|
|
|
|
mutable bool layout_text_up_to_date_ = false;
|
2017-02-24 21:01:42 +01:00
|
|
|
+
|
2021-06-04 03:34:56 +02:00
|
|
|
+ int draw_strings_flags_ = 0;
|
2017-02-24 21:01:42 +01:00
|
|
|
};
|
|
|
|
|
2021-06-04 03:34:56 +02:00
|
|
|
} // namespace gfx
|
2023-01-30 18:43:54 +01:00
|
|
|
diff --git ui/views/animation/ink_drop_host.h ui/views/animation/ink_drop_host.h
|
2024-05-23 03:52:35 +02:00
|
|
|
index c579f65dce9f0..a04e0d1f66aaa 100644
|
2023-01-30 18:43:54 +01:00
|
|
|
--- ui/views/animation/ink_drop_host.h
|
|
|
|
+++ ui/views/animation/ink_drop_host.h
|
2023-06-26 12:13:38 +02:00
|
|
|
@@ -194,6 +194,8 @@ class VIEWS_EXPORT InkDropHost {
|
2021-06-04 03:34:56 +02:00
|
|
|
View* host_view() { return host_view_; }
|
|
|
|
const View* host_view() const { return host_view_; }
|
2017-05-31 17:33:30 +02:00
|
|
|
|
|
|
|
+ InkDropMode ink_drop_mode() const { return ink_drop_mode_; }
|
|
|
|
+
|
2021-06-04 03:34:56 +02:00
|
|
|
private:
|
|
|
|
friend class test::InkDropHostTestApi;
|
|
|
|
|
2017-02-24 21:01:42 +01:00
|
|
|
diff --git ui/views/controls/button/label_button.cc ui/views/controls/button/label_button.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index 04d4aca2784dc..b3ce5e1f2174c 100644
|
2017-02-24 21:01:42 +01:00
|
|
|
--- ui/views/controls/button/label_button.cc
|
|
|
|
+++ ui/views/controls/button/label_button.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -596,6 +596,12 @@ void LabelButton::OnThemeChanged() {
|
2019-07-16 19:59:21 +02:00
|
|
|
SchedulePaint();
|
2017-05-31 17:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+void LabelButton::SetFontList(const gfx::FontList& font_list) {
|
|
|
|
+ cached_normal_font_list_ = font_list;
|
2017-08-08 22:10:24 +02:00
|
|
|
+ cached_default_button_font_list_ = font_list;
|
2017-05-31 17:33:30 +02:00
|
|
|
+ label_->SetFontList(cached_normal_font_list_);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void LabelButton::StateChanged(ButtonState old_state) {
|
2020-08-29 00:39:23 +02:00
|
|
|
Button::StateChanged(old_state);
|
|
|
|
ResetLabelEnabledColor();
|
2017-05-31 17:33:30 +02:00
|
|
|
diff --git ui/views/controls/button/label_button.h ui/views/controls/button/label_button.h
|
2024-06-14 19:01:45 +02:00
|
|
|
index aaa15dcd8c72b..7d5fe7306a37c 100644
|
2017-05-31 17:33:30 +02:00
|
|
|
--- ui/views/controls/button/label_button.h
|
|
|
|
+++ ui/views/controls/button/label_button.h
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -187,6 +187,9 @@ class VIEWS_EXPORT LabelButton : public Button,
|
2024-01-26 03:12:43 +01:00
|
|
|
// widget, and the parent of the containing widget.
|
|
|
|
ButtonState GetVisualState() const;
|
2017-05-31 17:33:30 +02:00
|
|
|
|
|
|
|
+ // Sets the font list used by this button.
|
|
|
|
+ void SetFontList(const gfx::FontList& font_list);
|
|
|
|
+
|
|
|
|
protected:
|
2024-01-26 03:12:43 +01:00
|
|
|
LabelButtonImageContainer* image_container() {
|
|
|
|
return image_container_.get();
|
2017-02-23 21:24:45 +01:00
|
|
|
diff --git ui/views/controls/label.cc ui/views/controls/label.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index 33e534c7eb6d0..3ed887e0dae41 100644
|
2017-02-23 21:24:45 +01:00
|
|
|
--- ui/views/controls/label.cc
|
|
|
|
+++ ui/views/controls/label.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -57,12 +57,29 @@ enum LabelPropertyKey {
|
2020-08-29 00:39:23 +02:00
|
|
|
kLabelLineHeight,
|
|
|
|
kLabelObscured,
|
|
|
|
kLabelAllowCharacterBreak,
|
|
|
|
+ kLabelDrawStringsFlags,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool IsOpaque(SkColor color) {
|
2019-09-04 17:13:32 +02:00
|
|
|
return SkColorGetA(color) == SK_AlphaOPAQUE;
|
|
|
|
}
|
2019-01-17 10:56:52 +01:00
|
|
|
|
2017-02-23 21:24:45 +01:00
|
|
|
+// 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.
|
2021-04-21 00:52:34 +02:00
|
|
|
+gfx::Range StripAcceleratorChars(int flags, std::u16string* text) {
|
2017-02-23 21:24:45 +01:00
|
|
|
+ if (flags & (gfx::Canvas::SHOW_PREFIX | gfx::Canvas::HIDE_PREFIX)) {
|
|
|
|
+ int char_pos = -1;
|
|
|
|
+ int char_span = 0;
|
2021-01-28 00:13:12 +01:00
|
|
|
+ *text = gfx::LocateAndRemoveAcceleratorChar(*text, &char_pos, &char_span);
|
2022-08-23 03:37:40 +02:00
|
|
|
+ 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));
|
|
|
|
+ }
|
2017-02-23 21:24:45 +01:00
|
|
|
+ }
|
2019-09-04 17:13:32 +02:00
|
|
|
+ return gfx::Range::InvalidRange();
|
2017-02-23 21:24:45 +01:00
|
|
|
+}
|
2019-01-17 10:56:52 +01:00
|
|
|
+
|
2019-09-04 17:13:32 +02:00
|
|
|
} // namespace
|
2019-01-17 10:56:52 +01:00
|
|
|
|
2019-09-04 17:13:32 +02:00
|
|
|
namespace views {
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -492,6 +509,15 @@ void Label::SetElideBehavior(gfx::ElideBehavior elide_behavior) {
|
2021-04-21 00:52:34 +02:00
|
|
|
OnPropertyChanged(&elide_behavior_, kPropertyEffectsPreferredSizeChanged);
|
2017-02-23 21:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+void Label::SetDrawStringsFlags(int flags) {
|
|
|
|
+ if (draw_strings_flags_ == flags)
|
|
|
|
+ return;
|
|
|
|
+ draw_strings_flags_ = flags;
|
2018-02-15 01:12:09 +01:00
|
|
|
+ full_text_->SetDrawStringsFlags(draw_strings_flags_);
|
2020-08-29 00:39:23 +02:00
|
|
|
+ OnPropertyChanged(&full_text_ + kLabelDrawStringsFlags,
|
|
|
|
+ kPropertyEffectsPreferredSizeChanged);
|
2017-02-23 21:24:45 +01:00
|
|
|
+}
|
|
|
|
+
|
2021-04-21 00:52:34 +02:00
|
|
|
std::u16string Label::GetTooltipText() const {
|
|
|
|
return tooltip_text_;
|
|
|
|
}
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -796,6 +822,16 @@ std::unique_ptr<gfx::RenderText> Label::CreateRenderText() const {
|
2021-01-28 00:13:12 +01:00
|
|
|
render_text->SelectRange(stored_selection_range_);
|
|
|
|
}
|
|
|
|
|
2017-02-23 21:24:45 +01:00
|
|
|
+ if (draw_strings_flags_ != 0) {
|
2021-04-21 00:52:34 +02:00
|
|
|
+ auto text_str = GetText();
|
2017-02-23 21:24:45 +01:00
|
|
|
+ gfx::Range range = StripAcceleratorChars(draw_strings_flags_, &text_str);
|
|
|
|
+ render_text->SetText(text_str);
|
|
|
|
+ if (range.IsValid()) {
|
|
|
|
+ render_text->SetDisplayRect(bounds());
|
2019-02-01 20:40:18 +01:00
|
|
|
+ render_text->ApplyStyle(gfx::TEXT_STYLE_UNDERLINE, true, range);
|
2017-02-23 21:24:45 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2021-01-28 00:13:12 +01:00
|
|
|
return render_text;
|
|
|
|
}
|
|
|
|
|
2017-02-23 21:24:45 +01:00
|
|
|
diff --git ui/views/controls/label.h ui/views/controls/label.h
|
2024-05-23 03:52:35 +02:00
|
|
|
index 40d9a89b66369..0c7245665d31b 100644
|
2017-02-23 21:24:45 +01:00
|
|
|
--- ui/views/controls/label.h
|
|
|
|
+++ ui/views/controls/label.h
|
2024-05-23 03:52:35 +02:00
|
|
|
@@ -245,6 +245,10 @@ class VIEWS_EXPORT Label : public View,
|
2019-09-04 17:13:32 +02:00
|
|
|
gfx::ElideBehavior GetElideBehavior() const;
|
2017-02-23 21:24:45 +01:00
|
|
|
void SetElideBehavior(gfx::ElideBehavior elide_behavior);
|
|
|
|
|
|
|
|
+ // Get or set the flags that control display of accelerator characters.
|
|
|
|
+ void SetDrawStringsFlags(int flags);
|
2019-09-04 17:13:32 +02:00
|
|
|
+ int GetDrawStringsFlags() const { return draw_strings_flags_; }
|
2017-02-23 21:24:45 +01:00
|
|
|
+
|
2019-09-04 17:13:32 +02:00
|
|
|
// 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
|
2024-05-23 03:52:35 +02:00
|
|
|
@@ -524,6 +528,7 @@ class VIEWS_EXPORT Label : public View,
|
2020-03-30 22:13:42 +02:00
|
|
|
int max_width_ = 0;
|
2021-03-04 23:36:57 +01:00
|
|
|
// This is used in single-line mode.
|
|
|
|
int max_width_single_line_ = 0;
|
2017-02-23 21:24:45 +01:00
|
|
|
+ int draw_strings_flags_ = 0;
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
std::unique_ptr<SelectionController> selection_controller_;
|
|
|
|
|
2017-02-22 19:05:27 +01:00
|
|
|
diff --git ui/views/controls/menu/menu_controller.cc ui/views/controls/menu/menu_controller.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index ef6a903caf5a9..c329a7684bfca 100644
|
2017-02-22 19:05:27 +01:00
|
|
|
--- ui/views/controls/menu/menu_controller.cc
|
|
|
|
+++ ui/views/controls/menu/menu_controller.cc
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -578,7 +578,8 @@ void MenuController::Run(Widget* parent,
|
2022-05-13 13:38:41 +02:00
|
|
|
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;
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -623,6 +624,7 @@ void MenuController::Run(Widget* parent,
|
2022-05-13 13:38:41 +02:00
|
|
|
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.
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -2247,6 +2249,7 @@ void MenuController::OpenMenuImpl(MenuItemView* item, bool show) {
|
2022-05-13 13:38:41 +02:00
|
|
|
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()) {
|
2023-04-04 20:00:13 +02:00
|
|
|
params.context = item->GetWidget();
|
|
|
|
// (crbug.com/1414232) The item to be open is a submenu. Make sure
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -2931,8 +2934,13 @@ MenuItemView* MenuController::FindInitialSelectableMenuItem(
|
2017-02-22 19:05:27 +01:00
|
|
|
|
|
|
|
void MenuController::OpenSubmenuChangeSelectionIfCan() {
|
|
|
|
MenuItemView* item = pending_state_.item;
|
2019-07-16 19:59:21 +02:00
|
|
|
- if (!item->HasSubmenu() || !item->GetEnabled())
|
|
|
|
+ if (!item->HasSubmenu() || !item->GetEnabled() || !item->GetParentMenuItem()) {
|
2017-02-22 19:05:27 +01:00
|
|
|
+ MenuItemView* submenu_item =
|
|
|
|
+ item->GetParentMenuItem() ? item->GetParentMenuItem() : item;
|
|
|
|
+ submenu_item->GetDelegate()->OnUnhandledOpenSubmenu(submenu_item,
|
|
|
|
+ base::i18n::IsRTL());
|
|
|
|
return;
|
|
|
|
+ }
|
2023-04-04 20:00:13 +02:00
|
|
|
|
|
|
|
// Show the sub-menu.
|
|
|
|
SetSelection(item, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -2952,8 +2960,10 @@ void MenuController::OpenSubmenuChangeSelectionIfCan() {
|
2017-02-22 19:05:27 +01:00
|
|
|
void MenuController::CloseSubmenu() {
|
|
|
|
MenuItemView* item = state_.item;
|
|
|
|
DCHECK(item);
|
|
|
|
- if (!item->GetParentMenuItem())
|
|
|
|
+ if (!item->GetParentMenuItem()) {
|
|
|
|
+ item->GetDelegate()->OnUnhandledCloseSubmenu(item, base::i18n::IsRTL());
|
|
|
|
return;
|
|
|
|
+ }
|
2017-07-27 01:19:27 +02:00
|
|
|
if (item->SubmenuIsShowing())
|
2017-02-22 19:05:27 +01:00
|
|
|
SetSelection(item, SELECTION_UPDATE_IMMEDIATELY);
|
|
|
|
else if (item->GetParentMenuItem()->GetParentMenuItem())
|
2022-05-13 13:38:41 +02:00
|
|
|
diff --git ui/views/controls/menu/menu_controller.h ui/views/controls/menu/menu_controller.h
|
2024-06-14 19:01:45 +02:00
|
|
|
index 4c25ffcf9ab92..df270df5c024e 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_controller.h
|
|
|
|
+++ ui/views/controls/menu/menu_controller.h
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -137,7 +137,9 @@ class VIEWS_EXPORT MenuController final : public gfx::AnimationDelegate,
|
2022-05-13 13:38:41 +02:00
|
|
|
MenuAnchorPosition position,
|
|
|
|
bool context_menu,
|
|
|
|
bool is_nested_drag,
|
2023-06-26 12:13:38 +02:00
|
|
|
- gfx::NativeView native_view_for_gestures = gfx::NativeView());
|
|
|
|
+ gfx::NativeView native_view_for_gestures = gfx::NativeView(),
|
2022-05-13 13:38:41 +02:00
|
|
|
+ gfx::AcceleratedWidget parent_widget =
|
|
|
|
+ gfx::kNullAcceleratedWidget);
|
|
|
|
|
|
|
|
bool for_drop() const { return for_drop_; }
|
|
|
|
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -738,6 +740,8 @@ class VIEWS_EXPORT MenuController final : public gfx::AnimationDelegate,
|
2022-05-13 13:38:41 +02:00
|
|
|
// RunType::SEND_GESTURE_EVENTS_TO_OWNER is set.
|
2023-06-26 12:13:38 +02:00
|
|
|
gfx::NativeView native_view_for_gestures_ = gfx::NativeView();
|
2022-05-13 13:38:41 +02:00
|
|
|
|
|
|
|
+ gfx::AcceleratedWidget parent_widget_ = gfx::kNullAcceleratedWidget;
|
|
|
|
+
|
|
|
|
// Indicates a possible drag operation.
|
|
|
|
bool possible_drag_ = false;
|
|
|
|
|
2017-02-22 19:05:27 +01:00
|
|
|
diff --git ui/views/controls/menu/menu_delegate.h ui/views/controls/menu/menu_delegate.h
|
2024-02-22 19:36:15 +01:00
|
|
|
index 0623d151ddd3e..243e8c573e474 100644
|
2017-02-22 19:05:27 +01:00
|
|
|
--- ui/views/controls/menu/menu_delegate.h
|
|
|
|
+++ ui/views/controls/menu/menu_delegate.h
|
2021-08-20 01:40:49 +02:00
|
|
|
@@ -73,6 +73,22 @@ class VIEWS_EXPORT MenuDelegate {
|
|
|
|
virtual const gfx::FontList* GetLabelFontList(int id) const;
|
2024-02-22 19:36:15 +01:00
|
|
|
virtual std::optional<SkColor> GetLabelColor(int id) const;
|
2017-05-31 17:33:30 +02:00
|
|
|
|
2017-03-03 23:37:23 +01:00
|
|
|
+ // 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
|
2017-02-25 06:03:31 +01:00
|
|
|
+ // |command_id| and its |is_hovered| state. Returns true if it chooses to
|
|
|
|
+ // override the color.
|
2017-03-03 23:37:23 +01:00
|
|
|
+ virtual bool GetBackgroundColor(int command_id,
|
|
|
|
+ bool is_hovered,
|
|
|
|
+ SkColor* override_color) const
|
|
|
|
+ { return false; }
|
2017-05-31 17:33:30 +02:00
|
|
|
+
|
2017-03-03 23:37:23 +01:00
|
|
|
// 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.
|
2021-04-21 00:52:34 +02:00
|
|
|
virtual std::u16string GetTooltipText(int id,
|
2022-02-21 23:23:40 +01:00
|
|
|
@@ -201,6 +217,11 @@ class VIEWS_EXPORT MenuDelegate {
|
2017-02-22 19:05:27 +01:00
|
|
|
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);
|
|
|
|
|
2022-05-13 13:38:41 +02:00
|
|
|
diff --git ui/views/controls/menu/menu_host.cc ui/views/controls/menu/menu_host.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index c7c9deb69dbba..0edd342c9a713 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_host.cc
|
|
|
|
+++ ui/views/controls/menu/menu_host.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -145,6 +145,8 @@ void MenuHost::InitMenuHost(const InitParams& init_params) {
|
2024-05-23 03:52:35 +02:00
|
|
|
: gfx::NativeWindow();
|
|
|
|
params.bounds = init_params.bounds;
|
2022-05-13 13:38:41 +02:00
|
|
|
|
|
|
|
+ params.parent_widget = init_params.parent_widget;
|
|
|
|
+
|
|
|
|
#if defined(USE_AURA)
|
2024-02-22 19:36:15 +01:00
|
|
|
params.init_properties_container.SetProperty(aura::client::kOwnedWindowAnchor,
|
|
|
|
init_params.owned_window_anchor);
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -152,7 +154,8 @@ void MenuHost::InitMenuHost(const InitParams& init_params) {
|
2022-05-13 13:38:41 +02:00
|
|
|
// 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
|
2024-05-23 03:52:35 +02:00
|
|
|
index fc1d5fccc3845..c065cafcd537c 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_host.h
|
|
|
|
+++ ui/views/controls/menu/menu_host.h
|
2024-05-23 03:52:35 +02:00
|
|
|
@@ -57,6 +57,8 @@ class MenuHost : public Widget, public WidgetObserver {
|
2022-05-13 13:38:41 +02:00
|
|
|
// 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);
|
2017-02-25 06:03:31 +01:00
|
|
|
diff --git ui/views/controls/menu/menu_item_view.cc ui/views/controls/menu/menu_item_view.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index 6377bb1fe7a6c..9f20510d92c80 100644
|
2017-02-25 06:03:31 +01:00
|
|
|
--- ui/views/controls/menu/menu_item_view.cc
|
|
|
|
+++ ui/views/controls/menu/menu_item_view.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1076,6 +1076,15 @@ void MenuItemView::PaintBackground(gfx::Canvas* canvas,
|
2018-11-30 23:21:07 +01:00
|
|
|
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();
|
2017-03-03 23:37:23 +01:00
|
|
|
+ SkColor override_color;
|
|
|
|
+ if (delegate && delegate->GetBackgroundColor(GetCommand(),
|
2021-10-19 00:17:16 +02:00
|
|
|
+ paint_as_selected,
|
2017-03-03 23:37:23 +01:00
|
|
|
+ &override_color)) {
|
|
|
|
+ canvas->DrawColor(override_color);
|
2021-10-19 00:17:16 +02:00
|
|
|
} else if (paint_as_selected) {
|
2018-11-30 23:21:07 +01:00
|
|
|
gfx::Rect item_bounds = GetLocalBounds();
|
2020-03-04 01:29:39 +01:00
|
|
|
if (type_ == Type::kActionableSubMenu) {
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1140,6 +1149,13 @@ void MenuItemView::PaintMinorIconAndText(gfx::Canvas* canvas, SkColor color) {
|
2018-09-04 11:43:21 +02:00
|
|
|
}
|
|
|
|
|
2021-10-19 00:17:16 +02:00
|
|
|
SkColor MenuItemView::GetTextColor(bool minor, bool paint_as_selected) const {
|
2017-02-25 06:03:31 +01:00
|
|
|
+ SkColor text_color;
|
2017-03-03 23:37:23 +01:00
|
|
|
+ const MenuDelegate *delegate = GetDelegate();
|
2021-10-19 00:17:16 +02:00
|
|
|
+ if (delegate && delegate->GetTextColor(GetCommand(), minor, paint_as_selected,
|
2017-03-03 23:37:23 +01:00
|
|
|
+ &text_color)) {
|
|
|
|
+ return text_color;
|
2017-02-25 06:03:31 +01:00
|
|
|
+ }
|
|
|
|
+
|
2023-04-04 20:00:13 +02:00
|
|
|
// Use a custom color if provided by the controller. If the item is selected,
|
|
|
|
// use the default color.
|
|
|
|
if (!paint_as_selected && foreground_color_id_.has_value()) {
|
2017-02-22 19:05:27 +01:00
|
|
|
diff --git ui/views/controls/menu/menu_model_adapter.cc ui/views/controls/menu/menu_model_adapter.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index d6a9c662edb9b..7bba7ca1cae5f 100644
|
2017-02-22 19:05:27 +01:00
|
|
|
--- ui/views/controls/menu/menu_model_adapter.cc
|
|
|
|
+++ ui/views/controls/menu/menu_model_adapter.cc
|
2022-08-23 03:37:40 +02:00
|
|
|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
|
|
#include "ui/views/controls/menu/menu_model_adapter.h"
|
|
|
|
|
|
|
|
+#include <limits>
|
|
|
|
#include <list>
|
|
|
|
#include <memory>
|
|
|
|
#include <utility>
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -236,6 +237,75 @@ bool MenuModelAdapter::IsItemChecked(int id) const {
|
2023-02-27 19:52:38 +01:00
|
|
|
return model->IsItemCheckedAt(index);
|
2017-02-22 19:05:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+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();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+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();
|
|
|
|
+}
|
2017-02-25 06:03:31 +01:00
|
|
|
+
|
2017-03-03 23:37:23 +01:00
|
|
|
+bool MenuModelAdapter::GetTextColor(int command_id,
|
|
|
|
+ bool is_minor,
|
|
|
|
+ bool is_hovered,
|
|
|
|
+ SkColor* override_color) const {
|
2017-02-25 06:03:31 +01:00
|
|
|
+ ui::MenuModel* model = menu_model_;
|
2022-07-25 19:49:32 +02:00
|
|
|
+ size_t index = 0;
|
2017-02-25 06:03:31 +01:00
|
|
|
+ if (ui::MenuModel::GetModelAndIndexForCommandId(command_id, &model, &index))
|
2017-03-03 23:37:23 +01:00
|
|
|
+ return model->GetTextColor(index, is_minor, is_hovered, override_color);
|
2017-02-25 06:03:31 +01:00
|
|
|
+
|
2022-08-23 03:37:40 +02:00
|
|
|
+ // Return the default color.
|
|
|
|
+ return menu_model_->GetBackgroundColor(std::numeric_limits<size_t>::max(),
|
|
|
|
+ is_hovered, override_color);
|
2017-02-25 06:03:31 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MenuModelAdapter::GetBackgroundColor(int command_id,
|
|
|
|
+ bool is_hovered,
|
|
|
|
+ SkColor* override_color) const {
|
|
|
|
+ ui::MenuModel* model = menu_model_;
|
2022-07-25 19:49:32 +02:00
|
|
|
+ size_t index = 0;
|
2017-02-25 06:03:31 +01:00
|
|
|
+ if (ui::MenuModel::GetModelAndIndexForCommandId(command_id, &model, &index))
|
|
|
|
+ return model->GetBackgroundColor(index, is_hovered, override_color);
|
|
|
|
+
|
2022-08-23 03:37:40 +02:00
|
|
|
+ // Return the default color.
|
|
|
|
+ return menu_model_->GetBackgroundColor(std::numeric_limits<size_t>::max(),
|
|
|
|
+ is_hovered, override_color);
|
2017-02-25 06:03:31 +01:00
|
|
|
+}
|
2017-02-22 19:05:27 +01:00
|
|
|
+
|
|
|
|
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
|
2024-05-23 03:52:35 +02:00
|
|
|
index 883188d50ce30..3d3ed449744de 100644
|
2017-02-22 19:05:27 +01:00
|
|
|
--- ui/views/controls/menu/menu_model_adapter.h
|
|
|
|
+++ ui/views/controls/menu/menu_model_adapter.h
|
2024-05-23 03:52:35 +02:00
|
|
|
@@ -93,6 +93,20 @@ class VIEWS_EXPORT MenuModelAdapter : public MenuDelegate,
|
2019-02-01 17:42:40 +01:00
|
|
|
bool IsCommandEnabled(int id) const override;
|
2017-02-22 19:05:27 +01:00
|
|
|
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;
|
2017-03-03 23:37:23 +01:00
|
|
|
+ bool GetTextColor(int command_id,
|
|
|
|
+ bool is_minor,
|
|
|
|
+ bool is_hovered,
|
|
|
|
+ SkColor* override_color) const override;
|
2017-02-25 06:03:31 +01:00
|
|
|
+ bool GetBackgroundColor(int command_id,
|
|
|
|
+ bool is_hovered,
|
|
|
|
+ SkColor* override_color) const override;
|
2017-02-22 19:05:27 +01:00
|
|
|
void WillShowMenu(MenuItemView* menu) override;
|
|
|
|
void WillHideMenu(MenuItemView* menu) override;
|
2017-05-31 17:33:30 +02:00
|
|
|
void OnMenuClosed(MenuItemView* menu) override;
|
2022-05-13 13:38:41 +02:00
|
|
|
diff --git ui/views/controls/menu/menu_runner.cc ui/views/controls/menu/menu_runner.cc
|
2024-02-22 19:36:15 +01:00
|
|
|
index 9f746392f6d83..fa37345b6e021 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner.cc
|
|
|
|
+++ ui/views/controls/menu/menu_runner.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -42,6 +42,7 @@ void MenuRunner::RunMenuAt(
|
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
ui::MenuSourceType source_type,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
2024-02-22 19:36:15 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) {
|
2022-05-13 13:38:41 +02:00
|
|
|
// Do not attempt to show the menu if the application is currently shutting
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -89,7 +90,7 @@ void MenuRunner::RunMenuAt(
|
2022-05-13 13:38:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl_->RunMenuAt(parent, button_controller, bounds, anchor, run_types_,
|
2023-12-06 21:16:15 +01:00
|
|
|
- native_view_for_gestures, corners,
|
|
|
|
+ native_view_for_gestures, parent_widget, corners,
|
|
|
|
std::move(show_menu_host_duration_histogram));
|
2022-05-13 13:38:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
diff --git ui/views/controls/menu/menu_runner.h ui/views/controls/menu/menu_runner.h
|
2024-02-22 19:36:15 +01:00
|
|
|
index c18d1c4d729e1..a73c48c02f1be 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner.h
|
|
|
|
+++ ui/views/controls/menu/menu_runner.h
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -157,6 +157,8 @@ class VIEWS_EXPORT MenuRunner {
|
2022-05-13 13:38:41 +02:00
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
ui::MenuSourceType source_type,
|
2023-06-26 12:13:38 +02:00
|
|
|
gfx::NativeView native_view_for_gestures = gfx::NativeView(),
|
2022-05-13 13:38:41 +02:00
|
|
|
+ gfx::AcceleratedWidget parent_widget =
|
2022-11-15 18:50:53 +01:00
|
|
|
+ gfx::kNullAcceleratedWidget,
|
2024-02-22 19:36:15 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners = std::nullopt,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram =
|
|
|
|
std::nullopt);
|
2022-05-13 13:38:41 +02:00
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl.cc ui/views/controls/menu/menu_runner_impl.cc
|
2024-02-22 19:36:15 +01:00
|
|
|
index 0ef0f5ed80dcd..2c2fefdc1b4d2 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl.cc
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -116,6 +116,7 @@ void MenuRunnerImpl::RunMenuAt(
|
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
2024-02-22 19:36:15 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) {
|
2022-05-13 13:38:41 +02:00
|
|
|
closing_event_time_ = base::TimeTicks();
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -189,7 +190,7 @@ void MenuRunnerImpl::RunMenuAt(
|
|
|
|
controller->Run(parent, button_controller, menu_.get(), bounds, anchor,
|
2022-05-13 13:38:41 +02:00
|
|
|
(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
|
2024-02-22 19:36:15 +01:00
|
|
|
index c36540ede44a1..6e60ee28bad17 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl.h
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl.h
|
2022-11-15 18:50:53 +01:00
|
|
|
@@ -53,6 +53,7 @@ class VIEWS_EXPORT MenuRunnerImpl : public MenuRunnerImplInterface,
|
2023-12-06 21:16:15 +01:00
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
2024-02-22 19:36:15 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners = std::nullopt,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram =
|
|
|
|
std::nullopt) override;
|
2022-05-13 13:38:41 +02:00
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl_adapter.cc ui/views/controls/menu/menu_runner_impl_adapter.cc
|
2024-02-22 19:36:15 +01:00
|
|
|
index 35f1542e2162d..702ede49238af 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_adapter.cc
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_adapter.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -36,10 +36,11 @@ void MenuRunnerImplAdapter::RunMenuAt(
|
2022-05-13 13:38:41 +02:00
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t types,
|
2022-11-15 18:50:53 +01:00
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
2024-02-22 19:36:15 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) {
|
2022-05-13 13:38:41 +02:00
|
|
|
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
|
2024-02-22 19:36:15 +01:00
|
|
|
index 546818cef0120..8d2bccf62588e 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_adapter.h
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_adapter.h
|
2022-11-15 18:50:53 +01:00
|
|
|
@@ -44,6 +44,7 @@ class VIEWS_EXPORT MenuRunnerImplAdapter : public MenuRunnerImplInterface {
|
2023-12-06 21:16:15 +01:00
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
2024-02-22 19:36:15 +01:00
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
|
|
|
std::optional<gfx::RoundedCornersF> corners = std::nullopt,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram =
|
|
|
|
std::nullopt) override;
|
2022-05-13 13:38:41 +02:00
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl_cocoa.h ui/views/controls/menu/menu_runner_impl_cocoa.h
|
2024-02-22 19:36:15 +01:00
|
|
|
index b0d0334939730..18a5a159ccaf4 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_cocoa.h
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_cocoa.h
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -43,6 +43,7 @@ class VIEWS_EXPORT MenuRunnerImplCocoa : public MenuRunnerImplInterface {
|
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) override;
|
|
|
|
void Cancel() override;
|
2022-05-13 13:38:41 +02:00
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl_cocoa.mm ui/views/controls/menu/menu_runner_impl_cocoa.mm
|
2024-02-22 19:36:15 +01:00
|
|
|
index c585f056973e2..02af08d23a9b9 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_cocoa.mm
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_cocoa.mm
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -70,6 +70,7 @@ void MenuRunnerImplCocoa::RunMenuAt(
|
2022-11-15 18:50:53 +01:00
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget /*parent_widget*/,
|
2024-02-22 19:36:15 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) {
|
2022-05-13 13:38:41 +02:00
|
|
|
DCHECK(!IsRunning());
|
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl_interface.h ui/views/controls/menu/menu_runner_impl_interface.h
|
2024-02-22 19:36:15 +01:00
|
|
|
index 972abab3bf46f..ce6b32b1524e8 100644
|
2022-05-13 13:38:41 +02:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_interface.h
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_interface.h
|
2023-12-06 21:16:15 +01:00
|
|
|
@@ -47,6 +47,8 @@ class MenuRunnerImplInterface {
|
2022-11-15 18:50:53 +01:00
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget =
|
|
|
|
+ gfx::kNullAcceleratedWidget,
|
2024-02-22 19:36:15 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners = std::nullopt,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram =
|
|
|
|
std::nullopt) = 0;
|
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl_mac.h ui/views/controls/menu/menu_runner_impl_mac.h
|
2024-03-19 22:11:42 +01:00
|
|
|
index db81eab045142..ca439366e66ef 100644
|
2024-02-22 19:36:15 +01:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_mac.h
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_mac.h
|
|
|
|
@@ -40,6 +40,7 @@ class VIEWS_EXPORT MenuRunnerImplMac : public MenuRunnerImplInterface {
|
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
2024-03-19 22:11:42 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) override;
|
2024-02-22 19:36:15 +01:00
|
|
|
void Cancel() override;
|
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl_mac.mm ui/views/controls/menu/menu_runner_impl_mac.mm
|
2024-03-19 22:11:42 +01:00
|
|
|
index 27f83d5eece36..27d07d70c912e 100644
|
2024-02-22 19:36:15 +01:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_mac.mm
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_mac.mm
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -47,6 +47,7 @@ void MenuRunnerImplMac::RunMenuAt(
|
2024-02-22 19:36:15 +01:00
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
2024-03-19 22:11:42 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) {
|
2024-02-22 19:36:15 +01:00
|
|
|
if (!implementation_) {
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -59,8 +60,8 @@ void MenuRunnerImplMac::RunMenuAt(
|
2024-02-22 19:36:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
implementation_->RunMenuAt(parent, button_controller, bounds, anchor,
|
|
|
|
- run_types, native_view_for_gestures, corners,
|
|
|
|
- show_menu_host_duration_histogram);
|
|
|
|
+ run_types, native_view_for_gestures, parent_widget,
|
|
|
|
+ corners, show_menu_host_duration_histogram);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuRunnerImplMac::Cancel() {
|
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl_remote_cocoa.h ui/views/controls/menu/menu_runner_impl_remote_cocoa.h
|
2024-03-19 22:11:42 +01:00
|
|
|
index 7aaf6d82e09d4..c3af2bdf748fb 100644
|
2024-02-22 19:36:15 +01:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_remote_cocoa.h
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_remote_cocoa.h
|
|
|
|
@@ -58,6 +58,7 @@ class VIEWS_EXPORT MenuRunnerImplRemoteCocoa
|
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
2024-03-19 22:11:42 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) override;
|
2024-02-22 19:36:15 +01:00
|
|
|
void Cancel() override;
|
|
|
|
diff --git ui/views/controls/menu/menu_runner_impl_remote_cocoa.mm ui/views/controls/menu/menu_runner_impl_remote_cocoa.mm
|
2024-03-19 22:11:42 +01:00
|
|
|
index e171461e28836..e137275a22a12 100644
|
2024-02-22 19:36:15 +01:00
|
|
|
--- ui/views/controls/menu/menu_runner_impl_remote_cocoa.mm
|
|
|
|
+++ ui/views/controls/menu/menu_runner_impl_remote_cocoa.mm
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -70,6 +70,7 @@ void MenuRunnerImplRemoteCocoa::RunMenuAt(
|
2024-02-22 19:36:15 +01:00
|
|
|
MenuAnchorPosition anchor,
|
|
|
|
int32_t run_types,
|
|
|
|
gfx::NativeView native_view_for_gestures,
|
|
|
|
+ gfx::AcceleratedWidget parent_widget,
|
2024-03-19 22:11:42 +01:00
|
|
|
std::optional<gfx::RoundedCornersF> corners,
|
|
|
|
std::optional<std::string> show_menu_host_duration_histogram) {
|
2024-02-22 19:36:15 +01:00
|
|
|
RunMenu(parent, bounds.CenterPoint());
|
2017-02-25 06:03:31 +01:00
|
|
|
diff --git ui/views/controls/menu/menu_scroll_view_container.cc ui/views/controls/menu/menu_scroll_view_container.cc
|
2024-05-23 03:52:35 +02:00
|
|
|
index 76f58311587d3..850a8d2c9197c 100644
|
2017-02-25 06:03:31 +01:00
|
|
|
--- ui/views/controls/menu/menu_scroll_view_container.cc
|
|
|
|
+++ ui/views/controls/menu/menu_scroll_view_container.cc
|
2024-05-23 03:52:35 +02:00
|
|
|
@@ -253,6 +253,11 @@ MenuScrollViewContainer::MenuScrollViewContainer(SubmenuView* content_view)
|
2022-04-27 21:24:24 +02:00
|
|
|
scroll_down_button_ = background_view_->AddChildView(
|
|
|
|
std::make_unique<MenuScrollButton>(content_view, false));
|
2017-02-25 06:03:31 +01:00
|
|
|
|
|
|
|
+ SkColor override_color;
|
|
|
|
+ MenuDelegate* delegate = content_view_->GetMenuItem()->GetDelegate();
|
|
|
|
+ if (delegate && delegate->GetBackgroundColor(-1, false, &override_color))
|
2017-07-27 01:19:27 +02:00
|
|
|
+ SetBackground(views::CreateSolidBackground(override_color));
|
2017-02-25 06:03:31 +01:00
|
|
|
+
|
|
|
|
arrow_ = BubbleBorderTypeFromAnchor(
|
|
|
|
content_view_->GetMenuItem()->GetMenuController()->GetAnchorPosition());
|
|
|
|
|
2022-06-17 15:28:55 +02:00
|
|
|
diff --git ui/views/test/ui_controls_factory_desktop_aura_ozone.cc ui/views/test/ui_controls_factory_desktop_aura_ozone.cc
|
2024-05-23 03:52:35 +02:00
|
|
|
index dcf4b60ad92c2..64fa80edefc1b 100644
|
2022-06-17 15:28:55 +02:00
|
|
|
--- ui/views/test/ui_controls_factory_desktop_aura_ozone.cc
|
|
|
|
+++ ui/views/test/ui_controls_factory_desktop_aura_ozone.cc
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -16,6 +16,7 @@
|
2023-01-30 18:43:54 +01:00
|
|
|
#include "base/task/single_thread_task_runner.h"
|
2022-06-17 15:28:55 +02:00
|
|
|
#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"
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -181,9 +182,11 @@ bool SendMouseMoveNotifyWhenDone(int screen_x,
|
2023-02-27 19:52:38 +01:00
|
|
|
aura::test::QueryLatestMousePositionRequestInHost(host);
|
|
|
|
host->ConvertPixelsToDIP(&root_current_location);
|
2022-06-17 15:28:55 +02:00
|
|
|
|
|
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
2023-02-27 19:52:38 +01:00
|
|
|
auto* screen = views::test::TestDesktopScreenOzone::GetInstance();
|
|
|
|
DCHECK_EQ(screen, display::Screen::GetScreen());
|
|
|
|
screen->set_cursor_screen_point(gfx::Point(screen_x, screen_y));
|
2022-06-17 15:28:55 +02:00
|
|
|
+#endif
|
|
|
|
|
2022-08-23 03:37:40 +02:00
|
|
|
#if !BUILDFLAG(IS_CHROMEOS_LACROS)
|
2023-02-27 19:52:38 +01:00
|
|
|
if (root_location != root_current_location &&
|
2017-05-31 17:33:30 +02:00
|
|
|
diff --git ui/views/view.h ui/views/view.h
|
2024-06-14 19:01:45 +02:00
|
|
|
index 1a8ad95eed953..a1fa62ac5dcc4 100644
|
2017-05-31 17:33:30 +02:00
|
|
|
--- ui/views/view.h
|
|
|
|
+++ ui/views/view.h
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -25,6 +25,7 @@
|
2024-05-23 03:52:35 +02:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2023-12-06 21:16:15 +01:00
|
|
|
#include "base/memory/safety_checks.h"
|
2022-04-21 20:58:48 +02:00
|
|
|
#include "base/observer_list.h"
|
2017-05-31 17:33:30 +02:00
|
|
|
+#include "base/supports_user_data.h"
|
2024-02-22 19:36:15 +01:00
|
|
|
#include "base/types/pass_key.h"
|
2017-05-31 17:33:30 +02:00
|
|
|
#include "build/build_config.h"
|
2019-01-17 10:56:52 +01:00
|
|
|
#include "third_party/skia/include/core/SkPath.h"
|
2024-03-19 22:11:42 +01:00
|
|
|
@@ -289,7 +290,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
|
2020-03-30 22:13:42 +02:00
|
|
|
public ui::EventTarget,
|
2017-07-27 01:19:27 +02:00
|
|
|
public ui::EventHandler,
|
2019-06-05 16:15:45 +02:00
|
|
|
public ui::PropertyHandler,
|
2021-06-04 03:34:56 +02:00
|
|
|
- public ui::metadata::MetaDataProvider {
|
|
|
|
+ public ui::metadata::MetaDataProvider,
|
|
|
|
+ public base::SupportsUserData {
|
2023-12-06 21:16:15 +01:00
|
|
|
// Do not remove this macro!
|
|
|
|
// The macro is maintained by the memory safety team.
|
|
|
|
ADVANCED_MEMORY_SAFETY_CHECKS();
|