Use IsViewClass<T> rather than class name comparisons.
Reworking the metadata, and IsViewClass<T> is faster and generally more accurate. Bug: N/A Change-Id: I9dd6f02c34a4894225216a17d074d0120d2428f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4902563 Commit-Queue: Allen Bauer <kylixrd@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Ted Choc <tedchoc@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1204723}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
db3e80a740
commit
d836b83f59
ash
app_list
views
assistant
system
chrome/browser/ui/views/bookmarks
components
media_message_center
ui_devtools
ui/views
cocoa
controls
window
@@ -48,6 +48,7 @@
|
|||||||
#include "third_party/skia/include/core/SkColor.h"
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
#include "ui/base/dragdrop/drag_drop_types.h"
|
#include "ui/base/dragdrop/drag_drop_types.h"
|
||||||
#include "ui/base/dragdrop/drop_target_event.h"
|
#include "ui/base/dragdrop/drop_target_event.h"
|
||||||
|
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||||
#include "ui/base/ui_base_types.h"
|
#include "ui/base/ui_base_types.h"
|
||||||
#include "ui/chromeos/styles/cros_tokens_color_mappings.h"
|
#include "ui/chromeos/styles/cros_tokens_color_mappings.h"
|
||||||
#include "ui/compositor/animation_throughput_reporter.h"
|
#include "ui/compositor/animation_throughput_reporter.h"
|
||||||
@@ -639,10 +640,6 @@ void AppListBubbleView::UpdateForNewSortingOrder(
|
|||||||
std::move(done_closure));
|
std::move(done_closure));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* AppListBubbleView::GetClassName() const {
|
|
||||||
return "AppListBubbleView";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AppListBubbleView::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
bool AppListBubbleView::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
||||||
switch (accelerator.key_code()) {
|
switch (accelerator.key_code()) {
|
||||||
case ui::VKEY_ESCAPE:
|
case ui::VKEY_ESCAPE:
|
||||||
@@ -871,4 +868,7 @@ void AppListBubbleView::MaybeFocusAndActivateSearchBox() {
|
|||||||
search_box_view_->search_box()->RequestFocus();
|
search_box_view_->search_box()->RequestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BEGIN_METADATA(AppListBubbleView, views::View)
|
||||||
|
END_METADATA
|
||||||
|
|
||||||
} // namespace ash
|
} // namespace ash
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include "base/functional/callback_forward.h"
|
#include "base/functional/callback_forward.h"
|
||||||
#include "base/memory/raw_ptr.h"
|
#include "base/memory/raw_ptr.h"
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
|
#include "ui/base/metadata/metadata_header_macros.h"
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
@@ -42,6 +43,8 @@ class ASH_EXPORT AppListBubbleView : public views::View,
|
|||||||
public SearchBoxViewDelegate,
|
public SearchBoxViewDelegate,
|
||||||
public AppListFolderController {
|
public AppListFolderController {
|
||||||
public:
|
public:
|
||||||
|
METADATA_HEADER(AppListBubbleView);
|
||||||
|
|
||||||
AppListBubbleView(AppListViewDelegate* view_delegate,
|
AppListBubbleView(AppListViewDelegate* view_delegate,
|
||||||
ApplicationDragAndDropHost* drag_and_drop_host);
|
ApplicationDragAndDropHost* drag_and_drop_host);
|
||||||
AppListBubbleView(const AppListBubbleView&) = delete;
|
AppListBubbleView(const AppListBubbleView&) = delete;
|
||||||
@@ -96,7 +99,6 @@ class ASH_EXPORT AppListBubbleView : public views::View,
|
|||||||
base::OnceClosure update_position_closure);
|
base::OnceClosure update_position_closure);
|
||||||
|
|
||||||
// views::View:
|
// views::View:
|
||||||
const char* GetClassName() const override;
|
|
||||||
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
|
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
|
||||||
void Layout() override;
|
void Layout() override;
|
||||||
bool GetDropFormats(int* formats,
|
bool GetDropFormats(int* formats,
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include "base/functional/callback.h"
|
#include "base/functional/callback.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "ui/aura/window.h"
|
#include "ui/aura/window.h"
|
||||||
|
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||||
#include "ui/compositor/layer.h"
|
#include "ui/compositor/layer.h"
|
||||||
#include "ui/gfx/geometry/insets.h"
|
#include "ui/gfx/geometry/insets.h"
|
||||||
#include "ui/views/border.h"
|
#include "ui/views/border.h"
|
||||||
@@ -104,14 +105,11 @@ PaginationModel* AppListMainView::GetAppsPaginationModel() {
|
|||||||
->pagination_model();
|
->pagination_model();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* AppListMainView::GetClassName() const {
|
|
||||||
return "AppListMainView";
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppListMainView::Layout() {
|
void AppListMainView::Layout() {
|
||||||
gfx::Rect rect = GetContentsBounds();
|
gfx::Rect rect = GetContentsBounds();
|
||||||
if (!rect.IsEmpty())
|
if (!rect.IsEmpty()) {
|
||||||
contents_view_->SetBoundsRect(rect);
|
contents_view_->SetBoundsRect(rect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppListMainView::QueryChanged(const std::u16string& trimmed_query,
|
void AppListMainView::QueryChanged(const std::u16string& trimmed_query,
|
||||||
@@ -125,8 +123,9 @@ void AppListMainView::QueryChanged(const std::u16string& trimmed_query,
|
|||||||
|
|
||||||
void AppListMainView::ActiveChanged(SearchBoxViewBase* sender) {
|
void AppListMainView::ActiveChanged(SearchBoxViewBase* sender) {
|
||||||
// Do not update views on closing.
|
// Do not update views on closing.
|
||||||
if (app_list_view_->app_list_state() == AppListViewState::kClosed)
|
if (app_list_view_->app_list_state() == AppListViewState::kClosed) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (search_box_view_->is_search_box_active()) {
|
if (search_box_view_->is_search_box_active()) {
|
||||||
// Show zero state suggestions when search box is activated with an empty
|
// Show zero state suggestions when search box is activated with an empty
|
||||||
@@ -189,4 +188,7 @@ void AppListMainView::CloseButtonPressed() {
|
|||||||
search_box_view_->ClearSearch();
|
search_box_view_->ClearSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BEGIN_METADATA(AppListMainView, views::View)
|
||||||
|
END_METADATA
|
||||||
|
|
||||||
} // namespace ash
|
} // namespace ash
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include "base/memory/raw_ptr.h"
|
#include "base/memory/raw_ptr.h"
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "base/timer/timer.h"
|
#include "base/timer/timer.h"
|
||||||
|
#include "ui/base/metadata/metadata_header_macros.h"
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
@@ -28,6 +29,8 @@ class SearchBoxViewBase;
|
|||||||
class ASH_EXPORT AppListMainView : public views::View,
|
class ASH_EXPORT AppListMainView : public views::View,
|
||||||
public SearchBoxViewDelegate {
|
public SearchBoxViewDelegate {
|
||||||
public:
|
public:
|
||||||
|
METADATA_HEADER(AppListMainView);
|
||||||
|
|
||||||
AppListMainView(AppListViewDelegate* delegate, AppListView* app_list_view);
|
AppListMainView(AppListViewDelegate* delegate, AppListView* app_list_view);
|
||||||
|
|
||||||
AppListMainView(const AppListMainView&) = delete;
|
AppListMainView(const AppListMainView&) = delete;
|
||||||
@@ -50,7 +53,6 @@ class ASH_EXPORT AppListMainView : public views::View,
|
|||||||
AppListViewDelegate* view_delegate() { return delegate_; }
|
AppListViewDelegate* view_delegate() { return delegate_; }
|
||||||
|
|
||||||
// Overridden from views::View:
|
// Overridden from views::View:
|
||||||
const char* GetClassName() const override;
|
|
||||||
void Layout() override;
|
void Layout() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@
|
|||||||
#include "ash/frame/non_client_frame_view_ash.h"
|
#include "ash/frame/non_client_frame_view_ash.h"
|
||||||
#include "chromeos/ui/frame/caption_buttons/caption_button_model.h"
|
#include "chromeos/ui/frame/caption_buttons/caption_button_model.h"
|
||||||
#include "chromeos/ui/frame/default_frame_header.h"
|
#include "chromeos/ui/frame/default_frame_header.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
#include "ui/views/window/caption_button_types.h"
|
#include "ui/views/window/caption_button_types.h"
|
||||||
#include "ui/views/window/frame_caption_button.h"
|
#include "ui/views/window/frame_caption_button.h"
|
||||||
@@ -79,8 +80,8 @@ void AssistantWebViewDelegateImpl::UpdateBackButtonVisibility(
|
|||||||
|
|
||||||
auto* non_client_view = widget->non_client_view();
|
auto* non_client_view = widget->non_client_view();
|
||||||
|
|
||||||
DCHECK_EQ(NonClientFrameViewAsh::kViewClassName,
|
DCHECK(
|
||||||
non_client_view->frame_view()->GetClassName());
|
views::IsViewClass<NonClientFrameViewAsh>(non_client_view->frame_view()));
|
||||||
|
|
||||||
auto* frame_view_ash =
|
auto* frame_view_ash =
|
||||||
static_cast<NonClientFrameViewAsh*>(non_client_view->frame_view());
|
static_cast<NonClientFrameViewAsh*>(non_client_view->frame_view());
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "ui/gfx/image/image_unittest_util.h"
|
#include "ui/gfx/image/image_unittest_util.h"
|
||||||
#include "ui/views/controls/image_view.h"
|
#include "ui/views/controls/image_view.h"
|
||||||
#include "ui/views/controls/label.h"
|
#include "ui/views/controls/label.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
@@ -94,11 +95,8 @@ class BluetoothDeviceListItemMultipleBatteryViewTest : public AshTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BatteryViewExistsAtIndex(int index) {
|
void BatteryViewExistsAtIndex(int index) {
|
||||||
EXPECT_EQ(bluetooth_device_list_multiple_battery_item()
|
EXPECT_TRUE(views::IsViewClass<BluetoothDeviceListItemBatteryView>(
|
||||||
->children()
|
bluetooth_device_list_multiple_battery_item()->children().at(index)));
|
||||||
.at(index)
|
|
||||||
->GetClassName(),
|
|
||||||
BluetoothDeviceListItemBatteryView::kViewClassName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "ash/system/network/network_detailed_network_view_impl.h"
|
#include "ash/system/network/network_detailed_network_view.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "ash/system/network/network_detailed_network_view.h"
|
#include "ash/system/network/network_detailed_network_view_impl.h"
|
||||||
#include "ash/system/network/network_detailed_view.h"
|
#include "ash/system/network/network_detailed_view.h"
|
||||||
#include "ash/system/network/network_list_mobile_header_view.h"
|
#include "ash/system/network/network_list_mobile_header_view.h"
|
||||||
#include "ash/system/network/network_list_network_item_view.h"
|
#include "ash/system/network/network_list_network_item_view.h"
|
||||||
@@ -217,15 +217,12 @@ TEST_F(NetworkDetailedNetworkViewTest, ViewsAreCreated) {
|
|||||||
NetworkListNetworkItemView* network_list_item =
|
NetworkListNetworkItemView* network_list_item =
|
||||||
AddNetworkListItem(NetworkType::kWiFi);
|
AddNetworkListItem(NetworkType::kWiFi);
|
||||||
ASSERT_NE(nullptr, network_list_item);
|
ASSERT_NE(nullptr, network_list_item);
|
||||||
EXPECT_STREQ("NetworkListNetworkItemView", network_list_item->GetClassName());
|
|
||||||
|
|
||||||
NetworkListWifiHeaderView* wifi_section = AddWifiSectionHeader();
|
NetworkListWifiHeaderView* wifi_section = AddWifiSectionHeader();
|
||||||
ASSERT_NE(nullptr, wifi_section);
|
ASSERT_NE(nullptr, wifi_section);
|
||||||
EXPECT_STREQ("NetworkListWifiHeaderView", wifi_section->GetClassName());
|
|
||||||
|
|
||||||
NetworkListMobileHeaderView* mobile_section = AddMobileSectionHeader();
|
NetworkListMobileHeaderView* mobile_section = AddMobileSectionHeader();
|
||||||
ASSERT_NE(nullptr, mobile_section);
|
ASSERT_NE(nullptr, mobile_section);
|
||||||
EXPECT_STREQ("NetworkListMobileHeaderView", mobile_section->GetClassName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(NetworkDetailedNetworkViewTest, ToggleInteractions) {
|
TEST_F(NetworkDetailedNetworkViewTest, ToggleInteractions) {
|
||||||
|
@@ -72,6 +72,7 @@
|
|||||||
#include "ui/views/style/typography_provider.h"
|
#include "ui/views/style/typography_provider.h"
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
#include "ui/views/view_class_properties.h"
|
#include "ui/views/view_class_properties.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
namespace {
|
namespace {
|
||||||
@@ -972,7 +973,7 @@ bool CalendarView::IsDateCellViewFocused() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return focused_view->GetClassName() == CalendarDateCellView::kViewClassName;
|
return views::IsViewClass<CalendarDateCellView>(focused_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CalendarView::IsAnimating() {
|
bool CalendarView::IsAnimating() {
|
||||||
@@ -1723,9 +1724,9 @@ void CalendarView::OnEvent(ui::Event* event) {
|
|||||||
// Sometimes the position of the upper row cells, which should be
|
// Sometimes the position of the upper row cells, which should be
|
||||||
// focused next, are above (and hidden behind) the header buttons. So
|
// focused next, are above (and hidden behind) the header buttons. So
|
||||||
// this loop skips those buttons.
|
// this loop skips those buttons.
|
||||||
while (current_focusable_view &&
|
while (
|
||||||
current_focusable_view->GetClassName() !=
|
current_focusable_view &&
|
||||||
CalendarDateCellView::kViewClassName) {
|
!views::IsViewClass<CalendarDateCellView>(current_focusable_view)) {
|
||||||
current_focusable_view = focus_manager->GetNextFocusableView(
|
current_focusable_view = focus_manager->GetNextFocusableView(
|
||||||
current_focusable_view, GetWidget(),
|
current_focusable_view, GetWidget(),
|
||||||
/*reverse=*/key_code == ui::VKEY_UP,
|
/*reverse=*/key_code == ui::VKEY_UP,
|
||||||
@@ -1833,7 +1834,7 @@ void CalendarView::OnMonthArrowButtonActivated(bool up,
|
|||||||
|
|
||||||
void CalendarView::AdjustDateCellVoxBounds() {
|
void CalendarView::AdjustDateCellVoxBounds() {
|
||||||
auto* focused_view = GetFocusManager()->GetFocusedView();
|
auto* focused_view = GetFocusManager()->GetFocusedView();
|
||||||
DCHECK_EQ(focused_view->GetClassName(), CalendarDateCellView::kViewClassName);
|
DCHECK(views::IsViewClass<CalendarDateCellView>(focused_view));
|
||||||
|
|
||||||
// When the Chrome Vox focusing box is in a `ScrollView`, the hidden content
|
// When the Chrome Vox focusing box is in a `ScrollView`, the hidden content
|
||||||
// height, which is `scroll_view_->GetVisibleRect().y()` should also be added.
|
// height, which is `scroll_view_->GetVisibleRect().y()` should also be added.
|
||||||
|
@@ -634,8 +634,9 @@ void RecordAppLaunch(Profile* profile, const GURL& url) {
|
|||||||
extensions::ExtensionRegistry::Get(profile)
|
extensions::ExtensionRegistry::Get(profile)
|
||||||
->enabled_extensions()
|
->enabled_extensions()
|
||||||
.GetAppByURL(url);
|
.GetAppByURL(url);
|
||||||
if (!extension)
|
if (!extension) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_BOOKMARK_BAR,
|
extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_BOOKMARK_BAR,
|
||||||
extension->GetType());
|
extension->GetType());
|
||||||
@@ -755,8 +756,9 @@ BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view)
|
|||||||
SetPaintToLayer();
|
SetPaintToLayer();
|
||||||
|
|
||||||
size_animation_.Reset(1);
|
size_animation_.Reset(1);
|
||||||
if (!gfx::Animation::ShouldRenderRichAnimation())
|
if (!gfx::Animation::ShouldRenderRichAnimation()) {
|
||||||
animations_enabled = false;
|
animations_enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
// May be null for tests.
|
// May be null for tests.
|
||||||
if (browser_view)
|
if (browser_view)
|
||||||
@@ -769,8 +771,9 @@ BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BookmarkBarView::~BookmarkBarView() {
|
BookmarkBarView::~BookmarkBarView() {
|
||||||
if (bookmark_model_)
|
if (bookmark_model_) {
|
||||||
bookmark_model_->RemoveObserver(this);
|
bookmark_model_->RemoveObserver(this);
|
||||||
|
}
|
||||||
|
|
||||||
// It's possible for the menu to outlive us, reset the observer to make sure
|
// It's possible for the menu to outlive us, reset the observer to make sure
|
||||||
// it doesn't have a reference to us.
|
// it doesn't have a reference to us.
|
||||||
@@ -803,8 +806,9 @@ void BookmarkBarView::SetPageNavigator(content::PageNavigator* navigator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkBarView::SetInfoBarVisible(bool infobar_visible) {
|
void BookmarkBarView::SetInfoBarVisible(bool infobar_visible) {
|
||||||
if (infobar_visible == infobar_visible_)
|
if (infobar_visible == infobar_visible_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
infobar_visible_ = infobar_visible;
|
infobar_visible_ = infobar_visible;
|
||||||
OnPropertyChanged(&infobar_visible_, views::kPropertyEffectsLayout);
|
OnPropertyChanged(&infobar_visible_, views::kPropertyEffectsLayout);
|
||||||
}
|
}
|
||||||
@@ -824,8 +828,9 @@ void BookmarkBarView::SetBookmarkBarState(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_animation_.Reset(state == BookmarkBar::SHOW ? 1 : 0);
|
size_animation_.Reset(state == BookmarkBar::SHOW ? 1 : 0);
|
||||||
if (!animations_enabled)
|
if (!animations_enabled) {
|
||||||
AnimationEnded(&size_animation_);
|
AnimationEnded(&size_animation_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
#if BUILDFLAG(IS_MAC)
|
||||||
@@ -865,8 +870,9 @@ const BookmarkNode* BookmarkBarView::GetNodeForButtonAtModelIndex(
|
|||||||
// Then check the bookmark buttons.
|
// Then check the bookmark buttons.
|
||||||
for (size_t i = 0; i < bookmark_buttons_.size(); ++i) {
|
for (size_t i = 0; i < bookmark_buttons_.size(); ++i) {
|
||||||
views::View* child = bookmark_buttons_[i];
|
views::View* child = bookmark_buttons_[i];
|
||||||
if (!child->GetVisible())
|
if (!child->GetVisible()) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (child->bounds().Contains(adjusted_loc))
|
if (child->bounds().Contains(adjusted_loc))
|
||||||
return bookmark_model_->bookmark_bar_node()->children()[i].get();
|
return bookmark_model_->bookmark_bar_node()->children()[i].get();
|
||||||
}
|
}
|
||||||
@@ -888,18 +894,22 @@ const BookmarkNode* BookmarkBarView::GetNodeForButtonAtModelIndex(
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuButton* BookmarkBarView::GetMenuButtonForNode(const BookmarkNode* node) {
|
MenuButton* BookmarkBarView::GetMenuButtonForNode(const BookmarkNode* node) {
|
||||||
if (node == managed_->managed_node())
|
if (node == managed_->managed_node()) {
|
||||||
return managed_bookmarks_button_;
|
return managed_bookmarks_button_;
|
||||||
if (node == bookmark_model_->other_node())
|
}
|
||||||
|
if (node == bookmark_model_->other_node()) {
|
||||||
return other_bookmarks_button_;
|
return other_bookmarks_button_;
|
||||||
if (node == bookmark_model_->bookmark_bar_node())
|
}
|
||||||
|
if (node == bookmark_model_->bookmark_bar_node()) {
|
||||||
return overflow_button_;
|
return overflow_button_;
|
||||||
|
}
|
||||||
// TODO: add logic to handle saved groups node(crbug.com/1223929 and
|
// TODO: add logic to handle saved groups node(crbug.com/1223929 and
|
||||||
// crbug.com/1223919)
|
// crbug.com/1223919)
|
||||||
absl::optional<size_t> index =
|
absl::optional<size_t> index =
|
||||||
bookmark_model_->bookmark_bar_node()->GetIndexOf(node);
|
bookmark_model_->bookmark_bar_node()->GetIndexOf(node);
|
||||||
if (!index.has_value() || !node->is_folder())
|
if (!index.has_value() || !node->is_folder()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
return static_cast<MenuButton*>(bookmark_buttons_[index.value()]);
|
return static_cast<MenuButton*>(bookmark_buttons_[index.value()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -958,8 +968,9 @@ std::u16string BookmarkBarView::CreateToolTipForURLAndTitle(
|
|||||||
|
|
||||||
// Only show the URL if the url and title differ.
|
// Only show the URL if the url and title differ.
|
||||||
if (title != base::UTF8ToUTF16(url.spec())) {
|
if (title != base::UTF8ToUTF16(url.spec())) {
|
||||||
if (!result.empty())
|
if (!result.empty()) {
|
||||||
result.push_back('\n');
|
result.push_back('\n');
|
||||||
|
}
|
||||||
|
|
||||||
// We need to explicitly specify the directionality of the URL's text to
|
// We need to explicitly specify the directionality of the URL's text to
|
||||||
// make sure it is treated as an LTR string when the context is RTL. For
|
// make sure it is treated as an LTR string when the context is RTL. For
|
||||||
@@ -1026,8 +1037,9 @@ gfx::Size BookmarkBarView::GetMinimumSize() const {
|
|||||||
|
|
||||||
void BookmarkBarView::Layout() {
|
void BookmarkBarView::Layout() {
|
||||||
// Skip layout during destruction, when no model exists.
|
// Skip layout during destruction, when no model exists.
|
||||||
if (!bookmark_model_)
|
if (!bookmark_model_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int x = GetLeadingMargin();
|
int x = GetLeadingMargin();
|
||||||
static constexpr int kBookmarkBarTrailingMargin = 8;
|
static constexpr int kBookmarkBarTrailingMargin = 8;
|
||||||
@@ -1265,8 +1277,9 @@ void BookmarkBarView::PaintChildren(const views::PaintInfo& paint_info) {
|
|||||||
bool BookmarkBarView::GetDropFormats(
|
bool BookmarkBarView::GetDropFormats(
|
||||||
int* formats,
|
int* formats,
|
||||||
std::set<ui::ClipboardFormatType>* format_types) {
|
std::set<ui::ClipboardFormatType>* format_types) {
|
||||||
if (!bookmark_model_ || !bookmark_model_->loaded())
|
if (!bookmark_model_ || !bookmark_model_->loaded()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
*formats = ui::OSExchangeData::URL;
|
*formats = ui::OSExchangeData::URL;
|
||||||
format_types->insert(bookmarks::BookmarkNodeData::GetBookmarkFormatType());
|
format_types->insert(bookmarks::BookmarkNodeData::GetBookmarkFormatType());
|
||||||
return true;
|
return true;
|
||||||
@@ -1282,8 +1295,9 @@ bool BookmarkBarView::CanDrop(const ui::OSExchangeData& data) {
|
|||||||
bookmarks::prefs::kEditBookmarksEnabled))
|
bookmarks::prefs::kEditBookmarksEnabled))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!drop_info_.get())
|
if (!drop_info_.get()) {
|
||||||
drop_info_ = std::make_unique<DropInfo>();
|
drop_info_ = std::make_unique<DropInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
// Only accept drops of 1 node, which is the case for all data dragged from
|
// Only accept drops of 1 node, which is the case for all data dragged from
|
||||||
// bookmark bar and menus.
|
// bookmark bar and menus.
|
||||||
@@ -1293,8 +1307,9 @@ bool BookmarkBarView::CanDrop(const ui::OSExchangeData& data) {
|
|||||||
void BookmarkBarView::OnDragEntered(const ui::DropTargetEvent& event) {}
|
void BookmarkBarView::OnDragEntered(const ui::DropTargetEvent& event) {}
|
||||||
|
|
||||||
int BookmarkBarView::OnDragUpdated(const ui::DropTargetEvent& event) {
|
int BookmarkBarView::OnDragUpdated(const ui::DropTargetEvent& event) {
|
||||||
if (!drop_info_.get())
|
if (!drop_info_.get()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (drop_info_->valid &&
|
if (drop_info_->valid &&
|
||||||
(drop_info_->x == event.x() && drop_info_->y == event.y())) {
|
(drop_info_->x == event.x() && drop_info_->y == event.y())) {
|
||||||
@@ -1324,8 +1339,9 @@ int BookmarkBarView::OnDragUpdated(const ui::DropTargetEvent& event) {
|
|||||||
drop_info_->valid = true;
|
drop_info_->valid = true;
|
||||||
|
|
||||||
if (drop_info_->is_menu_showing) {
|
if (drop_info_->is_menu_showing) {
|
||||||
if (bookmark_drop_menu_)
|
if (bookmark_drop_menu_) {
|
||||||
bookmark_drop_menu_->Cancel();
|
bookmark_drop_menu_->Cancel();
|
||||||
|
}
|
||||||
drop_info_->is_menu_showing = false;
|
drop_info_->is_menu_showing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1364,8 +1380,9 @@ views::View::DropCallback BookmarkBarView::GetDropCallback(
|
|||||||
const ui::DropTargetEvent& event) {
|
const ui::DropTargetEvent& event) {
|
||||||
StopShowFolderDropMenuTimer();
|
StopShowFolderDropMenuTimer();
|
||||||
|
|
||||||
if (bookmark_drop_menu_)
|
if (bookmark_drop_menu_) {
|
||||||
bookmark_drop_menu_->Cancel();
|
bookmark_drop_menu_->Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
if (!drop_info_ || !drop_info_->valid ||
|
if (!drop_info_ || !drop_info_->valid ||
|
||||||
drop_info_->location.operation == DragOperation::kNone)
|
drop_info_->location.operation == DragOperation::kNone)
|
||||||
@@ -1398,8 +1415,9 @@ void BookmarkBarView::VisibilityChanged(View* starting_from, bool is_visible) {
|
|||||||
|
|
||||||
void BookmarkBarView::ChildPreferredSizeChanged(views::View* child) {
|
void BookmarkBarView::ChildPreferredSizeChanged(views::View* child) {
|
||||||
// only rerender
|
// only rerender
|
||||||
if (child != saved_tab_group_bar_)
|
if (child != saved_tab_group_bar_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
InvalidateDrop();
|
InvalidateDrop();
|
||||||
}
|
}
|
||||||
@@ -1411,8 +1429,9 @@ void BookmarkBarView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
|||||||
|
|
||||||
void BookmarkBarView::AnimationProgressed(const gfx::Animation* animation) {
|
void BookmarkBarView::AnimationProgressed(const gfx::Animation* animation) {
|
||||||
// |browser_view_| can be null during tests.
|
// |browser_view_| can be null during tests.
|
||||||
if (browser_view_)
|
if (browser_view_) {
|
||||||
browser_view_->ToolbarSizeChanged(true);
|
browser_view_->ToolbarSizeChanged(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkBarView::AnimationEnded(const gfx::Animation* animation) {
|
void BookmarkBarView::AnimationEnded(const gfx::Animation* animation) {
|
||||||
@@ -1473,8 +1492,9 @@ void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model,
|
|||||||
BookmarkNodeRemovedImpl(model, old_parent, old_index);
|
BookmarkNodeRemovedImpl(model, old_parent, old_index);
|
||||||
if (BookmarkNodeAddedImpl(model, new_parent, new_index))
|
if (BookmarkNodeAddedImpl(model, new_parent, new_index))
|
||||||
needs_layout_and_paint = true;
|
needs_layout_and_paint = true;
|
||||||
if (needs_layout_and_paint)
|
if (needs_layout_and_paint) {
|
||||||
LayoutAndPaint();
|
LayoutAndPaint();
|
||||||
|
}
|
||||||
|
|
||||||
drop_weak_ptr_factory_.InvalidateWeakPtrs();
|
drop_weak_ptr_factory_.InvalidateWeakPtrs();
|
||||||
}
|
}
|
||||||
@@ -1485,8 +1505,9 @@ void BookmarkBarView::BookmarkNodeAdded(BookmarkModel* model,
|
|||||||
bool added_by_user) {
|
bool added_by_user) {
|
||||||
// See comment in BookmarkNodeMoved() for details on this.
|
// See comment in BookmarkNodeMoved() for details on this.
|
||||||
InvalidateDrop();
|
InvalidateDrop();
|
||||||
if (BookmarkNodeAddedImpl(model, parent, index))
|
if (BookmarkNodeAddedImpl(model, parent, index)) {
|
||||||
LayoutAndPaint();
|
LayoutAndPaint();
|
||||||
|
}
|
||||||
|
|
||||||
drop_weak_ptr_factory_.InvalidateWeakPtrs();
|
drop_weak_ptr_factory_.InvalidateWeakPtrs();
|
||||||
}
|
}
|
||||||
@@ -1502,8 +1523,9 @@ void BookmarkBarView::BookmarkNodeRemoved(BookmarkModel* model,
|
|||||||
// Close the menu if the menu is showing for the deleted node.
|
// Close the menu if the menu is showing for the deleted node.
|
||||||
if (bookmark_menu_ && bookmark_menu_->node() == node)
|
if (bookmark_menu_ && bookmark_menu_->node() == node)
|
||||||
bookmark_menu_->Cancel();
|
bookmark_menu_->Cancel();
|
||||||
if (BookmarkNodeRemovedImpl(model, parent, old_index))
|
if (BookmarkNodeRemovedImpl(model, parent, old_index)) {
|
||||||
LayoutAndPaint();
|
LayoutAndPaint();
|
||||||
|
}
|
||||||
|
|
||||||
drop_weak_ptr_factory_.InvalidateWeakPtrs();
|
drop_weak_ptr_factory_.InvalidateWeakPtrs();
|
||||||
}
|
}
|
||||||
@@ -1775,8 +1797,9 @@ void BookmarkBarView::Init() {
|
|||||||
managed_ = ManagedBookmarkServiceFactory::GetForProfile(browser_->profile());
|
managed_ = ManagedBookmarkServiceFactory::GetForProfile(browser_->profile());
|
||||||
if (bookmark_model_) {
|
if (bookmark_model_) {
|
||||||
bookmark_model_->AddObserver(this);
|
bookmark_model_->AddObserver(this);
|
||||||
if (bookmark_model_->loaded())
|
if (bookmark_model_->loaded()) {
|
||||||
BookmarkModelLoaded(bookmark_model_, false);
|
BookmarkModelLoaded(bookmark_model_, false);
|
||||||
|
}
|
||||||
// else case: we'll receive notification back from the BookmarkModel when
|
// else case: we'll receive notification back from the BookmarkModel when
|
||||||
// done loading, then we'll populate the bar.
|
// done loading, then we'll populate the bar.
|
||||||
}
|
}
|
||||||
@@ -1812,13 +1835,12 @@ std::unique_ptr<MenuButton> BookmarkBarView::CreateManagedBookmarksButton() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MenuButton> BookmarkBarView::CreateOverflowButton() {
|
std::unique_ptr<MenuButton> BookmarkBarView::CreateOverflowButton() {
|
||||||
auto button =
|
auto button = std::make_unique<BookmarkMenuButtonBase>(base::BindRepeating(
|
||||||
std::make_unique<BookmarkMenuButtonBase>(base::BindRepeating(
|
[](BookmarkBarView* bar, const ui::Event& event) {
|
||||||
[](BookmarkBarView* bar, const ui::Event& event) {
|
bar->OnMenuButtonPressed(bar->bookmark_model_->bookmark_bar_node(),
|
||||||
bar->OnMenuButtonPressed(bar->bookmark_model_->bookmark_bar_node(),
|
event);
|
||||||
event);
|
},
|
||||||
},
|
base::Unretained(this)));
|
||||||
base::Unretained(this)));
|
|
||||||
|
|
||||||
// The overflow button's image contains an arrow and therefore it is a
|
// The overflow button's image contains an arrow and therefore it is a
|
||||||
// direction sensitive image and we need to flip it if the UI layout is
|
// direction sensitive image and we need to flip it if the UI layout is
|
||||||
@@ -1951,8 +1973,9 @@ bool BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model,
|
|||||||
const BookmarkNode* parent,
|
const BookmarkNode* parent,
|
||||||
size_t index) {
|
size_t index) {
|
||||||
const bool needs_layout_and_paint = UpdateOtherAndManagedButtonsVisibility();
|
const bool needs_layout_and_paint = UpdateOtherAndManagedButtonsVisibility();
|
||||||
if (parent != model->bookmark_bar_node())
|
if (parent != model->bookmark_bar_node()) {
|
||||||
return needs_layout_and_paint;
|
return needs_layout_and_paint;
|
||||||
|
}
|
||||||
if (index < bookmark_buttons_.size()) {
|
if (index < bookmark_buttons_.size()) {
|
||||||
const BookmarkNode* node = parent->children()[index].get();
|
const BookmarkNode* node = parent->children()[index].get();
|
||||||
InsertBookmarkButtonAtIndex(CreateBookmarkButton(node), index);
|
InsertBookmarkButtonAtIndex(CreateBookmarkButton(node), index);
|
||||||
@@ -1973,8 +1996,9 @@ bool BookmarkBarView::BookmarkNodeRemovedImpl(BookmarkModel* model,
|
|||||||
// Only children of the bookmark_bar_node get buttons.
|
// Only children of the bookmark_bar_node get buttons.
|
||||||
return needs_layout;
|
return needs_layout;
|
||||||
}
|
}
|
||||||
if (index >= bookmark_buttons_.size())
|
if (index >= bookmark_buttons_.size()) {
|
||||||
return needs_layout;
|
return needs_layout;
|
||||||
|
}
|
||||||
|
|
||||||
views::LabelButton* button = bookmark_buttons_[index];
|
views::LabelButton* button = bookmark_buttons_[index];
|
||||||
bookmark_buttons_.erase(bookmark_buttons_.cbegin() + index);
|
bookmark_buttons_.erase(bookmark_buttons_.cbegin() + index);
|
||||||
@@ -2010,8 +2034,9 @@ void BookmarkBarView::BookmarkNodeChangedImpl(BookmarkModel* model,
|
|||||||
views::LabelButton* button = bookmark_buttons_[index];
|
views::LabelButton* button = bookmark_buttons_[index];
|
||||||
const int old_pref_width = button->GetPreferredSize().width();
|
const int old_pref_width = button->GetPreferredSize().width();
|
||||||
ConfigureButton(node, button);
|
ConfigureButton(node, button);
|
||||||
if (old_pref_width != button->GetPreferredSize().width())
|
if (old_pref_width != button->GetPreferredSize().width()) {
|
||||||
LayoutAndPaint();
|
LayoutAndPaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkBarView::ShowDropFolderForNode(const BookmarkNode* node) {
|
void BookmarkBarView::ShowDropFolderForNode(const BookmarkNode* node) {
|
||||||
@@ -2024,8 +2049,9 @@ void BookmarkBarView::ShowDropFolderForNode(const BookmarkNode* node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuButton* menu_button = GetMenuButtonForNode(node);
|
MenuButton* menu_button = GetMenuButtonForNode(node);
|
||||||
if (!menu_button)
|
if (!menu_button) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
size_t start_index = 0;
|
size_t start_index = 0;
|
||||||
if (node == bookmark_model_->bookmark_bar_node())
|
if (node == bookmark_model_->bookmark_bar_node())
|
||||||
@@ -2178,8 +2204,9 @@ void BookmarkBarView::InvalidateDrop() {
|
|||||||
drop_info_->valid = false;
|
drop_info_->valid = false;
|
||||||
SchedulePaint();
|
SchedulePaint();
|
||||||
}
|
}
|
||||||
if (bookmark_drop_menu_)
|
if (bookmark_drop_menu_) {
|
||||||
bookmark_drop_menu_->Cancel();
|
bookmark_drop_menu_->Cancel();
|
||||||
|
}
|
||||||
StopShowFolderDropMenuTimer();
|
StopShowFolderDropMenuTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2200,8 +2227,9 @@ void BookmarkBarView::WriteBookmarkDragData(const BookmarkNode* node,
|
|||||||
void BookmarkBarView::UpdateAppearanceForTheme() {
|
void BookmarkBarView::UpdateAppearanceForTheme() {
|
||||||
// We don't always have a color provider (ui tests, for example).
|
// We don't always have a color provider (ui tests, for example).
|
||||||
const ui::ColorProvider* color_provider = GetColorProvider();
|
const ui::ColorProvider* color_provider = GetColorProvider();
|
||||||
if (!color_provider)
|
if (!color_provider) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
for (size_t i = 0; i < bookmark_buttons_.size(); ++i) {
|
for (size_t i = 0; i < bookmark_buttons_.size(); ++i) {
|
||||||
ConfigureButton(bookmark_model_->bookmark_bar_node()->children()[i].get(),
|
ConfigureButton(bookmark_model_->bookmark_bar_node()->children()[i].get(),
|
||||||
bookmark_buttons_[i]);
|
bookmark_buttons_[i]);
|
||||||
@@ -2251,8 +2279,9 @@ bool BookmarkBarView::UpdateOtherAndManagedButtonsVisibility() {
|
|||||||
browser_->profile()->GetPrefs()->GetBoolean(
|
browser_->profile()->GetPrefs()->GetBoolean(
|
||||||
bookmarks::prefs::kShowManagedBookmarksInBookmarkBar);
|
bookmarks::prefs::kShowManagedBookmarksInBookmarkBar);
|
||||||
bool update_managed = show_managed != managed_bookmarks_button_->GetVisible();
|
bool update_managed = show_managed != managed_bookmarks_button_->GetVisible();
|
||||||
if (update_managed)
|
if (update_managed) {
|
||||||
managed_bookmarks_button_->SetVisible(show_managed);
|
managed_bookmarks_button_->SetVisible(show_managed);
|
||||||
|
}
|
||||||
|
|
||||||
return update_other || update_managed;
|
return update_other || update_managed;
|
||||||
}
|
}
|
||||||
@@ -2277,16 +2306,18 @@ void BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged() {
|
|||||||
// Only perform layout if required.
|
// Only perform layout if required.
|
||||||
bool visible =
|
bool visible =
|
||||||
chrome::ShouldShowAppsShortcutInBookmarkBar(browser_->profile());
|
chrome::ShouldShowAppsShortcutInBookmarkBar(browser_->profile());
|
||||||
if (apps_page_shortcut_->GetVisible() == visible)
|
if (apps_page_shortcut_->GetVisible() == visible) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
apps_page_shortcut_->SetVisible(visible);
|
apps_page_shortcut_->SetVisible(visible);
|
||||||
UpdateBookmarksSeparatorVisibility();
|
UpdateBookmarksSeparatorVisibility();
|
||||||
LayoutAndPaint();
|
LayoutAndPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
|
void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
|
||||||
if (UpdateOtherAndManagedButtonsVisibility())
|
if (UpdateOtherAndManagedButtonsVisibility()) {
|
||||||
LayoutAndPaint();
|
LayoutAndPaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkBarView::InsertBookmarkButtonAtIndex(
|
void BookmarkBarView::InsertBookmarkButtonAtIndex(
|
||||||
@@ -2304,9 +2335,8 @@ void BookmarkBarView::InsertBookmarkButtonAtIndex(
|
|||||||
DCHECK_EQ(*i++, saved_tab_group_bar_);
|
DCHECK_EQ(*i++, saved_tab_group_bar_);
|
||||||
}
|
}
|
||||||
const auto is_bookmark_button = [this](const auto* v) {
|
const auto is_bookmark_button = [this](const auto* v) {
|
||||||
const char* class_name = v->GetClassName();
|
return (views::IsViewClass<BookmarkButton>(v) ||
|
||||||
return (class_name == BookmarkButton::kViewClassName ||
|
views::IsViewClass<BookmarkFolderButton>(v)) &&
|
||||||
class_name == BookmarkFolderButton::kViewClassName) &&
|
|
||||||
v != overflow_button_ && v != other_bookmarks_button_;
|
v != overflow_button_ && v != other_bookmarks_button_;
|
||||||
};
|
};
|
||||||
i = std::find_if_not(i, children().cend(), is_bookmark_button);
|
i = std::find_if_not(i, children().cend(), is_bookmark_button);
|
||||||
@@ -2321,8 +2351,9 @@ void BookmarkBarView::InsertBookmarkButtonAtIndex(
|
|||||||
|
|
||||||
size_t BookmarkBarView::GetIndexForButton(views::View* button) {
|
size_t BookmarkBarView::GetIndexForButton(views::View* button) {
|
||||||
auto it = base::ranges::find(bookmark_buttons_, button);
|
auto it = base::ranges::find(bookmark_buttons_, button);
|
||||||
if (it == bookmark_buttons_.cend())
|
if (it == bookmark_buttons_.cend()) {
|
||||||
return static_cast<size_t>(-1);
|
return static_cast<size_t>(-1);
|
||||||
|
}
|
||||||
|
|
||||||
return static_cast<size_t>(it - bookmark_buttons_.cbegin());
|
return static_cast<size_t>(it - bookmark_buttons_.cbegin());
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "ui/views/layout/box_layout.h"
|
#include "ui/views/layout/box_layout.h"
|
||||||
#include "ui/views/style/typography.h"
|
#include "ui/views/style/typography.h"
|
||||||
#include "ui/views/view_class_properties.h"
|
#include "ui/views/view_class_properties.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
|
|
||||||
namespace media_message_center {
|
namespace media_message_center {
|
||||||
|
|
||||||
@@ -284,21 +285,25 @@ MediaNotificationViewImpl::MediaNotificationViewImpl(
|
|||||||
message_center::kNotificationCornerRadius);
|
message_center::kNotificationCornerRadius);
|
||||||
UpdateViewForExpandedState();
|
UpdateViewForExpandedState();
|
||||||
|
|
||||||
if (header_row_)
|
if (header_row_) {
|
||||||
header_row_->SetExpandButtonEnabled(GetExpandable());
|
header_row_->SetExpandButtonEnabled(GetExpandable());
|
||||||
|
}
|
||||||
|
|
||||||
if (item_)
|
if (item_) {
|
||||||
item_->SetView(this);
|
item_->SetView(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaNotificationViewImpl::~MediaNotificationViewImpl() {
|
MediaNotificationViewImpl::~MediaNotificationViewImpl() {
|
||||||
if (item_)
|
if (item_) {
|
||||||
item_->SetView(nullptr);
|
item_->SetView(nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaNotificationViewImpl::SetExpanded(bool expanded) {
|
void MediaNotificationViewImpl::SetExpanded(bool expanded) {
|
||||||
if (expanded_ == expanded)
|
if (expanded_ == expanded) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
expanded_ = expanded;
|
expanded_ = expanded;
|
||||||
|
|
||||||
@@ -320,17 +325,20 @@ void MediaNotificationViewImpl::UpdateCornerRadius(int top_radius,
|
|||||||
void MediaNotificationViewImpl::SetForcedExpandedState(
|
void MediaNotificationViewImpl::SetForcedExpandedState(
|
||||||
bool* forced_expanded_state) {
|
bool* forced_expanded_state) {
|
||||||
if (forced_expanded_state) {
|
if (forced_expanded_state) {
|
||||||
if (forced_expanded_state_ == *forced_expanded_state)
|
if (forced_expanded_state_ == *forced_expanded_state) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
forced_expanded_state_ = *forced_expanded_state;
|
forced_expanded_state_ = *forced_expanded_state;
|
||||||
} else {
|
} else {
|
||||||
if (!forced_expanded_state_.has_value())
|
if (!forced_expanded_state_.has_value()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
forced_expanded_state_ = absl::nullopt;
|
forced_expanded_state_ = absl::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header_row_)
|
if (header_row_) {
|
||||||
header_row_->SetExpandButtonEnabled(GetExpandable());
|
header_row_->SetExpandButtonEnabled(GetExpandable());
|
||||||
|
}
|
||||||
UpdateViewForExpandedState();
|
UpdateViewForExpandedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,8 +421,9 @@ void MediaNotificationViewImpl::UpdateWithMediaMetadata(
|
|||||||
RecordMetadataHistogram(Metadata::kArtist);
|
RecordMetadataHistogram(Metadata::kArtist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!metadata.album.empty())
|
if (!metadata.album.empty()) {
|
||||||
RecordMetadataHistogram(Metadata::kAlbum);
|
RecordMetadataHistogram(Metadata::kAlbum);
|
||||||
|
}
|
||||||
|
|
||||||
RecordMetadataHistogram(Metadata::kCount);
|
RecordMetadataHistogram(Metadata::kCount);
|
||||||
|
|
||||||
@@ -430,8 +439,9 @@ void MediaNotificationViewImpl::UpdateWithMediaActions(
|
|||||||
const base::flat_set<media_session::mojom::MediaSessionAction>& actions) {
|
const base::flat_set<media_session::mojom::MediaSessionAction>& actions) {
|
||||||
enabled_actions_ = actions;
|
enabled_actions_ = actions;
|
||||||
|
|
||||||
if (header_row_)
|
if (header_row_) {
|
||||||
header_row_->SetExpandButtonEnabled(GetExpandable());
|
header_row_->SetExpandButtonEnabled(GetExpandable());
|
||||||
|
}
|
||||||
UpdateViewForExpandedState();
|
UpdateViewForExpandedState();
|
||||||
|
|
||||||
PreferredSizeChanged();
|
PreferredSizeChanged();
|
||||||
@@ -448,8 +458,9 @@ void MediaNotificationViewImpl::UpdateWithMediaArtwork(
|
|||||||
|
|
||||||
UMA_HISTOGRAM_BOOLEAN(kArtworkHistogramName, has_artwork_);
|
UMA_HISTOGRAM_BOOLEAN(kArtworkHistogramName, has_artwork_);
|
||||||
|
|
||||||
if (GetWidget())
|
if (GetWidget()) {
|
||||||
UpdateForegroundColor();
|
UpdateForegroundColor();
|
||||||
|
}
|
||||||
|
|
||||||
container_->OnMediaArtworkChanged(image);
|
container_->OnMediaArtworkChanged(image);
|
||||||
|
|
||||||
@@ -462,20 +473,23 @@ void MediaNotificationViewImpl::UpdateWithMediaArtwork(
|
|||||||
void MediaNotificationViewImpl::UpdateWithFavicon(const gfx::ImageSkia& icon) {
|
void MediaNotificationViewImpl::UpdateWithFavicon(const gfx::ImageSkia& icon) {
|
||||||
GetMediaNotificationBackground()->UpdateFavicon(icon);
|
GetMediaNotificationBackground()->UpdateFavicon(icon);
|
||||||
|
|
||||||
if (GetWidget())
|
if (GetWidget()) {
|
||||||
UpdateForegroundColor();
|
UpdateForegroundColor();
|
||||||
|
}
|
||||||
SchedulePaint();
|
SchedulePaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaNotificationViewImpl::UpdateWithVectorIcon(
|
void MediaNotificationViewImpl::UpdateWithVectorIcon(
|
||||||
const gfx::VectorIcon* vector_icon) {
|
const gfx::VectorIcon* vector_icon) {
|
||||||
if (!header_row_)
|
if (!header_row_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
vector_header_icon_ = vector_icon;
|
vector_header_icon_ = vector_icon;
|
||||||
UpdateAppIconVisibility(header_row_, vector_header_icon_ != nullptr);
|
UpdateAppIconVisibility(header_row_, vector_header_icon_ != nullptr);
|
||||||
if (GetWidget())
|
if (GetWidget()) {
|
||||||
UpdateForegroundColor();
|
UpdateForegroundColor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaNotificationViewImpl::UpdateDeviceSelectorVisibility(bool visible) {
|
void MediaNotificationViewImpl::UpdateDeviceSelectorVisibility(bool visible) {
|
||||||
@@ -514,14 +528,16 @@ void MediaNotificationViewImpl::UpdateActionButtonsVisibility() {
|
|||||||
|
|
||||||
action_button->SetVisible(should_show);
|
action_button->SetVisible(should_show);
|
||||||
|
|
||||||
if (should_invalidate)
|
if (should_invalidate) {
|
||||||
action_button->InvalidateLayout();
|
action_button->InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
if (action_button == picture_in_picture_button_) {
|
if (action_button == picture_in_picture_button_) {
|
||||||
pip_button_separator_view_->SetVisible(should_show);
|
pip_button_separator_view_->SetVisible(should_show);
|
||||||
|
|
||||||
if (should_invalidate)
|
if (should_invalidate) {
|
||||||
pip_button_separator_view_->InvalidateLayout();
|
pip_button_separator_view_->InvalidateLayout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,8 +601,9 @@ void MediaNotificationViewImpl::UpdateViewForExpandedState() {
|
|||||||
SchedulePaint();
|
SchedulePaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header_row_)
|
if (header_row_) {
|
||||||
header_row_->SetExpanded(expanded);
|
header_row_->SetExpanded(expanded);
|
||||||
|
}
|
||||||
container_->OnExpanded(expanded);
|
container_->OnExpanded(expanded);
|
||||||
|
|
||||||
UpdateActionButtonsVisibility();
|
UpdateActionButtonsVisibility();
|
||||||
@@ -671,8 +688,9 @@ MediaNotificationViewImpl::GetMediaNotificationBackground() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MediaNotificationViewImpl::GetExpandable() const {
|
bool MediaNotificationViewImpl::GetExpandable() const {
|
||||||
if (forced_expanded_state_.has_value())
|
if (forced_expanded_state_.has_value()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
base::flat_set<MediaSessionAction> ignored_actions = {
|
base::flat_set<MediaSessionAction> ignored_actions = {
|
||||||
GetPlayPauseIgnoredAction(GetActionFromButtonTag(*play_pause_button_)),
|
GetPlayPauseIgnoredAction(GetActionFromButtonTag(*play_pause_button_)),
|
||||||
@@ -687,8 +705,9 @@ bool MediaNotificationViewImpl::GetExpandable() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MediaNotificationViewImpl::GetActuallyExpanded() const {
|
bool MediaNotificationViewImpl::GetActuallyExpanded() const {
|
||||||
if (forced_expanded_state_.has_value())
|
if (forced_expanded_state_.has_value()) {
|
||||||
return forced_expanded_state_.value();
|
return forced_expanded_state_.value();
|
||||||
|
}
|
||||||
return expanded_ && GetExpandable();
|
return expanded_ && GetExpandable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -758,8 +777,9 @@ void MediaNotificationViewImpl::UpdateForegroundColor() {
|
|||||||
// Update action buttons.
|
// Update action buttons.
|
||||||
for (views::View* child : playback_button_container_->children()) {
|
for (views::View* child : playback_button_container_->children()) {
|
||||||
// Skip the play pause button since it is a special case.
|
// Skip the play pause button since it is a special case.
|
||||||
if (child == play_pause_button_)
|
if (child == play_pause_button_) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
views::ImageButton* button = static_cast<views::ImageButton*>(child);
|
views::ImageButton* button = static_cast<views::ImageButton*>(child);
|
||||||
|
|
||||||
@@ -781,8 +801,9 @@ void MediaNotificationViewImpl::ButtonPressed(views::Button* button) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MediaNotificationViewImpl::MaybeShowOrHideArtistLabel() {
|
void MediaNotificationViewImpl::MaybeShowOrHideArtistLabel() {
|
||||||
if (!is_cros_)
|
if (!is_cros_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
artist_label_->SetVisible(!artist_label_->GetText().empty() || has_artwork_);
|
artist_label_->SetVisible(!artist_label_->GetText().empty() || has_artwork_);
|
||||||
}
|
}
|
||||||
@@ -793,8 +814,8 @@ std::vector<views::View*> MediaNotificationViewImpl::GetButtons() {
|
|||||||
playback_button_container_->children().cbegin(),
|
playback_button_container_->children().cbegin(),
|
||||||
playback_button_container_->children().cend());
|
playback_button_container_->children().cend());
|
||||||
base::EraseIf(buttons, [](views::View* view) {
|
base::EraseIf(buttons, [](views::View* view) {
|
||||||
return !(view->GetClassName() == views::ImageButton::kViewClassName ||
|
return !(views::IsViewClass<views::ImageButton>(view) ||
|
||||||
view->GetClassName() == views::ToggleImageButton::kViewClassName);
|
views::IsViewClass<views::ToggleImageButton>(view));
|
||||||
});
|
});
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "ui/views/controls/image_view.h"
|
#include "ui/views/controls/image_view.h"
|
||||||
#include "ui/views/test/button_test_api.h"
|
#include "ui/views/test/button_test_api.h"
|
||||||
#include "ui/views/test/views_test_base.h"
|
#include "ui/views/test/views_test_base.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
|
|
||||||
namespace media_message_center {
|
namespace media_message_center {
|
||||||
|
|
||||||
@@ -425,9 +426,10 @@ TEST_F(MediaNotificationViewImplTest, PlayToggle_FromObserver_Empty) {
|
|||||||
EnableAction(MediaSessionAction::kPlay);
|
EnableAction(MediaSessionAction::kPlay);
|
||||||
|
|
||||||
{
|
{
|
||||||
views::ToggleImageButton* button = static_cast<views::ToggleImageButton*>(
|
views::ToggleImageButton* button =
|
||||||
GetButtonForAction(MediaSessionAction::kPlay));
|
views::AsViewClass<views::ToggleImageButton>(
|
||||||
ASSERT_EQ(views::ToggleImageButton::kViewClassName, button->GetClassName());
|
GetButtonForAction(MediaSessionAction::kPlay));
|
||||||
|
ASSERT_TRUE(button);
|
||||||
EXPECT_FALSE(button->GetToggled());
|
EXPECT_FALSE(button->GetToggled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,9 +437,10 @@ TEST_F(MediaNotificationViewImplTest, PlayToggle_FromObserver_Empty) {
|
|||||||
media_session::mojom::MediaSessionInfo::New());
|
media_session::mojom::MediaSessionInfo::New());
|
||||||
|
|
||||||
{
|
{
|
||||||
views::ToggleImageButton* button = static_cast<views::ToggleImageButton*>(
|
views::ToggleImageButton* button =
|
||||||
GetButtonForAction(MediaSessionAction::kPlay));
|
views::AsViewClass<views::ToggleImageButton>(
|
||||||
ASSERT_EQ(views::ToggleImageButton::kViewClassName, button->GetClassName());
|
GetButtonForAction(MediaSessionAction::kPlay));
|
||||||
|
ASSERT_TRUE(button);
|
||||||
EXPECT_FALSE(button->GetToggled());
|
EXPECT_FALSE(button->GetToggled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -447,9 +450,10 @@ TEST_F(MediaNotificationViewImplTest, PlayToggle_FromObserver_PlaybackState) {
|
|||||||
EnableAction(MediaSessionAction::kPause);
|
EnableAction(MediaSessionAction::kPause);
|
||||||
|
|
||||||
{
|
{
|
||||||
views::ToggleImageButton* button = static_cast<views::ToggleImageButton*>(
|
views::ToggleImageButton* button =
|
||||||
GetButtonForAction(MediaSessionAction::kPlay));
|
views::AsViewClass<views::ToggleImageButton>(
|
||||||
ASSERT_EQ(views::ToggleImageButton::kViewClassName, button->GetClassName());
|
GetButtonForAction(MediaSessionAction::kPlay));
|
||||||
|
ASSERT_TRUE(button);
|
||||||
EXPECT_FALSE(button->GetToggled());
|
EXPECT_FALSE(button->GetToggled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,9 +465,10 @@ TEST_F(MediaNotificationViewImplTest, PlayToggle_FromObserver_PlaybackState) {
|
|||||||
view()->UpdateWithMediaSessionInfo(session_info.Clone());
|
view()->UpdateWithMediaSessionInfo(session_info.Clone());
|
||||||
|
|
||||||
{
|
{
|
||||||
views::ToggleImageButton* button = static_cast<views::ToggleImageButton*>(
|
views::ToggleImageButton* button =
|
||||||
GetButtonForAction(MediaSessionAction::kPause));
|
views::AsViewClass<views::ToggleImageButton>(
|
||||||
ASSERT_EQ(views::ToggleImageButton::kViewClassName, button->GetClassName());
|
GetButtonForAction(MediaSessionAction::kPause));
|
||||||
|
ASSERT_TRUE(button);
|
||||||
EXPECT_TRUE(button->GetToggled());
|
EXPECT_TRUE(button->GetToggled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,9 +477,10 @@ TEST_F(MediaNotificationViewImplTest, PlayToggle_FromObserver_PlaybackState) {
|
|||||||
view()->UpdateWithMediaSessionInfo(session_info.Clone());
|
view()->UpdateWithMediaSessionInfo(session_info.Clone());
|
||||||
|
|
||||||
{
|
{
|
||||||
views::ToggleImageButton* button = static_cast<views::ToggleImageButton*>(
|
views::ToggleImageButton* button =
|
||||||
GetButtonForAction(MediaSessionAction::kPlay));
|
views::AsViewClass<views::ToggleImageButton>(
|
||||||
ASSERT_EQ(views::ToggleImageButton::kViewClassName, button->GetClassName());
|
GetButtonForAction(MediaSessionAction::kPlay));
|
||||||
|
ASSERT_TRUE(button);
|
||||||
EXPECT_FALSE(button->GetToggled());
|
EXPECT_FALSE(button->GetToggled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,12 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "components/ui_devtools/views/overlay_agent_views.h"
|
|
||||||
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "components/ui_devtools/ui_devtools_unittest_utils.h"
|
#include "components/ui_devtools/ui_devtools_unittest_utils.h"
|
||||||
#include "components/ui_devtools/ui_element.h"
|
#include "components/ui_devtools/ui_element.h"
|
||||||
#include "components/ui_devtools/views/dom_agent_views.h"
|
#include "components/ui_devtools/views/dom_agent_views.h"
|
||||||
|
#include "components/ui_devtools/views/overlay_agent_views.h"
|
||||||
#include "components/ui_devtools/views/view_element.h"
|
#include "components/ui_devtools/views/view_element.h"
|
||||||
#include "components/ui_devtools/views/widget_element.h"
|
#include "components/ui_devtools/views/widget_element.h"
|
||||||
#include "ui/events/base_event_utils.h"
|
#include "ui/events/base_event_utils.h"
|
||||||
@@ -16,6 +15,7 @@
|
|||||||
#include "ui/events/types/event_type.h"
|
#include "ui/events/types/event_type.h"
|
||||||
#include "ui/gfx/geometry/rect.h"
|
#include "ui/gfx/geometry/rect.h"
|
||||||
#include "ui/views/test/views_test_base.h"
|
#include "ui/views/test/views_test_base.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
#include "ui/views/widget/widget_utils.h"
|
#include "ui/views/widget/widget_utils.h"
|
||||||
#include "ui/views/window/non_client_view.h"
|
#include "ui/views/window/non_client_view.h"
|
||||||
|
|
||||||
@@ -254,8 +254,7 @@ TEST_F(OverlayAgentTest, HighlightRects) {
|
|||||||
// view and adding the subviews directly causes NonClientView's hit test to
|
// view and adding the subviews directly causes NonClientView's hit test to
|
||||||
// fail.
|
// fail.
|
||||||
views::View* contents_view = widget()->GetContentsView();
|
views::View* contents_view = widget()->GetContentsView();
|
||||||
DCHECK_EQ(contents_view->GetClassName(),
|
DCHECK(views::IsViewClass<views::NonClientView>(contents_view));
|
||||||
views::NonClientView::kViewClassName);
|
|
||||||
views::NonClientView* non_client_view =
|
views::NonClientView* non_client_view =
|
||||||
static_cast<views::NonClientView*>(contents_view);
|
static_cast<views::NonClientView*>(contents_view);
|
||||||
views::View* client_view = non_client_view->client_view();
|
views::View* client_view = non_client_view->client_view();
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
#include "ui/views/controls/label.h"
|
#include "ui/views/controls/label.h"
|
||||||
#include "ui/views/controls/menu/menu_config.h"
|
#include "ui/views/controls/menu/menu_config.h"
|
||||||
#include "ui/views/controls/menu/menu_controller.h"
|
#include "ui/views/controls/menu/menu_controller.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
#include "ui/views/views_delegate.h"
|
#include "ui/views/views_delegate.h"
|
||||||
#include "ui/views/widget/native_widget_mac.h"
|
#include "ui/views/widget/native_widget_mac.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
@@ -1135,8 +1136,7 @@ bool NativeWidgetMacNSWindowHost::GetIsFocusedViewTextual(bool* is_textual) {
|
|||||||
views::FocusManager* focus_manager =
|
views::FocusManager* focus_manager =
|
||||||
root_view_ ? root_view_->GetWidget()->GetFocusManager() : nullptr;
|
root_view_ ? root_view_->GetWidget()->GetFocusManager() : nullptr;
|
||||||
*is_textual = focus_manager && focus_manager->GetFocusedView() &&
|
*is_textual = focus_manager && focus_manager->GetFocusedView() &&
|
||||||
focus_manager->GetFocusedView()->GetClassName() ==
|
IsViewClass<views::Label>(focus_manager->GetFocusedView());
|
||||||
views::Label::kViewClassName;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include "ui/views/controls/focus_ring.h"
|
#include "ui/views/controls/focus_ring.h"
|
||||||
#include "ui/views/resources/grit/views_resources.h"
|
#include "ui/views/resources/grit/views_resources.h"
|
||||||
#include "ui/views/vector_icons.h"
|
#include "ui/views/vector_icons.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
@@ -73,8 +74,9 @@ bool RadioButton::IsGroupFocusTraversable() const {
|
|||||||
|
|
||||||
void RadioButton::OnFocus() {
|
void RadioButton::OnFocus() {
|
||||||
Checkbox::OnFocus();
|
Checkbox::OnFocus();
|
||||||
if (select_on_focus_)
|
if (select_on_focus_) {
|
||||||
SetChecked(true);
|
SetChecked(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioButton::OnThemeChanged() {
|
void RadioButton::OnThemeChanged() {
|
||||||
@@ -94,8 +96,9 @@ void RadioButton::RequestFocusFromEvent() {
|
|||||||
void RadioButton::NotifyClick(const ui::Event& event) {
|
void RadioButton::NotifyClick(const ui::Event& event) {
|
||||||
// Set the checked state to true only if we are unchecked, since we can't
|
// Set the checked state to true only if we are unchecked, since we can't
|
||||||
// be toggled on and off like a checkbox.
|
// be toggled on and off like a checkbox.
|
||||||
if (!GetChecked())
|
if (!GetChecked()) {
|
||||||
SetChecked(true);
|
SetChecked(true);
|
||||||
|
}
|
||||||
LabelButton::NotifyClick(event);
|
LabelButton::NotifyClick(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,8 +107,9 @@ ui::NativeTheme::Part RadioButton::GetThemePart() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RadioButton::SetChecked(bool checked) {
|
void RadioButton::SetChecked(bool checked) {
|
||||||
if (checked == RadioButton::GetChecked())
|
if (checked == RadioButton::GetChecked()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (checked) {
|
if (checked) {
|
||||||
// We can't start from the root view because other parts of the UI might use
|
// We can't start from the root view because other parts of the UI might use
|
||||||
// radio buttons with the same group. This can happen when re-using the same
|
// radio buttons with the same group. This can happen when re-using the same
|
||||||
@@ -114,7 +118,7 @@ void RadioButton::SetChecked(bool checked) {
|
|||||||
GetViewsInGroupFromParent(GetGroup(), &other);
|
GetViewsInGroupFromParent(GetGroup(), &other);
|
||||||
for (auto* peer : other) {
|
for (auto* peer : other) {
|
||||||
if (peer != this) {
|
if (peer != this) {
|
||||||
DCHECK(!strcmp(peer->GetClassName(), kViewClassName))
|
DCHECK(IsViewClass<RadioButton>(peer))
|
||||||
<< "radio-button-nt has same group as non radio-button-nt views.";
|
<< "radio-button-nt has same group as non radio-button-nt views.";
|
||||||
static_cast<RadioButton*>(peer)->SetChecked(false);
|
static_cast<RadioButton*>(peer)->SetChecked(false);
|
||||||
}
|
}
|
||||||
@@ -143,8 +147,9 @@ SkPath RadioButton::GetFocusRingPath() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RadioButton::GetViewsInGroupFromParent(int group, Views* views) {
|
void RadioButton::GetViewsInGroupFromParent(int group, Views* views) {
|
||||||
if (parent())
|
if (parent()) {
|
||||||
parent()->GetViewsInGroup(group, views);
|
parent()->GetViewsInGroup(group, views);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_METADATA(RadioButton, Checkbox)
|
BEGIN_METADATA(RadioButton, Checkbox)
|
||||||
|
@@ -98,8 +98,9 @@ int CheckScrollBounds(int viewport_size, int content_size, int current_pos) {
|
|||||||
void ConstrainScrollToBounds(View* viewport,
|
void ConstrainScrollToBounds(View* viewport,
|
||||||
View* view,
|
View* view,
|
||||||
bool scroll_with_layers_enabled) {
|
bool scroll_with_layers_enabled) {
|
||||||
if (!view)
|
if (!view) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Note that even when ScrollView::ScrollsWithLayers() is true, the header row
|
// Note that even when ScrollView::ScrollsWithLayers() is true, the header row
|
||||||
// scrolls by repainting.
|
// scrolls by repainting.
|
||||||
@@ -131,10 +132,12 @@ int AdjustPosition(int current_position,
|
|||||||
int new_position,
|
int new_position,
|
||||||
int content_size,
|
int content_size,
|
||||||
int viewport_size) {
|
int viewport_size) {
|
||||||
if (-current_position == new_position)
|
if (-current_position == new_position) {
|
||||||
return new_position;
|
return new_position;
|
||||||
if (new_position < 0)
|
}
|
||||||
|
if (new_position < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
const int max_position = std::max(0, content_size - viewport_size);
|
const int max_position = std::max(0, content_size - viewport_size);
|
||||||
return (new_position > max_position) ? max_position : new_position;
|
return (new_position > max_position) ? max_position : new_position;
|
||||||
}
|
}
|
||||||
@@ -151,8 +154,9 @@ class ScrollView::Viewport : public View {
|
|||||||
~Viewport() override = default;
|
~Viewport() override = default;
|
||||||
|
|
||||||
void ScrollRectToVisible(const gfx::Rect& rect) override {
|
void ScrollRectToVisible(const gfx::Rect& rect) override {
|
||||||
if (children().empty() || !parent())
|
if (children().empty() || !parent()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If scrolling is disabled, it may have been handled by a parent View class
|
// If scrolling is disabled, it may have been handled by a parent View class
|
||||||
// so fall back to it.
|
// so fall back to it.
|
||||||
@@ -206,15 +210,17 @@ class ScrollView::Viewport : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateContentsViewportLayer() {
|
void UpdateContentsViewportLayer() {
|
||||||
if (!layer())
|
if (!layer()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const ui::LayerType new_layer_type =
|
const ui::LayerType new_layer_type =
|
||||||
CalculateLayerTypeForContentsViewport();
|
CalculateLayerTypeForContentsViewport();
|
||||||
|
|
||||||
bool layer_needs_update = layer()->type() != new_layer_type;
|
bool layer_needs_update = layer()->type() != new_layer_type;
|
||||||
if (layer_needs_update)
|
if (layer_needs_update) {
|
||||||
SetContentsViewportLayer(new_layer_type);
|
SetContentsViewportLayer(new_layer_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculates the layer type to use for |contents_viewport_|.
|
// Calculates the layer type to use for |contents_viewport_|.
|
||||||
@@ -314,8 +320,9 @@ ScrollView::ScrollView(ScrollWithLayers scroll_with_layers)
|
|||||||
more_content_right_->SetVisible(false);
|
more_content_right_->SetVisible(false);
|
||||||
more_content_bottom_->SetVisible(false);
|
more_content_bottom_->SetVisible(false);
|
||||||
|
|
||||||
if (scroll_with_layers_enabled_)
|
if (scroll_with_layers_enabled_) {
|
||||||
EnableViewportLayer();
|
EnableViewportLayer();
|
||||||
|
}
|
||||||
|
|
||||||
// If we're scrolling with layers, paint the overflow indicators to the layer.
|
// If we're scrolling with layers, paint the overflow indicators to the layer.
|
||||||
if (ScrollsWithLayers()) {
|
if (ScrollsWithLayers()) {
|
||||||
@@ -347,8 +354,9 @@ std::unique_ptr<ScrollView> ScrollView::CreateScrollViewWithBorder() {
|
|||||||
ScrollView* ScrollView::GetScrollViewForContents(View* contents) {
|
ScrollView* ScrollView::GetScrollViewForContents(View* contents) {
|
||||||
View* grandparent =
|
View* grandparent =
|
||||||
contents->parent() ? contents->parent()->parent() : nullptr;
|
contents->parent() ? contents->parent()->parent() : nullptr;
|
||||||
if (!grandparent || grandparent->GetClassName() != ScrollView::kViewClassName)
|
if (!grandparent || !IsViewClass<ScrollView>(grandparent)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto* scroll_view = static_cast<ScrollView*>(grandparent);
|
auto* scroll_view = static_cast<ScrollView*>(grandparent);
|
||||||
DCHECK_EQ(contents, scroll_view->contents());
|
DCHECK_EQ(contents, scroll_view->contents());
|
||||||
@@ -383,8 +391,9 @@ void ScrollView::SetContentsLayerType(ui::LayerType layer_type) {
|
|||||||
// layer are needed, consult with the owner.
|
// layer are needed, consult with the owner.
|
||||||
DCHECK(layer_type == ui::LAYER_TEXTURED || layer_type == ui::LAYER_NOT_DRAWN);
|
DCHECK(layer_type == ui::LAYER_TEXTURED || layer_type == ui::LAYER_NOT_DRAWN);
|
||||||
|
|
||||||
if (layer_type_ == layer_type)
|
if (layer_type_ == layer_type) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
layer_type_ = layer_type;
|
layer_type_ = layer_type;
|
||||||
}
|
}
|
||||||
@@ -411,8 +420,9 @@ void ScrollView::SetViewportRoundedCornerRadius(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::SetBackgroundColor(const absl::optional<SkColor>& color) {
|
void ScrollView::SetBackgroundColor(const absl::optional<SkColor>& color) {
|
||||||
if (background_color_ == color && !background_color_id_)
|
if (background_color_ == color && !background_color_id_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
background_color_ = color;
|
background_color_ = color;
|
||||||
background_color_id_ = absl::nullopt;
|
background_color_id_ = absl::nullopt;
|
||||||
UpdateBackground();
|
UpdateBackground();
|
||||||
@@ -421,8 +431,9 @@ void ScrollView::SetBackgroundColor(const absl::optional<SkColor>& color) {
|
|||||||
|
|
||||||
void ScrollView::SetBackgroundThemeColorId(
|
void ScrollView::SetBackgroundThemeColorId(
|
||||||
const absl::optional<ui::ColorId>& color_id) {
|
const absl::optional<ui::ColorId>& color_id) {
|
||||||
if (background_color_id_ == color_id && !background_color_)
|
if (background_color_id_ == color_id && !background_color_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
background_color_id_ = color_id;
|
background_color_id_ = color_id;
|
||||||
background_color_ = absl::nullopt;
|
background_color_ = absl::nullopt;
|
||||||
UpdateBackground();
|
UpdateBackground();
|
||||||
@@ -430,8 +441,9 @@ void ScrollView::SetBackgroundThemeColorId(
|
|||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect ScrollView::GetVisibleRect() const {
|
gfx::Rect ScrollView::GetVisibleRect() const {
|
||||||
if (!contents_)
|
if (!contents_) {
|
||||||
return gfx::Rect();
|
return gfx::Rect();
|
||||||
|
}
|
||||||
gfx::PointF offset = CurrentOffset();
|
gfx::PointF offset = CurrentOffset();
|
||||||
return gfx::Rect(offset.x(), offset.y(), contents_viewport_->width(),
|
return gfx::Rect(offset.x(), offset.y(), contents_viewport_->width(),
|
||||||
contents_viewport_->height());
|
contents_viewport_->height());
|
||||||
@@ -439,8 +451,9 @@ gfx::Rect ScrollView::GetVisibleRect() const {
|
|||||||
|
|
||||||
void ScrollView::SetHorizontalScrollBarMode(
|
void ScrollView::SetHorizontalScrollBarMode(
|
||||||
ScrollBarMode horizontal_scroll_bar_mode) {
|
ScrollBarMode horizontal_scroll_bar_mode) {
|
||||||
if (horizontal_scroll_bar_mode_ == horizontal_scroll_bar_mode)
|
if (horizontal_scroll_bar_mode_ == horizontal_scroll_bar_mode) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
horizontal_scroll_bar_mode_ = horizontal_scroll_bar_mode;
|
horizontal_scroll_bar_mode_ = horizontal_scroll_bar_mode;
|
||||||
OnPropertyChanged(&horizontal_scroll_bar_mode_, kPropertyEffectsPaint);
|
OnPropertyChanged(&horizontal_scroll_bar_mode_, kPropertyEffectsPaint);
|
||||||
|
|
||||||
@@ -453,8 +466,9 @@ void ScrollView::SetHorizontalScrollBarMode(
|
|||||||
|
|
||||||
void ScrollView::SetVerticalScrollBarMode(
|
void ScrollView::SetVerticalScrollBarMode(
|
||||||
ScrollBarMode vertical_scroll_bar_mode) {
|
ScrollBarMode vertical_scroll_bar_mode) {
|
||||||
if (vertical_scroll_bar_mode_ == vertical_scroll_bar_mode)
|
if (vertical_scroll_bar_mode_ == vertical_scroll_bar_mode) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Enabling vertical scrolling is incompatible with all scrolling being
|
// Enabling vertical scrolling is incompatible with all scrolling being
|
||||||
// interpreted as horizontal.
|
// interpreted as horizontal.
|
||||||
@@ -488,15 +502,17 @@ void ScrollView::SetTreatAllScrollEventsAsHorizontal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::SetAllowKeyboardScrolling(bool allow_keyboard_scrolling) {
|
void ScrollView::SetAllowKeyboardScrolling(bool allow_keyboard_scrolling) {
|
||||||
if (allow_keyboard_scrolling_ == allow_keyboard_scrolling)
|
if (allow_keyboard_scrolling_ == allow_keyboard_scrolling) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
allow_keyboard_scrolling_ = allow_keyboard_scrolling;
|
allow_keyboard_scrolling_ = allow_keyboard_scrolling;
|
||||||
OnPropertyChanged(&allow_keyboard_scrolling_, kPropertyEffectsNone);
|
OnPropertyChanged(&allow_keyboard_scrolling_, kPropertyEffectsNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::SetDrawOverflowIndicator(bool draw_overflow_indicator) {
|
void ScrollView::SetDrawOverflowIndicator(bool draw_overflow_indicator) {
|
||||||
if (draw_overflow_indicator_ == draw_overflow_indicator)
|
if (draw_overflow_indicator_ == draw_overflow_indicator) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
draw_overflow_indicator_ = draw_overflow_indicator;
|
draw_overflow_indicator_ = draw_overflow_indicator;
|
||||||
OnPropertyChanged(&draw_overflow_indicator_, kPropertyEffectsPaint);
|
OnPropertyChanged(&draw_overflow_indicator_, kPropertyEffectsPaint);
|
||||||
}
|
}
|
||||||
@@ -505,8 +521,9 @@ View* ScrollView::SetCustomOverflowIndicator(OverflowIndicatorAlignment side,
|
|||||||
std::unique_ptr<View> indicator,
|
std::unique_ptr<View> indicator,
|
||||||
int thickness,
|
int thickness,
|
||||||
bool fills_opaquely) {
|
bool fills_opaquely) {
|
||||||
if (thickness < 0)
|
if (thickness < 0) {
|
||||||
thickness = 0;
|
thickness = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (ScrollsWithLayers()) {
|
if (ScrollsWithLayers()) {
|
||||||
indicator->SetPaintToLayer();
|
indicator->SetPaintToLayer();
|
||||||
@@ -577,8 +594,9 @@ ScrollBar* ScrollView::SetVerticalScrollBar(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::SetHasFocusIndicator(bool has_focus_indicator) {
|
void ScrollView::SetHasFocusIndicator(bool has_focus_indicator) {
|
||||||
if (has_focus_indicator == draw_focus_indicator_)
|
if (has_focus_indicator == draw_focus_indicator_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
draw_focus_indicator_ = has_focus_indicator;
|
draw_focus_indicator_ = has_focus_indicator;
|
||||||
|
|
||||||
views::FocusRing::Get(this)->SchedulePaint();
|
views::FocusRing::Get(this)->SchedulePaint();
|
||||||
@@ -608,8 +626,9 @@ gfx::Size ScrollView::CalculatePreferredSize() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ScrollView::GetHeightForWidth(int width) const {
|
int ScrollView::GetHeightForWidth(int width) const {
|
||||||
if (!is_bounded())
|
if (!is_bounded()) {
|
||||||
return View::GetHeightForWidth(width);
|
return View::GetHeightForWidth(width);
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Insets insets = GetInsets();
|
gfx::Insets insets = GetInsets();
|
||||||
width = std::max(0, width - insets.width());
|
width = std::max(0, width - insets.width());
|
||||||
@@ -626,14 +645,16 @@ void ScrollView::Layout() {
|
|||||||
#if BUILDFLAG(IS_MAC)
|
#if BUILDFLAG(IS_MAC)
|
||||||
// On Mac, scrollbars may update their style one at a time, so they may
|
// On Mac, scrollbars may update their style one at a time, so they may
|
||||||
// temporarily be of different types. Refuse to lay out at this point.
|
// temporarily be of different types. Refuse to lay out at this point.
|
||||||
if (horiz_sb_->OverlapsContent() != vert_sb_->OverlapsContent())
|
if (horiz_sb_->OverlapsContent() != vert_sb_->OverlapsContent()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
DCHECK_EQ(horiz_sb_->OverlapsContent(), vert_sb_->OverlapsContent());
|
DCHECK_EQ(horiz_sb_->OverlapsContent(), vert_sb_->OverlapsContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (views::FocusRing::Get(this))
|
if (views::FocusRing::Get(this)) {
|
||||||
views::FocusRing::Get(this)->Layout();
|
views::FocusRing::Get(this)->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Rect available_rect = GetContentsBounds();
|
gfx::Rect available_rect = GetContentsBounds();
|
||||||
if (is_bounded()) {
|
if (is_bounded()) {
|
||||||
@@ -694,8 +715,9 @@ void ScrollView::Layout() {
|
|||||||
|
|
||||||
// Give |contents_| a chance to update its bounds if it depends on the
|
// Give |contents_| a chance to update its bounds if it depends on the
|
||||||
// viewport.
|
// viewport.
|
||||||
if (contents_)
|
if (contents_) {
|
||||||
contents_->Layout();
|
contents_->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
bool should_layout_contents = false;
|
bool should_layout_contents = false;
|
||||||
bool horiz_sb_required = false;
|
bool horiz_sb_required = false;
|
||||||
@@ -759,8 +781,9 @@ void ScrollView::Layout() {
|
|||||||
|
|
||||||
// Update to the real client size with the visible scrollbars.
|
// Update to the real client size with the visible scrollbars.
|
||||||
contents_viewport_->SetBoundsRect(viewport_bounds);
|
contents_viewport_->SetBoundsRect(viewport_bounds);
|
||||||
if (should_layout_contents && contents_)
|
if (should_layout_contents && contents_) {
|
||||||
contents_->Layout();
|
contents_->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
// Even when |contents_| needs to scroll, it can still be narrower or wider
|
// Even when |contents_| needs to scroll, it can still be narrower or wider
|
||||||
// the viewport. So ensure the scrolling layer can fill the viewport, so that
|
// the viewport. So ensure the scrolling layer can fill the viewport, so that
|
||||||
@@ -798,8 +821,9 @@ void ScrollView::Layout() {
|
|||||||
|
|
||||||
header_viewport_->SetBounds(contents_x, contents_y, viewport_bounds.width(),
|
header_viewport_->SetBounds(contents_x, contents_y, viewport_bounds.width(),
|
||||||
header_height);
|
header_height);
|
||||||
if (header_)
|
if (header_) {
|
||||||
header_->Layout();
|
header_->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
ConstrainScrollToBounds(header_viewport_, header_,
|
ConstrainScrollToBounds(header_viewport_, header_,
|
||||||
scroll_with_layers_enabled_);
|
scroll_with_layers_enabled_);
|
||||||
@@ -807,19 +831,22 @@ void ScrollView::Layout() {
|
|||||||
scroll_with_layers_enabled_);
|
scroll_with_layers_enabled_);
|
||||||
SchedulePaint();
|
SchedulePaint();
|
||||||
UpdateScrollBarPositions();
|
UpdateScrollBarPositions();
|
||||||
if (contents_)
|
if (contents_) {
|
||||||
UpdateOverflowIndicatorVisibility(CurrentOffset());
|
UpdateOverflowIndicatorVisibility(CurrentOffset());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScrollView::OnKeyPressed(const ui::KeyEvent& event) {
|
bool ScrollView::OnKeyPressed(const ui::KeyEvent& event) {
|
||||||
bool processed = false;
|
bool processed = false;
|
||||||
|
|
||||||
if (!allow_keyboard_scrolling_)
|
if (!allow_keyboard_scrolling_) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Give vertical scrollbar priority
|
// Give vertical scrollbar priority
|
||||||
if (IsVerticalScrollEnabled())
|
if (IsVerticalScrollEnabled()) {
|
||||||
processed = vert_sb_->OnKeyPressed(event);
|
processed = vert_sb_->OnKeyPressed(event);
|
||||||
|
}
|
||||||
|
|
||||||
if (!processed && IsHorizontalScrollEnabled())
|
if (!processed && IsHorizontalScrollEnabled())
|
||||||
processed = horiz_sb_->OnKeyPressed(event);
|
processed = horiz_sb_->OnKeyPressed(event);
|
||||||
@@ -850,8 +877,9 @@ bool ScrollView::OnMouseWheel(const ui::MouseWheelEvent& e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::OnScrollEvent(ui::ScrollEvent* event) {
|
void ScrollView::OnScrollEvent(ui::ScrollEvent* event) {
|
||||||
if (!contents_)
|
if (!contents_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Possibly force the scroll event to horizontal based on the configuration
|
// Possibly force the scroll event to horizontal based on the configuration
|
||||||
// option.
|
// option.
|
||||||
@@ -885,10 +913,12 @@ void ScrollView::OnScrollEvent(ui::ScrollEvent* event) {
|
|||||||
vert_sb_->ObserveScrollEvent(e);
|
vert_sb_->ObserveScrollEvent(e);
|
||||||
|
|
||||||
// Need to copy state back to original event.
|
// Need to copy state back to original event.
|
||||||
if (e.handled())
|
if (e.handled()) {
|
||||||
event->SetHandled();
|
event->SetHandled();
|
||||||
if (e.stopped_propagation())
|
}
|
||||||
|
if (e.stopped_propagation()) {
|
||||||
event->StopPropagation();
|
event->StopPropagation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::OnGestureEvent(ui::GestureEvent* event) {
|
void ScrollView::OnGestureEvent(ui::GestureEvent* event) {
|
||||||
@@ -925,8 +955,9 @@ void ScrollView::OnThemeChanged() {
|
|||||||
|
|
||||||
void ScrollView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
void ScrollView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
||||||
View::GetAccessibleNodeData(node_data);
|
View::GetAccessibleNodeData(node_data);
|
||||||
if (!contents_)
|
if (!contents_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
node_data->role = ax::mojom::Role::kScrollView;
|
node_data->role = ax::mojom::Role::kScrollView;
|
||||||
node_data->AddIntAttribute(ax::mojom::IntAttribute::kScrollX,
|
node_data->AddIntAttribute(ax::mojom::IntAttribute::kScrollX,
|
||||||
@@ -945,8 +976,9 @@ void ScrollView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ScrollView::HandleAccessibleAction(const ui::AXActionData& action_data) {
|
bool ScrollView::HandleAccessibleAction(const ui::AXActionData& action_data) {
|
||||||
if (!contents_)
|
if (!contents_) {
|
||||||
return View::HandleAccessibleAction(action_data);
|
return View::HandleAccessibleAction(action_data);
|
||||||
|
}
|
||||||
|
|
||||||
switch (action_data.action) {
|
switch (action_data.action) {
|
||||||
case ax::mojom::Action::kScrollLeft:
|
case ax::mojom::Action::kScrollLeft:
|
||||||
@@ -966,21 +998,24 @@ bool ScrollView::HandleAccessibleAction(const ui::AXActionData& action_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
|
void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
|
||||||
if (!contents_)
|
if (!contents_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gfx::PointF offset = CurrentOffset();
|
gfx::PointF offset = CurrentOffset();
|
||||||
if (source == horiz_sb_ && IsHorizontalScrollEnabled()) {
|
if (source == horiz_sb_ && IsHorizontalScrollEnabled()) {
|
||||||
position = AdjustPosition(offset.x(), position, contents_->width(),
|
position = AdjustPosition(offset.x(), position, contents_->width(),
|
||||||
contents_viewport_->width());
|
contents_viewport_->width());
|
||||||
if (offset.x() == position)
|
if (offset.x() == position) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
offset.set_x(position);
|
offset.set_x(position);
|
||||||
} else if (source == vert_sb_ && IsVerticalScrollEnabled()) {
|
} else if (source == vert_sb_ && IsVerticalScrollEnabled()) {
|
||||||
position = AdjustPosition(offset.y(), position, contents_->height(),
|
position = AdjustPosition(offset.y(), position, contents_->height(),
|
||||||
contents_viewport_->height());
|
contents_viewport_->height());
|
||||||
if (offset.y() == position)
|
if (offset.y() == position) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
offset.set_y(position);
|
offset.set_y(position);
|
||||||
}
|
}
|
||||||
ScrollToOffset(offset);
|
ScrollToOffset(offset);
|
||||||
@@ -1010,13 +1045,15 @@ bool ScrollView::DoesViewportOrScrollViewHaveLayer() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::UpdateViewportLayerForClipping() {
|
void ScrollView::UpdateViewportLayerForClipping() {
|
||||||
if (scroll_with_layers_enabled_)
|
if (scroll_with_layers_enabled_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const bool has_layer = DoesViewportOrScrollViewHaveLayer();
|
const bool has_layer = DoesViewportOrScrollViewHaveLayer();
|
||||||
const bool needs_layer = DoesDescendantHaveLayer(contents_viewport_);
|
const bool needs_layer = DoesDescendantHaveLayer(contents_viewport_);
|
||||||
if (has_layer == needs_layer)
|
if (has_layer == needs_layer) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (needs_layer)
|
if (needs_layer)
|
||||||
EnableViewportLayer();
|
EnableViewportLayer();
|
||||||
else
|
else
|
||||||
@@ -1067,8 +1104,9 @@ void ScrollView::ScrollContentsRegionToBeVisible(const gfx::Rect& rect) {
|
|||||||
// and the height is (max_y - y) to take into account the clipping of
|
// and the height is (max_y - y) to take into account the clipping of
|
||||||
// either viewport or the content size.
|
// either viewport or the content size.
|
||||||
const gfx::Rect vis_rect = GetVisibleRect();
|
const gfx::Rect vis_rect = GetVisibleRect();
|
||||||
if (vis_rect.Contains(gfx::Rect(x, y, max_x - x, max_y - y)))
|
if (vis_rect.Contains(gfx::Rect(x, y, max_x - x, max_y - y))) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Shift contents_'s X and Y so that the region is visible. If we
|
// Shift contents_'s X and Y so that the region is visible. If we
|
||||||
// need to shift up or left from where we currently are then we need
|
// need to shift up or left from where we currently are then we need
|
||||||
@@ -1128,8 +1166,9 @@ void ScrollView::ComputeScrollBarsVisibility(const gfx::Size& vp_size,
|
|||||||
|
|
||||||
// Make sure that a single scrollbar is created and visible as needed
|
// Make sure that a single scrollbar is created and visible as needed
|
||||||
void ScrollView::SetControlVisibility(View* control, bool should_show) {
|
void ScrollView::SetControlVisibility(View* control, bool should_show) {
|
||||||
if (!control)
|
if (!control) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (should_show) {
|
if (should_show) {
|
||||||
if (!control->GetVisible()) {
|
if (!control->GetVisible()) {
|
||||||
AddChildView(control);
|
AddChildView(control);
|
||||||
@@ -1142,8 +1181,9 @@ void ScrollView::SetControlVisibility(View* control, bool should_show) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::UpdateScrollBarPositions() {
|
void ScrollView::UpdateScrollBarPositions() {
|
||||||
if (!contents_)
|
if (!contents_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const gfx::PointF offset = CurrentOffset();
|
const gfx::PointF offset = CurrentOffset();
|
||||||
if (IsHorizontalScrollEnabled()) {
|
if (IsHorizontalScrollEnabled()) {
|
||||||
@@ -1164,8 +1204,9 @@ gfx::PointF ScrollView::CurrentOffset() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::ScrollByOffset(const gfx::PointF& offset) {
|
void ScrollView::ScrollByOffset(const gfx::PointF& offset) {
|
||||||
if (!contents_)
|
if (!contents_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gfx::PointF current_offset = CurrentOffset();
|
gfx::PointF current_offset = CurrentOffset();
|
||||||
ScrollToOffset(gfx::PointF(current_offset.x() + offset.x(),
|
ScrollToOffset(gfx::PointF(current_offset.x() + offset.x(),
|
||||||
@@ -1182,8 +1223,9 @@ void ScrollView::ScrollToOffset(const gfx::PointF& offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ScrollView::ScrollsWithLayers() const {
|
bool ScrollView::ScrollsWithLayers() const {
|
||||||
if (!scroll_with_layers_enabled_)
|
if (!scroll_with_layers_enabled_) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
// Just check for the presence of a layer since it's cheaper than querying the
|
// Just check for the presence of a layer since it's cheaper than querying the
|
||||||
// Feature flag each time.
|
// Feature flag each time.
|
||||||
return contents_viewport_->layer() != nullptr;
|
return contents_viewport_->layer() != nullptr;
|
||||||
@@ -1202,8 +1244,9 @@ bool ScrollView::IsVerticalScrollEnabled() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::EnableViewportLayer() {
|
void ScrollView::EnableViewportLayer() {
|
||||||
if (DoesViewportOrScrollViewHaveLayer())
|
if (DoesViewportOrScrollViewHaveLayer()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
contents_viewport_->InitializeContentsViewportLayer();
|
contents_viewport_->InitializeContentsViewportLayer();
|
||||||
contents_viewport_->layer()->SetMasksToBounds(true);
|
contents_viewport_->layer()->SetMasksToBounds(true);
|
||||||
more_content_left_->SetPaintToLayer();
|
more_content_left_->SetPaintToLayer();
|
||||||
@@ -1230,8 +1273,9 @@ void ScrollView::OnScrolled(const gfx::PointF& offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::ScrollHeader() {
|
void ScrollView::ScrollHeader() {
|
||||||
if (!header_)
|
if (!header_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int x_offset = CurrentOffset().x();
|
int x_offset = CurrentOffset().x();
|
||||||
if (header_->x() != -x_offset) {
|
if (header_->x() != -x_offset) {
|
||||||
@@ -1246,8 +1290,9 @@ void ScrollView::AddBorder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::UpdateBorder() {
|
void ScrollView::UpdateBorder() {
|
||||||
if (!draw_border_ || !GetWidget())
|
if (!draw_border_ || !GetWidget()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetBorder(CreateSolidBorder(
|
SetBorder(CreateSolidBorder(
|
||||||
1, GetColorProvider()->GetColor(
|
1, GetColorProvider()->GetColor(
|
||||||
@@ -1256,8 +1301,9 @@ void ScrollView::UpdateBorder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::UpdateBackground() {
|
void ScrollView::UpdateBackground() {
|
||||||
if (!GetWidget())
|
if (!GetWidget()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const absl::optional<SkColor> background_color = GetBackgroundColor();
|
const absl::optional<SkColor> background_color = GetBackgroundColor();
|
||||||
|
|
||||||
@@ -1363,8 +1409,9 @@ int VariableRowHeightScrollHelper::GetPageScrollIncrement(
|
|||||||
ScrollView* scroll_view,
|
ScrollView* scroll_view,
|
||||||
bool is_horizontal,
|
bool is_horizontal,
|
||||||
bool is_positive) {
|
bool is_positive) {
|
||||||
if (is_horizontal)
|
if (is_horizontal) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
// y coordinate is most likely negative.
|
// y coordinate is most likely negative.
|
||||||
int y = abs(scroll_view->contents()->y());
|
int y = abs(scroll_view->contents()->y());
|
||||||
int vis_height = scroll_view->contents()->parent()->height();
|
int vis_height = scroll_view->contents()->parent()->height();
|
||||||
@@ -1389,8 +1436,9 @@ int VariableRowHeightScrollHelper::GetLineScrollIncrement(
|
|||||||
ScrollView* scroll_view,
|
ScrollView* scroll_view,
|
||||||
bool is_horizontal,
|
bool is_horizontal,
|
||||||
bool is_positive) {
|
bool is_positive) {
|
||||||
if (is_horizontal)
|
if (is_horizontal) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
// y coordinate is most likely negative.
|
// y coordinate is most likely negative.
|
||||||
int y = abs(scroll_view->contents()->y());
|
int y = abs(scroll_view->contents()->y());
|
||||||
RowInfo row = GetRowInfo(y);
|
RowInfo row = GetRowInfo(y);
|
||||||
@@ -1421,8 +1469,9 @@ FixedRowHeightScrollHelper::FixedRowHeightScrollHelper(int top_margin,
|
|||||||
|
|
||||||
VariableRowHeightScrollHelper::RowInfo FixedRowHeightScrollHelper::GetRowInfo(
|
VariableRowHeightScrollHelper::RowInfo FixedRowHeightScrollHelper::GetRowInfo(
|
||||||
int y) {
|
int y) {
|
||||||
if (y < top_margin_)
|
if (y < top_margin_) {
|
||||||
return RowInfo(0, top_margin_);
|
return RowInfo(0, top_margin_);
|
||||||
|
}
|
||||||
return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
|
return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
|
||||||
row_height_);
|
row_height_);
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "ui/views/style/typography.h"
|
#include "ui/views/style/typography.h"
|
||||||
#include "ui/views/style/typography_provider.h"
|
#include "ui/views/style/typography_provider.h"
|
||||||
#include "ui/views/view_class_properties.h"
|
#include "ui/views/view_class_properties.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
|
|
||||||
@@ -97,8 +98,9 @@ void StyledLabel::SetText(std::u16string text) {
|
|||||||
// text elider tries to do so internally. There's no obvious reason to
|
// text elider tries to do so internally. There's no obvious reason to
|
||||||
// preserve trailing whitespace anyway.
|
// preserve trailing whitespace anyway.
|
||||||
base::TrimWhitespace(std::move(text), base::TRIM_TRAILING, &text);
|
base::TrimWhitespace(std::move(text), base::TRIM_TRAILING, &text);
|
||||||
if (text_ == text)
|
if (text_ == text) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
text_ = text;
|
text_ = text;
|
||||||
SetAccessibleName(text_);
|
SetAccessibleName(text_);
|
||||||
@@ -137,8 +139,9 @@ int StyledLabel::GetTextContext() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StyledLabel::SetTextContext(int text_context) {
|
void StyledLabel::SetTextContext(int text_context) {
|
||||||
if (text_context_ == text_context)
|
if (text_context_ == text_context) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
text_context_ = text_context;
|
text_context_ = text_context;
|
||||||
SetAccessibleRole(text_context_ == style::CONTEXT_DIALOG_TITLE
|
SetAccessibleRole(text_context_ == style::CONTEXT_DIALOG_TITLE
|
||||||
@@ -152,8 +155,9 @@ int StyledLabel::GetDefaultTextStyle() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StyledLabel::SetDefaultTextStyle(int text_style) {
|
void StyledLabel::SetDefaultTextStyle(int text_style) {
|
||||||
if (default_text_style_ == text_style)
|
if (default_text_style_ == text_style) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
default_text_style_ = text_style;
|
default_text_style_ = text_style;
|
||||||
OnPropertyChanged(&default_text_style_, kPropertyEffectsPreferredSizeChanged);
|
OnPropertyChanged(&default_text_style_, kPropertyEffectsPreferredSizeChanged);
|
||||||
@@ -179,8 +183,9 @@ int StyledLabel::GetLineHeight() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StyledLabel::SetLineHeight(int line_height) {
|
void StyledLabel::SetLineHeight(int line_height) {
|
||||||
if (line_height_ == line_height)
|
if (line_height_ == line_height) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
line_height_ = line_height;
|
line_height_ = line_height;
|
||||||
OnPropertyChanged(&line_height_, kPropertyEffectsPreferredSizeChanged);
|
OnPropertyChanged(&line_height_, kPropertyEffectsPreferredSizeChanged);
|
||||||
@@ -209,8 +214,9 @@ bool StyledLabel::GetAutoColorReadabilityEnabled() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StyledLabel::SetAutoColorReadabilityEnabled(bool auto_color_readability) {
|
void StyledLabel::SetAutoColorReadabilityEnabled(bool auto_color_readability) {
|
||||||
if (auto_color_readability_enabled_ == auto_color_readability)
|
if (auto_color_readability_enabled_ == auto_color_readability) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto_color_readability_enabled_ = auto_color_readability;
|
auto_color_readability_enabled_ = auto_color_readability;
|
||||||
OnPropertyChanged(&auto_color_readability_enabled_, kPropertyEffectsPaint);
|
OnPropertyChanged(&auto_color_readability_enabled_, kPropertyEffectsPaint);
|
||||||
@@ -221,8 +227,9 @@ bool StyledLabel::GetSubpixelRenderingEnabled() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StyledLabel::SetSubpixelRenderingEnabled(bool subpixel_rendering_enabled) {
|
void StyledLabel::SetSubpixelRenderingEnabled(bool subpixel_rendering_enabled) {
|
||||||
if (subpixel_rendering_enabled_ == subpixel_rendering_enabled)
|
if (subpixel_rendering_enabled_ == subpixel_rendering_enabled) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
subpixel_rendering_enabled_ = subpixel_rendering_enabled;
|
subpixel_rendering_enabled_ = subpixel_rendering_enabled;
|
||||||
OnPropertyChanged(&subpixel_rendering_enabled_, kPropertyEffectsPaint);
|
OnPropertyChanged(&subpixel_rendering_enabled_, kPropertyEffectsPaint);
|
||||||
@@ -329,8 +336,9 @@ void StyledLabel::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) {
|
|||||||
DCHECK_NE(gfx::ALIGN_TO_HEAD, alignment);
|
DCHECK_NE(gfx::ALIGN_TO_HEAD, alignment);
|
||||||
alignment = gfx::MaybeFlipForRTL(alignment);
|
alignment = gfx::MaybeFlipForRTL(alignment);
|
||||||
|
|
||||||
if (horizontal_alignment_ == alignment)
|
if (horizontal_alignment_ == alignment) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
horizontal_alignment_ = alignment;
|
horizontal_alignment_ = alignment;
|
||||||
PreferredSizeChanged();
|
PreferredSizeChanged();
|
||||||
}
|
}
|
||||||
@@ -346,8 +354,7 @@ void StyledLabel::ClickFirstLinkForTesting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
views::Link* StyledLabel::GetFirstLinkForTesting() {
|
views::Link* StyledLabel::GetFirstLinkForTesting() {
|
||||||
const auto it = base::ranges::find(children(), LinkFragment::kViewClassName,
|
const auto it = base::ranges::find_if(children(), &IsViewClass<LinkFragment>);
|
||||||
&View::GetClassName);
|
|
||||||
DCHECK(it != children().cend());
|
DCHECK(it != children().cend());
|
||||||
return static_cast<views::Link*>(*it);
|
return static_cast<views::Link*>(*it);
|
||||||
}
|
}
|
||||||
@@ -409,8 +416,9 @@ void StyledLabel::CalculateLayout(int width) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gfx::Range range = gfx::Range::InvalidRange();
|
gfx::Range range = gfx::Range::InvalidRange();
|
||||||
if (current_range != style_ranges_.end())
|
if (current_range != style_ranges_.end()) {
|
||||||
range = current_range->range;
|
range = current_range->range;
|
||||||
|
}
|
||||||
|
|
||||||
const size_t position = text_.size() - remaining_string.size();
|
const size_t position = text_.size() - remaining_string.size();
|
||||||
std::vector<std::u16string> substrings;
|
std::vector<std::u16string> substrings;
|
||||||
@@ -528,8 +536,9 @@ void StyledLabel::CalculateLayout(int width) const {
|
|||||||
std::max(line_size.height(), child_size.height()));
|
std::max(line_size.height(), child_size.height()));
|
||||||
|
|
||||||
views.push_back(child_view);
|
views.push_back(child_view);
|
||||||
if (label)
|
if (label) {
|
||||||
layout_views_->owned_views.push_back(std::move(label));
|
layout_views_->owned_views.push_back(std::move(label));
|
||||||
|
}
|
||||||
|
|
||||||
remaining_string = remaining_string.substr(chunk.size());
|
remaining_string = remaining_string.substr(chunk.size());
|
||||||
|
|
||||||
@@ -596,8 +605,9 @@ std::unique_ptr<Label> StyledLabel::CreateLabel(
|
|||||||
} else if (default_enabled_color_id_) {
|
} else if (default_enabled_color_id_) {
|
||||||
result->SetEnabledColorId(default_enabled_color_id_);
|
result->SetEnabledColorId(default_enabled_color_id_);
|
||||||
}
|
}
|
||||||
if (!style_info.tooltip.empty())
|
if (!style_info.tooltip.empty()) {
|
||||||
result->SetTooltipText(style_info.tooltip);
|
result->SetTooltipText(style_info.tooltip);
|
||||||
|
}
|
||||||
if (!style_info.accessible_name.empty())
|
if (!style_info.accessible_name.empty())
|
||||||
result->SetAccessibleName(style_info.accessible_name);
|
result->SetAccessibleName(style_info.accessible_name);
|
||||||
if (absl::holds_alternative<SkColor>(displayed_on_background_color_)) {
|
if (absl::holds_alternative<SkColor>(displayed_on_background_color_)) {
|
||||||
@@ -618,8 +628,7 @@ void StyledLabel::UpdateLabelBackgroundColor() {
|
|||||||
if (!child->GetProperty(kStyledLabelCustomViewKey)) {
|
if (!child->GetProperty(kStyledLabelCustomViewKey)) {
|
||||||
// TODO(kylixrd): Should updating the label background color even be
|
// TODO(kylixrd): Should updating the label background color even be
|
||||||
// allowed if there are custom views?
|
// allowed if there are custom views?
|
||||||
DCHECK((child->GetClassName() == Label::kViewClassName) ||
|
DCHECK(IsViewClass<Label>(child) || IsViewClass<LinkFragment>(child));
|
||||||
(child->GetClassName() == LinkFragment::kViewClassName));
|
|
||||||
static_cast<Label*>(child)->SetBackgroundColorId(
|
static_cast<Label*>(child)->SetBackgroundColorId(
|
||||||
absl::holds_alternative<ui::ColorId>(displayed_on_background_color_)
|
absl::holds_alternative<ui::ColorId>(displayed_on_background_color_)
|
||||||
? absl::optional<ui::ColorId>(
|
? absl::optional<ui::ColorId>(
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include "ui/views/buildflags.h"
|
#include "ui/views/buildflags.h"
|
||||||
#include "ui/views/layout/layout_provider.h"
|
#include "ui/views/layout/layout_provider.h"
|
||||||
#include "ui/views/style/platform_style.h"
|
#include "ui/views/style/platform_style.h"
|
||||||
|
#include "ui/views/view_utils.h"
|
||||||
#include "ui/views/views_features.h"
|
#include "ui/views/views_features.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
#include "ui/views/widget/widget_observer.h"
|
#include "ui/views/widget/widget_observer.h"
|
||||||
@@ -297,10 +298,7 @@ std::unique_ptr<NonClientFrameView> DialogDelegate::CreateDialogFrameView(
|
|||||||
const DialogClientView* DialogDelegate::GetDialogClientView() const {
|
const DialogClientView* DialogDelegate::GetDialogClientView() const {
|
||||||
if (!GetWidget())
|
if (!GetWidget())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
const views::View* client_view = GetWidget()->client_view();
|
return AsViewClass<DialogClientView>(GetWidget()->client_view());
|
||||||
return client_view->GetClassName() == DialogClientView::kViewClassName
|
|
||||||
? static_cast<const DialogClientView*>(client_view)
|
|
||||||
: nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogClientView* DialogDelegate::GetDialogClientView() {
|
DialogClientView* DialogDelegate::GetDialogClientView() {
|
||||||
@@ -346,7 +344,7 @@ views::View* DialogDelegate::GetFootnoteViewForTesting() const {
|
|||||||
// it to create anything other than a BubbleFrameView.
|
// it to create anything other than a BubbleFrameView.
|
||||||
// TODO(https://crbug.com/1011446): Make CreateDialogFrameView final, then
|
// TODO(https://crbug.com/1011446): Make CreateDialogFrameView final, then
|
||||||
// remove this DCHECK.
|
// remove this DCHECK.
|
||||||
DCHECK_EQ(frame->GetClassName(), BubbleFrameView::kViewClassName);
|
DCHECK(IsViewClass<BubbleFrameView>(frame));
|
||||||
return static_cast<BubbleFrameView*>(frame)->GetFootnoteView();
|
return static_cast<BubbleFrameView*>(frame)->GetFootnoteView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user