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

Side by Side Diff: android_webview/native/aw_contents.cc

Issue 16255010: Hookup android_webview scroll offset delegation to Java side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests now pass Created 7 years, 6 months 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 "android_webview/native/aw_contents.h" 5 #include "android_webview/native/aw_contents.h"
6 6
7 #include "android_webview/browser/aw_browser_context.h" 7 #include "android_webview/browser/aw_browser_context.h"
8 #include "android_webview/browser/aw_browser_main_parts.h" 8 #include "android_webview/browser/aw_browser_main_parts.h"
9 #include "android_webview/browser/gpu_memory_buffer_impl.h" 9 #include "android_webview/browser/gpu_memory_buffer_impl.h"
10 #include "android_webview/browser/in_process_view_renderer.h" 10 #include "android_webview/browser/in_process_view_renderer.h"
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 state_vector.size()); 621 state_vector.size());
622 PickleIterator iterator(pickle); 622 PickleIterator iterator(pickle);
623 623
624 return RestoreFromPickle(&iterator, web_contents_.get()); 624 return RestoreFromPickle(&iterator, web_contents_.get());
625 } 625 }
626 626
627 bool AwContents::OnDraw(JNIEnv* env, 627 bool AwContents::OnDraw(JNIEnv* env,
628 jobject obj, 628 jobject obj,
629 jobject canvas, 629 jobject canvas,
630 jboolean is_hardware_accelerated, 630 jboolean is_hardware_accelerated,
631 jint scroll_x, 631 jint scroll_x_pix,
632 jint scroll_y, 632 jint scroll_y_pix,
633 jint clip_left, 633 jint clip_left,
634 jint clip_top, 634 jint clip_top,
635 jint clip_right, 635 jint clip_right,
636 jint clip_bottom) { 636 jint clip_bottom) {
637 return browser_view_renderer_->OnDraw(canvas, 637 return browser_view_renderer_->OnDraw(
638 is_hardware_accelerated, 638 canvas,
639 gfx::Point(scroll_x, scroll_y), 639 is_hardware_accelerated,
640 gfx::Rect(clip_left, 640 gfx::Vector2d(scroll_x_pix, scroll_y_pix),
641 clip_top, 641 gfx::Rect(clip_left,
642 clip_right - clip_left, 642 clip_top,
643 clip_bottom - clip_top)); 643 clip_right - clip_left,
644 clip_bottom - clip_top));
644 } 645 }
645 646
646 void AwContents::SetPendingWebContentsForPopup( 647 void AwContents::SetPendingWebContentsForPopup(
647 scoped_ptr<content::WebContents> pending) { 648 scoped_ptr<content::WebContents> pending) {
648 if (pending_contents_.get()) { 649 if (pending_contents_.get()) {
649 // TODO(benm): Support holding multiple pop up window requests. 650 // TODO(benm): Support holding multiple pop up window requests.
650 LOG(WARNING) << "Blocking popup window creation as an outstanding " 651 LOG(WARNING) << "Blocking popup window creation as an outstanding "
651 << "popup window is still pending."; 652 << "popup window is still pending.";
652 base::MessageLoop::current()->DeleteSoon(FROM_HERE, pending.release()); 653 base::MessageLoop::current()->DeleteSoon(FROM_HERE, pending.release());
653 return; 654 return;
(...skipping 15 matching lines...) Expand all
669 if (obj.is_null()) 670 if (obj.is_null())
670 return gfx::Point(); 671 return gfx::Point();
671 std::vector<int> location; 672 std::vector<int> location;
672 base::android::JavaIntArrayToIntVector( 673 base::android::JavaIntArrayToIntVector(
673 env, 674 env,
674 Java_AwContents_getLocationOnScreen(env, obj.obj()).obj(), 675 Java_AwContents_getLocationOnScreen(env, obj.obj()).obj(),
675 &location); 676 &location);
676 return gfx::Point(location[0], location[1]); 677 return gfx::Point(location[0], location[1]);
677 } 678 }
678 679
680 void AwContents::ScrollContainerViewTo(gfx::Vector2d new_value) {
681 JNIEnv* env = AttachCurrentThread();
682 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
683 if (obj.is_null())
684 return;
685 Java_AwContents_scrollContainerViewTo(
686 env, obj.obj(), new_value.x(), new_value.y());
687 }
688
689
690 void AwContents::SetDipScale(JNIEnv* env, jobject obj, jdouble dipScale) {
691 browser_view_renderer_->SetDipScale(dipScale);
692 }
693
694 void AwContents::ScrollTo(JNIEnv* env, jobject obj, jint xPix, jint yPix) {
695 browser_view_renderer_->ScrollTo(gfx::Vector2d(xPix, yPix));
696 }
697
679 void AwContents::OnPageScaleFactorChanged(float page_scale_factor) { 698 void AwContents::OnPageScaleFactorChanged(float page_scale_factor) {
680 JNIEnv* env = AttachCurrentThread(); 699 JNIEnv* env = AttachCurrentThread();
681 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 700 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
682 if (obj.is_null()) 701 if (obj.is_null())
683 return; 702 return;
684 Java_AwContents_onPageScaleFactorChanged(env, obj.obj(), page_scale_factor); 703 Java_AwContents_onPageScaleFactorChanged(env, obj.obj(), page_scale_factor);
685 } 704 }
686 705
687 ScopedJavaLocalRef<jobject> AwContents::CapturePicture(JNIEnv* env, 706 ScopedJavaLocalRef<jobject> AwContents::CapturePicture(JNIEnv* env,
688 jobject obj) { 707 jobject obj) {
689 return browser_view_renderer_->CapturePicture(); 708 return browser_view_renderer_->CapturePicture();
690 } 709 }
691 710
692 void AwContents::EnableOnNewPicture(JNIEnv* env, 711 void AwContents::EnableOnNewPicture(JNIEnv* env,
693 jobject obj, 712 jobject obj,
694 jboolean enabled) { 713 jboolean enabled) {
695 browser_view_renderer_->EnableOnNewPicture(enabled); 714 browser_view_renderer_->EnableOnNewPicture(enabled);
696 } 715 }
697 716
698 } // namespace android_webview 717 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698