Merge change I7f11a67a into eclair-mr2

* changes:
  Properly integrate the software codecs into the OMXCodec::Create hierarchy of available components.
diff --git a/core/java/android/provider/Calendar.java b/core/java/android/provider/Calendar.java
index 5e36852..a52b86a 100644
--- a/core/java/android/provider/Calendar.java
+++ b/core/java/android/provider/Calendar.java
@@ -85,11 +85,6 @@
     public interface CalendarsColumns
     {
         /**
-         * A string that uniquely identifies this contact to its source
-         */
-        public static final String SOURCE_ID = "sourceid";
-
-        /**
          * The color of the calendar
          * <P>Type: INTEGER (color value)</P>
          */
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index b5c9900..e98d8ee 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -376,6 +376,124 @@
     }
 
     /**
+     * Constants for various styles of combining given name, family name etc into
+     * a full name.  For example, the western tradition follows the pattern
+     * 'given name' 'middle name' 'family name' with the alternative pattern being
+     * 'family name', 'given name' 'middle name'.  The CJK tradition is
+     * 'family name' 'middle name' 'given name', with Japanese favoring a space between
+     * the names and Chinese omitting the space.
+     * @hide
+     */
+    public interface FullNameStyle {
+        public static final int UNDEFINED = 0;
+        public static final int WESTERN = 1;
+
+        /**
+         * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
+         * which specific language it belongs to: Chinese, Japanese or Korean.
+         */
+        public static final int CJK = 2;
+
+        public static final int CHINESE = 3;
+        public static final int JAPANESE = 4;
+        public static final int KOREAN = 5;
+    }
+
+    /**
+     * Constants for various styles of capturing the pronunciation of a person's name.
+     * @hide
+     */
+    public interface PhoneticNameStyle {
+        public static final int UNDEFINED = 0;
+
+        /**
+         * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
+         * shown in UIs, but used for searches and sorting.
+         */
+        public static final int PINYIN = 3;
+
+        /**
+         * Hiragana and Katakana are two common styles of writing out the pronunciation
+         * of a Japanese names.
+         */
+        public static final int JAPANESE = 4;
+
+        /**
+         * Hangul is the Korean phonetic alphabet.
+         */
+        public static final int KOREAN = 5;
+    }
+
+    /**
+     * Types of data used to produce the display name for a contact. Listed in the order
+     * of increasing priority.
+     *
+     * @hide
+     */
+    public interface DisplayNameSources {
+        public static final int UNDEFINED = 0;
+        public static final int EMAIL = 10;
+        public static final int PHONE = 20;
+        public static final int ORGANIZATION = 30;
+        public static final int NICKNAME = 35;
+        public static final int STRUCTURED_NAME = 40;
+    }
+
+    /**
+     * @see Contacts
+     * @see RawContacts
+     * @hide
+     */
+    protected interface ContactNameColumns {
+
+        /**
+         * The kind of data that is used as the display name for the contact, see
+         * DisplayNameSources.
+         */
+        public static final String DISPLAY_NAME_SOURCE = "display_name_source";
+
+        /**
+         * The default text shown as the contact's display name.  It is based on
+         * available data, see {@link #DISPLAY_NAME_SOURCE}.
+         */
+        public static final String DISPLAY_NAME = "display_name";
+
+        /**
+         * Alternative representation of the display name.  If display name is
+         * based on the structured name and the structured name follows
+         * the Western full name style, then this field contains the "family name first"
+         * version of the full name.  Otherwise, it is the same as {@link #DISPLAY_NAME}.
+         */
+        public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
+
+        /**
+         * The type of alphabet used to capture the phonetic name.  See
+         * PhoneticNameStyle.
+         */
+        public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
+
+        /**
+         * Pronunciation of the full name. See PhoneticNameStyle.
+         */
+        public static final String PHONETIC_NAME = "phonetic_name";
+
+        /**
+         * Sort key that takes into account locale-based traditions for sorting
+         * names in address books.  More specifically, for Chinese names
+         * the sort key is the name's Pinyin spelling; for Japanese names
+         * it is the Hiragana version of the phonetic name.
+         */
+        public static final String SORT_KEY = "sort_key";
+
+        /**
+         * Sort key based on the alternative representation of the full name,
+         * specifically the one using the 'family name first' format for
+         * Western names.
+         */
+        public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
+    }
+
+    /**
      * Constants for the contacts table, which contains a record per aggregate
      * of raw contacts representing the same person.
      * <h3>Operations</h3>
@@ -1234,7 +1352,7 @@
      * </table>
      */
     public static final class RawContacts implements BaseColumns, RawContactsColumns,
