diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-24 22:49:41 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-24 22:49:41 +0000 |
commit | 9137e7343672ce086de636b92c500bf809c96d3e (patch) | |
tree | 6e8c5776131eb2b39e5542cda12c335c64434ccc /ash/ime | |
parent | 21d5a6b64618bb1c82cfef3aaccb646f1a4fad3b (diff) | |
download | chromium_src-9137e7343672ce086de636b92c500bf809c96d3e.zip chromium_src-9137e7343672ce086de636b92c500bf809c96d3e.tar.gz chromium_src-9137e7343672ce086de636b92c500bf809c96d3e.tar.bz2 |
views: Make View::set_border() take a scoped_ptr<>.
This makes the ownership situation much clearer. It also renames the function to SetBorder() (since it is not a simple accessor and can free previous instances of Border), and creates a Border::NullBorder() method (since "SetBorder(scoped_ptr<>())" is not clear).
BUG=none
R=sky@chromium.org
Review URL: https://codereview.chromium.org/145033006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/ime')
-rw-r--r-- | ash/ime/candidate_view.cc | 12 | ||||
-rw-r--r-- | ash/ime/candidate_window_view.cc | 27 | ||||
-rw-r--r-- | ash/ime/infolist_window.cc | 23 |
3 files changed, 33 insertions, 29 deletions
diff --git a/ash/ime/candidate_view.cc b/ash/ime/candidate_view.cc index 652998a..eaa790a 100644 --- a/ash/ime/candidate_view.cc +++ b/ash/ime/candidate_view.cc @@ -73,7 +73,7 @@ views::Label* CreateShortcutLabel( (orientation == ui::CandidateWindow::VERTICAL ? kVerticalShortcutLabelInsets : kHorizontalShortcutLabelInsets); - shortcut_label->set_border(views::Border::CreateEmptyBorder( + shortcut_label->SetBorder(views::Border::CreateEmptyBorder( insets.top(), insets.left(), insets.bottom(), insets.right())); // Add decoration based on the orientation. @@ -144,7 +144,7 @@ CandidateView::CandidateView( candidate_label_(NULL), annotation_label_(NULL), infolist_icon_(NULL) { - set_border(views::Border::CreateEmptyBorder(1, 1, 1, 1)); + SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); const ui::NativeTheme& theme = *GetNativeTheme(); shortcut_label_ = CreateShortcutLabel(orientation, theme); @@ -198,9 +198,9 @@ void CandidateView::StateChanged() { set_background( views::Background::CreateSolidBackground(theme->GetSystemColor( ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); - set_border(views::Border::CreateSolidBorder( - 1, theme->GetSystemColor( - ui::NativeTheme::kColorId_FocusedBorderColor))); + SetBorder(views::Border::CreateSolidBorder( + 1, + theme->GetSystemColor(ui::NativeTheme::kColorId_FocusedBorderColor))); // Cancel currently focused one. for (int i = 0; i < parent()->child_count(); ++i) { @@ -211,7 +211,7 @@ void CandidateView::StateChanged() { } } else { set_background(NULL); - set_border(views::Border::CreateEmptyBorder(1, 1, 1, 1)); + SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); } } diff --git a/ash/ime/candidate_window_view.cc b/ash/ime/candidate_window_view.cc index 28de0e7..8865e64 100644 --- a/ash/ime/candidate_window_view.cc +++ b/ash/ime/candidate_window_view.cc @@ -97,7 +97,7 @@ class InformationTextArea : public views::View { : min_width_(min_width) { label_ = new views::Label; label_->SetHorizontalAlignment(align); - label_->set_border(views::Border::CreateEmptyBorder(2, 2, 2, 4)); + label_->SetBorder(views::Border::CreateEmptyBorder(2, 2, 2, 4)); SetLayoutManager(new views::FillLayout()); AddChildView(label_); @@ -119,9 +119,12 @@ class InformationTextArea : public views::View { } // Sets the border thickness for top/bottom. - void SetBorder(BorderPosition position) { - set_border(views::Border::CreateSolidSidedBorder( - (position == TOP) ? 1 : 0, 0, (position == BOTTOM) ? 1 : 0, 0, + void SetBorderFromPosition(BorderPosition position) { + SetBorder(views::Border::CreateSolidSidedBorder( + (position == TOP) ? 1 : 0, + 0, + (position == BOTTOM) ? 1 : 0, + 0, GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_MenuBorderColor))); } @@ -153,7 +156,7 @@ CandidateWindowView::CandidateWindowView(gfx::NativeView parent) set_background( views::Background::CreateSolidBackground(theme->GetSystemColor( ui::NativeTheme::kColorId_WindowBackground))); - set_border(views::Border::CreateSolidBorder( + SetBorder(views::Border::CreateSolidBorder( 1, theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBorderColor))); SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); @@ -163,12 +166,12 @@ CandidateWindowView::CandidateWindowView(gfx::NativeView parent) auxiliary_text_->SetVisible(false); preedit_->SetVisible(false); candidate_area_->SetVisible(false); - preedit_->SetBorder(InformationTextArea::BOTTOM); + preedit_->SetBorderFromPosition(InformationTextArea::BOTTOM); if (candidate_window_.orientation() == ui::CandidateWindow::VERTICAL) { AddChildView(preedit_); AddChildView(candidate_area_); AddChildView(auxiliary_text_); - auxiliary_text_->SetBorder(InformationTextArea::TOP); + auxiliary_text_->SetBorderFromPosition(InformationTextArea::TOP); candidate_area_->SetLayoutManager(new views::BoxLayout( views::BoxLayout::kVertical, 0, 0, 0)); } else { @@ -176,7 +179,7 @@ CandidateWindowView::CandidateWindowView(gfx::NativeView parent) AddChildView(auxiliary_text_); AddChildView(candidate_area_); auxiliary_text_->SetAlignment(gfx::ALIGN_LEFT); - auxiliary_text_->SetBorder(InformationTextArea::BOTTOM); + auxiliary_text_->SetBorderFromPosition(InformationTextArea::BOTTOM); candidate_area_->SetLayoutManager(new views::BoxLayout( views::BoxLayout::kHorizontal, 0, 0, 0)); } @@ -192,8 +195,8 @@ views::Widget* CandidateWindowView::InitWidget() { widget->GetNativeView(), views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); - GetBubbleFrameView()->SetBubbleBorder( - new CandidateWindowBorder(parent_window())); + GetBubbleFrameView()->SetBubbleBorder(scoped_ptr<views::BubbleBorder>( + new CandidateWindowBorder(parent_window()))); return widget; } @@ -242,13 +245,13 @@ void CandidateWindowView::UpdateCandidates( if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL) { ReorderChildView(auxiliary_text_, -1); auxiliary_text_->SetAlignment(gfx::ALIGN_RIGHT); - auxiliary_text_->SetBorder(InformationTextArea::TOP); + auxiliary_text_->SetBorderFromPosition(InformationTextArea::TOP); candidate_area_->SetLayoutManager(new views::BoxLayout( views::BoxLayout::kVertical, 0, 0, 0)); } else { ReorderChildView(auxiliary_text_, 1); auxiliary_text_->SetAlignment(gfx::ALIGN_LEFT); - auxiliary_text_->SetBorder(InformationTextArea::BOTTOM); + auxiliary_text_->SetBorderFromPosition(InformationTextArea::BOTTOM); candidate_area_->SetLayoutManager(new views::BoxLayout( views::BoxLayout::kHorizontal, 0, 0, 0)); } diff --git a/ash/ime/infolist_window.cc b/ash/ime/infolist_window.cc index d72eed3..1b91c46 100644 --- a/ash/ime/infolist_window.cc +++ b/ash/ime/infolist_window.cc @@ -120,8 +120,7 @@ InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry, title_label_->SetPosition(gfx::Point(0, 0)); title_label_->SetFontList(title_font); title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - title_label_->set_border( - views::Border::CreateEmptyBorder(4, 7, 2, 4)); + title_label_->SetBorder(views::Border::CreateEmptyBorder(4, 7, 2, 4)); description_label_ = new views::Label(entry.body); description_label_->SetPosition(gfx::Point(0, 0)); @@ -129,8 +128,7 @@ InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry, description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); description_label_->SetMultiLine(true); description_label_->SizeToFit(kInfolistEntryWidth); - description_label_->set_border( - views::Border::CreateEmptyBorder(2, 17, 4, 4)); + description_label_->SetBorder(views::Border::CreateEmptyBorder(2, 17, 4, 4)); AddChildView(title_label_); AddChildView(description_label_); UpdateBackground(); @@ -157,12 +155,13 @@ void InfolistEntryView::UpdateBackground() { set_background( views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); - set_border( - views::Border::CreateSolidBorder(1, GetNativeTheme()->GetSystemColor( + SetBorder(views::Border::CreateSolidBorder( + 1, + GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_FocusedBorderColor))); } else { set_background(NULL); - set_border(views::Border::CreateEmptyBorder(1, 1, 1, 1)); + SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); } SchedulePaint(); } @@ -181,8 +180,9 @@ InfolistWindow::InfolistWindow(views::View* candidate_window, set_background( views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_WindowBackground))); - set_border( - views::Border::CreateSolidBorder(1, GetNativeTheme()->GetSystemColor( + SetBorder(views::Border::CreateSolidBorder( + 1, + GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_MenuBorderColor))); SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); @@ -194,7 +194,7 @@ InfolistWindow::InfolistWindow(views::View* candidate_window, caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); caption_label->SetEnabledColor(GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_LabelEnabledColor)); - caption_label->set_border(views::Border::CreateEmptyBorder(2, 2, 2, 2)); + caption_label->SetBorder(views::Border::CreateEmptyBorder(2, 2, 2, 2)); caption_label->set_background(views::Background::CreateSolidBackground( color_utils::AlphaBlend(SK_ColorBLACK, GetNativeTheme()->GetSystemColor( @@ -220,7 +220,8 @@ void InfolistWindow::InitWidget() { views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); // BubbleFrameView will be initialized through CreateBubble. - GetBubbleFrameView()->SetBubbleBorder(new InfolistBorder()); + GetBubbleFrameView()->SetBubbleBorder( + scoped_ptr<views::BubbleBorder>(new InfolistBorder())); SizeToContents(); } |