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

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

Issue 22265009: Implement initial version of scroll end effect Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to outstanding comments from sadrul@ Created 7 years, 1 month 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 ContentsContainer::ContentsContainer(views::View* active_web_view) 7 #include "content/public/browser/web_contents.h"
8 #include "content/public/browser/web_contents_view.h"
9 #include "ui/aura/window.h"
10 #include "ui/views/controls/webview/webview.h"
11
12 ContentsContainer::ContentsContainer(views::WebView* active_web_view)
8 : active_web_view_(active_web_view), 13 : active_web_view_(active_web_view),
9 active_top_margin_(0) { 14 active_top_margin_(0),
15 scroll_effect_active_(false) {
10 AddChildView(active_web_view_); 16 AddChildView(active_web_view_);
11 } 17 }
12 18
13 ContentsContainer::~ContentsContainer() { 19 ContentsContainer::~ContentsContainer() {
14 } 20 }
15 21
16 bool ContentsContainer::SetActiveTopMargin(int margin) { 22 bool ContentsContainer::SetActiveTopMargin(int margin) {
17 if (active_top_margin_ == margin) 23 if (active_top_margin_ == margin)
18 return false; 24 return false;
19 25
20 active_top_margin_ = margin; 26 active_top_margin_ = margin;
21 // Make sure we layout next time around. We need this in case our bounds 27 // Make sure we layout next time around. We need this in case our bounds
22 // haven't changed. 28 // haven't changed.
23 InvalidateLayout(); 29 InvalidateLayout();
24 return true; 30 return true;
25 } 31 }
26 32
33 void ContentsContainer::ActivateScrollEndEffect() {
34 scroll_effect_active_ = true;
35 active_web_view_->SetFastResize(true);
36 web_view_bounds_ = active_web_view_->bounds();
37 Layout();
38 }
39
40 void ContentsContainer::DeactivateScrollEndEffect() {
41 if (scroll_effect_active_ == false)
42 return;
43 scroll_effect_active_ = false;
44 active_web_view_->SetFastResize(false);
45 active_web_view_->SetBoundsRect(web_view_bounds_);
46 Layout();
47 }
48
49 void ContentsContainer::UpdateScrollEndEffectHeightDelta(int height_delta,
50 bool scrolling_down) {
51 DCHECK(scroll_effect_active_);
52
53 gfx::Rect clipping_bounds = web_view_bounds_;
54 clipping_bounds.set_height(clipping_bounds.height() - height_delta);
55 if (scrolling_down) {
56 active_web_view_->SetFastResizeGravity(
57 views::NativeViewHost::GRAVITY_NORTH);
58 } else {
59 active_web_view_->SetFastResizeGravity(
60 views::NativeViewHost::GRAVITY_SOUTH);
61 }
62 active_web_view_->SetBoundsRect(clipping_bounds);
63 }
64
27 void ContentsContainer::Layout() { 65 void ContentsContainer::Layout() {
28 int content_y = active_top_margin_; 66 int content_y = active_top_margin_;
29 int content_height = std::max(0, height() - content_y); 67 int content_height = std::max(0, height() - content_y);
30 68
31 active_web_view_->SetBounds(0, content_y, width(), content_height); 69 if (!scroll_effect_active_)
70 active_web_view_->SetBounds(0, content_y, width(), content_height);
32 71
33 // Need to invoke views::View in case any views whose bounds didn't change 72 // Need to invoke views::View in case any views whose bounds didn't change
34 // still need a layout. 73 // still need a layout.
35 views::View::Layout(); 74 views::View::Layout();
36 } 75 }
37 76
38 const char* ContentsContainer::GetClassName() const { 77 const char* ContentsContainer::GetClassName() const {
39 return "ContentsContainer"; 78 return "ContentsContainer";
40 } 79 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/contents_container.h ('k') | chrome/browser/ui/views/frame/scroll_end_effect_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698