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. |