-            ContactOptionsColumns, SyncColumns  {
+            ContactOptionsColumns, ContactNameColumns, SyncColumns  {
         /**
          * This utility class cannot be instantiated
          */
@@ -2889,6 +3007,21 @@
              * <P>Type: TEXT</P>
              */
             public static final String PHONETIC_FAMILY_NAME = DATA9;
+
+            /**
+             * The style used for combining given/middle/family name into a full name.
+             * See {@link ContactsContract.FullNameStyle}.
+             *
+             * @hide
+             */
+            public static final String FULL_NAME_STYLE = DATA10;
+
+            /**
+             * The alphabet used for capturing the phonetic name.
+             * See {@link ContactsContract.PhoneticNameStyle}.
+             * @hide
+             */
+            public static final String PHONETIC_NAME_STYLE = DATA11;
         }
 
         /**
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index a974653..7d49cb6a 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -486,6 +486,7 @@
     // obj=Rect in doc coordinates
     static final int INVAL_RECT_MSG_ID                  = 26;
     static final int REQUEST_KEYBOARD                   = 27;
+    static final int DO_MOTION_UP                       = 28;
 
     static final String[] HandlerDebugString = {
         "REMEMBER_PASSWORD", //              = 1;
@@ -514,7 +515,8 @@
         "PREVENT_TOUCH_ID", //               = 24;
         "WEBCORE_NEED_TOUCH_EVENTS", //      = 25;
         "INVAL_RECT_MSG_ID", //              = 26;
-        "REQUEST_KEYBOARD" //                = 27;
+        "REQUEST_KEYBOARD", //               = 27;
+        "DO_MOTION_UP" //                    = 28;
     };
 
     // If the site doesn't use the viewport meta tag to specify the viewport,
@@ -4852,7 +4854,23 @@
         // mLastTouchX and mLastTouchY are the point in the current viewport
         int contentX = viewToContentX((int) mLastTouchX + mScrollX);
         int contentY = viewToContentY((int) mLastTouchY + mScrollY);
-        if (nativeMotionUp(contentX, contentY, mNavSlop)) {
+        if (nativePointInNavCache(contentX, contentY, mNavSlop)) {
+            WebViewCore.MotionUpData motionUpData = new WebViewCore
+                    .MotionUpData();
+            motionUpData.mFrame = nativeCacheHitFramePointer();
+            motionUpData.mNode = nativeCacheHitNodePointer();
+            motionUpData.mBounds = nativeCacheHitNodeBounds();
+            motionUpData.mX = contentX;
+            motionUpData.mY = contentY;
+            mWebViewCore.sendMessageAtFrontOfQueue(EventHub.VALID_NODE_BOUNDS,
+                    motionUpData);
+        } else {
+            doMotionUp(contentX, contentY, false);
+        }
+    }
+
+    private void doMotionUp(int contentX, int contentY, boolean useNavCache) {
+        if (nativeMotionUp(contentX, contentY, useNavCache ? mNavSlop : 0)) {
             if (mLogEvent) {
                 Checkin.updateStats(mContext.getContentResolver(),
                         Checkin.Stats.Tag.BROWSER_SNAP_CENTER, 1, 0.0);
@@ -5097,7 +5115,7 @@
             // exclude INVAL_RECT_MSG_ID since it is frequently output
             if (DebugFlags.WEB_VIEW && msg.what != INVAL_RECT_MSG_ID) {
                 Log.v(LOGTAG, msg.what < REMEMBER_PASSWORD || msg.what
-                        > REQUEST_KEYBOARD ? Integer.toString(msg.what)
+                        > DO_MOTION_UP ? Integer.toString(msg.what)
                         : HandlerDebugString[msg.what - REMEMBER_PASSWORD]);
             }
             if (mWebViewCore == null) {
@@ -5443,6 +5461,11 @@
                                 ViewConfiguration.getScrollDefaultDelay());
                     }
                     break;
+
+                case DO_MOTION_UP:
+                    doMotionUp(msg.arg1, msg.arg2, (Boolean) msg.obj);
+                    break;
+
                 default:
                     super.handleMessage(msg);
                     break;
@@ -5931,6 +5954,9 @@
         nativeUpdateCachedTextfield(updatedText, mTextGeneration);
     }
 
+    private native int nativeCacheHitFramePointer();
+    private native Rect nativeCacheHitNodeBounds();
+    private native int nativeCacheHitNodePointer();
     /* package */ native void nativeClearCursor();
     private native void     nativeCreate(int ptr);
     private native int      nativeCursorFramePointer();
@@ -5992,6 +6018,7 @@
     private native int      nativeMoveGeneration();
     private native void     nativeMoveSelection(int x, int y,
             boolean extendSelection);
+    private native boolean  nativePointInNavCache(int x, int y, int slop);
     // Like many other of our native methods, you must make sure that
     // mNativeClass is not null before calling this method.
     private native void     nativeRecordButtons(boolean focused,
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index f542cb0..e198ee8 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -683,6 +683,14 @@
         KeyEvent mEvent;
     }
 
+    static class MotionUpData {
+        int mFrame;
+        int mNode;
+        Rect mBounds;
+        int mX;
+        int mY;
+    }
+
     static class PostUrlData {
         String mUrl;
         byte[] mPostData;
@@ -778,6 +786,7 @@
             "ON_PAUSE",     // = 143
             "ON_RESUME",    // = 144
             "FREE_MEMORY",  // = 145
+            "VALID_NODE_BOUNDS", // = 146
         };
 
     class EventHub {
@@ -841,6 +850,7 @@
         static final int ON_PAUSE = 143;
         static final int ON_RESUME = 144;
         static final int FREE_MEMORY = 145;
+        static final int VALID_NODE_BOUNDS = 146;
 
         // Network-based messaging
         static final int CLEAR_SSL_PREF_TABLE = 150;
@@ -893,7 +903,7 @@
                     if (DebugFlags.WEB_VIEW_CORE) {
                         Log.v(LOGTAG, (msg.what < UPDATE_FRAME_CACHE_IF_LOADING
                                 || msg.what
-                                > FREE_MEMORY ? Integer.toString(msg.what)
+                                > VALID_NODE_BOUNDS ? Integer.toString(msg.what)
                                 : HandlerDebugString[msg.what
                                         - UPDATE_FRAME_CACHE_IF_LOADING])
                                 + " arg1=" + msg.arg1 + " arg2=" + msg.arg2
@@ -1289,6 +1299,20 @@
                         case POPULATE_VISITED_LINKS:
                             nativeProvideVisitedHistory((String[])msg.obj);
                             break;
+
+                        case VALID_NODE_BOUNDS: {
+                            MotionUpData motionUpData = (MotionUpData) msg.obj;
+                            boolean result = nativeValidNodeAndBounds(
+                                    motionUpData.mFrame, motionUpData.mNode,
+                                    motionUpData.mBounds);
+                            Message message = mWebView.mPrivateHandler
+                                    .obtainMessage(WebView.DO_MOTION_UP,
+                                    motionUpData.mX, motionUpData.mY,
+                                    new Boolean(result));
+                            mWebView.mPrivateHandler.sendMessageAtFrontOfQueue(
+                                    message);
+                            break;
+                        }
                     }
                 }
             };
@@ -1432,6 +1456,11 @@
         mEventHub.sendMessage(Message.obtain(null, what, arg1, arg2, obj));
     }
 
