OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_frame_view.h" | 5 #include "ui/views/bubble/bubble_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 } | 356 } |
357 | 357 |
358 void BubbleFrameView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 358 void BubbleFrameView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
359 if (bubble_border_ && bubble_border_->use_theme_background_color()) { | 359 if (bubble_border_ && bubble_border_->use_theme_background_color()) { |
360 bubble_border_->set_background_color(GetNativeTheme()-> | 360 bubble_border_->set_background_color(GetNativeTheme()-> |
361 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)); | 361 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)); |
362 SchedulePaint(); | 362 SchedulePaint(); |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 void BubbleFrameView::ViewHierarchyChanged( | |
367 const ViewHierarchyChangedDetails& details) { | |
368 if (!details.is_add && details.parent == footnote_container_) { | |
sky
2017/05/24 00:03:35
Combine these two ifs into 1. Also, add a comment
mrefaat1
2017/05/24 02:27:17
Done.
| |
369 if (footnote_container_->child_count() == 1 && | |
370 details.child == footnote_container_->child_at(0)) { | |
371 footnote_container_->SetVisible(false); | |
372 footnote_container_ = nullptr; | |
373 } | |
374 } | |
375 } | |
376 | |
366 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) { | 377 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) { |
367 OnPaintBackground(canvas); | 378 OnPaintBackground(canvas); |
368 // Border comes after children. | 379 // Border comes after children. |
369 } | 380 } |
370 | 381 |
371 void BubbleFrameView::PaintChildren(const ui::PaintContext& context) { | 382 void BubbleFrameView::PaintChildren(const ui::PaintContext& context) { |
372 NonClientFrameView::PaintChildren(context); | 383 NonClientFrameView::PaintChildren(context); |
373 | 384 |
374 ui::PaintCache paint_cache; | 385 ui::PaintCache paint_cache; |
375 ui::PaintRecorder recorder(context, size(), &paint_cache); | 386 ui::PaintRecorder recorder(context, size(), &paint_cache); |
(...skipping 25 matching lines...) Expand all Loading... | |
401 new BoxLayout(BoxLayout::kVertical, content_margins_.left(), | 412 new BoxLayout(BoxLayout::kVertical, content_margins_.left(), |
402 content_margins_.top(), 0)); | 413 content_margins_.top(), 0)); |
403 footnote_container_->set_background( | 414 footnote_container_->set_background( |
404 Background::CreateSolidBackground(kFootnoteBackgroundColor)); | 415 Background::CreateSolidBackground(kFootnoteBackgroundColor)); |
405 footnote_container_->SetBorder( | 416 footnote_container_->SetBorder( |
406 CreateSolidSidedBorder(1, 0, 0, 0, kFootnoteBorderColor)); | 417 CreateSolidSidedBorder(1, 0, 0, 0, kFootnoteBorderColor)); |
407 footnote_container_->AddChildView(view); | 418 footnote_container_->AddChildView(view); |
408 AddChildView(footnote_container_); | 419 AddChildView(footnote_container_); |
409 } | 420 } |
410 | 421 |
422 void BubbleFrameView::RemoveFootnoteView() { | |
423 if (!footnote_container_) | |
424 return; | |
425 | |
426 RemoveChildView(footnote_container_); | |
427 footnote_container_->RemoveAllChildViews(true); | |
428 delete footnote_container_; | |
429 footnote_container_ = nullptr; | |
430 } | |
431 | |
411 gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, | 432 gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, |
412 const gfx::Size& client_size, | 433 const gfx::Size& client_size, |
413 bool adjust_if_offscreen) { | 434 bool adjust_if_offscreen) { |
414 gfx::Size size(GetSizeForClientSize(client_size)); | 435 gfx::Size size(GetSizeForClientSize(client_size)); |
415 | 436 |
416 const BubbleBorder::Arrow arrow = bubble_border_->arrow(); | 437 const BubbleBorder::Arrow arrow = bubble_border_->arrow(); |
417 if (adjust_if_offscreen && BubbleBorder::has_arrow(arrow)) { | 438 if (adjust_if_offscreen && BubbleBorder::has_arrow(arrow)) { |
418 // Try to mirror the anchoring if the bubble does not fit on the screen. | 439 // Try to mirror the anchoring if the bubble does not fit on the screen. |
419 if (!bubble_border_->is_arrow_at_center(arrow)) { | 440 if (!bubble_border_->is_arrow_at_center(arrow)) { |
420 MirrorArrowIfOffScreen(true, anchor_rect, size); | 441 MirrorArrowIfOffScreen(true, anchor_rect, size); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 | 556 |
536 DialogDelegate* dialog_delegate = | 557 DialogDelegate* dialog_delegate = |
537 GetWidget()->widget_delegate()->AsDialogDelegate(); | 558 GetWidget()->widget_delegate()->AsDialogDelegate(); |
538 if (dialog_delegate && dialog_delegate->ShouldSnapFrameWidth()) | 559 if (dialog_delegate && dialog_delegate->ShouldSnapFrameWidth()) |
539 size.set_width(LayoutProvider::Get()->GetSnappedDialogWidth(size.width())); | 560 size.set_width(LayoutProvider::Get()->GetSnappedDialogWidth(size.width())); |
540 | 561 |
541 return size; | 562 return size; |
542 } | 563 } |
543 | 564 |
544 } // namespace views | 565 } // namespace views |
OLD | NEW |