Skip to content

Commit

Permalink
Overload the BEGIN_METADATA macro
Browse files Browse the repository at this point in the history
This simplifies the use of the BEGIN_METADATA macro by overloading in
the support for nested types. Just use the same parameters in the same
order as the previous BEGIN_NESTED_METDATA macro.

Bug: 938501
Change-Id: Idbdda0de33fd3f8878f0e986156d41e696fc98c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2665567
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Auto-Submit: Allen Bauer <kylixrd@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Wei Li <weili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849291}
  • Loading branch information
Allen Bauer authored and Chromium LUCI CQ committed Feb 1, 2021
1 parent e7fcf54 commit c37c6e4
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ash/frame/non_client_frame_view_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ bool NonClientFrameViewAsh::OverlayView::DoesIntersectRect(
return header_view_->HitTestRect(rect);
}

BEGIN_NESTED_METADATA(NonClientFrameViewAsh, OverlayView, views::View)
BEGIN_METADATA(NonClientFrameViewAsh, OverlayView, views::View)
END_METADATA

NonClientFrameViewAsh::NonClientFrameViewAsh(views::Widget* frame)
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/ui/views/content_setting_bubble_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ void ContentSettingBubbleContents::ListItemContainer::UpdateScrollHeight(
}
}

BEGIN_NESTED_METADATA(ContentSettingBubbleContents,
ListItemContainer,
views::View)
BEGIN_METADATA(ContentSettingBubbleContents, ListItemContainer, views::View)
END_METADATA

// ContentSettingBubbleContents -----------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "content/public/browser/browser_thread.h"
#include "ui/views/metadata/metadata_impl_macros.h"

BEGIN_NESTED_METADATA(DesktopMediaListController, ListView, views::View)
BEGIN_METADATA(DesktopMediaListController, ListView, views::View)
END_METADATA

DesktopMediaListController::DesktopMediaListController(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool ExpandableContainerView::DetailsView::GetExpanded() const {
return expanded_;
}

BEGIN_NESTED_METADATA(ExpandableContainerView, DetailsView, views::View)
BEGIN_METADATA(ExpandableContainerView, DetailsView, views::View)
ADD_PROPERTY_METADATA(bool, Expanded)
END_METADATA

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/omnibox/omnibox_row_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ views::metadata::TypeConverter<OmniboxPopupModel::Selection>::FromString(
: base::nullopt;
}

BEGIN_NESTED_METADATA(OmniboxRowView, HeaderView, views::View)
BEGIN_METADATA(OmniboxRowView, HeaderView, views::View)
ADD_READONLY_PROPERTY_METADATA(OmniboxPopupModel::Selection, HeaderSelection)
END_METADATA

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ void MoveToAccountStoreBubbleView::MovingBannerView::UpdateFavicon(
to_view->UpdateBadge(favicon);
}

BEGIN_NESTED_METADATA(MoveToAccountStoreBubbleView,
MovingBannerView,
views::View)
BEGIN_METADATA(MoveToAccountStoreBubbleView, MovingBannerView, views::View)
END_METADATA

MoveToAccountStoreBubbleView::MoveToAccountStoreBubbleView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ void PasswordGenerationPopupViewViews::GeneratedPasswordBox::BuildColumnSet(
views::GridLayout::ColumnSize::kUsePreferred, 0, 0);
}

BEGIN_NESTED_METADATA(PasswordGenerationPopupViewViews,
GeneratedPasswordBox,
views::View)
BEGIN_METADATA(PasswordGenerationPopupViewViews,
GeneratedPasswordBox,
views::View)
END_METADATA

PasswordGenerationPopupViewViews::PasswordGenerationPopupViewViews(
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/subtle_notification_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void SubtleNotificationView::InstructionView::AddTextSegment(
AddChildView(key);
}

BEGIN_NESTED_METADATA(SubtleNotificationView, InstructionView, views::View)
BEGIN_METADATA(SubtleNotificationView, InstructionView, views::View)
ADD_PROPERTY_METADATA(base::string16, Text)
END_METADATA

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/toolbar/app_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class AppMenu::CutCopyPasteView : public AppMenuView {
}
};

BEGIN_NESTED_METADATA(AppMenu, CutCopyPasteView, AppMenuView)
BEGIN_METADATA(AppMenu, CutCopyPasteView, AppMenuView)
ADD_READONLY_PROPERTY_METADATA(int, MaxChildViewPreferredWidth)
END_METADATA

Expand Down Expand Up @@ -671,7 +671,7 @@ class AppMenu::ZoomView : public AppMenuView {
mutable bool zoom_label_max_width_valid_;
};

BEGIN_NESTED_METADATA(AppMenu, ZoomView, AppMenuView)
BEGIN_METADATA(AppMenu, ZoomView, AppMenuView)
ADD_READONLY_PROPERTY_METADATA(int, ZoomLabelMaxWidth)
END_METADATA

Expand Down
22 changes: 17 additions & 5 deletions ui/views/metadata/metadata_impl_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,29 @@
BEGIN_METADATA_INTERNAL( \
class_name, METADATA_CLASS_NAME_INTERNAL(class_name), class_name)

#define BEGIN_NESTED_METADATA(outer_class, class_name, parent_class_name) \
BEGIN_METADATA_INTERNAL(outer_class::class_name, \
METADATA_CLASS_NAME_INTERNAL(class_name), \
parent_class_name) \
#define _BEGIN_NESTED_METADATA(outer_class, class_name, parent_class_name) \
BEGIN_METADATA_INTERNAL(outer_class::class_name, \
METADATA_CLASS_NAME_INTERNAL(class_name), \
parent_class_name) \
METADATA_PARENT_CLASS_INTERNAL(parent_class_name)

#define BEGIN_METADATA(class_name, parent_class_name) \
#define _BEGIN_METADATA(class_name, parent_class_name) \
BEGIN_METADATA_INTERNAL( \
class_name, METADATA_CLASS_NAME_INTERNAL(class_name), parent_class_name) \
METADATA_PARENT_CLASS_INTERNAL(parent_class_name)

#define _GET_MD_MACRO_NAME(_1, _2, _3, NAME, ...) NAME

// The following macro overloads the above macros. For most cases, only two
// parameters are used. In some instances when a class is nested within another
// class, the first parameter should be the outer scope with the remaining
// parameters same as the non-nested macro.

#define BEGIN_METADATA(class_name1, class_name2, ...) \
_GET_MD_MACRO_NAME(class_name1, class_name2, ##__VA_ARGS__, \
_BEGIN_NESTED_METADATA, _BEGIN_METADATA) \
(class_name1, class_name2, ##__VA_ARGS__)

#define END_METADATA }

// This will fail to compile if the property accessors aren't in the form of
Expand Down

0 comments on commit c37c6e4

Please sign in to comment.