From 9546120ce410b3fc27f1d476b0908ea1ddb99e73 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 1 Sep 2014 20:10:14 +0800 Subject: [PATCH] linux: Fix API changes of Chrome 37. --- atom/browser/native_window_views.cc | 1 - atom/browser/ui/message_box_views.cc | 5 ++--- atom/browser/ui/views/frameless_view.cc | 6 +++--- atom/browser/ui/views/frameless_view.h | 6 +++--- atom/browser/ui/views/menu_bar.cc | 8 ++++---- atom/browser/ui/views/menu_delegate.cc | 2 +- atom/browser/ui/views/menu_delegate.h | 2 +- atom/browser/ui/views/menu_layout.cc | 5 +++-- atom/browser/ui/views/menu_layout.h | 5 +++-- atom/browser/ui/views/submenu_button.cc | 5 +++-- atom/browser/ui/views/submenu_button.h | 3 +++ vendor/brightray | 2 +- 12 files changed, 27 insertions(+), 23 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 5524711fdd69..3c1cd30c2350 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -145,7 +145,6 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents, params.bounds = bounds; params.delegate = this; params.type = views::Widget::InitParams::TYPE_WINDOW; - params.top_level = true; params.remove_standard_frame = !has_frame_; #if defined(USE_X11) diff --git a/atom/browser/ui/message_box_views.cc b/atom/browser/ui/message_box_views.cc index c050a3dd3c39..a807eaac0cf1 100644 --- a/atom/browser/ui/message_box_views.cc +++ b/atom/browser/ui/message_box_views.cc @@ -71,7 +71,7 @@ class MessageDialog : public views::WidgetDelegate, virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; // Overridden from views::View: - virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual gfx::Size GetPreferredSize() const OVERRIDE; virtual void Layout() OVERRIDE; virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; @@ -160,7 +160,6 @@ MessageDialog::MessageDialog(NativeWindow* parent_window, views::Widget::InitParams params; params.delegate = this; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - params.top_level = true; if (parent_) { params.parent = parent_->GetNativeWindow(); params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; @@ -264,7 +263,7 @@ views::ClientView* MessageDialog::CreateClientView(views::Widget* widget) { return new MessageDialogClientView(this, widget); } -gfx::Size MessageDialog::GetPreferredSize() { +gfx::Size MessageDialog::GetPreferredSize() const { gfx::Size size(0, buttons_[0]->GetPreferredSize().height()); for (size_t i = 0; i < buttons_.size(); ++i) size.Enlarge(buttons_[i]->GetPreferredSize().width(), 0); diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index a7c5f3c1765e..b02ec299dab1 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -95,16 +95,16 @@ void FramelessView::UpdateWindowIcon() { void FramelessView::UpdateWindowTitle() { } -gfx::Size FramelessView::GetPreferredSize() { +gfx::Size FramelessView::GetPreferredSize() const { return frame_->non_client_view()->GetWindowBoundsForClientBounds( gfx::Rect(frame_->client_view()->GetPreferredSize())).size(); } -gfx::Size FramelessView::GetMinimumSize() { +gfx::Size FramelessView::GetMinimumSize() const { return window_->GetMinimumSize(); } -gfx::Size FramelessView::GetMaximumSize() { +gfx::Size FramelessView::GetMaximumSize() const { return window_->GetMaximumSize(); } diff --git a/atom/browser/ui/views/frameless_view.h b/atom/browser/ui/views/frameless_view.h index 93b86f73774a..d9013d815550 100644 --- a/atom/browser/ui/views/frameless_view.h +++ b/atom/browser/ui/views/frameless_view.h @@ -38,9 +38,9 @@ class FramelessView : public views::NonClientFrameView { virtual void UpdateWindowTitle() OVERRIDE; // Overridden from View: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual gfx::Size GetMinimumSize() OVERRIDE; - virtual gfx::Size GetMaximumSize() OVERRIDE; + virtual gfx::Size GetPreferredSize() const OVERRIDE; + virtual gfx::Size GetMinimumSize() const OVERRIDE; + virtual gfx::Size GetMaximumSize() const OVERRIDE; virtual const char* GetClassName() const OVERRIDE; // Not owned. diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index 0cfa71e03647..dbbce6e0e246 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -74,10 +74,10 @@ void MenuBar::SetMenu(ui::MenuModel* model) { button->set_tag(i); #if defined(USE_X11) - button->SetEnabledColor(enabled_color_); - button->SetDisabledColor(disabled_color_); - button->SetHighlightColor(highlight_color_); - button->SetHoverColor(hover_color_); + button->SetTextColor(views::Button::STATE_NORMAL, enabled_color_); + button->SetTextColor(views::Button::STATE_DISABLED, disabled_color_); + button->SetTextColor(views::Button::STATE_PRESSED, highlight_color_); + button->SetTextColor(views::Button::STATE_HOVERED, hover_color_); button->SetUnderlineColor(enabled_color_); #elif defined(OS_WIN) button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_GRAYTEXT)); diff --git a/atom/browser/ui/views/menu_delegate.cc b/atom/browser/ui/views/menu_delegate.cc index e01a9d4c5253..88d1b689b5c3 100644 --- a/atom/browser/ui/views/menu_delegate.cc +++ b/atom/browser/ui/views/menu_delegate.cc @@ -73,7 +73,7 @@ bool MenuDelegate::IsTriggerableEvent(views::MenuItemView* source, return delegate()->IsTriggerableEvent(source, e); } -bool MenuDelegate::GetAccelerator(int id, ui::Accelerator* accelerator) { +bool MenuDelegate::GetAccelerator(int id, ui::Accelerator* accelerator) const { return delegate()->GetAccelerator(id, accelerator); } diff --git a/atom/browser/ui/views/menu_delegate.h b/atom/browser/ui/views/menu_delegate.h index ca6492cbc6cd..cad6017b9bd4 100644 --- a/atom/browser/ui/views/menu_delegate.h +++ b/atom/browser/ui/views/menu_delegate.h @@ -35,7 +35,7 @@ class MenuDelegate : public views::MenuDelegate { virtual bool IsTriggerableEvent(views::MenuItemView* source, const ui::Event& e) OVERRIDE; virtual bool GetAccelerator(int id, - ui::Accelerator* accelerator) OVERRIDE; + ui::Accelerator* accelerator) const OVERRIDE; virtual base::string16 GetLabel(int id) const OVERRIDE; virtual const gfx::FontList* GetLabelFontList(int id) const OVERRIDE; virtual bool IsCommandEnabled(int id) const OVERRIDE; diff --git a/atom/browser/ui/views/menu_layout.cc b/atom/browser/ui/views/menu_layout.cc index 5ed015fb8710..7215cee1c872 100644 --- a/atom/browser/ui/views/menu_layout.cc +++ b/atom/browser/ui/views/menu_layout.cc @@ -30,7 +30,7 @@ void MenuLayout::Layout(views::View* host) { menu_bar->SetBoundsRect(menu_Bar_bounds); } -gfx::Size MenuLayout::GetPreferredSize(views::View* host) { +gfx::Size MenuLayout::GetPreferredSize(const views::View* host) const { gfx::Size size = views::FillLayout::GetPreferredSize(host); if (!HasMenu(host)) return size; @@ -39,7 +39,8 @@ gfx::Size MenuLayout::GetPreferredSize(views::View* host) { return size; } -int MenuLayout::GetPreferredHeightForWidth(views::View* host, int width) { +int MenuLayout::GetPreferredHeightForWidth( + const views::View* host, int width) const { int height = views::FillLayout::GetPreferredHeightForWidth(host, width); if (!HasMenu(host)) return height; diff --git a/atom/browser/ui/views/menu_layout.h b/atom/browser/ui/views/menu_layout.h index 1b3d78e28d96..d01ccd609191 100644 --- a/atom/browser/ui/views/menu_layout.h +++ b/atom/browser/ui/views/menu_layout.h @@ -16,8 +16,9 @@ class MenuLayout : public views::FillLayout { // views::LayoutManager: virtual void Layout(views::View* host) OVERRIDE; - virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE; - virtual int GetPreferredHeightForWidth(views::View* host, int width) OVERRIDE; + virtual gfx::Size GetPreferredSize(const views::View* host) const OVERRIDE; + virtual int GetPreferredHeightForWidth( + const views::View* host, int width) const OVERRIDE; private: bool HasMenu(const views::View* host) const; diff --git a/atom/browser/ui/views/submenu_button.cc b/atom/browser/ui/views/submenu_button.cc index 4d3fd579e080..5049ffb0f487 100644 --- a/atom/browser/ui/views/submenu_button.cc +++ b/atom/browser/ui/views/submenu_button.cc @@ -34,9 +34,10 @@ SubmenuButton::SubmenuButton(views::ButtonListener* listener, text_width_(0), text_height_(0), underline_color_(SK_ColorBLACK) { + SetStyle(views::Button::STYLE_TEXTBUTTON); if (GetUnderlinePosition(title, &accelerator_, &underline_start_, &underline_end_)) - gfx::Canvas::SizeStringInt(text(), font_list(), &text_width_, + gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_, &text_height_, 0, 0); } @@ -85,7 +86,7 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text, void SubmenuButton::GetCharacterPosition( const base::string16& text, int index, int* pos) { int height; - gfx::Canvas::SizeStringInt(text.substr(0, index), font_list(), pos, &height, + gfx::Canvas::SizeStringInt(text.substr(0, index), GetFontList(), pos, &height, 0, 0); } diff --git a/atom/browser/ui/views/submenu_button.h b/atom/browser/ui/views/submenu_button.h index 457857c034ac..cb439218d489 100644 --- a/atom/browser/ui/views/submenu_button.h +++ b/atom/browser/ui/views/submenu_button.h @@ -20,6 +20,9 @@ class SubmenuButton : public views::MenuButton { void SetAcceleratorVisibility(bool visible); void SetUnderlineColor(SkColor color); + void SetEnabledColor(SkColor color); + void SetBackgroundColor(SkColor color); + base::char16 accelerator() const { return accelerator_; } // views::MenuButton: diff --git a/vendor/brightray b/vendor/brightray index 759cf77253e8..dafc85799ca3 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 759cf77253e8d3996745b6f6aeedcf3cb9465bbb +Subproject commit dafc85799ca31e3ddd7b5d0cc0ef7fbf38dcf88f