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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 10790066: Enable gesture events handling on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit fix to render_widget_host_view_android Created 8 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.Configuration; 8 import android.content.res.Configuration;
9 import android.graphics.Canvas; 9 import android.graphics.Canvas;
10 import android.os.Bundle;
10 import android.util.Log; 11 import android.util.Log;
11 import android.view.KeyEvent; 12 import android.view.KeyEvent;
12 import android.view.MotionEvent; 13 import android.view.MotionEvent;
13 import android.view.View; 14 import android.view.View;
14 import android.view.ViewGroup; 15 import android.view.ViewGroup;
15 import android.webkit.DownloadListener; 16 import android.webkit.DownloadListener;
16 17
17 import org.chromium.base.CalledByNative; 18 import org.chromium.base.CalledByNative;
18 import org.chromium.base.JNINamespace; 19 import org.chromium.base.JNINamespace;
19 import org.chromium.base.WeakContext; 20 import org.chromium.base.WeakContext;
21 import org.chromium.content.browser.ContentViewGestureHandler;
22 import org.chromium.content.browser.TouchPoint;
23 import org.chromium.content.browser.ZoomManager;
20 import org.chromium.content.common.TraceEvent; 24 import org.chromium.content.common.TraceEvent;
21 25
26 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat e;
27
22 /** 28 /**
23 * Contains all the major functionality necessary to manage the lifecycle of a C ontentView without 29 * Contains all the major functionality necessary to manage the lifecycle of a C ontentView without
24 * being tied to the view system. 30 * being tied to the view system.
25 */ 31 */
26 @JNINamespace("content") 32 @JNINamespace("content")
27 public class ContentViewCore { 33 public class ContentViewCore implements MotionEventDelegate {
28 private static final String TAG = ContentViewCore.class.getName(); 34 private static final String TAG = ContentViewCore.class.getName();
29 35
30 // The following constants match the ones in chrome/common/page_transition_t ypes.h. 36 // The following constants match the ones in chrome/common/page_transition_t ypes.h.
31 // Add more if you need them. 37 // Add more if you need them.
32 public static final int PAGE_TRANSITION_LINK = 0; 38 public static final int PAGE_TRANSITION_LINK = 0;
33 public static final int PAGE_TRANSITION_TYPED = 1; 39 public static final int PAGE_TRANSITION_TYPED = 1;
34 public static final int PAGE_TRANSITION_AUTO_BOOKMARK = 2; 40 public static final int PAGE_TRANSITION_AUTO_BOOKMARK = 2;
35 public static final int PAGE_TRANSITION_START_PAGE = 6; 41 public static final int PAGE_TRANSITION_START_PAGE = 6;
36 42
37 /** Translate the find selection into a normal selection. */ 43 /** Translate the find selection into a normal selection. */
38 public static final int FIND_SELECTION_ACTION_KEEP_SELECTION = 0; 44 public static final int FIND_SELECTION_ACTION_KEEP_SELECTION = 0;
39 /** Clear the find selection. */ 45 /** Clear the find selection. */
40 public static final int FIND_SELECTION_ACTION_CLEAR_SELECTION = 1; 46 public static final int FIND_SELECTION_ACTION_CLEAR_SELECTION = 1;
41 /** Focus and click the selected node (for links). */ 47 /** Focus and click the selected node (for links). */
42 public static final int FIND_SELECTION_ACTION_ACTIVATE_SELECTION = 2; 48 public static final int FIND_SELECTION_ACTION_ACTIVATE_SELECTION = 2;
43 49
44 // Personality of the ContentView. 50 // Personality of the ContentView.
45 private int mPersonality; 51 private int mPersonality;
46 // Used when ContentView implements a standalone View. 52 // Used when ContentView implements a standalone View.
47 public static final int PERSONALITY_VIEW = 0; 53 public static final int PERSONALITY_VIEW = 0;
48 // Used for Chrome. 54 // Used for Chrome.
49 public static final int PERSONALITY_CHROME = 1; 55 public static final int PERSONALITY_CHROME = 1;
50 56
51 // Used to avoid enabling zooming in / out in WebView zoom controls 57 // Used to avoid enabling zooming in / out in WebView zoom controls
52 // if resulting zooming will produce little visible difference. 58 // if resulting zooming will produce little visible difference.
53 private static float WEBVIEW_ZOOM_CONTROLS_EPSILON = 0.007f; 59 private static float WEBVIEW_ZOOM_CONTROLS_EPSILON = 0.007f;
54 60
61 // To avoid checkerboard, we clamp the fling velocity based on the maximum n umber of tiles
62 // should be allowed to upload per 100ms.
63 private static int MAX_NUM_UPLOAD_TILES = 12;
64
55 /** 65 /**
56 * Interface that consumers of {@link ContentViewCore} must implement to all ow the proper 66 * Interface that consumers of {@link ContentViewCore} must implement to all ow the proper
57 * dispatching of view methods through the containing view. 67 * dispatching of view methods through the containing view.
58 * 68 *
59 * <p> 69 * <p>
60 * All methods with the "super_" prefix should be routed to the parent of th e 70 * All methods with the "super_" prefix should be routed to the parent of th e
61 * implementing container view. 71 * implementing container view.
62 */ 72 */
63 @SuppressWarnings("javadoc") 73 @SuppressWarnings("javadoc")
64 public static interface InternalAccessDelegate { 74 public static interface InternalAccessDelegate {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // instance since the native side only holds a weak pointer to the client. W e chose this 126 // instance since the native side only holds a weak pointer to the client. W e chose this
117 // solution over the managed object owning the C++ object's memory since it' s a lot simpler 127 // solution over the managed object owning the C++ object's memory since it' s a lot simpler
118 // in terms of clean up. 128 // in terms of clean up.
119 private ContentViewClient mContentViewClient; 129 private ContentViewClient mContentViewClient;
120 130
121 private ContentSettings mContentSettings; 131 private ContentSettings mContentSettings;
122 132
123 // Native pointer to C++ ContentView object which will be set by nativeInit( ) 133 // Native pointer to C++ ContentView object which will be set by nativeInit( )
124 private int mNativeContentViewCore = 0; 134 private int mNativeContentViewCore = 0;
125 135
136 private ContentViewGestureHandler mContentViewGestureHandler;
126 private ZoomManager mZoomManager; 137 private ZoomManager mZoomManager;
127 138
128 // Cached page scale factor from native 139 // Cached page scale factor from native
129 private float mNativePageScaleFactor = 1.0f; 140 private float mNativePageScaleFactor = 1.0f;
130 private float mNativeMinimumScale = 1.0f; 141 private float mNativeMinimumScale = 1.0f;
131 private float mNativeMaximumScale = 1.0f; 142 private float mNativeMaximumScale = 1.0f;
132 143
133 // TODO(klobag): this is to avoid a bug in GestureDetector. With multi-touch , 144 // TODO(klobag): this is to avoid a bug in GestureDetector. With multi-touch ,
134 // mAlwaysInTapRegion is not reset. So when the last finger is up, onSingleT apUp() 145 // mAlwaysInTapRegion is not reset. So when the last finger is up, onSingleT apUp()
135 // will be mistakenly fired. 146 // will be mistakenly fired.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 protected ViewGroup getContainerView() { 227 protected ViewGroup getContainerView() {
217 return mContainerView; 228 return mContainerView;
218 } 229 }
219 230
220 // TODO(jrg): incomplete; upstream the rest of this method. 231 // TODO(jrg): incomplete; upstream the rest of this method.
221 private void initialize(Context context, int nativeWebContents, int personal ity) { 232 private void initialize(Context context, int nativeWebContents, int personal ity) {
222 mNativeContentViewCore = nativeInit(nativeWebContents); 233 mNativeContentViewCore = nativeInit(nativeWebContents);
223 234
224 mPersonality = personality; 235 mPersonality = personality;
225 mContentSettings = new ContentSettings(this, mNativeContentViewCore); 236 mContentSettings = new ContentSettings(this, mNativeContentViewCore);
226 mContainerView.setWillNotDraw(false);
227 mContainerView.setFocusable(true); 237 mContainerView.setFocusable(true);
228 mContainerView.setFocusableInTouchMode(true); 238 mContainerView.setFocusableInTouchMode(true);
229 if (mContainerView.getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY ) { 239 if (mContainerView.getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY ) {
230 mContainerView.setHorizontalScrollBarEnabled(false); 240 mContainerView.setHorizontalScrollBarEnabled(false);
231 mContainerView.setVerticalScrollBarEnabled(false); 241 mContainerView.setVerticalScrollBarEnabled(false);
232 } 242 }
233 mContainerView.setClickable(true); 243 mContainerView.setClickable(true);
234 initGestureDetectors(context); 244
245 mZoomManager = new ZoomManager(context, this);
246 mZoomManager.updateMultiTouchSupport();
247 mContentViewGestureHandler = new ContentViewGestureHandler(context, this , mZoomManager);
235 248
236 Log.i(TAG, "mNativeContentView=0x"+ Integer.toHexString(mNativeContentVi ewCore)); 249 Log.i(TAG, "mNativeContentView=0x"+ Integer.toHexString(mNativeContentVi ewCore));
237 } 250 }
238 251
239 /** 252 /**
240 * @return Whether the configured personality of this ContentView is {@link #PERSONALITY_VIEW}. 253 * @return Whether the configured personality of this ContentView is {@link #PERSONALITY_VIEW}.
241 */ 254 */
242 boolean isPersonalityView() { 255 boolean isPersonalityView() {
243 switch (mPersonality) { 256 switch (mPersonality) {
244 case PERSONALITY_VIEW: 257 case PERSONALITY_VIEW:
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 } 465 }
453 466
454 /** 467 /**
455 * Clears the WebView's page history in both the backwards and forwards 468 * Clears the WebView's page history in both the backwards and forwards
456 * directions. 469 * directions.
457 */ 470 */
458 public void clearHistory() { 471 public void clearHistory() {
459 if (mNativeContentViewCore != 0) nativeClearHistory(mNativeContentViewCo re); 472 if (mNativeContentViewCore != 0) nativeClearHistory(mNativeContentViewCo re);
460 } 473 }
461 474
475 // End FrameLayout overrides.
476
477
462 /** 478 /**
463 * Start pinch zoom. You must call {@link #pinchEnd} to stop. 479 * @see View#onTouchEvent(MotionEvent)
464 */ 480 */
465 void pinchBegin(long timeMs, int x, int y) { 481 public boolean onTouchEvent(MotionEvent event) {
482 return mContentViewGestureHandler.onTouchEvent(event);
483 }
484
485 /**
486 * @return ContentViewGestureHandler for all MotionEvent and gesture related calls.
487 */
488 ContentViewGestureHandler getContentViewGestureHandler() {
489 return mContentViewGestureHandler;
490 }
491
492 @Override
493 public boolean sendTouchEvent(long timeMs, int action, TouchPoint[] pts) {
466 if (mNativeContentViewCore != 0) { 494 if (mNativeContentViewCore != 0) {
467 // TODO(tedchoc): Pass pinch begin to native. 495 return nativeTouchEvent(mNativeContentViewCore, timeMs, action, pts) ;
496 }
497 return false;
498 }
499
500 @SuppressWarnings("unused")
501 @CalledByNative
502 private void didSetNeedTouchEvents(boolean needTouchEvents) {
503 mContentViewGestureHandler.didSetNeedTouchEvents(needTouchEvents);
504 }
505
506 @SuppressWarnings("unused")
507 @CalledByNative
508 private void confirmTouchEvent(boolean handled) {
509 mContentViewGestureHandler.confirmTouchEvent(handled);
510 }
511
512 @Override
513 public boolean sendGesture(int type, long timeMs, int x, int y, Bundle b) {
514 if (mNativeContentViewCore == 0) return false;
515
516 switch (type) {
517 case ContentViewGestureHandler.GESTURE_SHOW_PRESSED_STATE:
518 nativeShowPressState(mNativeContentViewCore, timeMs, x, y);
519 return true;
520 case ContentViewGestureHandler.GESTURE_DOUBLE_TAP:
521 nativeDoubleTap(mNativeContentViewCore, timeMs, x, y);
522 return true;
523 case ContentViewGestureHandler.GESTURE_SINGLE_TAP_UP:
524 nativeSingleTap(mNativeContentViewCore, timeMs, x, y, false);
525 return true;
526 case ContentViewGestureHandler.GESTURE_SINGLE_TAP_CONFIRMED:
527 handleTapOrPress(timeMs, x, y, false,
528 b.getBoolean(ContentViewGestureHandler.SHOW_PRESS, false ));
529 return true;
530 case ContentViewGestureHandler.GESTURE_LONG_PRESS:
531 handleTapOrPress(timeMs, x, y, true, false);
532 return true;
533 case ContentViewGestureHandler.GESTURE_SCROLL_START:
534 nativeScrollBegin(mNativeContentViewCore, timeMs, x, y);
535 return true;
536 case ContentViewGestureHandler.GESTURE_SCROLL_BY:
537 nativeScrollBy(mNativeContentViewCore, timeMs, x, y);
538 return true;
539 case ContentViewGestureHandler.GESTURE_SCROLL_END:
540 nativeScrollEnd(mNativeContentViewCore, timeMs);
541 return true;
542 case ContentViewGestureHandler.GESTURE_FLING_START:
543 nativeFlingStart(mNativeContentViewCore, timeMs, x, y,
544 clampFlingVelocityX(b.getInt(ContentViewGestureHandler.V ELOCITY_X, 0)),
545 clampFlingVelocityY(b.getInt(ContentViewGestureHandler.V ELOCITY_Y, 0)));
546 return true;
547 case ContentViewGestureHandler.GESTURE_FLING_CANCEL:
548 nativeFlingCancel(mNativeContentViewCore, timeMs);
549 return true;
550 case ContentViewGestureHandler.GESTURE_PINCH_BEGIN:
551 nativePinchBegin(mNativeContentViewCore, timeMs, x, y);
552 return true;
553 case ContentViewGestureHandler.GESTURE_PINCH_BY:
554 nativePinchBy(mNativeContentViewCore, timeMs, x, y,
555 b.getFloat(ContentViewGestureHandler.DELTA, 0));
556 return true;
557 case ContentViewGestureHandler.GESTURE_PINCH_END:
558 nativePinchEnd(mNativeContentViewCore, timeMs);
559 return true;
560 default:
561 return false;
468 } 562 }
469 } 563 }
470 564
471 /**
472 * Stop pinch zoom.
473 */
474 void pinchEnd(long timeMs) {
475 if (mNativeContentViewCore != 0) {
476 // TODO(tedchoc): Pass pinch end to native.
477 }
478 }
479
480 void setIgnoreSingleTap(boolean value) {
481 mIgnoreSingleTap = value;
482 }
483
484 /**
485 * Modify the ContentView magnification level. The effect of calling this
486 * method is exactly as after "pinch zoom".
487 *
488 * @param timeMs The event time in milliseconds.
489 * @param delta The ratio of the new magnification level over the current
490 * magnification level.
491 * @param anchorX The magnification anchor (X) in the current view
492 * coordinate.
493 * @param anchorY The magnification anchor (Y) in the current view
494 * coordinate.
495 */
496 void pinchBy(long timeMs, int anchorX, int anchorY, float delta) {
497 if (mNativeContentViewCore != 0) {
498 // TODO(tedchoc): Pass pinch by to native.
499 }
500 }
501
502 /** 565 /**
503 * This method should be called when the containing activity is paused 566 * This method should be called when the containing activity is paused
504 * 567 *
505 * @hide 568 * @hide
506 **/ 569 **/
507 public void onActivityPause() { 570 public void onActivityPause() {
508 TraceEvent.begin(); 571 TraceEvent.begin();
509 hidePopupDialog(); 572 hidePopupDialog();
510 TraceEvent.end(); 573 TraceEvent.end();
511 } 574 }
(...skipping 14 matching lines...) Expand all
526 * Note that when ContentView is used in the PERSONALITY_CHROME role, 589 * Note that when ContentView is used in the PERSONALITY_CHROME role,
527 * ContentSettings can only be used for retrieving settings values. For 590 * ContentSettings can only be used for retrieving settings values. For
528 * modifications, ChromeNativePreferences is to be used. 591 * modifications, ChromeNativePreferences is to be used.
529 * @return A ContentSettings object that can be used to control this WebView 's 592 * @return A ContentSettings object that can be used to control this WebView 's
530 * settings. 593 * settings.
531 */ 594 */
532 public ContentSettings getContentSettings() { 595 public ContentSettings getContentSettings() {
533 return mContentSettings; 596 return mContentSettings;
534 } 597 }
535 598
599 @Override
600 public boolean didUIStealScroll(float x, float y) {
601 // TODO(yusufo): Stubbed out for now. Upstream when computeHorizontalScr ollOffset is
602 // available.
603 return false;
604 }
605
536 private void hidePopupDialog() { 606 private void hidePopupDialog() {
537 SelectPopupDialog.hide(this); 607 SelectPopupDialog.hide(this);
538 } 608 }
539 609
540 // End FrameLayout overrides. 610 // End FrameLayout overrides.
541 611
542 /** 612 /**
543 * @see View#awakenScrollBars(int, boolean) 613 * @see View#awakenScrollBars(int, boolean)
544 */ 614 */
545 @SuppressWarnings("javadoc") 615 @SuppressWarnings("javadoc")
546 protected boolean awakenScrollBars(int startDelay, boolean invalidate) { 616 protected boolean awakenScrollBars(int startDelay, boolean invalidate) {
547 // For the default implementation of ContentView which draws the scrollB ars on the native 617 // For the default implementation of ContentView which draws the scrollB ars on the native
548 // side, calling this function may get us into a bad state where we keep drawing the 618 // side, calling this function may get us into a bad state where we keep drawing the
549 // scrollBars, so disable it by always returning false. 619 // scrollBars, so disable it by always returning false.
550 if (mContainerView.getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY ) { 620 if (mContainerView.getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY ) {
551 return false; 621 return false;
552 } else { 622 } else {
553 return mContainerViewInternals.super_awakenScrollBars(startDelay, in validate); 623 return mContainerViewInternals.super_awakenScrollBars(startDelay, in validate);
554 } 624 }
555 } 625 }
556 626
557 private void initGestureDetectors(final Context context) { 627 private void handleTapOrPress(
558 try { 628 long timeMs, int x, int y, boolean isLongPress, boolean showPress) {
559 TraceEvent.begin(); 629 //TODO(yusufo):Upstream the rest of the bits about handlerControllers.
560 // TODO(tedchoc): Upstream the rest of the initialization. 630 if (!mContainerView.isFocused()) mContainerView.requestFocus();
561 mZoomManager = new ZoomManager(context, this); 631
562 mZoomManager.updateMultiTouchSupport(); 632 if (isLongPress) {
563 } finally { 633 if (mNativeContentViewCore != 0) {
564 TraceEvent.end(); 634 nativeLongPress(mNativeContentViewCore, timeMs, x, y, false);
635 }
636 } else {
637 if (!showPress && mNativeContentViewCore != 0) {
638 nativeShowPressState(mNativeContentViewCore, timeMs, x, y);
639 }
640 if (mNativeContentViewCore != 0) {
641 nativeSingleTap(mNativeContentViewCore, timeMs, x, y, false);
642 }
565 } 643 }
566 } 644 }
567 645
568 void updateMultiTouchZoomSupport() { 646 void updateMultiTouchZoomSupport() {
569 mZoomManager.updateMultiTouchSupport(); 647 mZoomManager.updateMultiTouchSupport();
570 } 648 }
571 649
572 public boolean isMultiTouchZoomSupported() { 650 public boolean isMultiTouchZoomSupported() {
573 return mZoomManager.isMultiTouchZoomSupported(); 651 return mZoomManager.isMultiTouchZoomSupported();
574 } 652 }
575 653
576 void selectPopupMenuItems(int[] indices) { 654 void selectPopupMenuItems(int[] indices) {
577 if (mNativeContentViewCore != 0) { 655 if (mNativeContentViewCore != 0) {
578 nativeSelectPopupMenuItems(mNativeContentViewCore, indices); 656 nativeSelectPopupMenuItems(mNativeContentViewCore, indices);
579 } 657 }
580 } 658 }
581 659
660 /*
661 * To avoid checkerboard, we clamp the fling velocity based on the maximum n umber of tiles
662 * allowed to be uploaded per 100ms. Calculation is limited to one direction . We assume the
663 * tile size is 256x256. The precise distance / velocity should be calculate d based on the
664 * logic in Scroller.java. As it is almost linear for the first 100ms, we us e a simple math.
665 */
666 private int clampFlingVelocityX(int velocity) {
667 int cols = MAX_NUM_UPLOAD_TILES / (int) (Math.ceil((float) getHeight() / 256) + 1);
668 int maxVelocity = cols > 0 ? cols * 2560 : 1000;
669 if (Math.abs(velocity) > maxVelocity) {
670 return velocity > 0 ? maxVelocity : -maxVelocity;
671 } else {
672 return velocity;
673 }
674 }
675
676 private int clampFlingVelocityY(int velocity) {
677 int rows = MAX_NUM_UPLOAD_TILES / (int) (Math.ceil((float) getWidth() / 256) + 1);
678 int maxVelocity = rows > 0 ? rows * 2560 : 1000;
679 if (Math.abs(velocity) > maxVelocity) {
680 return velocity > 0 ? maxVelocity : -maxVelocity;
681 } else {
682 return velocity;
683 }
684 }
685
582 /** 686 /**
583 * Register the listener to be used when content can not be handled by the 687 * Register the listener to be used when content can not be handled by the
584 * rendering engine, and should be downloaded instead. This will replace the 688 * rendering engine, and should be downloaded instead. This will replace the
585 * current listener. 689 * current listener.
586 * @param listener An implementation of DownloadListener. 690 * @param listener An implementation of DownloadListener.
587 */ 691 */
588 // TODO(nileshagrawal): decide if setDownloadDelegate will be public API. If so, 692 // TODO(nileshagrawal): decide if setDownloadDelegate will be public API. If so,
589 // this method should be deprecated and the javadoc should make reference to the 693 // this method should be deprecated and the javadoc should make reference to the
590 // fact that a ContentViewDownloadDelegate will be used in preference to a 694 // fact that a ContentViewDownloadDelegate will be used in preference to a
591 // DownloadListener. 695 // DownloadListener.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 795
692 if (mNativeContentViewCore == 0) { 796 if (mNativeContentViewCore == 0) {
693 return false; 797 return false;
694 } 798 }
695 799
696 long timeMs = System.currentTimeMillis(); 800 long timeMs = System.currentTimeMillis();
697 int x = getWidth() / 2; 801 int x = getWidth() / 2;
698 int y = getHeight() / 2; 802 int y = getHeight() / 2;
699 float delta = 1.25f; 803 float delta = 1.25f;
700 804
701 pinchBegin(timeMs, x, y); 805 getContentViewGestureHandler().pinchBegin(timeMs, x, y);
702 pinchBy(timeMs, x, y, delta); 806 getContentViewGestureHandler().pinchBy(timeMs, x, y, delta);
703 pinchEnd(timeMs); 807 getContentViewGestureHandler().pinchEnd(timeMs);
704 808
705 return true; 809 return true;
706 } 810 }
707 811
708 /** 812 /**
709 * Zooms out the WebView by 20% (or less if that would result in zooming out 813 * Zooms out the WebView by 20% (or less if that would result in zooming out
710 * more than possible). 814 * more than possible).
711 * 815 *
712 * @return True if there was a zoom change, false otherwise. 816 * @return True if there was a zoom change, false otherwise.
713 */ 817 */
714 // This method uses the term 'zoom' for legacy reasons, but relates 818 // This method uses the term 'zoom' for legacy reasons, but relates
715 // to what chrome calls the 'page scale factor'. 819 // to what chrome calls the 'page scale factor'.
716 public boolean zoomOut() { 820 public boolean zoomOut() {
717 if (!canZoomOut()) { 821 if (!canZoomOut()) {
718 return false; 822 return false;
719 } 823 }
720 824
721 if (mNativeContentViewCore == 0) { 825 if (mNativeContentViewCore == 0) {
722 return false; 826 return false;
723 } 827 }
724 828
725 long timeMs = System.currentTimeMillis(); 829 long timeMs = System.currentTimeMillis();
726 int x = getWidth() / 2; 830 int x = getWidth() / 2;
727 int y = getHeight() / 2; 831 int y = getHeight() / 2;
728 float delta = 0.8f; 832 float delta = 0.8f;
729 833
730 pinchBegin(timeMs, x, y); 834 getContentViewGestureHandler().pinchBegin(timeMs, x, y);
731 pinchBy(timeMs, x, y, delta); 835 getContentViewGestureHandler().pinchBy(timeMs, x, y, delta);
732 pinchEnd(timeMs); 836 getContentViewGestureHandler().pinchEnd(timeMs);
733 837
734 return true; 838 return true;
735 } 839 }
736 840
737 // Invokes the graphical zoom picker widget for this ContentView. 841 /**
842 * Invokes the graphical zoom picker widget for this ContentView.
843 */
844 @Override
738 public void invokeZoomPicker() { 845 public void invokeZoomPicker() {
739 if (mContentSettings.supportZoom()) { 846 if (mContentSettings.supportZoom()) {
740 mZoomManager.invokeZoomPicker(); 847 mZoomManager.invokeZoomPicker();
741 } 848 }
742 } 849 }
743 850
744 // Unlike legacy WebView getZoomControls which returns external zoom control s, 851 // Unlike legacy WebView getZoomControls which returns external zoom control s,
745 // this method returns built-in zoom controls. This method is used in tests. 852 // this method returns built-in zoom controls. This method is used in tests.
746 public View getZoomControlsForTest() { 853 public View getZoomControlsForTest() {
747 return mZoomManager.getZoomControlsViewForTest(); 854 return mZoomManager.getZoomControlsViewForTest();
(...skipping 29 matching lines...) Expand all
777 884
778 private native String nativeGetTitle(int nativeContentViewCoreImpl); 885 private native String nativeGetTitle(int nativeContentViewCoreImpl);
779 886
780 private native double nativeGetLoadProgress(int nativeContentViewCoreImpl); 887 private native double nativeGetLoadProgress(int nativeContentViewCoreImpl);
781 888
782 private native boolean nativeIsIncognito(int nativeContentViewCoreImpl); 889 private native boolean nativeIsIncognito(int nativeContentViewCoreImpl);
783 890
784 // Returns true if the native side crashed so that java side can draw a sad tab. 891 // Returns true if the native side crashed so that java side can draw a sad tab.
785 private native boolean nativeCrashed(int nativeContentViewCoreImpl); 892 private native boolean nativeCrashed(int nativeContentViewCoreImpl);
786 893
894 private native boolean nativeTouchEvent(int nativeContentViewCoreImpl,
895 long timeMs, int action,
896 TouchPoint[] pts);
897
898 private native void nativeScrollBegin(int nativeContentViewCoreImpl, long ti meMs, int x, int y);
899
900 private native void nativeScrollEnd(int nativeContentViewCoreImpl, long time Ms);
901
902 private native void nativeScrollBy(
903 int nativeContentViewCoreImpl, long timeMs, int deltaX, int deltaY);
904
905 private native void nativeFlingStart(
906 int nativeContentViewCoreImpl, long timeMs, int x, int y, int vx, in t vy);
907
908 private native void nativeFlingCancel(int nativeContentViewCoreImpl, long ti meMs);
909
910 private native void nativeSingleTap(
911 int nativeContentViewCoreImpl, long timeMs, int x, int y, boolean li nkPreviewTap);
912
913 private native void nativeShowPressState(
914 int nativeContentViewCoreImpl, long timeMs, int x, int y);
915
916 private native void nativeDoubleTap(int nativeContentViewCoreImpl, long time Ms, int x, int y);
917
918 private native void nativeLongPress(int nativeContentViewCoreImpl, long time Ms, int x, int y,
919 boolean linkPreviewTap);
920
921 private native void nativePinchBegin(int nativeContentViewCoreImpl, long tim eMs, int x, int y);
922
923 private native void nativePinchEnd(int nativeContentViewCoreImpl, long timeM s);
924
925 private native void nativePinchBy(int nativeContentViewCoreImpl, long timeMs ,
926 int anchorX, int anchorY, float deltaScale);
927
787 private native boolean nativeCanGoBack(int nativeContentViewCoreImpl); 928 private native boolean nativeCanGoBack(int nativeContentViewCoreImpl);
788 929
789 private native boolean nativeCanGoForward(int nativeContentViewCoreImpl); 930 private native boolean nativeCanGoForward(int nativeContentViewCoreImpl);
790 931
791 private native boolean nativeCanGoToOffset(int nativeContentViewCoreImpl, in t offset); 932 private native boolean nativeCanGoToOffset(int nativeContentViewCoreImpl, in t offset);
792 933
793 private native void nativeGoToOffset(int nativeContentViewCoreImpl, int offs et); 934 private native void nativeGoToOffset(int nativeContentViewCoreImpl, int offs et);
794 935
795 private native void nativeGoBack(int nativeContentViewCoreImpl); 936 private native void nativeGoBack(int nativeContentViewCoreImpl);
796 937
797 private native void nativeGoForward(int nativeContentViewCoreImpl); 938 private native void nativeGoForward(int nativeContentViewCoreImpl);
798 939
799 private native void nativeStopLoading(int nativeContentViewCoreImpl); 940 private native void nativeStopLoading(int nativeContentViewCoreImpl);
800 941
801 private native void nativeReload(int nativeContentViewCoreImpl); 942 private native void nativeReload(int nativeContentViewCoreImpl);
802 943
803 private native void nativeSelectPopupMenuItems(int nativeContentViewCoreImpl , int[] indices); 944 private native void nativeSelectPopupMenuItems(int nativeContentViewCoreImpl , int[] indices);
804 945
805 private native void nativeSetClient(int nativeContentViewCoreImpl, ContentVi ewClient client); 946 private native void nativeSetClient(int nativeContentViewCoreImpl, ContentVi ewClient client);
806 947
807 private native boolean nativeNeedsReload(int nativeContentViewCoreImpl); 948 private native boolean nativeNeedsReload(int nativeContentViewCoreImpl);
808 949
809 private native void nativeClearHistory(int nativeContentViewCoreImpl); 950 private native void nativeClearHistory(int nativeContentViewCoreImpl);
810 } 951 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698