Skip to content

Commit

Permalink
Fix misuses of View::SetFillsBoundsOpaquely and remove the API to make
Browse files Browse the repository at this point in the history
layers less likely to be misused in the same way in the future.

Also fix some unnecessary calls to aura::Window::SetTransparent().

BUG=none
TBR=avi@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#379619}
  • Loading branch information
estade authored and Commit bot committed Mar 7, 2016
1 parent b893546 commit 122489a
Show file tree
Hide file tree
Showing 35 changed files with 41 additions and 58 deletions.
2 changes: 1 addition & 1 deletion ash/frame/custom_frame_view_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void CustomFrameViewAsh::HeaderView::OnMaximizeModeEnded() {
void CustomFrameViewAsh::HeaderView::OnImmersiveRevealStarted() {
fullscreen_visible_fraction_ = 0;
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
parent()->Layout();
}

Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/overflow_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void OverflowBubbleView::InitOverflowBubble(views::View* anchor,

// Makes bubble view has a layer and clip its children layers.
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
layer()->SetMasksToBounds(true);

shelf_view_ = shelf_view;
Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/shelf_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void ShelfButton::Init() {

// TODO: refactor the layers so each button doesn't require 2.
icon_view_->SetPaintToLayer(true);
icon_view_->SetFillsBoundsOpaquely(false);
icon_view_->layer()->SetFillsBoundsOpaquely(false);
icon_view_->SetHorizontalAlignment(views::ImageView::CENTER);
icon_view_->SetVerticalAlignment(views::ImageView::LEADING);

Expand Down
2 changes: 1 addition & 1 deletion ash/system/status_area_widget_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ StatusAreaWidgetDelegate::StatusAreaWidgetDelegate()
// navigation completion by the user.
set_allow_deactivate_on_esc(true);
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
}

StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() {
Expand Down
2 changes: 1 addition & 1 deletion ash/system/tray/tray_background_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget)
tray_event_filter_.reset(new TrayEventFilter);

SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
// Start the tray items not visible, because visibility changes are animated.
views::View::SetVisible(false);
}
Expand Down
2 changes: 1 addition & 1 deletion ash/system/tray/tray_empty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ views::View* TrayEmpty::CreateDefaultView(user::LoginStatus status) {
view->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
0, 0, 0));
view->SetPaintToLayer(true);
view->SetFillsBoundsOpaquely(false);
view->layer()->SetFillsBoundsOpaquely(false);
return view;
}

Expand Down
2 changes: 1 addition & 1 deletion ash/system/tray/tray_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TrayItemView::TrayItemView(SystemTrayItem* owner)
label_(NULL),
image_view_(NULL) {
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
SetLayoutManager(
new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
}
Expand Down
7 changes: 4 additions & 3 deletions ash/system/tray/tray_popup_item_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ TrayPopupItemContainer::TrayPopupItemContainer(views::View* view,
views::BoxLayout::kVertical, 0, 0, 0);
layout->SetDefaultFlex(1);
SetLayoutManager(layout);
SetPaintToLayer(view->layer() != NULL);
if (view->layer())
SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
if (view->layer()) {
SetPaintToLayer(true);
layer()->SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
}
AddChildView(view);
SetVisible(view->visible());
}
Expand Down
2 changes: 1 addition & 1 deletion ash/touch/touch_hud_debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class TouchHudCanvas : public views::View {
: touch_log_(touch_log),
scale_(1) {
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);

paint_.setStyle(SkPaint::kFill_Style);
}
Expand Down
2 changes: 1 addition & 1 deletion ash/touch/touch_hud_projection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TouchPointView : public views::View,
gradient_center_(SkPoint::Make(kPointRadius + 1,
kPointRadius + 1)) {
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);