+    void sendMessageAtFrontOfQueue(int what, Object obj) {
+        mEventHub.sendMessageAtFrontOfQueue(Message.obtain(
+                null, what, obj));
+    }
+
     void sendMessageDelayed(int what, Object obj, long delay) {
         mEventHub.sendMessageDelayed(Message.obtain(null, what, obj), delay);
     }
@@ -2275,4 +2304,7 @@
     private native void nativeResume();
     private native void nativeFreeMemory();
     private native void nativeFullScreenPluginHidden(int npp);
+    private native boolean nativeValidNodeAndBounds(int frame, int node,
+            Rect bounds);
+
 }
diff --git a/core/res/res/values-en-rUS/donottranslate-names.xml b/core/res/res/values-en-rUS/donottranslate-names.xml
index ae38ddf..f8ec765 100644
--- a/core/res/res/values-en-rUS/donottranslate-names.xml
+++ b/core/res/res/values-en-rUS/donottranslate-names.xml
@@ -156,8 +156,8 @@
         MRS, MS, PASTOR, PROF, REP, REVEREND, REV, SEN, ST
     </string>
     <string name="common_name_suffixes">
-        B.A., BA, D.D.S., DDS, I, II, III, IV, IX, JR, M.A., M.D, MA,
-        MD, MS, PH.D., PHD, SR, V, VI, VII, VIII, X
+        B.A., BA, D.D.S., DDS, I, II, III, IV, IX, JR., M.A., M.D., MA,
+        MD, MS, PH.D., PHD, SR., V, VI, VII, VIII, X
     </string>
     <string name="common_last_name_prefixes">
         D\', DE, DEL, DI, LA, LE, MC, SAN, ST, TER, VAN, VON