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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/contents_container.cc
diff --git a/chrome/browser/ui/views/frame/contents_container.cc b/chrome/browser/ui/views/frame/contents_container.cc
index 9461aa99b2408bca73bd0eaadc0c5119e72f5f61..8f3a7e299ec71a9a7ceaf904aaf18bdd4b8544f2 100644
--- a/chrome/browser/ui/views/frame/contents_container.cc
+++ b/chrome/browser/ui/views/frame/contents_container.cc
@@ -4,9 +4,15 @@
#include "chrome/browser/ui/views/frame/contents_container.h"
-ContentsContainer::ContentsContainer(views::View* active_web_view)
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
+#include "ui/aura/window.h"
+#include "ui/views/controls/webview/webview.h"
+
+ContentsContainer::ContentsContainer(views::WebView* active_web_view)
: active_web_view_(active_web_view),
- active_top_margin_(0) {
+ active_top_margin_(0),
+ scroll_effect_active_(false) {
AddChildView(active_web_view_);
}
@@ -24,11 +30,44 @@ bool ContentsContainer::SetActiveTopMargin(int margin) {
return true;
}
+void ContentsContainer::ActivateScrollEndEffect() {
+ scroll_effect_active_ = true;
+ active_web_view_->SetFastResize(true);
+ web_view_bounds_ = active_web_view_->bounds();
+ Layout();
+}
+
+void ContentsContainer::DeactivateScrollEndEffect() {
+ if (scroll_effect_active_ == false)
+ return;
+ scroll_effect_active_ = false;
+ active_web_view_->SetFastResize(false);
+ active_web_view_->SetBoundsRect(web_view_bounds_);
+ Layout();
+}
+
+void ContentsContainer::UpdateScrollEndEffectHeightDelta(int height_delta,
+ bool scrolling_down) {
+ DCHECK(scroll_effect_active_);
+
+ gfx::Rect clipping_bounds = web_view_bounds_;
+ clipping_bounds.set_height(clipping_bounds.height() - height_delta);
+ if (scrolling_down) {
+ active_web_view_->SetFastResizeGravity(
+ views::NativeViewHost::GRAVITY_NORTH);
+ } else {
+ active_web_view_->SetFastResizeGravity(
+ views::NativeViewHost::GRAVITY_SOUTH);
+ }
+ active_web_view_->SetBoundsRect(clipping_bounds);
+}
+
void ContentsContainer::Layout() {
int content_y = active_top_margin_;
int content_height = std::max(0, height() - content_y);
- active_web_view_->SetBounds(0, content_y, width(), content_height);
+ if (!scroll_effect_active_)
+ active_web_view_->SetBounds(0, content_y, width(), content_height);
// Need to invoke views::View in case any views whose bounds didn't change
// still need a layout.
« 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