Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: ui/views/window/dialog_client_view.cc

Issue 12225095: Interactive autofill: Adds footnote view to accept legal documents in the UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/window/dialog_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (cancel_button_ || ok_button_) 364 if (cancel_button_ || ok_button_)
365 width += style_params_.related_button_hspacing; 365 width += style_params_.related_button_hspacing;
366 } 366 }
367 if (width > 0) { 367 if (width > 0) {
368 width += 2 * style_params_.button_hedge_margin; 368 width += 2 * style_params_.button_hedge_margin;
369 prefsize.set_width(std::max(prefsize.width(), width)); 369 prefsize.set_width(std::max(prefsize.width(), width));
370 } 370 }
371 } 371 }
372 prefsize.Enlarge(0, button_height); 372 prefsize.Enlarge(0, button_height);
373 373
374 if (footnote_view_) { 374 const gfx::Size& footnote_size = GetFootnoteSize();
375 gfx::Size footnote_size = footnote_view_->GetPreferredSize(); 375 prefsize.Enlarge(0, footnote_size.height());
376 prefsize.Enlarge(0, footnote_size.height()); 376 prefsize.set_width(std::max(prefsize.width(), footnote_size.width()));
377 prefsize.set_width(std::max(prefsize.width(), footnote_size.width()));
378 }
379 377
380 return prefsize; 378 return prefsize;
381 } 379 }
382 380
383 bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) { 381 bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) {
384 // We only expect Escape key. 382 // We only expect Escape key.
385 DCHECK(accelerator.key_code() == ui::VKEY_ESCAPE); 383 DCHECK(accelerator.key_code() == ui::VKEY_ESCAPE);
386 Close(); 384 Close();
387 return true; 385 return true;
388 } 386 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 ok_button_->GetPreferredSize().height()); 484 ok_button_->GetPreferredSize().height());
487 return button_height; 485 return button_height;
488 } 486 }
489 487
490 int DialogClientView::GetDialogButtonsAreaHeight() const { 488 int DialogClientView::GetDialogButtonsAreaHeight() const {
491 return !has_dialog_buttons() ? 0 : 489 return !has_dialog_buttons() ? 0 :
492 GetButtonsHeight() + style_params_.button_content_spacing + 490 GetButtonsHeight() + style_params_.button_content_spacing +
493 style_params_.button_vedge_margin; 491 style_params_.button_vedge_margin;
494 } 492 }
495 493
496 int DialogClientView::GetFootnoteViewHeight() const { 494 gfx::Size DialogClientView::GetFootnoteSize() const {
497 return footnote_view_ ? footnote_view_->GetPreferredSize().height() : 0; 495 return footnote_view_ && footnote_view_->visible() ?
496 footnote_view_->GetPreferredSize() : gfx::Size();
498 } 497 }
499 498
500 void DialogClientView::LayoutDialogButtons() { 499 void DialogClientView::LayoutDialogButtons() {
501 gfx::Rect lb = GetContentsBounds(); 500 gfx::Rect lb = GetContentsBounds();
502 gfx::Rect extra_bounds; 501 gfx::Rect extra_bounds;
503 int bottom_y = lb.bottom() - style_params_.button_vedge_margin; 502 int bottom_y = lb.bottom() - style_params_.button_vedge_margin;
504 if (footnote_view_) 503 bottom_y -= GetFootnoteSize().height();
505 bottom_y -= footnote_view_->GetPreferredSize().height();
506 504
507 int button_height = GetButtonsHeight(); 505 int button_height = GetButtonsHeight();
508 if (cancel_button_) { 506 if (cancel_button_) {
509 gfx::Size ps = cancel_button_->GetPreferredSize(); 507 gfx::Size ps = cancel_button_->GetPreferredSize();
510 int button_x = lb.right() - ps.width() - style_params_.button_hedge_margin; 508 int button_x = lb.right() - ps.width() - style_params_.button_hedge_margin;
511 int button_y = bottom_y - ps.height(); 509 int button_y = bottom_y - ps.height();
512 cancel_button_->SetBounds(button_x, button_y, ps.width(), ps.height()); 510 cancel_button_->SetBounds(button_x, button_y, ps.width(), ps.height());
513 // The extra view bounds are dependent on this button. 511 // The extra view bounds are dependent on this button.
514 extra_bounds.set_width(std::max(0, cancel_button_->x())); 512 extra_bounds.set_width(std::max(0, cancel_button_->x()));
515 extra_bounds.set_y(cancel_button_->y()); 513 extra_bounds.set_y(cancel_button_->y());
(...skipping 18 matching lines...) Expand all
534 int height = size_extra_view_height_to_buttons_ ? 532 int height = size_extra_view_height_to_buttons_ ?
535 std::max(ps.height(), button_height) : ps.height(); 533 std::max(ps.height(), button_height) : ps.height();
536 extra_bounds.set_height(height); 534 extra_bounds.set_height(height);
537 extra_view_->SetBoundsRect(extra_bounds); 535 extra_view_->SetBoundsRect(extra_bounds);
538 } 536 }
539 } 537 }
540 538
541 void DialogClientView::LayoutContentsView() { 539 void DialogClientView::LayoutContentsView() {
542 gfx::Rect lb = GetContentsBounds(); 540 gfx::Rect lb = GetContentsBounds();
543 lb.set_height(std::max(0, lb.height() - GetDialogButtonsAreaHeight() - 541 lb.set_height(std::max(0, lb.height() - GetDialogButtonsAreaHeight() -
544 GetFootnoteViewHeight())); 542 GetFootnoteSize().height()));
545 contents_view()->SetBoundsRect(lb); 543 contents_view()->SetBoundsRect(lb);
546 contents_view()->Layout(); 544 contents_view()->Layout();
547 } 545 }
548 546
549 void DialogClientView::LayoutFootnoteView() { 547 void DialogClientView::LayoutFootnoteView() {
550 int height = GetFootnoteViewHeight(); 548 int height = GetFootnoteSize().height();
551 gfx::Rect bounds = GetContentsBounds(); 549 gfx::Rect bounds = GetContentsBounds();
552 bounds.set_y(bounds.height() - height); 550 bounds.set_y(bounds.height() - height);
553 bounds.set_height(height); 551 bounds.set_height(height);
554 footnote_view_->SetBoundsRect(bounds); 552 footnote_view_->SetBoundsRect(bounds);
555 footnote_view_->Layout(); 553 footnote_view_->Layout();
556 } 554 }
557 555
558 void DialogClientView::CreateExtraView() { 556 void DialogClientView::CreateExtraView() {
559 View* extra_view = GetDialogDelegate()->GetExtraView(); 557 View* extra_view = GetDialogDelegate()->GetExtraView();
560 if (extra_view && !extra_view_) { 558 if (extra_view && !extra_view_) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 } 598 }
601 saved_focus_manager_ = focus_manager; 599 saved_focus_manager_ = focus_manager;
602 // Listen for focus change events so we can update the default button. 600 // Listen for focus change events so we can update the default button.
603 if (focus_manager) { 601 if (focus_manager) {
604 focus_manager->AddFocusChangeListener(this); 602 focus_manager->AddFocusChangeListener(this);
605 listening_to_focus_ = true; 603 listening_to_focus_ = true;
606 } 604 }
607 } 605 }
608 606
609 } // namespace views 607 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698