SetSize(gfx::Size(2 * kPointRadius + 2, 2 * kPointRadius + 2));

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/dropdown_bar_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void DropdownBarHost::Init(views::View* host_view,
// Views which also paint to a Layer. See http://crbug.com/589497
scoped_ptr<views::View> clip_view(new views::View());
clip_view->SetPaintToLayer(true);
clip_view->SetFillsBoundsOpaquely(false);
clip_view->layer()->SetFillsBoundsOpaquely(false);
clip_view->layer()->SetMasksToBounds(true);
clip_view->AddChildView(view_);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ bool ImmersiveModeControllerAsh::UpdateTabIndicators() {
void ImmersiveModeControllerAsh::OnImmersiveRevealStarted() {
visible_fraction_ = 0;
browser_view_->top_container()->SetPaintToLayer(true);
browser_view_->top_container()->SetFillsBoundsOpaquely(false);
browser_view_->top_container()->layer()->SetFillsBoundsOpaquely(false);
UpdateTabIndicators();
LayoutBrowserRootView();
FOR_EACH_OBSERVER(Observer, observers_, OnImmersiveRevealStarted());
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/infobars/infobar_container_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ InfoBarContainerView::InfoBarContainerView(Delegate* delegate)
set_id(VIEW_ID_INFO_BAR_CONTAINER);
SetEventTargeter(make_scoped_ptr(new views::ViewTargeter(this)));
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
}

InfoBarContainerView::~InfoBarContainerView() {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/location_bar/bubble_icon_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void BubbleIconView::OnNativeThemeChanged(const ui::NativeTheme* theme) {

void BubbleIconView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
image_->SetPaintToLayer(true);
image_->SetFillsBoundsOpaquely(false);
image_->layer()->SetFillsBoundsOpaquely(false);
views::InkDropHostView::AddInkDropLayer(ink_drop_layer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void IconLabelBubbleView::OnNativeThemeChanged(

void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
image()->SetPaintToLayer(true);
image()->SetFillsBoundsOpaquely(false);
image()->layer()->SetFillsBoundsOpaquely(false);
InkDropHostView::AddInkDropLayer(ink_drop_layer);
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/location_bar/location_bar_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void LocationBarView::Init() {
if (ui::MaterialDesignController::IsModeMaterial()) {
// Make sure children with layers are clipped. See http://crbug.com/589497
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
layer()->SetMasksToBounds(true);
} else if (is_popup_mode_) {
const int kOmniboxPopupBorderImages[] =
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/ui/views/tabs/tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1538,9 +1538,10 @@ void Tab::AdvanceLoadingAnimation() {
const bool paint_to_layer = controller_->CanPaintThrobberToLayer();
if (paint_to_layer != !!throbber_->layer()) {
throbber_->SetPaintToLayer(paint_to_layer);
throbber_->SetFillsBoundsOpaquely(false);
if (paint_to_layer)
if (paint_to_layer) {
throbber_->layer()->SetFillsBoundsOpaquely(false);
ScheduleIconPaint(); // Ensure the non-layered throbber goes away.
}
}
if (!throbber_->visible()) {
ScheduleIconPaint(); // Repaint the icon area to hide the favicon.
Expand Down
1 change: 0 additions & 1 deletion content/browser/web_contents/web_contents_view_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,6 @@ void WebContentsViewAura::CreateView(
window_.reset(new aura::Window(this));
window_->set_owned_by_parent(false);
window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
window_->SetTransparent(false);
window_->Init(ui::LAYER_NOT_DRAWN);
window_->AddObserver(this);
aura::Window* root_window = context ? context->GetRootWindow() : NULL;
Expand Down
1 change: 0 additions & 1 deletion content/browser/web_contents/web_contents_view_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void WebContentsViewMus::CreateView(const gfx::Size& initial_size,
aura_window_.reset(new aura::Window(this));
aura_window_->set_owned_by_parent(false);
aura_window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
aura_window_->SetTransparent(false);
aura_window_->Init(ui::LAYER_NOT_DRAWN);
aura::Window* root_window = context ? context->GetRootWindow() : nullptr;
if (root_window) {
Expand Down
2 changes: 1 addition & 1 deletion ui/app_list/views/app_list_folder_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ AppListFolderView::AppListFolderView(AppsContainerView* container_view,
view_model_->Add(items_grid_view_, kIndexChildItems);

SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);

model_->AddObserver(this);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/app_list/views/app_list_main_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void AppListMainView::AddContentsViews() {
search_box_view_->set_contents_view(contents_view_);

contents_view_->SetPaintToLayer(true);
contents_view_->SetFillsBoundsOpaquely(false);
contents_view_->layer()->SetFillsBoundsOpaquely(false);
contents_view_->layer()->SetMasksToBounds(true);

delegate_->StartSearch();
Expand Down
6 changes: 3 additions & 3 deletions ui/app_list/views/app_list_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,14 @@ void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
app_list_main_view_ = new AppListMainView(delegate_);
AddChildView(app_list_main_view_);
app_list_main_view_->SetPaintToLayer(true);
app_list_main_view_->SetFillsBoundsOpaquely(false);
app_list_main_view_->layer()->SetFillsBoundsOpaquely(false);
app_list_main_view_->layer()->SetMasksToBounds(true);

// This will be added to the |search_box_widget_| after the app list widget is
// initialized.
search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_);
search_box_view_->SetPaintToLayer(true);
search_box_view_->SetFillsBoundsOpaquely(false);
search_box_view_->layer()->SetFillsBoundsOpaquely(false);
search_box_view_->layer()->SetMasksToBounds(true);

// TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and
Expand All @@ -465,7 +465,7 @@ void AppListView::InitContents(gfx::NativeView parent, int initial_apps_page) {
speech_view_ = new SpeechView(delegate_);
speech_view_->SetVisible(false);
speech_view_->SetPaintToLayer(true);
speech_view_->SetFillsBoundsOpaquely(false);
speech_view_->layer()->SetFillsBoundsOpaquely(false);
speech_view_->layer()->SetOpacity(0.0f);
AddChildView(speech_view_);
}
Expand Down
10 changes: 4 additions & 6 deletions ui/app_list/views/apps_grid_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ AppsGridView::AppsGridView(AppsGridViewDelegate* delegate)
// Clip any icons that are outside the grid view's bounds. These icons would
// otherwise be visible to the user when the grid view is off screen.
layer()->SetMasksToBounds(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);

pagination_model_.SetTransitionDurations(kPageTransitionDurationInMs,
kOverscrollPageTransitionDurationMs);
Expand Down Expand Up @@ -803,9 +803,7 @@ void AppsGridView::InitiateDragFromReparentItemInRootLevelGridView(
AddChildView(view);
drag_view_ = view;
drag_view_->SetPaintToLayer(true);
// Note: For testing purpose, SetFillsBoundsOpaquely can be set to true to
// show the gray background.
drag_view_->SetFillsBoundsOpaquely(false);
drag_view_->layer()->SetFillsBoundsOpaquely(false);
drag_view_->SetBoundsRect(drag_view_rect);
drag_view_->SetDragUIState(); // Hide the title of the drag_view_.

Expand Down Expand Up @@ -1080,7 +1078,7 @@ AppListItemView* AppsGridView::CreateViewForItemAtIndex(size_t index) {
AppListItemView* view = new AppListItemView(this,
item_list_->item_at(index));
view->SetPaintToLayer(true);
view->SetFillsBoundsOpaquely(false);
view->layer()->SetFillsBoundsOpaquely(false);
return view;
}

Expand Down Expand Up @@ -1326,7 +1324,7 @@ void AppsGridView::AnimationBetweenRows(AppListItemView* view,
layer = view->RecreateLayer();
layer->SuppressPaint();

view->SetFillsBoundsOpaquely(false);
view->layer()->SetFillsBoundsOpaquely(false);
view->layer()->SetOpacity(0.f);
}

Expand Down
2 changes: 1 addition & 1 deletion ui/app_list/views/folder_background_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ FolderBackgroundView::FolderBackgroundView()
: folder_view_(NULL),
show_state_(NO_BUBBLE) {
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
}

FolderBackgroundView::~FolderBackgroundView() {
Expand Down
2 changes: 1 addition & 1 deletion ui/app_list/views/pulsing_block_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace app_list {

PulsingBlockView::PulsingBlockView(const gfx::Size& size, bool start_delay) {
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);

const int max_delay = kAnimationDurationInMs * arraysize(kAnimationOpacity);
const int delay = start_delay ? base::RandInt(0, max_delay) : 0;
Expand Down
2 changes: 1 addition & 1 deletion ui/app_list/views/top_icon_animation_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TopIconAnimationView::TopIconAnimationView(const gfx::ImageSkia& icon,
AddChildView(icon_);

SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
}

TopIconAnimationView::~TopIconAnimationView() {
Expand Down
2 changes: 1 addition & 1 deletion ui/message_center/views/message_center_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ MessageCenterView::MessageCenterView(MessageCenter* message_center,
views::Background::CreateSolidBackground(kMessageCenterBackgroundColor));

scroller_->SetPaintToLayer(true);
scroller_->SetFillsBoundsOpaquely(false);
scroller_->layer()->SetFillsBoundsOpaquely(false);
scroller_->layer()->SetMasksToBounds(true);

empty_list_view_.reset(new NoNotificationMessageView);
Expand Down
2 changes: 1 addition & 1 deletion ui/views/animation/ink_drop_host_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ InkDropHostView::~InkDropHostView() {}

void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
layer()->Add(ink_drop_layer);
layer()->StackAtBottom(ink_drop_layer);
}
Expand Down
2 changes: 0 additions & 2 deletions ui/views/bubble/tray_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ TrayBubbleView::TrayBubbleView(gfx::NativeView parent_window,
set_close_on_deactivate(init_params.close_on_deactivate);
set_margins(gfx::Insets());
SetPaintToLayer(true);
SetFillsBoundsOpaquely(true);

bubble_content_mask_.reset(
new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius()));
Expand Down Expand Up @@ -507,7 +506,6 @@ void TrayBubbleView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
if (details.is_add && details.child == this) {
details.parent->SetPaintToLayer(true);
details.parent->SetFillsBoundsOpaquely(true);
details.parent->layer()->SetMasksToBounds(true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ui/views/controls/button/label_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ LabelButton::LabelButton(ButtonListener* listener, const base::string16& text)

AddChildView(ink_drop_container_);
ink_drop_container_->SetPaintToLayer(true);
ink_drop_container_->SetFillsBoundsOpaquely(false);
ink_drop_container_->layer()->SetFillsBoundsOpaquely(false);
ink_drop_container_->SetVisible(false);

AddChildView(image_);
Expand Down Expand Up @@ -407,7 +407,7 @@ void LabelButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {

void LabelButton::AddInkDropLayer(ui::Layer* ink_drop_layer) {
image()->SetPaintToLayer(true);
image()->SetFillsBoundsOpaquely(false);
image()->layer()->SetFillsBoundsOpaquely(false);
ink_drop_container_->SetVisible(true);
ink_drop_container_->layer()->Add(ink_drop_layer);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/scrollbar/cocoa_scroll_bar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
// This is necessary, otherwise the thumb will be rendered below the views if
// those views paint to their own layers.
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
}

CocoaScrollBarThumb::~CocoaScrollBarThumb() {}
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/scrollbar/overlay_scroll_bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ OverlayScrollBarThumb::OverlayScrollBarThumb(BaseScrollBar* scroll_bar)
// This is necessary, otherwise the thumb will be rendered below the views if
// those views paint to their own layers.
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
}

OverlayScrollBarThumb::~OverlayScrollBarThumb() {
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/slide_out_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SlideOutView::SlideOutView() {
// If accelerated compositing is not available, this widget tracks the
// OnSlideOut event but does not render any visible changes.
SetPaintToLayer(true);
SetFillsBoundsOpaquely(false);
layer()->SetFillsBoundsOpaquely(false);
}

SlideOutView::~SlideOutView() {
Expand Down
6 changes: 0 additions & 6 deletions ui/views/view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1437,12 +1437,6 @@ void View::OnPaintBorder(gfx::Canvas* canvas) {

// Accelerated Painting --------------------------------------------------------

void View::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) {
// This method should not have the side-effect of creating the layer.
if (layer())
layer()->SetFillsBoundsOpaquely(fills_bounds_opaquely);
}

gfx::Vector2d View::CalculateOffsetToAncestorWithLayer(
ui::Layer** layer_parent) {
if (layer()) {
Expand Down
7 changes: 0 additions & 7 deletions ui/views/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Returns whether the view is enabled.
bool enabled() const { return enabled_; }

// This indicates that the view completely fills its bounds in an opaque
// color. This doesn't affect compositing but is a hint to the compositor to
// optimize painting.
// Note that this method does not implicitly create a layer if one does not
// already exist for the View, but is a no-op in that case.
void SetFillsBoundsOpaquely(bool fills_bounds_opaquely);

// Transformations -----------------------------------------------------------

// Methods for setting transformations for a view (e.g. rotation, scaling).
Expand Down

0 comments on commit 122489a

Please sign in to comment.