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

Side by Side Diff: chrome/browser/ui/views/frame/contents_container.cc

Issue 10832216: Clicks broken in NTP section of Search overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 "chrome/browser/ui/views/frame/contents_container.h" 5 #include "chrome/browser/ui/views/frame/contents_container.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/views/controls/webview/webview.h"
8 9
9 using content::WebContents; 10 using content::WebContents;
10 11
11 // static 12 // static
12 const char ContentsContainer::kViewClassName[] = 13 const char ContentsContainer::kViewClassName[] =
13 "browser/ui/views/frame/ContentsContainer"; 14 "browser/ui/views/frame/ContentsContainer";
14 15
15 ContentsContainer::ContentsContainer(views::View* active) 16 ContentsContainer::ContentsContainer(views::WebView* active)
16 : active_(active), 17 : active_(active),
17 overlay_(NULL), 18 overlay_(NULL),
18 preview_(NULL), 19 preview_(NULL),
19 preview_web_contents_(NULL), 20 preview_web_contents_(NULL),
20 active_top_margin_(0) { 21 active_top_margin_(0) {
21 AddChildView(active_); 22 AddChildView(active_);
22 } 23 }
23 24
24 ContentsContainer::~ContentsContainer() { 25 ContentsContainer::~ContentsContainer() {
25 } 26 }
26 27
28 void ContentsContainer::SetActive(views::WebView* active) {
29 if (active_)
30 RemoveChildView(active_);
31 active_ = active;
32 // Note the active view is always the first child.
33 if (active_)
34 AddChildViewAt(active_, 0);
35 Layout();
36 }
37
27 void ContentsContainer::SetOverlay(views::View* overlay) { 38 void ContentsContainer::SetOverlay(views::View* overlay) {
28 if (overlay_) 39 if (overlay_)
29 RemoveChildView(overlay_); 40 RemoveChildView(overlay_);
30 overlay_ = overlay; 41 overlay_ = overlay;
31 if (overlay_) 42 if (overlay_)
32 AddChildView(overlay_); 43 AddChildView(overlay_);
33 Layout(); 44 Layout();
34 } 45 }
35 46
36 void ContentsContainer::MakePreviewContentsActiveContents() { 47 void ContentsContainer::MakePreviewContentsActiveContents() {
37 DCHECK(preview_); 48 DCHECK(preview_);
38 49
39 active_ = preview_; 50 active_ = preview_;
40 preview_ = NULL; 51 preview_ = NULL;
41 preview_web_contents_ = NULL; 52 preview_web_contents_ = NULL;
42 Layout(); 53 Layout();
43 } 54 }
44 55
45 void ContentsContainer::SetPreview(views::View* preview, 56 void ContentsContainer::SetPreview(views::WebView* preview,
46 WebContents* preview_web_contents) { 57 WebContents* preview_web_contents) {
47 if (preview == preview_) 58 if (preview == preview_)
48 return; 59 return;
49 60
50 if (preview_) 61 if (preview_)
51 RemoveChildView(preview_); 62 RemoveChildView(preview_);
52 preview_ = preview; 63 preview_ = preview;
53 preview_web_contents_ = preview_web_contents; 64 preview_web_contents_ = preview_web_contents;
54 if (preview_) 65 if (preview_)
55 AddChildView(preview_); 66 AddChildView(preview_);
(...skipping 14 matching lines...) Expand all
70 gfx::Rect ContentsContainer::GetPreviewBounds() { 81 gfx::Rect ContentsContainer::GetPreviewBounds() {
71 gfx::Point screen_loc; 82 gfx::Point screen_loc;
72 ConvertPointToScreen(this, &screen_loc); 83 ConvertPointToScreen(this, &screen_loc);
73 return gfx::Rect(screen_loc, size()); 84 return gfx::Rect(screen_loc, size());
74 } 85 }
75 86
76 void ContentsContainer::Layout() { 87 void ContentsContainer::Layout() {
77 int content_y = active_top_margin_; 88 int content_y = active_top_margin_;
78 int content_height = std::max(0, height() - content_y); 89 int content_height = std::max(0, height() - content_y);
79 90
80 active_->SetBounds(0, content_y, width(), content_height); 91 if (active_)
92 active_->SetBounds(0, content_y, width(), content_height);
81 93
82 if (overlay_) 94 if (overlay_)
83 overlay_->SetBounds(0, 0, width(), height()); 95 overlay_->SetBounds(0, 0, width(), height());
84 96
85 if (preview_) 97 if (preview_)
86 preview_->SetBounds(0, 0, width(), height()); 98 preview_->SetBounds(0, 0, width(), height());
87 99
88 // Need to invoke views::View in case any views whose bounds didn't change 100 // Need to invoke views::View in case any views whose bounds didn't change
89 // still need a layout. 101 // still need a layout.
90 views::View::Layout(); 102 views::View::Layout();
91 } 103 }
92 104
93 std::string ContentsContainer::GetClassName() const { 105 std::string ContentsContainer::GetClassName() const {
94 return kViewClassName; 106 return kViewClassName;
95 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698