Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #330 from shaoboyan/scroll
Browse files Browse the repository at this point in the history
Port OverScrolled Event to ContentViewClient for Crosswalk.
  • Loading branch information
Raphael Kubo da Costa committed Mar 25, 2016
2 parents 5c3da74 + 9fb96d2 commit bde07cf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions content/browser/android/content_view_core_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,14 @@ bool ContentViewCoreImpl::ShouldBlockMediaRequest(const GURL& url) {
j_url.obj());
}

void ContentViewCoreImpl::DidOverscroll(bool clampedX, bool clampedY) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
if (!j_obj.is_null()) {
Java_ContentViewCore_didOverscroll(env, j_obj.obj(), clampedX, clampedY);
}
}

void ContentViewCoreImpl::DidStopFlinging() {
JNIEnv* env = AttachCurrentThread();

Expand Down
2 changes: 2 additions & 0 deletions content/browser/android/content_view_core_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ class ContentViewCoreImpl : public ContentViewCore,

void DidStopFlinging();

void DidOverscroll(bool clampedX, bool clampedY);

// Returns the context with which the ContentViewCore was created, typically
// the Activity context.
base::android::ScopedJavaLocalRef<jobject> GetContext() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,10 @@ void RenderWidgetHostViewAndroid::DidOverscroll(

if (overscroll_controller_)
overscroll_controller_->OnOverscrolled(params);

bool clampedX = params.latest_overscroll_delta.x() != 0 ? true : false;
bool clampedY = params.latest_overscroll_delta.y() != 0 ? true : false;
content_view_core_->DidOverscroll(clampedX, clampedY);
}

void RenderWidgetHostViewAndroid::DidStopFlinging() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,10 @@ public int getDesiredWidthMeasureSpec() {
public int getDesiredHeightMeasureSpec() {
return UNSPECIFIED_MEASURE_SPEC;
}

/**
* Called when overscroll event has been fired
**/
public void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3363,6 +3363,14 @@ public void setContextualSearchClient(ContextualSearchClient contextualSearchCli
mContextualSearchClient = contextualSearchClient;
}

@CalledByNative
public void didOverscroll(boolean clampedX, boolean clampedY) {
mContentViewClient.onOverScrolled(mRenderCoordinates.getScrollXPixInt(),
mRenderCoordinates.getScrollYPixInt(),
clampedX,
clampedY);
}

private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate,
long windowAndroidPtr, HashSet<Object> retainedObjectSet);
private static native ContentViewCore nativeFromWebContentsAndroid(WebContents webContents);
Expand Down

0 comments on commit bde07cf

Please sign in to comment.