Commit 58e3dc6d authored by pkasting's avatar pkasting Committed by Commit bot

Change overscroll functions to pass floats.

The source values for these are floats, and the lone nontrivial consumer
(athena) wants floats.  So avoid truncating to int in the meantime.

BUG=81439
TEST=none

Review URL: https://codereview.chromium.org/645223003

Cr-Commit-Position: refs/heads/master@{#299347}
parent 8163d134
......@@ -155,8 +155,8 @@ class WebActivityController : public AcceleratorHandler {
const SkColor kDefaultTitleColor = SkColorSetRGB(0xf2, 0xf2, 0xf2);
const int kIconSize = 32;
const int kDistanceShowReloadMessage = 100;
const int kDistanceReload = 150;
const float kDistanceShowReloadMessage = 100;
const float kDistanceReload = 150;
} // namespace
......@@ -267,7 +267,7 @@ class AthenaWebView : public views::WebView {
return value != "0";
}
virtual void OverscrollUpdate(int delta_y) override {
virtual void OverscrollUpdate(float delta_y) override {
overscroll_y_ = delta_y;
if (overscroll_y_ > kDistanceShowReloadMessage) {
if (!reload_message_)
......@@ -275,9 +275,8 @@ class AthenaWebView : public views::WebView {
reload_message_->Show();
float opacity = 1.0f;
if (overscroll_y_ < kDistanceReload) {
opacity =
(overscroll_y_ - kDistanceShowReloadMessage) /
static_cast<float>(kDistanceReload - kDistanceShowReloadMessage);
opacity = (overscroll_y_ - kDistanceShowReloadMessage) /
(kDistanceReload - kDistanceShowReloadMessage);
}
reload_message_->GetLayer()->SetOpacity(opacity);
} else if (reload_message_) {
......@@ -412,7 +411,7 @@ class AthenaWebView : public views::WebView {
bool fullscreen_;
// The distance that the user has overscrolled vertically.
int overscroll_y_;
float overscroll_y_;
DISALLOW_COPY_AND_ASSIGN(AthenaWebView);
};
......
......@@ -1197,7 +1197,7 @@ bool Browser::TabsNeedBeforeUnloadFired() {
return unload_controller_->TabsNeedBeforeUnloadFired();
}
void Browser::OverscrollUpdate(int delta_y) {
void Browser::OverscrollUpdate(float delta_y) {
window_->OverscrollUpdate(delta_y);
}
......
......@@ -441,7 +441,7 @@ class Browser : public TabStripModelObserver,
virtual void HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
virtual void OverscrollUpdate(int delta_y) override;
virtual void OverscrollUpdate(float delta_y) override;
virtual void ShowValidationMessage(content::WebContents* web_contents,
const gfx::Rect& anchor_in_root_view,
const base::string16& main_text,
......
......@@ -378,7 +378,7 @@ class BrowserWindow : public ui::BaseWindow {
// Invoked when the amount of vertical overscroll changes. |delta_y| is the
// amount of overscroll that has occured in the y-direction.
virtual void OverscrollUpdate(int delta_y) {}
virtual void OverscrollUpdate(float delta_y) {}
// Returns the height inset for RenderView when detached bookmark bar is
// shown. Invoked when a new RenderHostView is created for a non-NTP
......
......@@ -2438,7 +2438,7 @@ void BrowserView::ShowAvatarBubbleFromAvatarButton(
}
}
void BrowserView::OverscrollUpdate(int delta_y) {
void BrowserView::OverscrollUpdate(float delta_y) {
if (scroll_end_effect_controller_)
scroll_end_effect_controller_->OverscrollUpdate(delta_y);
}
......
......@@ -363,7 +363,7 @@ class BrowserView : public BrowserWindow,
const gfx::Rect& rect) override;
virtual void ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode,
const signin::ManageAccountsParams& manage_accounts_params) override;
virtual void OverscrollUpdate(int delta_y) override;
virtual void OverscrollUpdate(float delta_y) override;
virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() override;
virtual void ExecuteExtensionCommand(
const extensions::Extension* extension,
......
......@@ -21,7 +21,7 @@ class ScrollEndEffectController {
// Interface that allows vertical overscroll activies to be communicated to
// the controller.
virtual void OverscrollUpdate(int delta_y) = 0;
virtual void OverscrollUpdate(float delta_y) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ScrollEndEffectController);
......
......@@ -14,6 +14,6 @@ ScrollEndEffectControllerAsh::ScrollEndEffectControllerAsh() {
ScrollEndEffectControllerAsh::~ScrollEndEffectControllerAsh() {
}
void ScrollEndEffectControllerAsh::OverscrollUpdate(int delta_y) {
void ScrollEndEffectControllerAsh::OverscrollUpdate(float delta_y) {
// TODO(rharrison): Implement initial version of scroll end effect
}
......@@ -14,7 +14,7 @@ class ScrollEndEffectControllerAsh : public ScrollEndEffectController {
virtual ~ScrollEndEffectControllerAsh();
// ScrollEndEffectController overides:
virtual void OverscrollUpdate(int delta_y) override;
virtual void OverscrollUpdate(float delta_y) override;
private:
DISALLOW_COPY_AND_ASSIGN(ScrollEndEffectControllerAsh);
......
......@@ -912,7 +912,8 @@ void WebContentsViewAura::CompleteOverscrollNavigation(OverscrollMode mode) {
gfx::Transform transform;
int content_width =
web_contents_->GetRenderWidgetHostView()->GetViewBounds().width();
int translate_x = mode == OVERSCROLL_WEST ? -content_width : content_width;
float translate_x = static_cast<float>(mode == OVERSCROLL_WEST ?
-content_width : content_width);
transform.Translate(translate_x, 0);
target->SetTransform(transform);
UpdateOverscrollWindowBrightness(translate_x);
......@@ -927,21 +928,22 @@ aura::Window* WebContentsViewAura::GetWindowToAnimateForOverscroll() {
overscroll_window_.get() : GetContentNativeView();
}
gfx::Vector2d WebContentsViewAura::GetTranslationForOverscroll(int delta_x,
int delta_y) {
gfx::Vector2dF WebContentsViewAura::GetTranslationForOverscroll(float delta_x,
float delta_y) {
if (current_overscroll_gesture_ == OVERSCROLL_NORTH ||
current_overscroll_gesture_ == OVERSCROLL_SOUTH) {
return gfx::Vector2d(0, delta_y);
return gfx::Vector2dF(0, delta_y);
}
// For horizontal overscroll, scroll freely if a navigation is possible. Do a
// resistive scroll otherwise.
const NavigationControllerImpl& controller = web_contents_->GetController();
const gfx::Rect& bounds = GetViewBounds();
const float bounds_width = static_cast<float>(bounds.width());
if (ShouldNavigateForward(controller, current_overscroll_gesture_))
return gfx::Vector2d(std::max(-bounds.width(), delta_x), 0);
return gfx::Vector2dF(std::max(-bounds_width, delta_x), 0);
else if (ShouldNavigateBack(controller, current_overscroll_gesture_))
return gfx::Vector2d(std::min(bounds.width(), delta_x), 0);
return gfx::Vector2d();
return gfx::Vector2dF(std::min(bounds_width, delta_x), 0);
return gfx::Vector2dF();
}
void WebContentsViewAura::PrepareOverscrollNavigationOverlay() {
......@@ -984,7 +986,8 @@ void WebContentsViewAura::AttachTouchEditableToRenderView() {
touch_editable_->AttachToView(rwhva);
}
void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(int delta_y) {
void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(
float delta_y) {
if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled())
web_contents_->GetDelegate()->OverscrollUpdate(delta_y);
}
......@@ -1302,7 +1305,7 @@ bool WebContentsViewAura::OnOverscrollUpdate(float delta_x, float delta_y) {
return false;
aura::Window* target = GetWindowToAnimateForOverscroll();
gfx::Vector2d translate = GetTranslationForOverscroll(delta_x, delta_y);
gfx::Vector2dF translate = GetTranslationForOverscroll(delta_x, delta_y);
gfx::Transform transform;
if (current_overscroll_gesture_ == OVERSCROLL_NORTH ||
......
......@@ -88,7 +88,7 @@ class WebContentsViewAura
// Returns the amount the animating window should be translated in response to
// the overscroll gesture.
gfx::Vector2d GetTranslationForOverscroll(int delta_x, int delta_y);
gfx::Vector2dF GetTranslationForOverscroll(float delta_x, float delta_y);
// A window showing the screenshot is overlayed during a navigation triggered
// by overscroll. This function sets this up.
......@@ -100,7 +100,7 @@ class WebContentsViewAura
void AttachTouchEditableToRenderView();
void OverscrollUpdateForWebContentsDelegate(int delta_y);
void OverscrollUpdateForWebContentsDelegate(float delta_y);
// Overridden from WebContentsView:
virtual gfx::NativeView GetNativeView() const override;
......
......@@ -77,7 +77,7 @@ class VerticalOverscrollTracker : public content::WebContentsDelegate {
return true;
}
virtual void OverscrollUpdate(int delta_y) override {
virtual void OverscrollUpdate(float delta_y) override {
++count_;
}
......
......@@ -162,7 +162,7 @@ class CONTENT_EXPORT WebContentsDelegate {
// Callback that allows vertical overscroll activies to be communicated to the
// delegate. |delta_y| is the total amount of overscroll.
virtual void OverscrollUpdate(int delta_y) {}
virtual void OverscrollUpdate(float delta_y) {}
// Invoked when a vertical overscroll completes.
virtual void OverscrollComplete() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment