Bug 776547 - Add text selection support for web apps. r=wesj a=lsblakk
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Mon, 23 Jul 2012 15:41:55 -0700
changeset 102176 6addc3c4408ecdaca3e572dbcf3bd4d11f19daae
parent 102175 63e4dbbffa2c62542672da074a1b958d3e79c6e5
child 102177 77e31940e4dc2a55ea133ae2b956e2bbd6098538
push id1756
push usermleibovic@mozilla.com
push dateMon, 23 Jul 2012 23:27:54 +0000
treeherdermozilla-aurora@6addc3c4408e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj, lsblakk
bugs776547
milestone16.0a2
Bug 776547 - Add text selection support for web apps. r=wesj a=lsblakk
mobile/android/base/Makefile.in
mobile/android/base/TextSelection.java
mobile/android/base/resources/layout-xlarge-v11/gecko_app.xml.in
mobile/android/base/resources/layout/gecko_app.xml.in
mobile/android/base/resources/layout/shared_ui_components.xml
mobile/android/base/resources/layout/web_app.xml
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -284,16 +284,17 @@ RES_LAYOUT = \
   res/layout/launch_app_listitem.xml \
   res/layout/menu_item.xml \
   res/layout/menu_popup.xml \
   res/layout/notification_icon_text.xml \
   res/layout/notification_progress.xml \
   res/layout/notification_progress_text.xml \
   res/layout/site_setting_title.xml \
   res/layout/setup_screen.xml \
+  res/layout/shared_ui_components.xml \
   res/layout/site_identity_popup.xml \
   res/layout/remote_tabs.xml \
   res/layout/remote_tabs_child.xml \
   res/layout/remote_tabs_group.xml \
   res/layout/tabs_counter.xml \
   res/layout/tabs_panel.xml \
   res/layout/tabs_panel_toolbar.xml \
   res/layout/tabs_panel_toolbar_menu.xml \
--- a/mobile/android/base/TextSelection.java
+++ b/mobile/android/base/TextSelection.java
@@ -13,19 +13,24 @@ class TextSelection implements GeckoEven
 
     private final TextSelectionHandle mStartHandle;
     private final TextSelectionHandle mEndHandle;
 
     TextSelection(TextSelectionHandle startHandle, TextSelectionHandle endHandle) {
         mStartHandle = startHandle;
         mEndHandle = endHandle;
 
-        GeckoAppShell.registerGeckoEventListener("TextSelection:ShowHandles", this);
-        GeckoAppShell.registerGeckoEventListener("TextSelection:HideHandles", this);
-        GeckoAppShell.registerGeckoEventListener("TextSelection:PositionHandles", this);
+        // Only register listeners if we have valid start/end handles
+        if (mStartHandle == null || mEndHandle == null) {
+            Log.e(LOGTAG, "Failed to initialize text selection because at least one handle is null");
+        } else {
+            GeckoAppShell.registerGeckoEventListener("TextSelection:ShowHandles", this);
+            GeckoAppShell.registerGeckoEventListener("TextSelection:HideHandles", this);
+            GeckoAppShell.registerGeckoEventListener("TextSelection:PositionHandles", this);
+        }
     }
 
     void destroy() {
         GeckoAppShell.unregisterGeckoEventListener("TextSelection:ShowHandles", this);
         GeckoAppShell.unregisterGeckoEventListener("TextSelection:HideHandles", this);
         GeckoAppShell.unregisterGeckoEventListener("TextSelection:PositionHandles", this);
     }
 
--- a/mobile/android/base/resources/layout-xlarge-v11/gecko_app.xml.in
+++ b/mobile/android/base/resources/layout-xlarge-v11/gecko_app.xml.in
@@ -20,33 +20,23 @@
  
         <!-- BrowserToolbar will be added dynamically -->
         
         <RelativeLayout android:id="@+id/gecko_layout"
                         android:layout_width="fill_parent"
                         android:layout_height="fill_parent"
                         android:layout_weight="1">
 
-            <AbsoluteLayout android:id="@+id/plugin_container"
-                            android:background="@android:color/transparent"
-                            android:layout_width="fill_parent"
-                            android:layout_height="fill_parent"/>
-
-            <org.mozilla.gecko.FormAssistPopup android:id="@+id/form_assist_popup"
-                                               android:layout_width="fill_parent"
-                                               android:layout_height="fill_parent"
-                                               android:visibility="gone"/>
+            <include layout="@layout/shared_ui_components"/>
 
             <org.mozilla.gecko.AboutHomeContent android:id="@+id/abouthome_content"
                                                 android:layout_width="fill_parent"
                                                 android:layout_height="fill_parent"
                                                 android:background="@drawable/abouthome_bg_repeat"/>
 
-            <include layout="@layout/text_selection_handles"/>
-
         </RelativeLayout>
 
         <org.mozilla.gecko.FindInPageBar android:id="@+id/find_in_page"
                                          android:layout_width="fill_parent"
                                          android:layout_height="wrap_content"
                                          android:layout_gravity="bottom"
                                          style="@style/FindBar"
                                          android:visibility="gone"/>
--- a/mobile/android/base/resources/layout/gecko_app.xml.in
+++ b/mobile/android/base/resources/layout/gecko_app.xml.in
@@ -20,33 +20,23 @@
  
         <!-- BrowserToolbar will be added dynamically -->
 
         <RelativeLayout android:id="@+id/gecko_layout"
                         android:layout_width="fill_parent"
                         android:layout_height="fill_parent"
                         android:layout_weight="1">
 
-            <AbsoluteLayout android:id="@+id/plugin_container"
-                            android:background="@android:color/transparent"
-                            android:layout_width="fill_parent"
-                            android:layout_height="fill_parent"/>
-
-            <org.mozilla.gecko.FormAssistPopup android:id="@+id/form_assist_popup"
-                                               android:layout_width="fill_parent"
-                                               android:layout_height="fill_parent"
-                                               android:visibility="gone"/>
+            <include layout="@layout/shared_ui_components"/>
 
             <org.mozilla.gecko.AboutHomeContent android:id="@+id/abouthome_content"
                                                 android:layout_width="fill_parent"
                                                 android:layout_height="fill_parent"
                                                 android:background="@drawable/abouthome_bg_repeat"/>
 
-            <include layout="@layout/text_selection_handles"/>
-
         </RelativeLayout>
 
         <org.mozilla.gecko.FindInPageBar android:id="@+id/find_in_page"
                                          android:layout_width="fill_parent"
                                          android:layout_height="wrap_content"
                                          android:layout_gravity="bottom"
                                          style="@style/FindBar"
                                          android:visibility="gone"/>
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/resources/layout/shared_ui_components.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<!-- This file is used to include shared UI components in different gecko app
+     layouts, such as gecko_app.xml and web_app.xml -->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <AbsoluteLayout android:id="@+id/plugin_container"
+                    android:background="@android:color/transparent"
+                    android:layout_width="fill_parent"
+                    android:layout_height="fill_parent"/>
+
+    <org.mozilla.gecko.FormAssistPopup android:id="@+id/form_assist_popup"
+                                       android:layout_width="fill_parent"
+                                       android:layout_height="fill_parent"
+                                       android:visibility="gone"/>
+
+    <include layout="@layout/text_selection_handles"/>
+
+</merge>
--- a/mobile/android/base/resources/layout/web_app.xml
+++ b/mobile/android/base/resources/layout/web_app.xml
@@ -3,21 +3,13 @@
               android:id="@+id/main_layout"
               style="@style/Screen">
 
     <RelativeLayout android:id="@+id/gecko_layout"
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent"
                     android:layout_weight="1">
 
-        <AbsoluteLayout android:id="@+id/plugin_container"
-                        android:background="@android:color/transparent"
-                        android:layout_width="fill_parent"
-                        android:layout_height="fill_parent"/>
-
-        <org.mozilla.gecko.FormAssistPopup android:id="@+id/form_assist_popup"
-                                           android:layout_width="fill_parent"
-                                           android:layout_height="fill_parent"
-                                           android:visibility="gone"/>
+        <include layout="@layout/shared_ui_components"/>
 
    </RelativeLayout>
 
 </LinearLayout>