ContentView.java revision b2df76ea8fec9e32f6f3718986dba0d95315b29c
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 3// found in the LICENSE file. 4 5package org.chromium.content.browser; 6 7import android.app.Activity; 8import android.content.Context; 9import android.content.res.Configuration; 10import android.graphics.Bitmap; 11import android.graphics.Canvas; 12import android.graphics.Rect; 13import android.os.Build; 14import android.util.AttributeSet; 15import android.view.KeyEvent; 16import android.view.MotionEvent; 17import android.view.View; 18import android.view.accessibility.AccessibilityEvent; 19import android.view.accessibility.AccessibilityNodeInfo; 20import android.view.inputmethod.EditorInfo; 21import android.view.inputmethod.InputConnection; 22import android.widget.FrameLayout; 23 24import com.google.common.annotations.VisibleForTesting; 25 26import org.chromium.content.common.TraceEvent; 27import org.chromium.ui.WindowAndroid; 28 29/** 30 * The containing view for {@link ContentViewCore} that exists in the Android UI hierarchy and 31 * exposes the various {@link View} functionality to it. 32 * 33 * TODO(joth): Remove any methods overrides from this class that were added for WebView 34 * compatibility. 35 */ 36public class ContentView extends FrameLayout 37 implements ContentViewCore.InternalAccessDelegate, PageInfo { 38 39 private final ContentViewCore mContentViewCore; 40 41 private float mCurrentTouchOffsetX; 42 private float mCurrentTouchOffsetY; 43 44 /** 45 * Creates an instance of a ContentView. 46 * @param context The Context the view is running in, through which it can 47 * access the current theme, resources, etc. 48 * @param nativeWebContents A pointer to the native web contents. 49 * @param windowAndroid An instance of the WindowAndroid. 50 * @return A ContentView instance. 51 */ 52 public static ContentView newInstance(Context context, int nativeWebContents, 53 WindowAndroid windowAndroid) { 54 return newInstance(context, nativeWebContents, windowAndroid, null, 55 android.R.attr.webViewStyle); 56 } 57 58 /** 59 * Creates an instance of a ContentView. 60 * @param context The Context the view is running in, through which it can 61 * access the current theme, resources, etc. 62 * @param nativeWebContents A pointer to the native web contents. 63 * @param windowAndroid An instance of the WindowAndroid. 64 * @param attrs The attributes of the XML tag that is inflating the view. 65 * @return A ContentView instance. 66 */ 67 public static ContentView newInstance(Context context, int nativeWebContents, 68 WindowAndroid windowAndroid, AttributeSet attrs) { 69 // TODO(klobag): use the WebViewStyle as the default style for now. It enables scrollbar. 70 // When ContentView is moved to framework, we can define its own style in the res. 71 return newInstance(context, nativeWebContents, windowAndroid, attrs, 72 android.R.attr.webViewStyle); 73 } 74 75 /** 76 * Creates an instance of a ContentView. 77 * @param context The Context the view is running in, through which it can 78 * access the current theme, resources, etc. 79 * @param nativeWebContents A pointer to the native web contents. 80 * @param windowAndroid An instance of the WindowAndroid. 81 * @param attrs The attributes of the XML tag that is inflating the view. 82 * @param defStyle The default style to apply to this view. 83 * @return A ContentView instance. 84 */ 85 public static ContentView newInstance(Context context, int nativeWebContents, 86 WindowAndroid windowAndroid, AttributeSet attrs, int defStyle) { 87 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { 88 return new ContentView(context, nativeWebContents, windowAndroid, attrs, defStyle); 89 } else { 90 return new JellyBeanContentView(context, nativeWebContents, windowAndroid, attrs, 91 defStyle); 92 } 93 } 94 95 protected ContentView(Context context, int nativeWebContents, WindowAndroid windowAndroid, 96 AttributeSet attrs, int defStyle) { 97 super(context, attrs, defStyle); 98 99 mContentViewCore = new ContentViewCore(context); 100 mContentViewCore.initialize(this, this, nativeWebContents, windowAndroid, 101 Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN ? 102 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC : 103 ContentViewCore.INPUT_EVENTS_DELIVERED_IMMEDIATELY); 104 } 105 106 // PageInfo implementation. 107 108 @Override 109 public String getUrl() { 110 return mContentViewCore.getUrl(); 111 } 112 113 @Override 114 public String getTitle() { 115 return mContentViewCore.getTitle(); 116 } 117 118 @Override 119 public boolean isReadyForSnapshot() { 120 return !isCrashed() && isReady(); 121 } 122 123 @Override 124 public Bitmap getBitmap() { 125 return getBitmap(getWidth(), getHeight()); 126 } 127 128 @Override 129 public Bitmap getBitmap(int width, int height) { 130 return mContentViewCore.getBitmap(width, height); 131 } 132 133 @Override 134 public int getBackgroundColor() { 135 return mContentViewCore.getBackgroundColor(); 136 } 137 138 @Override 139 public View getView() { 140 return this; 141 } 142 143 /** 144 * @return The core component of the ContentView that handles JNI communication. Should only be 145 * used for passing to native. 146 */ 147 public ContentViewCore getContentViewCore() { 148 return mContentViewCore; 149 } 150 151 /** 152 * @return The cache of scales and positions used to convert coordinates from/to CSS. 153 */ 154 public RenderCoordinates getRenderCoordinates() { 155 return mContentViewCore.getRenderCoordinates(); 156 } 157 158 /** 159 * Returns true if the given Activity has hardware acceleration enabled 160 * in its manifest, or in its foreground window. 161 * 162 * TODO(husky): Remove when ContentViewCore.initialize() is refactored (see TODO there) 163 * TODO(dtrainor) This is still used by other classes. Make sure to pull some version of this 164 * out before removing it. 165 */ 166 public static boolean hasHardwareAcceleration(Activity activity) { 167 return ContentViewCore.hasHardwareAcceleration(activity); 168 } 169 170 /** 171 * Destroy the internal state of the WebView. This method may only be called 172 * after the WebView has been removed from the view system. No other methods 173 * may be called on this WebView after this method has been called. 174 */ 175 public void destroy() { 176 mContentViewCore.destroy(); 177 } 178 179 /** 180 * Returns true initially, false after destroy() has been called. 181 * It is illegal to call any other public method after destroy(). 182 */ 183 public boolean isAlive() { 184 return mContentViewCore.isAlive(); 185 } 186 187 /** 188 * For internal use. Throws IllegalStateException if mNativeContentView is 0. 189 * Use this to ensure we get a useful Java stack trace, rather than a native 190 * crash dump, from use-after-destroy bugs in Java code. 191 */ 192 void checkIsAlive() throws IllegalStateException { 193 mContentViewCore.checkIsAlive(); 194 } 195 196 public void setContentViewClient(ContentViewClient client) { 197 mContentViewCore.setContentViewClient(client); 198 } 199 200 @VisibleForTesting 201 public ContentViewClient getContentViewClient() { 202 return mContentViewCore.getContentViewClient(); 203 } 204 205 /** 206 * Load url without fixing up the url string. Consumers of ContentView are responsible for 207 * ensuring the URL passed in is properly formatted (i.e. the scheme has been added if left 208 * off during user input). 209 * 210 * @param params Parameters for this load. 211 */ 212 public void loadUrl(LoadUrlParams params) { 213 mContentViewCore.loadUrl(params); 214 } 215 216 /** 217 * Stops loading the current web contents. 218 */ 219 public void stopLoading() { 220 mContentViewCore.stopLoading(); 221 } 222 223 /** 224 * @return Whether the current WebContents has a previous navigation entry. 225 */ 226 public boolean canGoBack() { 227 return mContentViewCore.canGoBack(); 228 } 229 230 /** 231 * @return Whether the current WebContents has a navigation entry after the current one. 232 */ 233 public boolean canGoForward() { 234 return mContentViewCore.canGoForward(); 235 } 236 237 /** 238 * @param offset The offset into the navigation history. 239 * @return Whether we can move in history by given offset 240 */ 241 public boolean canGoToOffset(int offset) { 242 return mContentViewCore.canGoToOffset(offset); 243 } 244 245 /** 246 * Navigates to the specified offset from the "current entry". Does nothing if the offset is out 247 * of bounds. 248 * @param offset The offset into the navigation history. 249 */ 250 public void goToOffset(int offset) { 251 mContentViewCore.goToOffset(offset); 252 } 253 254 /** 255 * Goes to the navigation entry before the current one. 256 */ 257 public void goBack() { 258 mContentViewCore.goBack(); 259 } 260 261 /** 262 * Goes to the navigation entry following the current one. 263 */ 264 public void goForward() { 265 mContentViewCore.goForward(); 266 } 267 268 /** 269 * Reload the current page. 270 */ 271 public void reload() { 272 mContentViewCore.reload(); 273 } 274 275 /** 276 * Clears the WebView's page history in both the backwards and forwards 277 * directions. 278 */ 279 public void clearHistory() { 280 mContentViewCore.clearHistory(); 281 } 282 283 String getSelectedText() { 284 return mContentViewCore.getSelectedText(); 285 } 286 287 /** 288 * Start profiling the update speed. You must call {@link #stopFpsProfiling} 289 * to stop profiling. 290 */ 291 @VisibleForTesting 292 public void startFpsProfiling() { 293 // TODO(nileshagrawal): Implement this. 294 } 295 296 /** 297 * Stop profiling the update speed. 298 */ 299 @VisibleForTesting 300 public float stopFpsProfiling() { 301 // TODO(nileshagrawal): Implement this. 302 return 0.0f; 303 } 304 305 /** 306 * Fling the ContentView from the current position. 307 * @param x Fling touch starting position 308 * @param y Fling touch starting position 309 * @param velocityX Initial velocity of the fling (X) measured in pixels per second. 310 * @param velocityY Initial velocity of the fling (Y) measured in pixels per second. 311 */ 312 @VisibleForTesting 313 public void fling(long timeMs, int x, int y, int velocityX, int velocityY) { 314 mContentViewCore.getContentViewGestureHandler().fling(timeMs, x, y, velocityX, velocityY); 315 } 316 317 void endFling(long timeMs) { 318 mContentViewCore.getContentViewGestureHandler().endFling(timeMs); 319 } 320 321 /** 322 * Start pinch zoom. You must call {@link #pinchEnd} to stop. 323 */ 324 @VisibleForTesting 325 public void pinchBegin(long timeMs, int x, int y) { 326 mContentViewCore.getContentViewGestureHandler().pinchBegin(timeMs, x, y); 327 } 328 329 /** 330 * Stop pinch zoom. 331 */ 332 @VisibleForTesting 333 public void pinchEnd(long timeMs) { 334 mContentViewCore.getContentViewGestureHandler().pinchEnd(timeMs); 335 } 336 337 void setIgnoreSingleTap(boolean value) { 338 mContentViewCore.getContentViewGestureHandler().setIgnoreSingleTap(value); 339 } 340 341 /** 342 * Modify the ContentView magnification level. The effect of calling this 343 * method is exactly as after "pinch zoom". 344 * 345 * @param timeMs The event time in milliseconds. 346 * @param delta The ratio of the new magnification level over the current 347 * magnification level. 348 * @param anchorX The magnification anchor (X) in the current view 349 * coordinate. 350 * @param anchorY The magnification anchor (Y) in the current view 351 * coordinate. 352 */ 353 @VisibleForTesting 354 public void pinchBy(long timeMs, int anchorX, int anchorY, float delta) { 355 mContentViewCore.getContentViewGestureHandler().pinchBy(timeMs, anchorX, anchorY, delta); 356 } 357 358 /** 359 * Injects the passed JavaScript code in the current page and evaluates it. 360 * 361 * @throws IllegalStateException If the ContentView has been destroyed. 362 */ 363 public void evaluateJavaScript(String script) throws IllegalStateException { 364 mContentViewCore.evaluateJavaScript(script, null); 365 } 366 367 /** 368 * This method should be called when the containing activity is paused. 369 **/ 370 public void onActivityPause() { 371 mContentViewCore.onActivityPause(); 372 } 373 374 /** 375 * This method should be called when the containing activity is resumed. 376 **/ 377 public void onActivityResume() { 378 mContentViewCore.onActivityResume(); 379 } 380 381 /** 382 * To be called when the ContentView is shown. 383 **/ 384 public void onShow() { 385 mContentViewCore.onShow(); 386 } 387 388 /** 389 * To be called when the ContentView is hidden. 390 **/ 391 public void onHide() { 392 mContentViewCore.onHide(); 393 } 394 395 /** 396 * Return the ContentSettings object used to retrieve the settings for this 397 * ContentView. 398 * @return A ContentSettings object that can be used to retrieve this ContentView's 399 * settings. 400 */ 401 public ContentSettings getContentSettings() { 402 return mContentViewCore.getContentSettings(); 403 } 404 405 /** 406 * Hides the select action bar. 407 */ 408 public void hideSelectActionBar() { 409 mContentViewCore.hideSelectActionBar(); 410 } 411 412 // FrameLayout overrides. 413 414 // Needed by ContentViewCore.InternalAccessDelegate 415 @Override 416 public boolean drawChild(Canvas canvas, View child, long drawingTime) { 417 return super.drawChild(canvas, child, drawingTime); 418 } 419 420 // Needed by ContentViewCore.InternalAccessDelegate 421 @Override 422 public void onScrollChanged(int l, int t, int oldl, int oldt) { 423 super.onScrollChanged(l, t, oldl, oldt); 424 } 425 426 @Override 427 protected void onSizeChanged(int w, int h, int ow, int oh) { 428 TraceEvent.begin(); 429 super.onSizeChanged(w, h, ow, oh); 430 mContentViewCore.onSizeChanged(w, h, ow, oh); 431 TraceEvent.end(); 432 } 433 434 @Override 435 public InputConnection onCreateInputConnection(EditorInfo outAttrs) { 436 return mContentViewCore.onCreateInputConnection(outAttrs); 437 } 438 439 @Override 440 public boolean onCheckIsTextEditor() { 441 return mContentViewCore.onCheckIsTextEditor(); 442 } 443 444 @Override 445 protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { 446 TraceEvent.begin(); 447 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); 448 mContentViewCore.onFocusChanged(gainFocus, direction, previouslyFocusedRect); 449 TraceEvent.end(); 450 } 451 452 @Override 453 public boolean onKeyUp(int keyCode, KeyEvent event) { 454 return mContentViewCore.onKeyUp(keyCode, event); 455 } 456 457 @Override 458 public boolean dispatchKeyEventPreIme(KeyEvent event) { 459 return mContentViewCore.dispatchKeyEventPreIme(event); 460 } 461 462 @Override 463 public boolean dispatchKeyEvent(KeyEvent event) { 464 if (isFocused()) { 465 return mContentViewCore.dispatchKeyEvent(event); 466 } else { 467 return super.dispatchKeyEvent(event); 468 } 469 } 470 471 @Override 472 public boolean onTouchEvent(MotionEvent event) { 473 MotionEvent offset = createOffsetMotionEvent(event); 474 boolean consumed = mContentViewCore.onTouchEvent(offset); 475 offset.recycle(); 476 return consumed; 477 } 478 479 /** 480 * Mouse move events are sent on hover enter, hover move and hover exit. 481 * They are sent on hover exit because sometimes it acts as both a hover 482 * move and hover exit. 483 */ 484 @Override 485 public boolean onHoverEvent(MotionEvent event) { 486 return mContentViewCore.onHoverEvent(event); 487 } 488 489 @Override 490 public boolean onGenericMotionEvent(MotionEvent event) { 491 return mContentViewCore.onGenericMotionEvent(event); 492 } 493 494 /** 495 * Sets the current amount to offset incoming touch events by. This is used to handle content 496 * moving and not lining up properly with the android input system. 497 * @param dx The X offset in pixels to shift touch events. 498 * @param dy The Y offset in pixels to shift touch events. 499 */ 500 public void setCurrentMotionEventOffsets(float dx, float dy) { 501 mCurrentTouchOffsetX = dx; 502 mCurrentTouchOffsetY = dy; 503 } 504 505 private MotionEvent createOffsetMotionEvent(MotionEvent src) { 506 MotionEvent dst = MotionEvent.obtain(src); 507 dst.offsetLocation(mCurrentTouchOffsetX, mCurrentTouchOffsetY); 508 return dst; 509 } 510 511 @Override 512 protected void onConfigurationChanged(Configuration newConfig) { 513 mContentViewCore.onConfigurationChanged(newConfig); 514 } 515 516 /** 517 * Currently the ContentView scrolling happens in the native side. In 518 * the Java view system, it is always pinned at (0, 0). scrollBy() and scrollTo() 519 * are overridden, so that View's mScrollX and mScrollY will be unchanged at 520 * (0, 0). This is critical for drawing ContentView correctly. 521 */ 522 @Override 523 public void scrollBy(int x, int y) { 524 mContentViewCore.scrollBy(x, y); 525 } 526 527 @Override 528 public void scrollTo(int x, int y) { 529 mContentViewCore.scrollTo(x, y); 530 } 531 532 @Override 533 protected int computeHorizontalScrollExtent() { 534 // TODO (dtrainor): Need to expose scroll events properly to public. Either make getScroll* 535 // work or expose computeHorizontalScrollOffset()/computeVerticalScrollOffset as public. 536 return mContentViewCore.computeHorizontalScrollExtent(); 537 } 538 539 @Override 540 protected int computeHorizontalScrollOffset() { 541 return mContentViewCore.computeHorizontalScrollOffset(); 542 } 543 544 @Override 545 protected int computeHorizontalScrollRange() { 546 return mContentViewCore.computeHorizontalScrollRange(); 547 } 548 549 @Override 550 protected int computeVerticalScrollExtent() { 551 return mContentViewCore.computeVerticalScrollExtent(); 552 } 553 554 @Override 555 protected int computeVerticalScrollOffset() { 556 return mContentViewCore.computeVerticalScrollOffset(); 557 } 558 559 @Override 560 protected int computeVerticalScrollRange() { 561 return mContentViewCore.computeVerticalScrollRange(); 562 } 563 564 // End FrameLayout overrides. 565 566 @Override 567 public boolean awakenScrollBars(int startDelay, boolean invalidate) { 568 return mContentViewCore.awakenScrollBars(startDelay, invalidate); 569 } 570 571 @Override 572 public boolean awakenScrollBars() { 573 return super.awakenScrollBars(); 574 } 575 576 public int getSingleTapX() { 577 return mContentViewCore.getContentViewGestureHandler().getSingleTapX(); 578 } 579 580 public int getSingleTapY() { 581 return mContentViewCore.getContentViewGestureHandler().getSingleTapY(); 582 } 583 584 @Override 585 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { 586 super.onInitializeAccessibilityNodeInfo(info); 587 mContentViewCore.onInitializeAccessibilityNodeInfo(info); 588 } 589 590 /** 591 * Fills in scrolling values for AccessibilityEvents. 592 * @param event Event being fired. 593 */ 594 @Override 595 public void onInitializeAccessibilityEvent(AccessibilityEvent event) { 596 super.onInitializeAccessibilityEvent(event); 597 mContentViewCore.onInitializeAccessibilityEvent(event); 598 } 599 600 @Override 601 protected void onAttachedToWindow() { 602 super.onAttachedToWindow(); 603 mContentViewCore.onAttachedToWindow(); 604 } 605 606 @Override 607 protected void onDetachedFromWindow() { 608 super.onDetachedFromWindow(); 609 mContentViewCore.onDetachedFromWindow(); 610 } 611 612 @Override 613 protected void onVisibilityChanged(View changedView, int visibility) { 614 super.onVisibilityChanged(changedView, visibility); 615 mContentViewCore.onVisibilityChanged(changedView, visibility); 616 } 617 618 /** 619 * Register the delegate to be used when content can not be handled by 620 * the rendering engine, and should be downloaded instead. This will replace 621 * the current delegate. 622 * @param delegate An implementation of ContentViewDownloadDelegate. 623 */ 624 public void setDownloadDelegate(ContentViewDownloadDelegate delegate) { 625 mContentViewCore.setDownloadDelegate(delegate); 626 } 627 628 // Called by DownloadController. 629 ContentViewDownloadDelegate getDownloadDelegate() { 630 return mContentViewCore.getDownloadDelegate(); 631 } 632 633 public boolean getUseDesktopUserAgent() { 634 return mContentViewCore.getUseDesktopUserAgent(); 635 } 636 637 /** 638 * Set whether or not we're using a desktop user agent for the currently loaded page. 639 * @param override If true, use a desktop user agent. Use a mobile one otherwise. 640 * @param reloadOnChange Reload the page if the UA has changed. 641 */ 642 public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange) { 643 mContentViewCore.setUseDesktopUserAgent(override, reloadOnChange); 644 } 645 646 /** 647 * @return Whether the native ContentView has crashed. 648 */ 649 public boolean isCrashed() { 650 return mContentViewCore.isCrashed(); 651 } 652 653 /** 654 * @return Whether a reload happens when this ContentView is activated. 655 */ 656 public boolean needsReload() { 657 return mContentViewCore.needsReload(); 658 } 659 660 /** 661 * Checks whether the WebView can be zoomed in. 662 * 663 * @return True if the WebView can be zoomed in. 664 */ 665 // This method uses the term 'zoom' for legacy reasons, but relates 666 // to what chrome calls the 'page scale factor'. 667 public boolean canZoomIn() { 668 return mContentViewCore.canZoomIn(); 669 } 670 671 /** 672 * Checks whether the WebView can be zoomed out. 673 * 674 * @return True if the WebView can be zoomed out. 675 */ 676 // This method uses the term 'zoom' for legacy reasons, but relates 677 // to what chrome calls the 'page scale factor'. 678 public boolean canZoomOut() { 679 return mContentViewCore.canZoomOut(); 680 } 681 682 /** 683 * Zooms in the WebView by 25% (or less if that would result in zooming in 684 * more than possible). 685 * 686 * @return True if there was a zoom change, false otherwise. 687 */ 688 // This method uses the term 'zoom' for legacy reasons, but relates 689 // to what chrome calls the 'page scale factor'. 690 public boolean zoomIn() { 691 return mContentViewCore.zoomIn(); 692 } 693 694 /** 695 * Zooms out the WebView by 20% (or less if that would result in zooming out 696 * more than possible). 697 * 698 * @return True if there was a zoom change, false otherwise. 699 */ 700 // This method uses the term 'zoom' for legacy reasons, but relates 701 // to what chrome calls the 'page scale factor'. 702 public boolean zoomOut() { 703 return mContentViewCore.zoomOut(); 704 } 705 706 /** 707 * Resets the zoom factor of the WebView. 708 * 709 * @return True if there was a zoom change, false otherwise. 710 */ 711 // This method uses the term 'zoom' for legacy reasons, but relates 712 // to what chrome calls the 'page scale factor'. 713 public boolean zoomReset() { 714 return mContentViewCore.zoomReset(); 715 } 716 717 /** 718 * Return the current scale of the WebView 719 * @return The current scale. 720 */ 721 public float getScale() { 722 return mContentViewCore.getScale(); 723 } 724 725 /** 726 * If the view is ready to draw contents to the screen. In hardware mode, 727 * the initialization of the surface texture may not occur until after the 728 * view has been added to the layout. This method will return {@code true} 729 * once the texture is actually ready. 730 */ 731 public boolean isReady() { 732 return mContentViewCore.isReady(); 733 } 734 735 /** 736 * Returns whether or not accessibility injection is being used. 737 */ 738 public boolean isInjectingAccessibilityScript() { 739 return mContentViewCore.isInjectingAccessibilityScript(); 740 } 741 742 /** 743 * Enable or disable accessibility features. 744 */ 745 public void setAccessibilityState(boolean state) { 746 mContentViewCore.setAccessibilityState(state); 747 } 748 749 /** 750 * Stop any TTS notifications that are currently going on. 751 */ 752 public void stopCurrentAccessibilityNotifications() { 753 mContentViewCore.stopCurrentAccessibilityNotifications(); 754 } 755 756 /** 757 * Inform WebKit that Fullscreen mode has been exited by the user. 758 */ 759 public void exitFullscreen() { 760 mContentViewCore.exitFullscreen(); 761 } 762 763 /** 764 * Return content scroll y. 765 * 766 * @return The vertical scroll position in pixels. 767 */ 768 public int getContentScrollY() { 769 return mContentViewCore.computeVerticalScrollOffset(); 770 } 771 772 /** 773 * Return content height. 774 * 775 * @return The height of the content in pixels. 776 */ 777 public int getContentHeight() { 778 return mContentViewCore.computeVerticalScrollRange(); 779 } 780 781 /////////////////////////////////////////////////////////////////////////////////////////////// 782 // Start Implementation of ContentViewCore.InternalAccessDelegate // 783 /////////////////////////////////////////////////////////////////////////////////////////////// 784 785 @Override 786 public boolean super_onKeyUp(int keyCode, KeyEvent event) { 787 return super.onKeyUp(keyCode, event); 788 } 789 790 @Override 791 public boolean super_dispatchKeyEventPreIme(KeyEvent event) { 792 return super.dispatchKeyEventPreIme(event); 793 } 794 795 @Override 796 public boolean super_dispatchKeyEvent(KeyEvent event) { 797 return super.dispatchKeyEvent(event); 798 } 799 800 @Override 801 public boolean super_onGenericMotionEvent(MotionEvent event) { 802 return super.onGenericMotionEvent(event); 803 } 804 805 @Override 806 public void super_onConfigurationChanged(Configuration newConfig) { 807 super.onConfigurationChanged(newConfig); 808 } 809 810 @Override 811 public boolean super_awakenScrollBars(int startDelay, boolean invalidate) { 812 return super.awakenScrollBars(startDelay, invalidate); 813 } 814 815 /////////////////////////////////////////////////////////////////////////////////////////////// 816 // End Implementation of ContentViewCore.InternalAccessDelegate // 817 /////////////////////////////////////////////////////////////////////////////////////////////// 818} 819