| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/bubble/bubble_dialog_delegate.h" | 5 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ui/accessibility/ax_node_data.h" | 8 #include "ui/accessibility/ax_node_data.h" |
| 9 #include "ui/base/default_style.h" | 9 #include "ui/base/default_style.h" |
| 10 #include "ui/base/material_design/material_design_controller.h" | 10 #include "ui/base/material_design/material_design_controller.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) { | 98 ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) { |
| 99 DialogClientView* client = new DialogClientView(widget, GetContentsView()); | 99 DialogClientView* client = new DialogClientView(widget, GetContentsView()); |
| 100 client->set_button_row_insets(gfx::Insets()); | 100 client->set_button_row_insets(gfx::Insets()); |
| 101 widget->non_client_view()->set_mirror_client_in_rtl(mirror_arrow_in_rtl_); | 101 widget->non_client_view()->set_mirror_client_in_rtl(mirror_arrow_in_rtl_); |
| 102 return client; | 102 return client; |
| 103 } | 103 } |
| 104 | 104 |
| 105 NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView( | 105 NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView( |
| 106 Widget* widget) { | 106 Widget* widget) { |
| 107 ViewsDelegate* views_delegate = ViewsDelegate::GetInstance(); | 107 BubbleFrameView* frame = new BubbleFrameView(title_margins_, margins_); |
| 108 BubbleFrameView* frame = new BubbleFrameView( | |
| 109 views_delegate ? views_delegate->GetDialogFrameViewInsets() | |
| 110 : gfx::Insets(kPanelVertMargin, kPanelHorizMargin, 0, | |
| 111 kPanelHorizMargin), | |
| 112 margins()); | |
| 113 // Note: In CreateBubble, the call to SizeToContents() will cause | 108 // Note: In CreateBubble, the call to SizeToContents() will cause |
| 114 // the relayout that this call requires. | 109 // the relayout that this call requires. |
| 115 frame->SetTitleFontList(GetTitleFontList()); | 110 frame->SetTitleFontList(GetTitleFontList()); |
| 116 frame->SetFootnoteView(CreateFootnoteView()); | 111 frame->SetFootnoteView(CreateFootnoteView()); |
| 117 | 112 |
| 118 BubbleBorder::Arrow adjusted_arrow = arrow(); | 113 BubbleBorder::Arrow adjusted_arrow = arrow(); |
| 119 if (base::i18n::IsRTL() && mirror_arrow_in_rtl_) | 114 if (base::i18n::IsRTL() && mirror_arrow_in_rtl_) |
| 120 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); | 115 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); |
| 121 frame->SetBubbleBorder(std::unique_ptr<BubbleBorder>( | 116 frame->SetBubbleBorder(std::unique_ptr<BubbleBorder>( |
| 122 new BubbleBorder(adjusted_arrow, shadow(), color()))); | 117 new BubbleBorder(adjusted_arrow, shadow(), color()))); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 : close_on_deactivate_(true), | 208 : close_on_deactivate_(true), |
| 214 anchor_view_storage_id_(ViewStorage::GetInstance()->CreateStorageID()), | 209 anchor_view_storage_id_(ViewStorage::GetInstance()->CreateStorageID()), |
| 215 anchor_widget_(NULL), | 210 anchor_widget_(NULL), |
| 216 arrow_(arrow), | 211 arrow_(arrow), |
| 217 mirror_arrow_in_rtl_(PlatformStyle::kMirrorBubbleArrowInRTLByDefault), | 212 mirror_arrow_in_rtl_(PlatformStyle::kMirrorBubbleArrowInRTLByDefault), |
| 218 shadow_(BubbleBorder::SMALL_SHADOW), | 213 shadow_(BubbleBorder::SMALL_SHADOW), |
| 219 color_explicitly_set_(false), | 214 color_explicitly_set_(false), |
| 220 accept_events_(true), | 215 accept_events_(true), |
| 221 adjust_if_offscreen_(true), | 216 adjust_if_offscreen_(true), |
| 222 parent_window_(NULL) { | 217 parent_window_(NULL) { |
| 223 margins_ = ViewsDelegate::GetInstance() | 218 ViewsDelegate* views_delegate = ViewsDelegate::GetInstance(); |
| 224 ? ViewsDelegate::GetInstance()->GetBubbleDialogMargins() | 219 margins_ = views_delegate ? views_delegate->GetBubbleDialogMargins() |
| 225 : gfx::Insets(kPanelVertMargin, kPanelHorizMargin, | 220 : gfx::Insets(kPanelVertMargin, kPanelHorizMargin); |
| 226 kPanelVertMargin, kPanelHorizMargin); | 221 title_margins_ = views_delegate |
| 222 ? views_delegate->GetDialogFrameViewInsets() |
| 223 : gfx::Insets(kPanelVertMargin, kPanelHorizMargin, 0, |
| 224 kPanelHorizMargin); |
| 227 if (anchor_view) | 225 if (anchor_view) |
| 228 SetAnchorView(anchor_view); | 226 SetAnchorView(anchor_view); |
| 229 UpdateColorsFromTheme(GetNativeTheme()); | 227 UpdateColorsFromTheme(GetNativeTheme()); |
| 230 } | 228 } |
| 231 | 229 |
| 232 gfx::Rect BubbleDialogDelegateView::GetBubbleBounds() { | 230 gfx::Rect BubbleDialogDelegateView::GetBubbleBounds() { |
| 233 // The argument rect has its origin at the bubble's arrow anchor point; | 231 // The argument rect has its origin at the bubble's arrow anchor point; |
| 234 // its size is the preferred size of the bubble's client view (this view). | 232 // its size is the preferred size of the bubble's client view (this view). |
| 235 bool anchor_minimized = anchor_widget() && anchor_widget()->IsMinimized(); | 233 bool anchor_minimized = anchor_widget() && anchor_widget()->IsMinimized(); |
| 236 return GetBubbleFrameView()->GetUpdatedWindowBounds( | 234 return GetBubbleFrameView()->GetUpdatedWindowBounds( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 // http://crbug.com/474622 for details. | 324 // http://crbug.com/474622 for details. |
| 327 if (widget == GetWidget() && visible) { | 325 if (widget == GetWidget() && visible) { |
| 328 ui::AXNodeData node_data; | 326 ui::AXNodeData node_data; |
| 329 GetAccessibleNodeData(&node_data); | 327 GetAccessibleNodeData(&node_data); |
| 330 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) | 328 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) |
| 331 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 329 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 332 } | 330 } |
| 333 } | 331 } |
| 334 | 332 |
| 335 } // namespace views | 333 } // namespace views |
| OLD | NEW |