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

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

Issue 13684002: cros: Instant extended support for immersive fullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: works now Created 7 years, 8 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/public/browser/notification_service.h" 7 #include "content/public/browser/notification_service.h"
8 #include "content/public/browser/notification_types.h" 8 #include "content/public/browser/notification_types.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 }; 77 };
78 78
79 } // namespace 79 } // namespace
80 80
81 ContentsContainer::ContentsContainer(views::WebView* active) 81 ContentsContainer::ContentsContainer(views::WebView* active)
82 : active_(active), 82 : active_(active),
83 overlay_(NULL), 83 overlay_(NULL),
84 overlay_web_contents_(NULL), 84 overlay_web_contents_(NULL),
85 draw_drop_shadow_(false), 85 draw_drop_shadow_(false),
86 active_top_margin_(0), 86 active_top_margin_(0),
87 overlay_top_margin_(0),
87 overlay_height_(100), 88 overlay_height_(100),
88 overlay_height_units_(INSTANT_SIZE_PERCENT) { 89 overlay_height_units_(INSTANT_SIZE_PERCENT) {
89 AddChildView(active_); 90 AddChildView(active_);
90 } 91 }
91 92
92 ContentsContainer::~ContentsContainer() { 93 ContentsContainer::~ContentsContainer() {
93 } 94 }
94 95
95 void ContentsContainer::MakeOverlayContentsActiveContents() { 96 void ContentsContainer::MakeOverlayContentsActiveContents() {
96 DCHECK(overlay_); 97 DCHECK(overlay_);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 if (!overlay_) 205 if (!overlay_)
205 return; 206 return;
206 // To force |overlay_| to the topmost in the z-order, remove it, then add it 207 // To force |overlay_| to the topmost in the z-order, remove it, then add it
207 // back. 208 // back.
208 // See comments in SetOverlay() for why shadow view is removed. 209 // See comments in SetOverlay() for why shadow view is removed.
209 bool removed_shadow = false; 210 bool removed_shadow = false;
210 if (shadow_view_.get()) { 211 if (shadow_view_.get()) {
211 RemoveChildView(shadow_view_.get()); 212 RemoveChildView(shadow_view_.get());
212 removed_shadow = true; 213 removed_shadow = true;
213 } 214 }
215 // TODO(jamescook): This can be done more efficiently with ReorderChildView().
kuan 2013/04/15 18:49:36 i think not. when porting 1993 to windows, mad@ h
James Cook 2013/04/16 18:51:01 OK. Removed TODO.
214 RemoveChildView(overlay_); 216 RemoveChildView(overlay_);
215 AddChildView(overlay_); 217 AddChildView(overlay_);
216 if (removed_shadow) // Add back shadow view if it was removed. 218 if (removed_shadow) // Add back shadow view if it was removed.
217 AddChildView(shadow_view_.get()); 219 AddChildView(shadow_view_.get());
218 Layout(); 220 Layout();
219 } 221 }
220 222
221 void ContentsContainer::SetActiveTopMargin(int margin) { 223 void ContentsContainer::SetActiveTopMargin(int margin) {
222 if (active_top_margin_ == margin) 224 if (active_top_margin_ == margin)
223 return; 225 return;
224 226
225 active_top_margin_ = margin; 227 active_top_margin_ = margin;
226 // Make sure we layout next time around. We need this in case our bounds 228 // Make sure we layout next time around. We need this in case our bounds
227 // haven't changed. 229 // haven't changed.
228 InvalidateLayout(); 230 InvalidateLayout();
229 } 231 }
230 232
233 void ContentsContainer::SetOverlayTopMargin(int margin) {
234 if (overlay_top_margin_ == margin)
235 return;
236 overlay_top_margin_ = margin;
237 // Make sure we layout next time around. We need this in case our bounds
238 // haven't changed.
239 InvalidateLayout();
240 }
241
231 gfx::Rect ContentsContainer::GetOverlayBounds() const { 242 gfx::Rect ContentsContainer::GetOverlayBounds() const {
232 gfx::Point screen_loc; 243 gfx::Point screen_loc;
233 ConvertPointToScreen(this, &screen_loc); 244 ConvertPointToScreen(this, &screen_loc);
234 return gfx::Rect(screen_loc, size()); 245 return gfx::Rect(screen_loc, size());
235 } 246 }
236 247
237 bool ContentsContainer::WillOverlayBeFullHeight( 248 bool ContentsContainer::WillOverlayBeFullHeight(
238 int overlay_height, 249 int overlay_height,
239 InstantSizeUnits overlay_height_units) const { 250 InstantSizeUnits overlay_height_units) const {
240 int height_in_pixels = OverlayHeightInPixels(height(), overlay_height, 251 int height_in_pixels = OverlayHeightInPixels(height(), overlay_height,
241 overlay_height_units); 252 overlay_height_units);
242 return height_in_pixels == height(); 253 return height_in_pixels == height();
243 } 254 }
244 255
245 bool ContentsContainer::IsOverlayFullHeight() const { 256 bool ContentsContainer::IsOverlayFullHeight() const {
246 return overlay_ && overlay_height_ == 100 && 257 return overlay_ && overlay_height_ == 100 &&
247 overlay_height_units_ == INSTANT_SIZE_PERCENT; 258 overlay_height_units_ == INSTANT_SIZE_PERCENT;
248 } 259 }
249 260
250 void ContentsContainer::Layout() { 261 void ContentsContainer::Layout() {
251 int content_y = active_top_margin_; 262 int content_y = active_top_margin_;
252 int content_height = std::max(0, height() - content_y); 263 int content_height = std::max(0, height() - content_y);
253 264
254 active_->SetBounds(0, content_y, width(), content_height); 265 active_->SetBounds(0, content_y, width(), content_height);
255 266
256 if (overlay_) { 267 if (overlay_) {
257 overlay_->SetBounds(0, 0, width(), 268 int overlay_height_pixels =
258 OverlayHeightInPixels(height(), overlay_height_, 269 OverlayHeightInPixels(height(), overlay_height_, overlay_height_units_);
259 overlay_height_units_)); 270 overlay_->SetBounds(0, overlay_top_margin_, width(), overlay_height_pixels);
kuan 2013/04/15 18:49:36 so u have problem making the height like content_h
James Cook 2013/04/16 18:51:01 I thought that clamping the overlay size was causi
260 if (draw_drop_shadow_) { 271 if (draw_drop_shadow_) {
261 #if !defined(OS_WIN) 272 #if !defined(OS_WIN)
262 DCHECK(shadow_view_.get() && shadow_view_->parent()); 273 DCHECK(shadow_view_.get() && shadow_view_->parent());
263 shadow_view_->SetBounds(0, overlay_->bounds().height(), width(), 274 shadow_view_->SetBounds(0, overlay_->bounds().bottom(), width(),
264 shadow_view_->GetPreferredSize().height()); 275 shadow_view_->GetPreferredSize().height());
265 #endif // !defined(OS_WIN) 276 #endif // !defined(OS_WIN)
266 } 277 }
267 } 278 }
268 279
269 // Need to invoke views::View in case any views whose bounds didn't change 280 // Need to invoke views::View in case any views whose bounds didn't change
270 // still need a layout. 281 // still need a layout.
271 views::View::Layout(); 282 views::View::Layout();
272 } 283 }
273 284
274 std::string ContentsContainer::GetClassName() const { 285 std::string ContentsContainer::GetClassName() const {
275 return kViewClassName; 286 return kViewClassName;
276 } 287 }
277 288
278 void ContentsContainer::Observe(int type, 289 void ContentsContainer::Observe(int type,
279 const content::NotificationSource& source, 290 const content::NotificationSource& source,
280 const content::NotificationDetails& details) { 291 const content::NotificationDetails& details) {
281 DCHECK_EQ(content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, 292 DCHECK_EQ(content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
282 type); 293 type);
283 // Remove shadow view if it's not needed. 294 // Remove shadow view if it's not needed.
284 if (overlay_ && !draw_drop_shadow_) { 295 if (overlay_ && !draw_drop_shadow_) {
285 DCHECK(overlay_web_contents_); 296 DCHECK(overlay_web_contents_);
286 DCHECK_EQ(overlay_web_contents_->GetRenderViewHost(), 297 DCHECK_EQ(overlay_web_contents_->GetRenderViewHost(),
287 (content::Source<content::RenderWidgetHost>(source)).ptr()); 298 (content::Source<content::RenderWidgetHost>(source)).ptr());
288 shadow_view_.reset(); 299 shadow_view_.reset();
289 } 300 }
290 } 301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698