diff --git a/accessible/src/atk/AccessibleWrap.cpp b/accessible/src/atk/AccessibleWrap.cpp index 95ad19303e97..061af8e7b3bb 100644 --- a/accessible/src/atk/AccessibleWrap.cpp +++ b/accessible/src/atk/AccessibleWrap.cpp @@ -141,11 +141,6 @@ struct MaiAtkObjectClass static guint mai_atk_object_signals [LAST_SIGNAL] = { 0, }; -#ifdef MAI_LOGGING -int32_t sMaiAtkObjCreated = 0; -int32_t sMaiAtkObjDeleted = 0; -#endif - G_BEGIN_DECLS /* callbacks for MaiAtkObject */ static void classInitCB(AtkObjectClass *aClass); @@ -232,33 +227,15 @@ mai_atk_object_get_type(void) return type; } -#ifdef MAI_LOGGING -int32_t AccessibleWrap::mAccWrapCreated = 0; -int32_t AccessibleWrap::mAccWrapDeleted = 0; -#endif - AccessibleWrap:: AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) : Accessible(aContent, aDoc), mAtkObject(nullptr) { -#ifdef MAI_LOGGING - ++mAccWrapCreated; -#endif - MAI_LOG_DEBUG(("==AccessibleWrap creating: this=%p,total=%d left=%d\n", - (void*)this, mAccWrapCreated, - (mAccWrapCreated-mAccWrapDeleted))); } AccessibleWrap::~AccessibleWrap() { NS_ASSERTION(!mAtkObject, "ShutdownAtkObject() is not called"); - -#ifdef MAI_LOGGING - ++mAccWrapDeleted; -#endif - MAI_LOG_DEBUG(("==AccessibleWrap deleting: this=%p,total=%d left=%d\n", - (void*)this, mAccWrapDeleted, - (mAccWrapCreated-mAccWrapDeleted))); } void @@ -482,8 +459,6 @@ GetUniqueMaiAtkTypeName(uint16_t interfacesBits) interfacesBits); name[MAI_ATK_TYPE_NAME_LEN] = '\0'; - MAI_LOG_DEBUG(("MaiWidget::LastedTypeName=%s\n", name)); - return name; } @@ -603,13 +578,6 @@ initializeCB(AtkObject *aAtkObj, gpointer aData) /* initialize object */ MAI_ATK_OBJECT(aAtkObj)->accWrap = static_cast(aData); - -#ifdef MAI_LOGGING - ++sMaiAtkObjCreated; -#endif - MAI_LOG_DEBUG(("MaiAtkObj Create obj=%p for AccWrap=%p, all=%d, left=%d\n", - (void*)aAtkObj, (void*)aData, sMaiAtkObjCreated, - (sMaiAtkObjCreated-sMaiAtkObjDeleted))); } void @@ -619,13 +587,6 @@ finalizeCB(GObject *aObj) return; NS_ASSERTION(MAI_ATK_OBJECT(aObj)->accWrap == nullptr, "AccWrap NOT null"); -#ifdef MAI_LOGGING - ++sMaiAtkObjDeleted; -#endif - MAI_LOG_DEBUG(("MaiAtkObj Delete obj=%p, all=%d, left=%d\n", - (void*)aObj, sMaiAtkObjCreated, - (sMaiAtkObjCreated-sMaiAtkObjDeleted))); - // call parent finalize function // finalize of GObjectClass will unref the accessible parent if has if (G_OBJECT_CLASS (parent_class)->finalize) @@ -992,7 +953,6 @@ AccessibleWrap::FirePlatformEvent(AccEvent* aEvent) case nsIAccessibleEvent::EVENT_FOCUS: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_FOCUS\n")); a11y::RootAccessible* rootAccWrap = accWrap->RootAccessible(); if (rootAccWrap && rootAccWrap->mActivated) { atk_focus_tracker_notify(atkObj); @@ -1015,7 +975,6 @@ AccessibleWrap::FirePlatformEvent(AccEvent* aEvent) } case nsIAccessibleEvent::EVENT_VALUE_CHANGE: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_VALUE_CHANGE\n")); nsCOMPtr value(do_QueryObject(accessible)); if (value) { // Make sure this is a numeric value // Don't fire for MSAA string value changes (e.g. text editing) @@ -1029,7 +988,6 @@ AccessibleWrap::FirePlatformEvent(AccEvent* aEvent) case nsIAccessibleEvent::EVENT_SELECTION_REMOVE: { // XXX: dupe events may be fired - MAI_LOG_DEBUG(("\n\nReceived: EVENT_SELECTION_CHANGED\n")); AccSelChangeEvent* selChangeEvent = downcast_accEvent(aEvent); g_signal_emit_by_name(AccessibleWrap::GetAtkObject(selChangeEvent->Widget()), "selection_changed"); @@ -1038,128 +996,86 @@ AccessibleWrap::FirePlatformEvent(AccEvent* aEvent) case nsIAccessibleEvent::EVENT_SELECTION_WITHIN: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_SELECTION_CHANGED\n")); g_signal_emit_by_name(atkObj, "selection_changed"); break; } case nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TEXT_SELECTION_CHANGED\n")); g_signal_emit_by_name(atkObj, "text_selection_changed"); break; case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TEXT_CARET_MOVED\n")); - AccCaretMoveEvent* caretMoveEvent = downcast_accEvent(aEvent); NS_ASSERTION(caretMoveEvent, "Event needs event data"); if (!caretMoveEvent) break; int32_t caretOffset = caretMoveEvent->GetCaretOffset(); - - MAI_LOG_DEBUG(("\n\nCaret postion: %d", caretOffset)); - g_signal_emit_by_name(atkObj, - "text_caret_moved", - // Curent caret position - caretOffset); + g_signal_emit_by_name(atkObj, "text_caret_moved", caretOffset); } break; case nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TEXT_ATTRIBUTE_CHANGED\n")); - - g_signal_emit_by_name(atkObj, - "text-attributes-changed"); + g_signal_emit_by_name(atkObj, "text-attributes-changed"); break; case nsIAccessibleEvent::EVENT_TABLE_MODEL_CHANGED: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_MODEL_CHANGED\n")); g_signal_emit_by_name(atkObj, "model_changed"); break; case nsIAccessibleEvent::EVENT_TABLE_ROW_INSERT: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_ROW_INSERT\n")); AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent); NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE); int32_t rowIndex = tableEvent->GetIndex(); int32_t numRows = tableEvent->GetCount(); - g_signal_emit_by_name(atkObj, - "row_inserted", - // After which the rows are inserted - rowIndex, - // The number of the inserted - numRows); + g_signal_emit_by_name(atkObj, "row_inserted", rowIndex, numRows); } break; case nsIAccessibleEvent::EVENT_TABLE_ROW_DELETE: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_ROW_DELETE\n")); AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent); NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE); int32_t rowIndex = tableEvent->GetIndex(); int32_t numRows = tableEvent->GetCount(); - g_signal_emit_by_name(atkObj, - "row_deleted", - // After which the rows are deleted - rowIndex, - // The number of the deleted - numRows); + g_signal_emit_by_name(atkObj, "row_deleted", rowIndex, numRows); } break; case nsIAccessibleEvent::EVENT_TABLE_ROW_REORDER: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_ROW_REORDER\n")); g_signal_emit_by_name(atkObj, "row_reordered"); break; } case nsIAccessibleEvent::EVENT_TABLE_COLUMN_INSERT: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_COLUMN_INSERT\n")); AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent); NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE); int32_t colIndex = tableEvent->GetIndex(); int32_t numCols = tableEvent->GetCount(); - - g_signal_emit_by_name(atkObj, - "column_inserted", - // After which the columns are inserted - colIndex, - // The number of the inserted - numCols); + g_signal_emit_by_name(atkObj, "column_inserted", colIndex, numCols); } break; case nsIAccessibleEvent::EVENT_TABLE_COLUMN_DELETE: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_COLUMN_DELETE\n")); AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent); NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE); int32_t colIndex = tableEvent->GetIndex(); int32_t numCols = tableEvent->GetCount(); - - g_signal_emit_by_name(atkObj, - "column_deleted", - // After which the columns are deleted - colIndex, - // The number of the deleted - numCols); + g_signal_emit_by_name(atkObj, "column_deleted", colIndex, numCols); } break; case nsIAccessibleEvent::EVENT_TABLE_COLUMN_REORDER: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TABLE_COLUMN_REORDER\n")); g_signal_emit_by_name(atkObj, "column_reordered"); break; case nsIAccessibleEvent::EVENT_SECTION_CHANGED: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_SECTION_CHANGED\n")); g_signal_emit_by_name(atkObj, "visible_data_changed"); break; @@ -1176,16 +1092,11 @@ AccessibleWrap::FirePlatformEvent(AccEvent* aEvent) * Need more verification by AT test. */ case nsIAccessibleEvent::EVENT_MENU_START: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_MENU_START\n")); - break; - case nsIAccessibleEvent::EVENT_MENU_END: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_MENU_END\n")); break; case nsIAccessibleEvent::EVENT_WINDOW_ACTIVATE: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_WINDOW_ACTIVATED\n")); accessible->AsRoot()->mActivated = true; guint id = g_signal_lookup ("activate", MAI_TYPE_ATK_OBJECT); g_signal_emit(atkObj, id, 0); @@ -1196,7 +1107,6 @@ AccessibleWrap::FirePlatformEvent(AccEvent* aEvent) case nsIAccessibleEvent::EVENT_WINDOW_DEACTIVATE: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_WINDOW_DEACTIVATED\n")); accessible->AsRoot()->mActivated = false; guint id = g_signal_lookup ("deactivate", MAI_TYPE_ATK_OBJECT); g_signal_emit(atkObj, id, 0); @@ -1204,52 +1114,41 @@ AccessibleWrap::FirePlatformEvent(AccEvent* aEvent) case nsIAccessibleEvent::EVENT_WINDOW_MAXIMIZE: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_WINDOW_MAXIMIZE\n")); guint id = g_signal_lookup ("maximize", MAI_TYPE_ATK_OBJECT); g_signal_emit(atkObj, id, 0); } break; case nsIAccessibleEvent::EVENT_WINDOW_MINIMIZE: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_WINDOW_MINIMIZE\n")); guint id = g_signal_lookup ("minimize", MAI_TYPE_ATK_OBJECT); g_signal_emit(atkObj, id, 0); } break; case nsIAccessibleEvent::EVENT_WINDOW_RESTORE: { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_WINDOW_RESTORE\n")); guint id = g_signal_lookup ("restore", MAI_TYPE_ATK_OBJECT); g_signal_emit(atkObj, id, 0); } break; case nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE: - { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_DOCUMENT_LOAD_COMPLETE\n")); g_signal_emit_by_name (atkObj, "load_complete"); - } break; + break; case nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD: - { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_DOCUMENT_RELOAD\n")); g_signal_emit_by_name (atkObj, "reload"); - } break; + break; case nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED: - { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_DOCUMENT_LOAD_STOPPED\n")); g_signal_emit_by_name (atkObj, "load_stopped"); - } break; + break; case nsIAccessibleEvent::EVENT_MENUPOPUP_START: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_MENUPOPUP_START\n")); atk_focus_tracker_notify(atkObj); // fire extra focus event atk_object_notify_state_change(atkObj, ATK_STATE_VISIBLE, true); atk_object_notify_state_change(atkObj, ATK_STATE_SHOWING, true); break; case nsIAccessibleEvent::EVENT_MENUPOPUP_END: - MAI_LOG_DEBUG(("\n\nReceived: EVENT_MENUPOPUP_END\n")); atk_object_notify_state_change(atkObj, ATK_STATE_VISIBLE, false); atk_object_notify_state_change(atkObj, ATK_STATE_SHOWING, false); break; @@ -1262,8 +1161,6 @@ nsresult AccessibleWrap::FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject* aObject) { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_STATE_CHANGE\n")); - AccStateChangeEvent* event = downcast_accEvent(aEvent); NS_ENSURE_TRUE(event, NS_ERROR_FAILURE); @@ -1294,8 +1191,6 @@ nsresult AccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent, AtkObject* aObject) { - MAI_LOG_DEBUG(("\n\nReceived: EVENT_TEXT_REMOVED/INSERTED\n")); - AccTextChangeEvent* event = downcast_accEvent(aEvent); NS_ENSURE_TRUE(event, NS_ERROR_FAILURE); @@ -1335,12 +1230,6 @@ nsresult AccessibleWrap::FireAtkShowHideEvent(AccEvent* aEvent, AtkObject* aObject, bool aIsAdded) { - if (aIsAdded) { - MAI_LOG_DEBUG(("\n\nReceived: Show event\n")); - } else { - MAI_LOG_DEBUG(("\n\nReceived: Hide event\n")); - } - int32_t indexInParent = getIndexInParentCB(aObject); AtkObject *parentObject = getParentCB(aObject); NS_ENSURE_STATE(parentObject); diff --git a/accessible/src/atk/AccessibleWrap.h b/accessible/src/atk/AccessibleWrap.h index 6c75332b4a32..9143ac7dbcc8 100644 --- a/accessible/src/atk/AccessibleWrap.h +++ b/accessible/src/atk/AccessibleWrap.h @@ -9,11 +9,6 @@ #include "nsCOMPtr.h" #include "Accessible.h" -#include "prlog.h" - -#ifdef PR_LOGGING -#define MAI_LOGGING -#endif /* #ifdef PR_LOGGING */ struct _AtkObject; typedef struct _AtkObject AtkObject; @@ -60,12 +55,6 @@ public: // nsAccessNode virtual void Shutdown(); -#ifdef MAI_LOGGING - virtual void DumpAccessibleWrapInfo(int aDepth) {} - static int32_t mAccWrapCreated; - static int32_t mAccWrapDeleted; -#endif - // return the atk object for this AccessibleWrap NS_IMETHOD GetNativeInterface(void **aOutAccessible); virtual nsresult HandleAccEvent(AccEvent* aEvent); diff --git a/accessible/src/atk/ApplicationAccessibleWrap.cpp b/accessible/src/atk/ApplicationAccessibleWrap.cpp index dbfd787ea45c..65176d16e327 100644 --- a/accessible/src/atk/ApplicationAccessibleWrap.cpp +++ b/accessible/src/atk/ApplicationAccessibleWrap.cpp @@ -33,57 +33,6 @@ static const char sATKLibName[] = "libatk-1.0.so.0"; static const char sATKHyperlinkImplGetTypeSymbol[] = "atk_hyperlink_impl_get_type"; -/* gail function pointer */ -static guint (* gail_add_global_event_listener) (GSignalEmissionHook listener, - const gchar *event_type); -static void (* gail_remove_global_event_listener) (guint remove_listener); -static void (* gail_remove_key_event_listener) (guint remove_listener); -static AtkObject * (*gail_get_root) (void); - -/* maiutil */ - -static guint mai_util_add_global_event_listener(GSignalEmissionHook listener, - const gchar *event_type); -static void mai_util_remove_global_event_listener(guint remove_listener); -static guint mai_util_add_key_event_listener(AtkKeySnoopFunc listener, - gpointer data); -static void mai_util_remove_key_event_listener(guint remove_listener); -static AtkObject *mai_util_get_root(void); -static G_CONST_RETURN gchar *mai_util_get_toolkit_name(void); -static G_CONST_RETURN gchar *mai_util_get_toolkit_version(void); - - -/* Misc */ - -static void _listener_info_destroy(gpointer data); -static guint add_listener (GSignalEmissionHook listener, - const gchar *object_type, - const gchar *signal, - const gchar *hook_data, - guint gail_listenerid = 0); -static AtkKeyEventStruct *atk_key_event_from_gdk_event_key(GdkEventKey *key); -static gboolean notify_hf(gpointer key, gpointer value, gpointer data); -static void insert_hf(gpointer key, gpointer value, gpointer data); -static gint mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event, - gpointer func_data); - -static GHashTable* sListener_list = NULL; -static gint sListener_idx = 1; - -#define MAI_TYPE_UTIL (mai_util_get_type ()) -#define MAI_UTIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MAI_TYPE_UTIL, MaiUtil)) -#define MAI_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MAI_TYPE_UTIL, MaiUtilClass)) -#define MAI_IS_UTIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MAI_TYPE_UTIL)) -#define MAI_IS_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MAI_TYPE_UTIL)) -#define MAI_UTIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MAI_TYPE_UTIL, MaiUtilClass)) - -static GHashTable* sKey_listener_list = NULL; -static guint sKey_snooper_id = 0; static bool sToplevel_event_hook_added = false; static gulong sToplevel_show_hook = 0; static gulong sToplevel_hide_hook = 0; @@ -93,24 +42,6 @@ typedef void (*GnomeAccessibilityInit) (void); typedef void (*GnomeAccessibilityShutdown) (void); G_END_DECLS -struct MaiUtil -{ - AtkUtil parent; - GList *listener_list; -}; - -struct MaiKeyEventInfo -{ - AtkKeyEventStruct *key_event; - gpointer func_data; -}; - -union AtkKeySnoopFuncPointer -{ - AtkKeySnoopFunc func_ptr; - gpointer data; -}; - struct GnomeAccessibilityModule { const char *libName; @@ -121,32 +52,6 @@ struct GnomeAccessibilityModule GnomeAccessibilityShutdown shutdown; }; -struct MaiUtilClass -{ - AtkUtilClass parent_class; -}; - -GType mai_util_get_type (void); -static void mai_util_class_init(MaiUtilClass *klass); - -/* supporting */ -PRLogModuleInfo *gMaiLog = NULL; - -#define MAI_VERSION MOZILLA_VERSION -#define MAI_NAME "Gecko" - -struct MaiUtilListenerInfo -{ - gint key; - guint signal_id; - gulong hook_id; - // For window create/destory/minimize/maximize/restore/activate/deactivate - // events, we'll chain gail_util's add/remove_global_event_listener. - // So we store the listenerid returned by gail's add_global_event_listener - // in this structure to call gail's remove_global_event_listener later. - guint gail_listenerid; -}; - static GnomeAccessibilityModule sAtkBridge = { #ifdef AIX "libatk-bridge.a(libatk-bridge.so.0)", NULL, @@ -163,352 +68,6 @@ static GnomeAccessibilityModule sGail = { "gnome_accessibility_module_shutdown", NULL }; -GType -mai_util_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo tinfo = { - sizeof(MaiUtilClass), - (GBaseInitFunc) NULL, /* base init */ - (GBaseFinalizeFunc) NULL, /* base finalize */ - (GClassInitFunc) mai_util_class_init, /* class init */ - (GClassFinalizeFunc) NULL, /* class finalize */ - NULL, /* class data */ - sizeof(MaiUtil), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) NULL, /* instance init */ - NULL /* value table */ - }; - - type = g_type_register_static(ATK_TYPE_UTIL, - "MaiUtil", &tinfo, GTypeFlags(0)); - } - return type; -} - -static void -window_added (AtkObject *atk_obj, - guint index, - AtkObject *child) -{ - if (!IS_MAI_OBJECT(child)) - return; - - static guint id = g_signal_lookup ("create", MAI_TYPE_ATK_OBJECT); - g_signal_emit (child, id, 0); -} - -static void -window_removed (AtkObject *atk_obj, - guint index, - AtkObject *child) -{ - if (!IS_MAI_OBJECT(child)) - return; - - static guint id = g_signal_lookup ("destroy", MAI_TYPE_ATK_OBJECT); - g_signal_emit (child, id, 0); -} - -/* intialize the the atk interface (function pointers) with MAI implementation. - * When atk bridge get loaded, these interface can be used. - */ -static void -mai_util_class_init(MaiUtilClass *klass) -{ - AtkUtilClass *atk_class; - gpointer data; - - data = g_type_class_peek(ATK_TYPE_UTIL); - atk_class = ATK_UTIL_CLASS(data); - - // save gail function pointer - gail_add_global_event_listener = atk_class->add_global_event_listener; - gail_remove_global_event_listener = atk_class->remove_global_event_listener; - gail_remove_key_event_listener = atk_class->remove_key_event_listener; - gail_get_root = atk_class->get_root; - - atk_class->add_global_event_listener = - mai_util_add_global_event_listener; - atk_class->remove_global_event_listener = - mai_util_remove_global_event_listener; - atk_class->add_key_event_listener = mai_util_add_key_event_listener; - atk_class->remove_key_event_listener = mai_util_remove_key_event_listener; - atk_class->get_root = mai_util_get_root; - atk_class->get_toolkit_name = mai_util_get_toolkit_name; - atk_class->get_toolkit_version = mai_util_get_toolkit_version; - - sListener_list = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, - _listener_info_destroy); - // Keep track of added/removed windows. - AtkObject *root = atk_get_root (); - g_signal_connect (root, "children-changed::add", (GCallback) window_added, NULL); - g_signal_connect (root, "children-changed::remove", (GCallback) window_removed, NULL); -} - -static guint -mai_util_add_global_event_listener(GSignalEmissionHook listener, - const gchar *event_type) -{ - guint rc = 0; - gchar **split_string; - - split_string = g_strsplit (event_type, ":", 3); - - if (split_string) { - if (!strcmp ("window", split_string[0])) { - guint gail_listenerid = 0; - if (gail_add_global_event_listener) { - // call gail's function to track gtk native window events - gail_listenerid = - gail_add_global_event_listener(listener, event_type); - } - - rc = add_listener (listener, "MaiAtkObject", split_string[1], - event_type, gail_listenerid); - } - else { - rc = add_listener (listener, split_string[1], split_string[2], - event_type); - } - g_strfreev(split_string); - } - return rc; -} - -static void -mai_util_remove_global_event_listener(guint remove_listener) -{ - if (remove_listener > 0) { - MaiUtilListenerInfo *listener_info; - gint tmp_idx = remove_listener; - - listener_info = (MaiUtilListenerInfo *) - g_hash_table_lookup(sListener_list, &tmp_idx); - - if (listener_info != NULL) { - if (gail_remove_global_event_listener && - listener_info->gail_listenerid) { - gail_remove_global_event_listener(listener_info->gail_listenerid); - } - - /* Hook id of 0 and signal id of 0 are invalid */ - if (listener_info->hook_id != 0 && listener_info->signal_id != 0) { - /* Remove the emission hook */ - g_signal_remove_emission_hook(listener_info->signal_id, - listener_info->hook_id); - - /* Remove the element from the hash */ - g_hash_table_remove(sListener_list, &tmp_idx); - } - else { - g_warning("Invalid listener hook_id %ld or signal_id %d\n", - listener_info->hook_id, listener_info->signal_id); - } - } - else { - // atk-bridge is initialized with gail (e.g. yelp) - // try gail_remove_global_event_listener - if (gail_remove_global_event_listener) { - return gail_remove_global_event_listener(remove_listener); - } - - g_warning("No listener with the specified listener id %d", - remove_listener); - } - } - else { - g_warning("Invalid listener_id %d", remove_listener); - } -} - -static AtkKeyEventStruct * -atk_key_event_from_gdk_event_key (GdkEventKey *key) -{ - AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1); - switch (key->type) { - case GDK_KEY_PRESS: - event->type = ATK_KEY_EVENT_PRESS; - break; - case GDK_KEY_RELEASE: - event->type = ATK_KEY_EVENT_RELEASE; - break; - default: - g_assert_not_reached (); - return NULL; - } - event->state = key->state; - event->keyval = key->keyval; - event->length = key->length; - if (key->string && key->string [0] && - (key->state & GDK_CONTROL_MASK || - g_unichar_isgraph (g_utf8_get_char (key->string)))) { - event->string = key->string; - } - else if (key->type == GDK_KEY_PRESS || - key->type == GDK_KEY_RELEASE) { - event->string = gdk_keyval_name (key->keyval); - } - event->keycode = key->hardware_keycode; - event->timestamp = key->time; - - MAI_LOG_DEBUG(("MaiKey:\tsym %u\n\tmods %x\n\tcode %u\n\ttime %lx\n", - (unsigned int) event->keyval, - (unsigned int) event->state, - (unsigned int) event->keycode, - (unsigned long int) event->timestamp)); - return event; -} - -static gboolean -notify_hf(gpointer key, gpointer value, gpointer data) -{ - MaiKeyEventInfo *info = (MaiKeyEventInfo *)data; - AtkKeySnoopFuncPointer atkKeySnoop; - atkKeySnoop.data = value; - return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE : FALSE; -} - -static void -insert_hf(gpointer key, gpointer value, gpointer data) -{ - GHashTable *new_table = (GHashTable *) data; - g_hash_table_insert (new_table, key, value); -} - -static gint -mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event, gpointer func_data) -{ - /* notify each AtkKeySnoopFunc in turn... */ - - MaiKeyEventInfo *info = g_new0(MaiKeyEventInfo, 1); - gint consumed = 0; - if (sKey_listener_list) { - GHashTable *new_hash = g_hash_table_new(NULL, NULL); - g_hash_table_foreach (sKey_listener_list, insert_hf, new_hash); - info->key_event = atk_key_event_from_gdk_event_key (event); - info->func_data = func_data; - consumed = g_hash_table_foreach_steal (new_hash, notify_hf, info); - g_hash_table_destroy (new_hash); - g_free(info->key_event); - } - g_free(info); - return (consumed ? 1 : 0); -} - -static guint -mai_util_add_key_event_listener (AtkKeySnoopFunc listener, - gpointer data) -{ - NS_ENSURE_TRUE(listener, 0); - - static guint key=0; - - if (!sKey_listener_list) { - sKey_listener_list = g_hash_table_new(NULL, NULL); - sKey_snooper_id = gtk_key_snooper_install(mai_key_snooper, data); - } - AtkKeySnoopFuncPointer atkKeySnoop; - atkKeySnoop.func_ptr = listener; - g_hash_table_insert(sKey_listener_list, GUINT_TO_POINTER (key++), - atkKeySnoop.data); - return key; -} - -static void -mai_util_remove_key_event_listener (guint remove_listener) -{ - if (!sKey_listener_list) { - // atk-bridge is initialized with gail (e.g. yelp) - // try gail_remove_key_event_listener - return gail_remove_key_event_listener(remove_listener); - } - - g_hash_table_remove(sKey_listener_list, GUINT_TO_POINTER (remove_listener)); - if (g_hash_table_size(sKey_listener_list) == 0) { - gtk_key_snooper_remove(sKey_snooper_id); - } -} - -AtkObject* -mai_util_get_root(void) -{ - ApplicationAccessible* app = ApplicationAcc(); - if (app) - return app->GetAtkObject(); - - // We've shutdown, try to use gail instead - // (to avoid assert in spi_atk_tidy_windows()) - // XXX tbsaunde then why didn't we replace the gail atk_util impl? - if (gail_get_root) - return gail_get_root(); - - return nullptr; -} - -G_CONST_RETURN gchar * -mai_util_get_toolkit_name(void) -{ - return MAI_NAME; -} - -G_CONST_RETURN gchar * -mai_util_get_toolkit_version(void) -{ - return MAI_VERSION; -} - -void -_listener_info_destroy(gpointer data) -{ - g_free(data); -} - -guint -add_listener (GSignalEmissionHook listener, - const gchar *object_type, - const gchar *signal, - const gchar *hook_data, - guint gail_listenerid) -{ - GType type; - guint signal_id; - gint rc = 0; - - type = g_type_from_name(object_type); - if (type) { - signal_id = g_signal_lookup(signal, type); - if (signal_id > 0) { - MaiUtilListenerInfo *listener_info; - - rc = sListener_idx; - - listener_info = (MaiUtilListenerInfo *) - g_malloc(sizeof(MaiUtilListenerInfo)); - listener_info->key = sListener_idx; - listener_info->hook_id = - g_signal_add_emission_hook(signal_id, 0, listener, - g_strdup(hook_data), - (GDestroyNotify)g_free); - listener_info->signal_id = signal_id; - listener_info->gail_listenerid = gail_listenerid; - - g_hash_table_insert(sListener_list, &(listener_info->key), - listener_info); - sListener_idx++; - } - else { - g_warning("Invalid signal type %s\n", signal); - } - } - else { - g_warning("Invalid object type %s\n", object_type); - } - return rc; -} - static nsresult LoadGtkModule(GnomeAccessibilityModule& aModule); static gboolean toplevel_event_watcher(GSignalInvocationHint*, guint, @@ -519,16 +78,11 @@ static gboolean toplevel_event_watcher(GSignalInvocationHint*, guint, ApplicationAccessibleWrap::ApplicationAccessibleWrap(): ApplicationAccessible() { - MAI_LOG_DEBUG(("======Create AppRootAcc=%p\n", (void*)this)); - if (ShouldA11yBeEnabled()) { // Load and initialize gail library. nsresult rv = LoadGtkModule(sGail); - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) (*sGail.init)(); - } else { - MAI_LOG_DEBUG(("Fail to load lib: %s\n", sGail.libName)); - } } } @@ -544,15 +98,13 @@ nsAccessNodeWrap::InitAccessibility() return; // Initialize the MAI Utility class, it will overwrite gail_util. - g_type_class_unref(g_type_class_ref(MAI_TYPE_UTIL)); + g_type_class_unref(g_type_class_ref(mai_util_get_type())); // Init atk-bridge now PR_SetEnv("NO_AT_BRIDGE=0"); nsresult rv = LoadGtkModule(sAtkBridge); if (NS_SUCCEEDED(rv)) { (*sAtkBridge.init)(); - } else { - MAI_LOG_DEBUG(("Fail to load lib: %s\n", sAtkBridge.libName)); } if (!sToplevel_event_hook_added) { @@ -573,7 +125,6 @@ nsAccessNodeWrap::InitAccessibility() ApplicationAccessibleWrap::~ApplicationAccessibleWrap() { - MAI_LOG_DEBUG(("======Destory AppRootAcc=%p\n", (void*)this)); AccessibleWrap::ShutdownAtkObject(); } @@ -788,9 +339,6 @@ LoadGtkModule(GnomeAccessibilityModule& aModule) NS_ENSURE_ARG(aModule.libName); if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) { - - MAI_LOG_DEBUG(("Fail to load lib: %s in default path\n", aModule.libName)); - //try to load the module with "gtk-2.0/modules" appended char *curLibPath = PR_GetLibraryPath(); nsAutoCString libPath(curLibPath); @@ -799,7 +347,6 @@ LoadGtkModule(GnomeAccessibilityModule& aModule) #else libPath.Append(":/usr/lib"); #endif - MAI_LOG_DEBUG(("Current Lib path=%s\n", libPath.get())); PR_FreeLibraryName(curLibPath); int16_t loc1 = 0, loc2 = 0; @@ -814,16 +361,13 @@ LoadGtkModule(GnomeAccessibilityModule& aModule) sub.Append("/gtk-2.0/modules/"); sub.Append(aModule.libName); aModule.lib = PR_LoadLibrary(sub.get()); - if (aModule.lib) { - MAI_LOG_DEBUG(("Ok, load %s from %s\n", aModule.libName, sub.get())); + if (aModule.lib) break; - } + loc1 = loc2+1; } - if (!aModule.lib) { - MAI_LOG_DEBUG(("Fail to load %s\n", aModule.libName)); + if (!aModule.lib) return NS_ERROR_FAILURE; - } } //we have loaded the library, try to get the function ptrs @@ -833,9 +377,6 @@ LoadGtkModule(GnomeAccessibilityModule& aModule) aModule.shutdownName))) { //fail, :( - MAI_LOG_DEBUG(("Fail to find symbol %s in %s", - aModule.init ? aModule.shutdownName : aModule.initName, - aModule.libName)); PR_UnloadLibrary(aModule.lib); aModule.lib = NULL; return NS_ERROR_FAILURE; diff --git a/accessible/src/atk/InterfaceInitFuncs.h b/accessible/src/atk/InterfaceInitFuncs.h index 805001e8222d..20cab6da9e7b 100644 --- a/accessible/src/atk/InterfaceInitFuncs.h +++ b/accessible/src/atk/InterfaceInitFuncs.h @@ -17,6 +17,8 @@ class AccessibleWrap; } // namespace a11y } // namespace mozilla +struct MaiUtilClass; + extern "C" { void actionInterfaceInitCB(AtkActionIface* aIface); void componentInterfaceInitCB(AtkComponentIface* aIface); diff --git a/accessible/src/atk/Makefile.in b/accessible/src/atk/Makefile.in index 3ba8ee4d2709..746d0ac764c9 100644 --- a/accessible/src/atk/Makefile.in +++ b/accessible/src/atk/Makefile.in @@ -34,6 +34,7 @@ CPPSRCS = \ nsMaiInterfaceDocument.cpp \ nsMaiInterfaceImage.cpp \ RootAccessibleWrap.cpp \ + UtilInterface.cpp \ $(NULL) EXPORTS = \ diff --git a/accessible/src/atk/UtilInterface.cpp b/accessible/src/atk/UtilInterface.cpp new file mode 100644 index 000000000000..2e80ebedbbb4 --- /dev/null +++ b/accessible/src/atk/UtilInterface.cpp @@ -0,0 +1,404 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* 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/. */ + +#include "ApplicationAccessibleWrap.h" +#include "mozilla/Likely.h" +#include "nsAccessibilityService.h" +#include "nsMai.h" + +#include +#include +#include + +using namespace mozilla; +using namespace mozilla::a11y; + +typedef AtkUtil MaiUtil; +typedef AtkUtilClass MaiUtilClass; + +#define MAI_VERSION MOZILLA_VERSION +#define MAI_NAME "Gecko" + +extern "C" { +static guint (*gail_add_global_event_listener)(GSignalEmissionHook listener, + const gchar* event_type); +static void (*gail_remove_global_event_listener) (guint remove_listener); +static void (*gail_remove_key_event_listener) (guint remove_listener); +static AtkObject* (*gail_get_root)(); +} + +struct MaiUtilListenerInfo +{ + gint key; + guint signal_id; + gulong hook_id; + // For window create/destory/minimize/maximize/restore/activate/deactivate + // events, we'll chain gail_util's add/remove_global_event_listener. + // So we store the listenerid returned by gail's add_global_event_listener + // in this structure to call gail's remove_global_event_listener later. + guint gail_listenerid; +}; + +static GHashTable* sListener_list = NULL; +static gint sListener_idx = 1; + +extern "C" { +static guint +add_listener (GSignalEmissionHook listener, + const gchar *object_type, + const gchar *signal, + const gchar *hook_data, + guint gail_listenerid = 0) +{ + GType type; + guint signal_id; + gint rc = 0; + + type = g_type_from_name(object_type); + if (type) { + signal_id = g_signal_lookup(signal, type); + if (signal_id > 0) { + MaiUtilListenerInfo *listener_info; + + rc = sListener_idx; + + listener_info = (MaiUtilListenerInfo *) + g_malloc(sizeof(MaiUtilListenerInfo)); + listener_info->key = sListener_idx; + listener_info->hook_id = + g_signal_add_emission_hook(signal_id, 0, listener, + g_strdup(hook_data), + (GDestroyNotify)g_free); + listener_info->signal_id = signal_id; + listener_info->gail_listenerid = gail_listenerid; + + g_hash_table_insert(sListener_list, &(listener_info->key), + listener_info); + sListener_idx++; + } + else { + g_warning("Invalid signal type %s\n", signal); + } + } + else { + g_warning("Invalid object type %s\n", object_type); + } + return rc; +} + +static guint +mai_util_add_global_event_listener(GSignalEmissionHook listener, + const gchar *event_type) +{ + guint rc = 0; + gchar **split_string; + + split_string = g_strsplit (event_type, ":", 3); + + if (split_string) { + if (!strcmp ("window", split_string[0])) { + guint gail_listenerid = 0; + if (gail_add_global_event_listener) { + // call gail's function to track gtk native window events + gail_listenerid = + gail_add_global_event_listener(listener, event_type); + } + + rc = add_listener (listener, "MaiAtkObject", split_string[1], + event_type, gail_listenerid); + } + else { + rc = add_listener (listener, split_string[1], split_string[2], + event_type); + } + g_strfreev(split_string); + } + return rc; +} + +static void +mai_util_remove_global_event_listener(guint remove_listener) +{ + if (remove_listener > 0) { + MaiUtilListenerInfo *listener_info; + gint tmp_idx = remove_listener; + + listener_info = (MaiUtilListenerInfo *) + g_hash_table_lookup(sListener_list, &tmp_idx); + + if (listener_info != NULL) { + if (gail_remove_global_event_listener && + listener_info->gail_listenerid) { + gail_remove_global_event_listener(listener_info->gail_listenerid); + } + + /* Hook id of 0 and signal id of 0 are invalid */ + if (listener_info->hook_id != 0 && listener_info->signal_id != 0) { + /* Remove the emission hook */ + g_signal_remove_emission_hook(listener_info->signal_id, + listener_info->hook_id); + + /* Remove the element from the hash */ + g_hash_table_remove(sListener_list, &tmp_idx); + } + else { + g_warning("Invalid listener hook_id %ld or signal_id %d\n", + listener_info->hook_id, listener_info->signal_id); + } + } + else { + // atk-bridge is initialized with gail (e.g. yelp) + // try gail_remove_global_event_listener + if (gail_remove_global_event_listener) { + return gail_remove_global_event_listener(remove_listener); + } + + g_warning("No listener with the specified listener id %d", + remove_listener); + } + } + else { + g_warning("Invalid listener_id %d", remove_listener); + } +} + +static AtkKeyEventStruct * +atk_key_event_from_gdk_event_key (GdkEventKey *key) +{ + AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1); + switch (key->type) { + case GDK_KEY_PRESS: + event->type = ATK_KEY_EVENT_PRESS; + break; + case GDK_KEY_RELEASE: + event->type = ATK_KEY_EVENT_RELEASE; + break; + default: + g_assert_not_reached (); + return NULL; + } + event->state = key->state; + event->keyval = key->keyval; + event->length = key->length; + if (key->string && key->string [0] && + (key->state & GDK_CONTROL_MASK || + g_unichar_isgraph (g_utf8_get_char (key->string)))) { + event->string = key->string; + } + else if (key->type == GDK_KEY_PRESS || + key->type == GDK_KEY_RELEASE) { + event->string = gdk_keyval_name (key->keyval); + } + event->keycode = key->hardware_keycode; + event->timestamp = key->time; + + return event; +} + +struct MaiKeyEventInfo +{ + AtkKeyEventStruct *key_event; + gpointer func_data; +}; + +union AtkKeySnoopFuncPointer +{ + AtkKeySnoopFunc func_ptr; + gpointer data; +}; + +static gboolean +notify_hf(gpointer key, gpointer value, gpointer data) +{ + MaiKeyEventInfo *info = (MaiKeyEventInfo *)data; + AtkKeySnoopFuncPointer atkKeySnoop; + atkKeySnoop.data = value; + return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE : FALSE; +} + +static void +insert_hf(gpointer key, gpointer value, gpointer data) +{ + GHashTable *new_table = (GHashTable *) data; + g_hash_table_insert (new_table, key, value); +} + +static GHashTable* sKey_listener_list = NULL; + +static gint +mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event, gpointer func_data) +{ + /* notify each AtkKeySnoopFunc in turn... */ + + MaiKeyEventInfo *info = g_new0(MaiKeyEventInfo, 1); + gint consumed = 0; + if (sKey_listener_list) { + GHashTable *new_hash = g_hash_table_new(NULL, NULL); + g_hash_table_foreach (sKey_listener_list, insert_hf, new_hash); + info->key_event = atk_key_event_from_gdk_event_key (event); + info->func_data = func_data; + consumed = g_hash_table_foreach_steal (new_hash, notify_hf, info); + g_hash_table_destroy (new_hash); + g_free(info->key_event); + } + g_free(info); + return (consumed ? 1 : 0); +} + +static guint sKey_snooper_id = 0; + +static guint +mai_util_add_key_event_listener (AtkKeySnoopFunc listener, + gpointer data) +{ + if (MOZ_UNLIKELY(!listener)) + return 0; + + static guint key=0; + + if (!sKey_listener_list) { + sKey_listener_list = g_hash_table_new(NULL, NULL); + sKey_snooper_id = gtk_key_snooper_install(mai_key_snooper, data); + } + AtkKeySnoopFuncPointer atkKeySnoop; + atkKeySnoop.func_ptr = listener; + g_hash_table_insert(sKey_listener_list, GUINT_TO_POINTER (key++), + atkKeySnoop.data); + return key; +} + +static void +mai_util_remove_key_event_listener (guint remove_listener) +{ + if (!sKey_listener_list) { + // atk-bridge is initialized with gail (e.g. yelp) + // try gail_remove_key_event_listener + return gail_remove_key_event_listener(remove_listener); + } + + g_hash_table_remove(sKey_listener_list, GUINT_TO_POINTER (remove_listener)); + if (g_hash_table_size(sKey_listener_list) == 0) { + gtk_key_snooper_remove(sKey_snooper_id); + } +} + +static AtkObject* +mai_util_get_root() +{ + ApplicationAccessible* app = ApplicationAcc(); + if (app) + return app->GetAtkObject(); + + // We've shutdown, try to use gail instead + // (to avoid assert in spi_atk_tidy_windows()) + // XXX tbsaunde then why didn't we replace the gail atk_util impl? + if (gail_get_root) + return gail_get_root(); + + return nullptr; +} + +static const gchar* +mai_util_get_toolkit_name() +{ + return MAI_NAME; +} + +static const gchar* +mai_util_get_toolkit_version() +{ + return MAI_VERSION; +} + +static void +_listener_info_destroy(gpointer data) +{ + g_free(data); +} + +static void +window_added (AtkObject *atk_obj, + guint index, + AtkObject *child) +{ + if (!IS_MAI_OBJECT(child)) + return; + + static guint id = g_signal_lookup ("create", MAI_TYPE_ATK_OBJECT); + g_signal_emit (child, id, 0); +} + +static void +window_removed (AtkObject *atk_obj, + guint index, + AtkObject *child) +{ + if (!IS_MAI_OBJECT(child)) + return; + + static guint id = g_signal_lookup ("destroy", MAI_TYPE_ATK_OBJECT); + g_signal_emit (child, id, 0); +} + + static void +UtilInterfaceInit(MaiUtilClass* klass) +{ + AtkUtilClass *atk_class; + gpointer data; + + data = g_type_class_peek(ATK_TYPE_UTIL); + atk_class = ATK_UTIL_CLASS(data); + + // save gail function pointer + gail_add_global_event_listener = atk_class->add_global_event_listener; + gail_remove_global_event_listener = atk_class->remove_global_event_listener; + gail_remove_key_event_listener = atk_class->remove_key_event_listener; + gail_get_root = atk_class->get_root; + + atk_class->add_global_event_listener = + mai_util_add_global_event_listener; + atk_class->remove_global_event_listener = + mai_util_remove_global_event_listener; + atk_class->add_key_event_listener = mai_util_add_key_event_listener; + atk_class->remove_key_event_listener = mai_util_remove_key_event_listener; + atk_class->get_root = mai_util_get_root; + atk_class->get_toolkit_name = mai_util_get_toolkit_name; + atk_class->get_toolkit_version = mai_util_get_toolkit_version; + + sListener_list = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, + _listener_info_destroy); + // Keep track of added/removed windows. + AtkObject *root = atk_get_root (); + g_signal_connect (root, "children-changed::add", (GCallback) window_added, NULL); + g_signal_connect (root, "children-changed::remove", (GCallback) window_removed, NULL); +} +} + +GType +mai_util_get_type() +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo tinfo = { + sizeof(MaiUtilClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) UtilInterfaceInit, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof(MaiUtil), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + type = g_type_register_static(ATK_TYPE_UTIL, + "MaiUtil", &tinfo, GTypeFlags(0)); + } + return type; +} + diff --git a/accessible/src/atk/nsMai.h b/accessible/src/atk/nsMai.h index 19f1356fa8ee..a7cc10db85ad 100644 --- a/accessible/src/atk/nsMai.h +++ b/accessible/src/atk/nsMai.h @@ -13,25 +13,6 @@ #include "AccessibleWrap.h" -extern PRLogModuleInfo *gMaiLog; - -#ifdef MAI_LOGGING -#define MAI_LOG(level, args) \ -PR_BEGIN_MACRO \ - if (!gMaiLog) { \ - gMaiLog = PR_NewLogModule("Mai"); \ - PR_ASSERT(gMaiLog); \ - } \ - PR_LOG(gMaiLog, (level), args); \ -PR_END_MACRO -#else -#define MAI_LOG(level, args) -#endif - -#define MAI_LOG_DEBUG(args) MAI_LOG(PR_LOG_DEBUG, args) -#define MAI_LOG_WARNING(args) MAI_LOG(PR_LOG_WARNING, args) -#define MAI_LOG_ERROR(args) MAI_LOG(PR_LOG_ERROR, args) - #define MAI_TYPE_ATK_OBJECT (mai_atk_object_get_type ()) #define MAI_ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ MAI_TYPE_ATK_OBJECT, MaiAtkObject)) @@ -46,6 +27,7 @@ PR_END_MACRO MAI_TYPE_ATK_OBJECT, \ MaiAtkObjectClass)) GType mai_atk_object_get_type(void); +GType mai_util_get_type(); mozilla::a11y::AccessibleWrap* GetAccessibleWrap(AtkObject* aAtkObj); #endif /* __NS_MAI_H__ */ diff --git a/accessible/src/atk/nsMaiInterfaceEditableText.cpp b/accessible/src/atk/nsMaiInterfaceEditableText.cpp index ebec2aa2bb4b..663325ce86eb 100644 --- a/accessible/src/atk/nsMaiInterfaceEditableText.cpp +++ b/accessible/src/atk/nsMaiInterfaceEditableText.cpp @@ -26,8 +26,6 @@ setTextContentsCB(AtkEditableText *aText, const gchar *aString) if (!text || !text->IsTextRole()) return; - MAI_LOG_DEBUG(("EditableText: setTextContentsCB, aString=%s", aString)); - NS_ConvertUTF8toUTF16 strContent(aString); text->SetTextContents(strContent); } @@ -46,9 +44,6 @@ insertTextCB(AtkEditableText *aText, NS_ConvertUTF8toUTF16 strContent(aString, aLength); text->InsertText(strContent, *aPosition); - - MAI_LOG_DEBUG(("EditableText: insert aString=%s, aLength=%d, aPosition=%d", - aString, aLength, *aPosition)); } static void @@ -62,8 +57,6 @@ copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos) if (!text || !text->IsTextRole()) return; - MAI_LOG_DEBUG(("EditableText: copyTextCB, aStartPos=%d, aEndPos=%d", - aStartPos, aEndPos)); text->CopyText(aStartPos, aEndPos); } @@ -78,8 +71,6 @@ cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos) if (!text || !text->IsTextRole()) return; - MAI_LOG_DEBUG(("EditableText: cutTextCB, aStartPos=%d, aEndPos=%d", - aStartPos, aEndPos)); text->CutText(aStartPos, aEndPos); } @@ -94,8 +85,6 @@ deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos) if (!text || !text->IsTextRole()) return; - MAI_LOG_DEBUG(("EditableText: deleteTextCB, aStartPos=%d, aEndPos=%d", - aStartPos, aEndPos)); text->DeleteText(aStartPos, aEndPos); } @@ -110,7 +99,6 @@ pasteTextCB(AtkEditableText *aText, gint aPosition) if (!text || !text->IsTextRole()) return; - MAI_LOG_DEBUG(("EditableText: pasteTextCB, aPosition=%d", aPosition)); text->PasteText(aPosition); } } diff --git a/accessible/src/jsat/Makefile.in b/accessible/src/jsat/Makefile.in index 1093d1368f7b..64c7045c4a5a 100644 --- a/accessible/src/jsat/Makefile.in +++ b/accessible/src/jsat/Makefile.in @@ -12,9 +12,7 @@ include $(DEPTH)/config/autoconf.mk INSTALL_TARGETS += ACCESSFU ACCESSFU_FILES := \ - AccessFu.css \ AccessFu.jsm \ - content-script.js \ EventManager.jsm \ jar.mn \ Makefile.in \ diff --git a/b2g/chrome/content/settings.js b/b2g/chrome/content/settings.js index 0d09205beea3..5ffb93fc40b6 100644 --- a/b2g/chrome/content/settings.js +++ b/b2g/chrome/content/settings.js @@ -64,36 +64,32 @@ SettingsListener.observe('audio.volume.master', 0.5, function(value) { audioManager.masterVolume = Math.max(0.0, Math.min(value, 1.0)); }); -let audioSettings = []; +let audioChannelSettings = []; if ("nsIAudioManager" in Ci) { const nsIAudioManager = Ci.nsIAudioManager; - audioSettings = [ - // settings name, default value, stream type - ['audio.volume.voice_call', 10, nsIAudioManager.STREAM_TYPE_VOICE_CALL], - ['audio.volume.system', 15, nsIAudioManager.STREAM_TYPE_SYSTEM], - ['audio.volume.ring', 7, nsIAudioManager.STREAM_TYPE_RING], - ['audio.volume.music', 15, nsIAudioManager.STREAM_TYPE_MUSIC], - ['audio.volume.alarm', 7, nsIAudioManager.STREAM_TYPE_ALARM], - ['audio.volume.notification', 7, nsIAudioManager.STREAM_TYPE_NOTIFICATION], - ['audio.volume.bt_sco', 15, nsIAudioManager.STREAM_TYPE_BLUETOOTH_SCO], - ['audio.volume.enforced_audible', 7, nsIAudioManager.STREAM_TYPE_ENFORCED_AUDIBLE], - ['audio.volume.dtmf', 15, nsIAudioManager.STREAM_TYPE_DTMF], - ['audio.volume.tts', 15, nsIAudioManager.STREAM_TYPE_TTS], - ['audio.volume.fm', 15, nsIAudioManager.STREAM_TYPE_FM], + audioChannelSettings = [ + // settings name, max value, apply to stream types + ['audio.volume.content', 15, [nsIAudioManager.STREAM_TYPE_SYSTEM, nsIAudioManager.STREAM_TYPE_MUSIC, nsIAudioManager.STREAM_TYPE_FM]], + ['audio.volume.notification', 15, [nsIAudioManager.STREAM_TYPE_RING, nsIAudioManager.STREAM_TYPE_NOTIFICATION]], + ['audio.volume.alarm', 15, [nsIAudioManager.STREAM_TYPE_ALARM]], + ['audio.volume.telephony', 5, [nsIAudioManager.STREAM_TYPE_VOICE_CALL]], + ['audio.volume.bt_sco', 15, [nsIAudioManager.STREAM_TYPE_BLUETOOTH_SCO]], ]; } -for each (let [setting, defaultValue, streamType] in audioSettings) { - (function AudioStreamSettings(s, d, t) { - SettingsListener.observe(s, d, function(value) { +for each (let [setting, maxValue, streamTypes] in audioChannelSettings) { + (function AudioStreamSettings(setting, maxValue, streamTypes) { + SettingsListener.observe(setting, maxValue, function(value) { let audioManager = Services.audioManager; if (!audioManager) return; - audioManager.setStreamVolumeIndex(t, Math.min(value, d)); + for each(let streamType in streamTypes) { + audioManager.setStreamVolumeIndex(streamType, Math.min(value, maxValue)); + } }); - })(setting, defaultValue, streamType); + })(setting, maxValue, streamTypes); } // =================== Console ====================== @@ -157,12 +153,14 @@ Components.utils.import('resource://gre/modules/ctypes.jsm'); '@mozilla.org/settingsService;1', 'nsISettingsService'); let lock = gSettingsService.createLock(); - //MOZ_B2G_VERSION is set in b2g/confvars.sh, and is outputed as a #define value - //from configure.in, defaults to 1.0.0 if this value is not exist + // MOZ_B2G_VERSION is set in b2g/confvars.sh, and is output as a #define value + // from configure.in, defaults to 1.0.0 if this value is not exist. #filter attemptSubstitution let os_version = '@MOZ_B2G_VERSION@'; + let os_name = '@MOZ_B2G_OS_NAME@'; #unfilter attemptSubstitution lock.set('deviceinfo.os', os_version, null, null); + lock.set('deviceinfo.software', os_name + ' ' + os_version, null, null); let appInfo = Cc["@mozilla.org/xre/app-info;1"] .getService(Ci.nsIXULAppInfo); @@ -172,8 +170,9 @@ Components.utils.import('resource://gre/modules/ctypes.jsm'); let update_channel = Services.prefs.getCharPref('app.update.channel'); lock.set('deviceinfo.update_channel', update_channel, null, null); - //Get the hardware info from android properties - let hardware_version = null; + // Get the hardware info and firmware revision from device properties. + let hardware_info = null; + let firmware_revision = null; try { let cutils = ctypes.open('libcutils.so'); let cbuf = ctypes.char.array(128)(); @@ -189,12 +188,14 @@ Components.utils.import('resource://gre/modules/ctypes.jsm'); c_property_get(key, cbuf, defaultValue); return cbuf.readString(); } - hardware_version = property_get('ro.hardware'); + hardware_info = property_get('ro.hardware'); + firmware_revision = property_get('ro.firmware_revision'); cutils.close(); } catch(e) { - //Error + // Error. } - lock.set('deviceinfo.hardware', hardware_version, null, null); + lock.set('deviceinfo.hardware', hardware_info, null, null); + lock.set('deviceinfo.firmware_revision', firmware_revision, null, null); })(); // =================== Debugger ==================== diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index 499bf06184bd..42b6ca53e825 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -928,6 +928,15 @@ window.addEventListener('ContentStart', function update_onContentStart() { }, "headphones-status-changed", false); })(); +(function audioChannelChangedTracker() { + Services.obs.addObserver(function(aSubject, aTopic, aData) { + shell.sendChromeEvent({ + type: 'audio-channel-changed', + channel: aData + }); +}, "audio-channel-changed", false); +})(); + (function recordingStatusTracker() { let gRecordingActiveCount = 0; diff --git a/b2g/components/SignInToWebsite.jsm b/b2g/components/SignInToWebsite.jsm index 1183d3c43e3f..75fe785bd00e 100644 --- a/b2g/components/SignInToWebsite.jsm +++ b/b2g/components/SignInToWebsite.jsm @@ -76,7 +76,7 @@ const Cu = Components.utils; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/IdentityUtils.jsm"); +Cu.import("resource://gre/modules/identity/IdentityUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "IdentityService", "resource://gre/modules/identity/MinimalIdentity.jsm"); diff --git a/b2g/config/otoro/config.json b/b2g/config/otoro/config.json index c27804fc3ebd..776ed5635c6c 100644 --- a/b2g/config/otoro/config.json +++ b/b2g/config/otoro/config.json @@ -6,14 +6,22 @@ "mock_files": [["/home/cltbld/.ssh", "/home/mock_mozilla/.ssh"]], "build_targets": [], "upload_files": [ - "{workdir}/out/target/product/otoro/*.img", "{objdir}/dist/b2g-update/*.mar", "{objdir}/dist/b2g-*.tar.gz", "{objdir}/dist/b2g-*.crashreporter-symbols.zip", "{workdir}/sources.xml" ], + "zip_files": [ + ["{workdir}/out/target/product/otoro/*.img", "out/target/product/otoro/"], + "{workdir}/boot.img", + "{workdir}/flash.sh", + "{workdir}/load-config.sh", + "{workdir}/.config", + "{workdir}/sources.xml" + ], "env": { "VARIANT": "user", + "MOZILLA_OFFICIAL": "1", "B2GUPDATER": "1" }, "gaia": { diff --git a/b2g/config/otoro/releng-otoro.tt b/b2g/config/otoro/releng-otoro.tt index dd9993522b8d..6a92d1ccc9c6 100644 --- a/b2g/config/otoro/releng-otoro.tt +++ b/b2g/config/otoro/releng-otoro.tt @@ -4,5 +4,11 @@ "digest": "0ccae39ee8910947fe3cf51fa3a45e820d2ff11571f6ccec29d9b3e5ae7f7709c1ad657210fbfea98baadd032c3d6a58e00ddbb2e93acafd751089869a72fed6", "algorithm": "sha512", "filename": "gonk.tar.xz" +}, +{ +"size": 4139008, +"digest": "b1eac90cebe52708d512bbc293c507da9d93bc8c6a78cbbbd78cc9b7beb2cd335bef9bf8e4bf5a9dc38521f7080d29a743626f9e4af6c42ec211db22dc9d0fda", +"algorithm": "sha512", +"filename": "boot.img" } ] diff --git a/b2g/config/panda-gaia-central/README b/b2g/config/panda-gaia-central/README new file mode 120000 index 000000000000..ca663238783c --- /dev/null +++ b/b2g/config/panda-gaia-central/README @@ -0,0 +1 @@ +../panda/README \ No newline at end of file diff --git a/b2g/config/panda-gaia-central/config.json b/b2g/config/panda-gaia-central/config.json new file mode 100644 index 000000000000..6e708d8863bc --- /dev/null +++ b/b2g/config/panda-gaia-central/config.json @@ -0,0 +1,24 @@ +{ + "config_version": 1, + "tooltool_manifest": "releng-pandaboard.tt", + "mock_target": "mozilla-centos6-i386", + "mock_packages": ["ccache", "make", "bison", "flex", "gcc", "g++", "mpfr", "zlib-devel", "ncurses-devel", "zip", "autoconf213", "glibc-static", "perl-Digest-SHA", "wget", "alsa-lib", "atk", "cairo", "dbus-glib", "fontconfig", "freetype", "glib2", "gtk2", "libXRender", "libXt", "pango", "mozilla-python27-mercurial", "openssh-clients", "nss-devel"], + "mock_files": [["/home/cltbld/.ssh", "/home/mock_mozilla/.ssh"]], + "build_targets": ["boottarball", "systemtarball", "userdatatarball"], + "upload_files": [ + "{workdir}/out/target/product/panda/*.tar.bz2", + "{objdir}/dist/b2g-update/*.mar", + "{objdir}/dist/b2g-*.tar.gz", + "{objdir}/dist/b2g-*.crashreporter-symbols.zip", + "{srcdir}/b2g/config/panda/README", + "{workdir}/sources.xml" + ], + "gaia": { + "vcs": "hgtool", + "repo": "http://hg.mozilla.org/integration/gaia-central", + "l10n": { + "vcs": "hgtool", + "root": "http://hg.mozilla.org/gaia-l10n" + } + } +} diff --git a/b2g/config/panda-gaia-central/releng-pandaboard.tt b/b2g/config/panda-gaia-central/releng-pandaboard.tt new file mode 120000 index 000000000000..f270dafc6d70 --- /dev/null +++ b/b2g/config/panda-gaia-central/releng-pandaboard.tt @@ -0,0 +1 @@ +../panda/releng-pandaboard.tt \ No newline at end of file diff --git a/b2g/config/panda-gaia-central/sources.xml b/b2g/config/panda-gaia-central/sources.xml new file mode 120000 index 000000000000..5e01c30ca19e --- /dev/null +++ b/b2g/config/panda-gaia-central/sources.xml @@ -0,0 +1 @@ +../panda/sources.xml \ No newline at end of file diff --git a/b2g/config/tooltool-manifests/macosx64/releng.manifest b/b2g/config/tooltool-manifests/macosx64/releng.manifest index f1be4c8a135d..f363c9a95ace 100644 --- a/b2g/config/tooltool-manifests/macosx64/releng.manifest +++ b/b2g/config/tooltool-manifests/macosx64/releng.manifest @@ -1,6 +1,6 @@ [ { -"clang_version": "r168596" +"clang_version": "r169139" }, { "size": 47, @@ -9,8 +9,8 @@ "filename": "setup.sh" }, { -"size": 56147341, -"digest": "4baed5cbe0189a509b6a328ee35ee488250677f8ea149e6d01af74c7a4a27c898a4112f78af57b33a4e788b2947813b65ab0922e06b67bd504878803dab44f5c", +"size": 56158651, +"digest": "38d718f20a8fa9218e22ade312e724e6c9cdd7c6650e023cfdc21b5505fe7aa3743ae41c0abd717a1bbccec4c4271be2fa82d0e2f96c91e693d70e33b4dc00d6", "algorithm": "sha512", "filename": "clang.tar.bz2" } diff --git a/b2g/config/unagi/config.json b/b2g/config/unagi/config.json index bd4b2bd451c7..6b22ef682b8e 100644 --- a/b2g/config/unagi/config.json +++ b/b2g/config/unagi/config.json @@ -6,14 +6,22 @@ "mock_files": [["/home/cltbld/.ssh", "/home/mock_mozilla/.ssh"]], "build_targets": [], "upload_files": [ - "{workdir}/out/target/product/unagi/*.img", "{objdir}/dist/b2g-update/*.mar", "{objdir}/dist/b2g-*.tar.gz", "{objdir}/dist/b2g-*.crashreporter-symbols.zip", "{workdir}/sources.xml" ], + "zip_files": [ + ["{workdir}/out/target/product/unagi/*.img", "out/target/product/unagi/"], + "{workdir}/boot.img", + "{workdir}/flash.sh", + "{workdir}/load-config.sh", + "{workdir}/.config", + "{workdir}/sources.xml" + ], "env": { "VARIANT": "user", + "MOZILLA_OFFICIAL": "1", "B2GUPDATER": "1" }, "gaia": { diff --git a/b2g/config/unagi/releng-unagi.tt b/b2g/config/unagi/releng-unagi.tt index 1272491a86c3..f8ea002eb2a0 100644 --- a/b2g/config/unagi/releng-unagi.tt +++ b/b2g/config/unagi/releng-unagi.tt @@ -4,5 +4,11 @@ "digest": "553e88831f0760ef8de039a037c91499ff9334691f0532835c73a44352750a4911752cf0d5346f5e023f64b2351ed7f49a2a833c27538ddde59ad505f50ab063", "algorithm": "sha512", "filename": "gonk.tar.xz" +}, +{ +"size": 8859648, +"digest": "05d4a99e0f36cd91d1b10a2b558979ea776e9a7e03b8a921af3b0bfc62e2d96cf4faa20586c39885b6f8b25089fe07726794620a3b18c4826a2f71e29d90a8ef", +"algorithm": "sha512", +"filename": "boot.img" } ] diff --git a/b2g/confvars.sh b/b2g/confvars.sh index 7ca5f52792de..7c0337b5f5ae 100755 --- a/b2g/confvars.sh +++ b/b2g/confvars.sh @@ -11,6 +11,7 @@ MOZ_APP_UA_NAME=Firefox MOZ_UA_OS_AGNOSTIC=1 MOZ_B2G_VERSION=1.0.0-prerelease +MOZ_B2G_OS_NAME=Boot2Gecko MOZ_BRANDING_DIRECTORY=b2g/branding/unofficial MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official diff --git a/browser/base/content/browser-appmenu.inc b/browser/base/content/browser-appmenu.inc index 215c19ce29d6..d06e4fa33d67 100644 --- a/browser/base/content/browser-appmenu.inc +++ b/browser/base/content/browser-appmenu.inc @@ -27,12 +27,6 @@ label="&newNavigatorCmd.label;" command="cmd_newNavigator" key="key_newNavigator"/> -#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING - -#endif -#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING +#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING + +#else 0 && dl.size > 0) - maxTime = Math.max(maxTime, (dl.size - dl.amountTransferred) / dl.speed); - else - maxTime = -1; - } - else if (dl.state == gDownloadMgr.DOWNLOAD_PAUSED) - numPaused++; - } - - // Get the remaining time string and last sec for time estimation - let timeLeft; - [timeLeft, this._lastTime] = - this.DownloadUtils.getTimeLeft(maxTime, this._lastTime); - - // Figure out how many downloads are currently downloading - let numDls = numActive - numPaused; - let status = this._activeStr; - - // If all downloads are paused, show the paused message instead - if (numDls == 0) { - numDls = numPaused; - status = this._pausedStr; - } - - // Get the correct plural form and insert the number of downloads and time - // left message if necessary - status = PluralForm.get(numDls, status); - status = status.replace("#1", numDls); - status = status.replace("#2", timeLeft); - - // Update the panel and show it - this._panel.label = status; - this._panel.hidden = false; - }, - - ////////////////////////////////////////////////////////////////////////////// - //// nsIDownloadProgressListener - - /** - * Update status for download progress changes - */ - onProgressChange: function() { - this.updateStatus(); - }, - - /** - * Update status for download state changes - */ - onDownloadStateChange: function() { - this.updateStatus(); - }, - - onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus, aDownload) { - }, - - onSecurityChange: function(aWebProgress, aRequest, aState, aDownload) { - }, - - ////////////////////////////////////////////////////////////////////////////// - //// nsISupports - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadProgressListener]), -}; - function getNotificationBox(aWindow) { var foundBrowser = gBrowser.getBrowserForDocument(aWindow.document); if (foundBrowser) diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index 880d8be0e3cf..aaaf041e33b1 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -251,7 +251,6 @@ _BROWSER_FILES = \ alltabslistener.html \ zoom_test.html \ dummy_page.html \ - browser_tabMatchesInAwesomebar.js \ file_bug550565_popup.html \ file_bug550565_favicon.ico \ browser_aboutHome.js \ @@ -318,6 +317,7 @@ _BROWSER_FILES += \ browser_private_browsing_window.js \ browser_save_link-perwindowpb.js \ browser_save_private_link_perwindowpb.js \ + browser_tabMatchesInAwesomebar_perwindowpb.js \ $(NULL) else _BROWSER_FILES += \ @@ -325,6 +325,7 @@ _BROWSER_FILES += \ browser_bug767836.js \ browser_save_link.js \ browser_save_private_link.js \ + browser_tabMatchesInAwesomebar.js \ $(NULL) endif diff --git a/browser/base/content/test/browser_bug816527.js b/browser/base/content/test/browser_bug816527.js index ffcb6d77d0f2..30a4090f2d3e 100644 --- a/browser/base/content/test/browser_bug816527.js +++ b/browser/base/content/test/browser_bug816527.js @@ -18,19 +18,19 @@ function test() { testOnWindow({}, function(aNormalWindow) { testOnWindow({private: true}, function(aPrivateWindow) { - runTest(aNormalWindow, aPrivateWindow, function() { + runTest(aNormalWindow, aPrivateWindow, false, function() { aNormalWindow.close(); aPrivateWindow.close(); testOnWindow({}, function(aNormalWindow) { testOnWindow({private: true}, function(aPrivateWindow) { - runTest(aPrivateWindow, aNormalWindow, function() { + runTest(aPrivateWindow, aNormalWindow, false, function() { aNormalWindow.close(); aPrivateWindow.close(); testOnWindow({private: true}, function(aPrivateWindow) { - runTest(aPrivateWindow, aPrivateWindow, function() { + runTest(aPrivateWindow, aPrivateWindow, false, function() { aPrivateWindow.close(); testOnWindow({}, function(aNormalWindow) { - runTest(aNormalWindow, aNormalWindow, function() { + runTest(aNormalWindow, aNormalWindow, true, function() { aNormalWindow.close(); finish(); }); @@ -44,7 +44,7 @@ function test() { }); }); - function runTest(aSourceWindow, aDestWindow, aCallback) { + function runTest(aSourceWindow, aDestWindow, aExpectSuccess, aCallback) { // Open the base tab let baseTab = aSourceWindow.gBrowser.addTab(testURL); baseTab.linkedBrowser.addEventListener("load", function() { @@ -91,21 +91,25 @@ function test() { function onTabClose(aEvent) { aDestWindow.gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, false); aDestWindow.gBrowser.removeEventListener("load", onLoad, false); + clearTimeout(timeout); // Should only happen when we expect success - ok(false, "Tab closed as expected"); + ok(aExpectSuccess, "Tab closed as expected"); aCallback(); } function onLoad(aEvent) { aDestWindow.gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, false); aDestWindow.gBrowser.removeEventListener("load", onLoad, false); + clearTimeout(timeout); // Should only happen when we expect success - ok(false, "Tab loaded as expected"); + ok(aExpectSuccess, "Tab loaded as expected"); aCallback(); } aDestWindow.gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false); aDestWindow.gBrowser.addEventListener("load", onLoad, false); - setTimeout(function() { + let timeout = setTimeout(function() { + aDestWindow.gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, false); + aDestWindow.gBrowser.removeEventListener("load", onLoad, false); aCallback(); }, 500); diff --git a/browser/base/content/test/browser_tabMatchesInAwesomebar_perwindowpb.js b/browser/base/content/test/browser_tabMatchesInAwesomebar_perwindowpb.js new file mode 100644 index 000000000000..4c994762243a --- /dev/null +++ b/browser/base/content/test/browser_tabMatchesInAwesomebar_perwindowpb.js @@ -0,0 +1,248 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim:set ts=2 sw=2 sts=2 et: + * 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/. */ + +const TEST_URL_BASES = [ + "http://example.org/browser/browser/base/content/test/dummy_page.html#tabmatch", + "http://example.org/browser/browser/base/content/test/moz.png#tabmatch" +]; + +var gController = Cc["@mozilla.org/autocomplete/controller;1"]. + getService(Ci.nsIAutoCompleteController); + +var gTabWaitCount = 0; +var gTabCounter = 0; + +var gTestSteps = [ + function() { + info("Running step 1"); + for (let i = 0; i < 10; i++) { + let tab = gBrowser.addTab(); + loadTab(tab, TEST_URL_BASES[0] + (++gTabCounter)); + } + }, + function() { + info("Running step 2"); + gBrowser.selectTabAtIndex(1); + gBrowser.removeCurrentTab(); + gBrowser.selectTabAtIndex(1); + gBrowser.removeCurrentTab(); + for (let i = 1; i < gBrowser.tabs.length; i++) + loadTab(gBrowser.tabs[i], TEST_URL_BASES[1] + (++gTabCounter)); + }, + function() { + info("Running step 3"); + for (let i = 1; i < gBrowser.tabs.length; i++) + loadTab(gBrowser.tabs[i], TEST_URL_BASES[0] + gTabCounter); + }, + function() { + info("Running step 4 - ensure we don't register subframes as open pages"); + let tab = gBrowser.addTab(); + tab.linkedBrowser.addEventListener("load", function () { + tab.linkedBrowser.removeEventListener("load", arguments.callee, true); + // Start the sub-document load. + executeSoon(function () { + tab.linkedBrowser.addEventListener("load", function (e) { + tab.linkedBrowser.removeEventListener("load", arguments.callee, true); + ensure_opentabs_match_db(nextStep); + }, true); + tab.linkedBrowser.contentDocument.querySelector("iframe").src = "http://test2.example.org/"; + }); + }, true); + tab.linkedBrowser.loadURI('data:text/html,'); + }, + function() { + info("Running step 5 - remove tab immediately"); + let tab = gBrowser.addTab("about:logo"); + gBrowser.removeTab(tab); + ensure_opentabs_match_db(nextStep); + }, + function() { + info("Running step 6 - check swapBrowsersAndCloseOther preserves registered switch-to-tab result"); + let tabToKeep = gBrowser.addTab(); + let tab = gBrowser.addTab(); + tab.linkedBrowser.addEventListener("load", function () { + tab.linkedBrowser.removeEventListener("load", arguments.callee, true); + gBrowser.swapBrowsersAndCloseOther(tabToKeep, tab); + ensure_opentabs_match_db(function () { + gBrowser.removeTab(tabToKeep); + ensure_opentabs_match_db(nextStep); + }); + }, true); + tab.linkedBrowser.loadURI("about:mozilla"); + }, + function() { + info("Running step 7 - close all tabs"); + + Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand"); + + gBrowser.addTab("about:blank", {skipAnimation: true}); + while (gBrowser.tabs.length > 1) { + info("Removing tab: " + gBrowser.tabs[0].linkedBrowser.currentURI.spec); + gBrowser.selectTabAtIndex(0); + gBrowser.removeCurrentTab(); + } + ensure_opentabs_match_db(nextStep); + } +]; + + + +function test() { + waitForExplicitFinish(); + nextStep(); +} + +function loadTab(tab, url) { + // Because adding visits is async, we will not be notified immediately. + let visited = false; + let loaded = false; + + function maybeCheckResults() { + if (visited && loaded && --gTabWaitCount == 0) { + ensure_opentabs_match_db(nextStep); + } + } + + tab.linkedBrowser.addEventListener("load", function () { + tab.linkedBrowser.removeEventListener("load", arguments.callee, true); + loaded = true; + maybeCheckResults(); + }, true); + + if (!visited) { + Services.obs.addObserver( + function (aSubject, aTopic, aData) { + if (url != aSubject.QueryInterface(Ci.nsIURI).spec) + return; + Services.obs.removeObserver(arguments.callee, aTopic); + visited = true; + maybeCheckResults(); + }, + "uri-visit-saved", + false + ); + } + + gTabWaitCount++; + info("Loading page: " + url); + tab.linkedBrowser.loadURI(url); +} + +function waitForRestoredTab(tab) { + gTabWaitCount++; + + tab.linkedBrowser.addEventListener("load", function () { + tab.linkedBrowser.removeEventListener("load", arguments.callee, true); + if (--gTabWaitCount == 0) { + ensure_opentabs_match_db(nextStep); + } + }, true); +} + + +function nextStep() { + if (gTestSteps.length == 0) { + while (gBrowser.tabs.length > 1) { + gBrowser.selectTabAtIndex(1); + gBrowser.removeCurrentTab(); + } + + waitForClearHistory(finish); + + return; + } + + var stepFunc = gTestSteps.shift(); + stepFunc(); +} + +function ensure_opentabs_match_db(aCallback) { + var tabs = {}; + + var winEnum = Services.wm.getEnumerator("navigator:browser"); + while (winEnum.hasMoreElements()) { + let browserWin = winEnum.getNext(); + // skip closed-but-not-destroyed windows + if (browserWin.closed) + continue; + + for (let i = 0; i < browserWin.gBrowser.tabContainer.childElementCount; i++) { + let browser = browserWin.gBrowser.getBrowserAtIndex(i); + let url = browser.currentURI.spec; + if (browserWin.isBlankPageURL(url)) + continue; + if (!(url in tabs)) + tabs[url] = 1; + else + tabs[url]++; + } + } + + checkAutocompleteResults(tabs, aCallback); +} + +/** + * Clears history invoking callback when done. + */ +function waitForClearHistory(aCallback) { + const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished"; + let observer = { + observe: function(aSubject, aTopic, aData) { + Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED); + aCallback(); + } + }; + Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false); + + PlacesUtils.bhistory.removeAllPages(); +} + +function checkAutocompleteResults(aExpected, aCallback) +{ + gController.input = { + timeout: 10, + textValue: "", + searches: ["history"], + searchParam: "enable-actions", + popupOpen: false, + minResultsForPopup: 0, + invalidate: function() {}, + disableAutoComplete: false, + completeDefaultIndex: false, + get popup() { return this; }, + onSearchBegin: function() {}, + onSearchComplete: function () + { + info("Found " + gController.matchCount + " matches."); + // Check to see the expected uris and titles match up (in any order) + for (let i = 0; i < gController.matchCount; i++) { + let uri = gController.getValueAt(i).replace(/^moz-action:[^,]+,/i, ""); + + info("Search for '" + uri + "' in open tabs."); + ok(uri in aExpected, "Registered open page found in autocomplete."); + // Remove the found entry from expected results. + delete aExpected[uri]; + } + + // Make sure there is no reported open page that is not open. + for (let entry in aExpected) { + ok(false, "'" + entry + "' not found in autocomplete."); + } + + executeSoon(aCallback); + }, + setSelectedIndex: function() {}, + get searchCount() { return this.searches.length; }, + getSearchAt: function(aIndex) this.searches[aIndex], + QueryInterface: XPCOMUtils.generateQI([ + Ci.nsIAutoCompleteInput, + Ci.nsIAutoCompletePopup, + ]) + }; + + info("Searching open pages."); + gController.startSearch(Services.prefs.getCharPref("browser.urlbar.restrict.openpage")); +} diff --git a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml index 29be6f155d97..4cb878c262fc 100644 --- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml +++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.xhtml @@ -13,10 +13,18 @@ %globalDTD; %browserDTD; +#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING +#ifdef XP_MACOSX + +#else + &brandShortName;&fileMenu.label;"> +#endif +#else #ifdef XP_MACOSX #else &brandShortName;&toolsMenu.label;"> +#endif #endif %privatebrowsingpageDTD; @@ -31,9 +39,15 @@ body.private .showNormal { display: none; } +#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING + body.appMenuButtonVisible .fileMenu { + display: none; + } +#else body.appMenuButtonVisible .toolsMenu { display: none; } +#endif body.appMenuButtonInvisible .appMenuButton { display: none; } @@ -93,10 +107,16 @@ document.body.classList.add(appMenuButtonIsVisible ? "appMenuButtonVisible" : "appMenuButtonInvisible"); }, false); - + +#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING + function openPrivateWindow() { + mainWindow.OpenBrowserWindow({private: true}); + } +#else function togglePrivateBrowsing() { mainWindow.gPrivateBrowsingUI.toggleMode(); } +#endif ]]> @@ -117,27 +137,48 @@
+#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING +

&privatebrowsingpage.perwindow.issueDesc;

+

&privatebrowsingpage.perwindow.issueDesc.normal;

+#else

&privatebrowsingpage.issueDesc;

&privatebrowsingpage.issueDesc.normal;

+#endif
+#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING +

&privatebrowsingpage.perwindow.description;

+#else

&privatebrowsingpage.description;

+#endif
+#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING +
+#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING +

&privatebrowsingpage.howToStop3;

+

&privatebrowsingpage.howToStart3;

+#else

&privatebrowsingpage.howToStop2;

&privatebrowsingpage.howToStart2;

+#endif
diff --git a/browser/components/privatebrowsing/test/browser/obsolete/Makefile.in b/browser/components/privatebrowsing/test/browser/obsolete/Makefile.in index 64ed67a9121f..db00c282813b 100644 --- a/browser/components/privatebrowsing/test/browser/obsolete/Makefile.in +++ b/browser/components/privatebrowsing/test/browser/obsolete/Makefile.in @@ -24,10 +24,8 @@ MOCHITEST_BROWSER_FILES = \ browser_privatebrowsing_searchbar.js \ browser_privatebrowsing_sslsite_transition.js \ $(filter disabled-since-it-no-longer-makes-sense, browser_privatebrowsing_transition.js) \ - $(filter disabled--bug-564934, browser_privatebrowsing_downloadmonitor.js) \ browser_privatebrowsing_urlbarundo.js \ browser_privatebrowsing_viewsource.js \ - staller.sjs \ $(NULL) # Turn off private browsing tests that perma-timeout on Linux. diff --git a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_downloadmonitor.js b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_downloadmonitor.js deleted file mode 100644 index 3e15f9f05a19..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_downloadmonitor.js +++ /dev/null @@ -1,153 +0,0 @@ -/* 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 test makes sure that the download monitor status bar panel is correctly -// cleared when switching the private browsing mode on or off. - -function test() { - // initialization - let pb = Cc["@mozilla.org/privatebrowsing;1"]. - getService(Ci.nsIPrivateBrowsingService); - let dm = Cc["@mozilla.org/download-manager;1"]. - getService(Ci.nsIDownloadManager); - if (!gDownloadMgr) - gDownloadMgr = dm; - let panel = document.getElementById("download-monitor"); - waitForExplicitFinish(); - - let acceptDialog = 0; - let confirmCalls = 0; - function promptObserver(aSubject, aTopic, aData) { - let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow); - confirmCalls++; - if (acceptDialog-- > 0) - dialogWin.document.documentElement.getButton("accept").click(); - } - - Services.obs.addObserver(promptObserver, "common-dialog-loaded", false); - - // Add a new download - let [file, persist] = addDownload(dm, { - isPrivate: PrivateBrowsingUtils.isWindowPrivate(window), - resultFileName: "pbtest-1", - downloadName: "PB Test 1" - }); - - // Make sure that the download is being displayed in the monitor panel - if (!DownloadMonitorPanel.inited()) - DownloadMonitorPanel.init(); - else - DownloadMonitorPanel.updateStatus(); - ok(!panel.hidden, "The download panel should be successfully added initially"); - - // Enter the private browsing mode - acceptDialog = 1; - pb.privateBrowsingEnabled = true; - is(confirmCalls, 1, "One prompt was accepted"); - ok(pb.privateBrowsingEnabled, "The private browsing transition was successful"); - - executeSoon(function () { - ok(panel.hidden, "The download panel should be hidden when entering the private browsing mode"); - - // Add a new download - let [file2, persist2] = addDownload(dm, { - isPrivate: PrivateBrowsingUtils.isWindowPrivate(window), - resultFileName: "pbtest-2", - downloadName: "PB Test 2" - }); - - // Update the panel - DownloadMonitorPanel.updateStatus(); - - // Make sure that the panel is visible - ok(!panel.hidden, "The download panel should show up when a new download is added"); - - // Exit the private browsing mode - acceptDialog = 1; - pb.privateBrowsingEnabled = false; - is(confirmCalls, 2, "One prompt was accepted"); - ok(!pb.privateBrowsingEnabled, "The private browsing transition was successful"); - - executeSoon(function () { - ok(panel.hidden, "The download panel should be hidden when leaving the private browsing mode"); - - // cleanup - let dls = dm.activeDownloads; - while (dls.hasMoreElements()) { - let dl = dls.getNext().QueryInterface(Ci.nsIDownload); - dm.removeDownload(dl.id); - let file = dl.targetFile; - if (file.exists()) - file.remove(false); - } - if (file.exists()) - file.remove(false); - - Services.obs.removeObserver(promptObserver, "common-dialog-loaded", false); - finish(); - }); - }); -} - -/** - * Adds a download to the DM, and starts it. - * (Copied from toolkit/componentns/downloads/test/unit/head_download_manager.js) - * @param aParams (optional): an optional object which contains the function - * parameters: - * resultFileName: leaf node for the target file - * targetFile: nsIFile for the target (overrides resultFileName) - * sourceURI: the download source URI - * downloadName: the display name of the download - * runBeforeStart: a function to run before starting the download - * isPrivate: whether the download is private - */ -function addDownload(dm, aParams) -{ - if (!aParams) - aParams = {}; - if (!("resultFileName" in aParams)) - aParams.resultFileName = "download.result"; - if (!("targetFile" in aParams)) { - let dirSvc = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties); - aParams.targetFile = dirSvc.get("ProfD", Ci.nsIFile); - aParams.targetFile.append(aParams.resultFileName); - } - if (!("sourceURI" in aParams)) - aParams.sourceURI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/staller.sjs"; - if (!("downloadName" in aParams)) - aParams.downloadName = null; - if (!("runBeforeStart" in aParams)) - aParams.runBeforeStart = function () {}; - - const nsIWBP = Ci.nsIWebBrowserPersist; - let persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] - .createInstance(Ci.nsIWebBrowserPersist); - persist.persistFlags = nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES | - nsIWBP.PERSIST_FLAGS_BYPASS_CACHE | - nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION; - - let dl = dm.addDownload(Ci.nsIDownloadManager.DOWNLOAD_TYPE_DOWNLOAD, - createURI(aParams.sourceURI), - createURI(aParams.targetFile), aParams.downloadName, null, - Math.round(Date.now() * 1000), null, persist, aParams.isPrivate); - - // This will throw if it isn't found, and that would mean test failure, so no - // try catch block - let test = dm.getDownload(dl.id); - - aParams.runBeforeStart.call(undefined, dl); - - persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener); - persist.savePrivacyAwareURI(dl.source, null, null, null, null, dl.targetFile, - aParams.isPrivate); - - return [dl.targetFile, persist]; -} - -function createURI(aObj) { - let ios = Services.io; - return (aObj instanceof Ci.nsIFile) ? ios.newFileURI(aObj) : - ios.newURI(aObj, null, null); -} diff --git a/browser/components/privatebrowsing/test/browser/obsolete/staller.sjs b/browser/components/privatebrowsing/test/browser/obsolete/staller.sjs deleted file mode 100644 index 72c3fdb8b46e..000000000000 --- a/browser/components/privatebrowsing/test/browser/obsolete/staller.sjs +++ /dev/null @@ -1,27 +0,0 @@ -/* 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 provides the tests with a download URL which never finishes. - -var timer; - -function handleRequest(request, response) { - response.setStatusLine(request.httpVersion, 200, "OK"); - response.processAsync(); - - const nsITimer = Components.interfaces.nsITimer; - - function stall() { - timer = null; - // This write will throw if the connection has been closed by the browser. - response.write("stalling...\n"); - timer = Components.classes["@mozilla.org/timer;1"] - .createInstance(nsITimer); - timer.initWithCallback(stall, 500, nsITimer.TYPE_ONE_SHOT); - } - - response.setHeader("Content-Type", "text/plain", false); - response.setHeader("Accept-Ranges", "none", false); - stall(); -} diff --git a/browser/components/tabview/test/Makefile.in b/browser/components/tabview/test/Makefile.in index e18298d39893..758ada2fcfef 100644 --- a/browser/components/tabview/test/Makefile.in +++ b/browser/components/tabview/test/Makefile.in @@ -69,7 +69,6 @@ _BROWSER_FILES = \ browser_tabview_bug622835.js \ browser_tabview_bug623768.js \ browser_tabview_bug624692.js \ - browser_tabview_bug624727.js \ browser_tabview_bug624847.js \ browser_tabview_bug624931.js \ browser_tabview_bug624953.js \ @@ -107,7 +106,6 @@ _BROWSER_FILES = \ browser_tabview_bug649006.js \ browser_tabview_bug649307.js \ browser_tabview_bug649319.js \ - browser_tabview_bug650280.js \ browser_tabview_bug650573.js \ browser_tabview_bug651311.js \ browser_tabview_bug654295.js \ @@ -150,7 +148,6 @@ _BROWSER_FILES = \ browser_tabview_group.js \ browser_tabview_launch.js \ browser_tabview_multiwindow_search.js \ - browser_tabview_privatebrowsing.js \ browser_tabview_rtl.js \ browser_tabview_search.js \ browser_tabview_snapping.js \ @@ -168,12 +165,17 @@ _BROWSER_FILES = \ ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING _BROWSER_FILES += \ - browser_tabview_bug624265_perwindowpb.js \ - $(NULL) + browser_tabview_bug624265_perwindowpb.js \ + browser_tabview_bug624727_perwindowpb.js \ + browser_tabview_bug650280_perwindowpb.js \ + $(NULL) else _BROWSER_FILES += \ - browser_tabview_bug624265.js \ - $(NULL) + browser_tabview_bug624265.js \ + browser_tabview_bug624727.js \ + browser_tabview_bug650280.js \ + browser_tabview_privatebrowsing.js \ + $(NULL) endif diff --git a/browser/components/tabview/test/browser_tabview_bug624727_perwindowpb.js b/browser/components/tabview/test/browser_tabview_bug624727_perwindowpb.js new file mode 100644 index 000000000000..4e8ca437e714 --- /dev/null +++ b/browser/components/tabview/test/browser_tabview_bug624727_perwindowpb.js @@ -0,0 +1,143 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + let createGroupItem = function (aWindow) { + let cw = aWindow.TabView.getContentWindow(); + let bounds = new cw.Rect(20, 20, 400, 200); + let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); + cw.UI.setActive(groupItem); + + let groupItemId = groupItem.id; + registerCleanupFunction(function() { + let groupItem = cw.GroupItems.groupItem(groupItemId); + if (groupItem) + groupItem.close(); + }); + + for (let i=0; i<3; i++) + aWindow.gBrowser.addTab('about:blank'); + } + + let assertTabViewIsHidden = function (aWindow, prefix) { + ok(!aWindow.TabView.isVisible(), prefix + ': tabview is hidden'); + } + + let assertNumberOfTabs = function (aWindow, prefix, num) { + is(aWindow.gBrowser.tabs.length, num, prefix + ': there are ' + num + ' tabs'); + } + + let assertNumberOfPinnedTabs = function (aWindow, prefix, num) { + is(aWindow.gBrowser._numPinnedTabs, num, prefix + ': there are ' + num + ' pinned tabs'); + } + + let assertNumberOfGroups = function (aCW, prefix, num) { + is(aCW.GroupItems.groupItems.length, num, prefix + ': there are ' + num + ' groups'); + } + + let assertOneTabInGroup = function (prefix, groupItem) { + is(groupItem.getChildren().length, 1, prefix + ': group contains one tab'); + } + + let assertValidPrerequisites = function (aWindow, prefix) { + assertNumberOfTabs(aWindow, prefix, 1); + assertNumberOfPinnedTabs(aWindow, prefix, 0); + assertTabViewIsHidden(aWindow, prefix); + } + + let assertValidSetup = function (aWindow, prefix) { + let cw = aWindow.TabView.getContentWindow(); + assertNumberOfGroups(cw, prefix, 2); + assertNumberOfTabs(aWindow, prefix, 4); + assertNumberOfPinnedTabs(aWindow, prefix, 2); + + let [group1, group2] = cw.GroupItems.groupItems; + assertOneTabInGroup(prefix, group1); + assertOneTabInGroup(prefix, group2); + } + + let testStateAfterEnteringPB = function (aWindow, aCallback) { + let prefix = 'window is private'; + ok(PrivateBrowsingUtils.isWindowPrivate(aWindow), prefix); + + assertTabViewIsHidden(aWindow, prefix); + + showTabView(function () { + let cw = aWindow.TabView.getContentWindow(); + + assertNumberOfGroups(cw, prefix, 1); + assertNumberOfTabs(aWindow, prefix, 1); + assertOneTabInGroup(prefix, cw.GroupItems.groupItems[0]); + aCallback(); + }, aWindow); + } + + let testStateAfterLeavingPB = function (aWindow) { + let prefix = 'window is not private'; + ok(!PrivateBrowsingUtils.isWindowPrivate(aWindow), prefix); + + assertTabViewIsHidden(aWindow, prefix); + + showTabView(function () { + assertValidSetup(aWindow, prefix); + finishTest(aWindow); + }, aWindow); + } + + let finishTest = function (aWindow) { + let cw = aWindow.TabView.getContentWindow(); + + // Remove pinned tabs + aWindow.gBrowser.removeTab(aWindow.gBrowser.tabs[0]); + aWindow.gBrowser.removeTab(aWindow.gBrowser.tabs[0]); + + cw.GroupItems.groupItems[1].closeAll(); + + hideTabView(function () { + assertValidPrerequisites(aWindow, 'exit'); + assertNumberOfGroups(cw, 'exit', 1); + aWindow.close(); + finish(); + }, aWindow); + } + + let testOnWindow = function(aIsPrivate, aCallback) { + let win = OpenBrowserWindow({private: aIsPrivate}); + win.addEventListener("load", function onLoad() { + win.removeEventListener("load", onLoad, false); + executeSoon(function() { aCallback(win) }); + }, false); + } + + waitForExplicitFinish(); + testOnWindow(false, function(publicWindow) { + registerCleanupFunction(function () publicWindow.TabView.hide()); + assertValidPrerequisites(publicWindow, 'start'); + + showTabView(function () { + let cw = publicWindow.TabView.getContentWindow(); + assertNumberOfGroups(cw, 'start', 1); + createGroupItem(publicWindow); + + afterAllTabsLoaded(function () { + // Setup + let groupItems = cw.GroupItems.groupItems; + let [tabItem1, tabItem2, ] = groupItems[1].getChildren(); + publicWindow.gBrowser.pinTab(tabItem1.tab); + publicWindow.gBrowser.pinTab(tabItem2.tab); + + assertValidSetup(publicWindow, 'setup'); + hideTabView(function() { + testOnWindow(true, function(privateWindow) { + testStateAfterEnteringPB(privateWindow, function() { + privateWindow.close(); + hideTabView(function() { + testStateAfterLeavingPB(publicWindow); + }, publicWindow); + }); + }); + }, publicWindow); + }); + }, publicWindow); + }); +} diff --git a/browser/components/tabview/test/browser_tabview_bug650280_perwindowpb.js b/browser/components/tabview/test/browser_tabview_bug650280_perwindowpb.js new file mode 100644 index 000000000000..75c22bbcac6a --- /dev/null +++ b/browser/components/tabview/test/browser_tabview_bug650280_perwindowpb.js @@ -0,0 +1,75 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + let enableSearch = function (aCW, aCallback) { + if (aCW.Search.isEnabled()) { + aCallback(); + return; + } + + aCW.addEventListener("tabviewsearchenabled", function onSearchEnabled() { + aCW.removeEventListener("tabviewsearchenabled", onSearchEnabled, false); + executeSoon(aCallback); + }, false); + + aCW.Search.ensureShown(); + }; + + let getSearchboxValue = function (aCW) { + return aCW.iQ("#searchbox").val(); + }; + + let prepareSearchbox = function (aCW, aCallback) { + ok(!aCW.Search.isEnabled(), "search is disabled"); + + executeSoon(function() { + enableSearch(aCW, function() { + aCW.iQ("#searchbox").val("moz"); + aCallback(); + }); + }); + }; + + let searchAndSwitchPBMode = function (aWindow, aCallback) { + showTabView(function() { + let cw = aWindow.TabView.getContentWindow(); + + prepareSearchbox(cw, function() { + testOnWindow(!PrivateBrowsingUtils.isWindowPrivate(aWindow), function(win) { + showTabView(function() { + let contentWindow = win.TabView.getContentWindow(); + ok(!contentWindow.Search.isEnabled(), "search is disabled"); + is(getSearchboxValue(contentWindow), "", "search box is empty"); + aWindow.TabView.hide(); + win.close(); + hideTabView(function() { + aWindow.close(); + aCallback(); + }, aWindow); + }, win); + }); + }); + }, aWindow); + }; + + let testOnWindow = function(aIsPrivate, aCallback) { + let win = OpenBrowserWindow({private: aIsPrivate}); + win.addEventListener("load", function onLoad() { + win.removeEventListener("load", onLoad, false); + executeSoon(function() { aCallback(win) }); + }, false); + } + + waitForExplicitFinish(); + + testOnWindow(false, function(win) { + searchAndSwitchPBMode(win, function() { + testOnWindow(true, function(win) { + searchAndSwitchPBMode(win, function() { + finish(); + }); + }); + }); + }); +} diff --git a/browser/config/tooltool-manifests/linux32/clang.manifest b/browser/config/tooltool-manifests/linux32/clang.manifest index 6fbd90dbb0bd..72ed344eba75 100644 --- a/browser/config/tooltool-manifests/linux32/clang.manifest +++ b/browser/config/tooltool-manifests/linux32/clang.manifest @@ -1,6 +1,6 @@ [ { -"clang_version": "r168596" +"clang_version": "r169139" }, { "size": 47, @@ -9,8 +9,8 @@ "filename": "setup.sh" }, { -"size": 62525599, -"digest": "50818d3288713821a520c3c4c5b01f0a782a5ac5b4c8f5d2a198af150323b93d07bf6b5f87d9ef4a9b49308ce788112907a211b02d7d5123338ad6a0265100b8", +"size": 62513298, +"digest": "1c9dfc75d4a06438da4d079282178274054e07d814ec6bc8e45c9e62589293df11858c74ce301c53b5bd758c56dc1c593a97cd5034b47ea753c518fd9af69ea4", "algorithm": "sha512", "filename": "clang.tar.bz2" } diff --git a/browser/config/tooltool-manifests/linux64/clang.manifest b/browser/config/tooltool-manifests/linux64/clang.manifest index 0e34233394fa..727f6ee5139e 100644 --- a/browser/config/tooltool-manifests/linux64/clang.manifest +++ b/browser/config/tooltool-manifests/linux64/clang.manifest @@ -1,6 +1,6 @@ [ { -"clang_version": "r168596" +"clang_version": "r169139" }, { "size": 47, @@ -9,8 +9,8 @@ "filename": "setup.sh" }, { -"size": 62868457, -"digest": "f5ebd0e6a3238f309ac554f266a58e558e08dd5959579c8b9dd78ce1d88162990d850bad3164dccfced5ce2cf5aa1448baaf94878ad96c1a5fa025e567bf0d61", +"size": 62856551, +"digest": "3542a25815f89555f2e2b4c67fbffa432c341d824395b452698d8d90ee0216e045531adcad14bf7071be1a41c016b4652cf955270b652bcdbd7b04a02cc3c9f9", "algorithm": "sha512", "filename": "clang.tar.bz2" } diff --git a/browser/config/tooltool-manifests/macosx32/releng.manifest b/browser/config/tooltool-manifests/macosx32/releng.manifest index f1be4c8a135d..f363c9a95ace 100644 --- a/browser/config/tooltool-manifests/macosx32/releng.manifest +++ b/browser/config/tooltool-manifests/macosx32/releng.manifest @@ -1,6 +1,6 @@ [ { -"clang_version": "r168596" +"clang_version": "r169139" }, { "size": 47, @@ -9,8 +9,8 @@ "filename": "setup.sh" }, { -"size": 56147341, -"digest": "4baed5cbe0189a509b6a328ee35ee488250677f8ea149e6d01af74c7a4a27c898a4112f78af57b33a4e788b2947813b65ab0922e06b67bd504878803dab44f5c", +"size": 56158651, +"digest": "38d718f20a8fa9218e22ade312e724e6c9cdd7c6650e023cfdc21b5505fe7aa3743ae41c0abd717a1bbccec4c4271be2fa82d0e2f96c91e693d70e33b4dc00d6", "algorithm": "sha512", "filename": "clang.tar.bz2" } diff --git a/browser/config/tooltool-manifests/macosx64/releng.manifest b/browser/config/tooltool-manifests/macosx64/releng.manifest index f1be4c8a135d..f363c9a95ace 100644 --- a/browser/config/tooltool-manifests/macosx64/releng.manifest +++ b/browser/config/tooltool-manifests/macosx64/releng.manifest @@ -1,6 +1,6 @@ [ { -"clang_version": "r168596" +"clang_version": "r169139" }, { "size": 47, @@ -9,8 +9,8 @@ "filename": "setup.sh" }, { -"size": 56147341, -"digest": "4baed5cbe0189a509b6a328ee35ee488250677f8ea149e6d01af74c7a4a27c898a4112f78af57b33a4e788b2947813b65ab0922e06b67bd504878803dab44f5c", +"size": 56158651, +"digest": "38d718f20a8fa9218e22ade312e724e6c9cdd7c6650e023cfdc21b5505fe7aa3743ae41c0abd717a1bbccec4c4271be2fa82d0e2f96c91e693d70e33b4dc00d6", "algorithm": "sha512", "filename": "clang.tar.bz2" } diff --git a/browser/devtools/framework/Toolbox.jsm b/browser/devtools/framework/Toolbox.jsm index fba34dfb4c00..0a407d23fcd9 100644 --- a/browser/devtools/framework/Toolbox.jsm +++ b/browser/devtools/framework/Toolbox.jsm @@ -18,7 +18,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "CommandUtils", // DO NOT put Require.jsm or gcli.jsm into lazy getters as this breaks the // requisition import a few lines down. -Cu.import("resource://gre/modules/devtools/gcli.jsm"); +Cu.import("resource:///modules/devtools/gcli.jsm"); Cu.import("resource://gre/modules/devtools/Require.jsm"); let Requisition = require('gcli/cli').Requisition; diff --git a/browser/devtools/framework/test/head.js b/browser/devtools/framework/test/head.js index 796a7946c2d0..c451b9dafd3e 100644 --- a/browser/devtools/framework/test/head.js +++ b/browser/devtools/framework/test/head.js @@ -5,7 +5,7 @@ let tempScope = {}; Components.utils.import("resource:///modules/devtools/Target.jsm", tempScope); let TargetFactory = tempScope.TargetFactory; -Components.utils.import("resource:///modules/devtools/Console.jsm", tempScope); +Components.utils.import("resource://gre/modules/devtools/Console.jsm", tempScope); let console = tempScope.console; /** diff --git a/browser/devtools/inspector/InspectorPanel.jsm b/browser/devtools/inspector/InspectorPanel.jsm index c426138b18cc..9022787390ce 100644 --- a/browser/devtools/inspector/InspectorPanel.jsm +++ b/browser/devtools/inspector/InspectorPanel.jsm @@ -13,7 +13,7 @@ Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/devtools/EventEmitter.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "MarkupView", - "resource://gre/modules/devtools/MarkupView.jsm"); + "resource:///modules/devtools/MarkupView.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Selection", "resource:///modules/devtools/Selection.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "HTMLBreadcrumbs", diff --git a/browser/devtools/styleeditor/StyleEditorChrome.jsm b/browser/devtools/styleeditor/StyleEditorChrome.jsm index 7c2aeb6099e5..f827f7b6d0a8 100644 --- a/browser/devtools/styleeditor/StyleEditorChrome.jsm +++ b/browser/devtools/styleeditor/StyleEditorChrome.jsm @@ -370,17 +370,25 @@ StyleEditorChrome.prototype = { aEditor.removeActionListener(this); self.selectedStyleSheetIndex = aEditor.styleSheetIndex; aEditor.sourceEditor.setCaretPosition(line - 1, col - 1); + + let newSheet = self._styleSheetToSelect.sheet; + let newLine = self._styleSheetToSelect.line; + let newCol = self._styleSheetToSelect.col; + self._styleSheetToSelect = null; + if (newSheet != sheet) { + self._window.setTimeout(self.selectStyleSheet.bind(self, newSheet, newLine, newCol), 0); + } } }); } else { // If a line or column was specified we move the caret appropriately. aEditor.sourceEditor.setCaretPosition(line - 1, col - 1); + self._styleSheetToSelect = null; } } this._view.activeSummary = summary; this.selectedStyleSheetIndex = aEditor.styleSheetIndex; - this._styleSheetToSelect = null; }.bind(this); if (!this.editors.length) { diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js b/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js index e3d214aa5282..ccb182b1ffd5 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js @@ -150,6 +150,9 @@ function performLineCheck(aEditor, aLine, aCallback) return aEditor.sourceEditor; }, successFn: checkForCorrectState, - failureFn: finishTest, + failureFn: function() { + info("selectedStyleSheetIndex " + SEC.selectedStyleSheetIndex + " expected " + aEditor.styleSheetIndex); + finishTest(); + }, }); } diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index ebd68610cef4..d23c5fe6e869 100644 --- a/browser/extensions/pdfjs/README.mozilla +++ b/browser/extensions/pdfjs/README.mozilla @@ -1,4 +1,4 @@ This is the pdf.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 0.6.141 +Current extension version is: 0.6.172 diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index 2900a2f5dee6..ae95747b4e87 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -22,7 +22,7 @@ var PDFJS = {}; 'use strict'; PDFJS.build = -'033545c'; +'3c7ef79'; /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ @@ -517,6 +517,17 @@ var PDFDocument = (function PDFDocumentClosure() { if (find(stream, '%PDF-', 1024)) { // Found the header, trim off any garbage before it. stream.moveStart(); + // Reading file format version + var MAX_VERSION_LENGTH = 12; + var version = '', ch; + while ((ch = stream.getChar()) > ' ') { + if (version.length >= MAX_VERSION_LENGTH) { + break; + } + version += ch; + } + // removing "%PDF-"-prefix + this.pdfFormatVersion = version.substring(5); return; } // May not be a PDF file, continue anyway. @@ -537,11 +548,12 @@ var PDFDocument = (function PDFDocumentClosure() { return shadow(this, 'numPages', num); }, getDocumentInfo: function PDFDocument_getDocumentInfo() { - var docInfo; + var docInfo = { + PDFFormatVersion: this.pdfFormatVersion + }; if (this.xref.trailer.has('Info')) { var infoDict = this.xref.trailer.get('Info'); - docInfo = {}; var validEntries = DocumentInfoValidators.entries; // Only fill the document info with valid entries from the spec. for (var key in validEntries) { @@ -658,6 +670,8 @@ function assert(cond, msg) { // Combines two URLs. The baseUrl shall be absolute URL. If the url is an // absolute URL, it will be returned as is. function combineUrl(baseUrl, url) { + if (!url) + return baseUrl; if (url.indexOf(':') >= 0) return url; if (url.charAt(0) == '/') { @@ -767,15 +781,17 @@ var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; var Util = PDFJS.Util = (function UtilClosure() { function Util() {} - Util.makeCssRgb = function Util_makeCssRgb(r, g, b) { - var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0; - return 'rgb(' + ri + ',' + gi + ',' + bi + ')'; + Util.makeCssRgb = function Util_makeCssRgb(rgb) { + return 'rgb(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ')'; }; - Util.makeCssCmyk = function Util_makeCssCmyk(c, m, y, k) { - c = (new DeviceCmykCS()).getRgb([c, m, y, k]); - var ri = (255 * c[0]) | 0, gi = (255 * c[1]) | 0, bi = (255 * c[2]) | 0; - return 'rgb(' + ri + ',' + gi + ',' + bi + ')'; + Util.makeCssCmyk = function Util_makeCssCmyk(cmyk) { + var cs = new DeviceCmykCS(); + Util.makeCssCmyk = function makeCssCmyk(cmyk) { + var rgb = cs.getRgb(cmyk, 0); + return Util.makeCssRgb(rgb); + }; + return Util.makeCssCmyk(cmyk); }; // For 2d affine transforms @@ -2899,8 +2915,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { }, setStrokeColor: function CanvasGraphics_setStrokeColor(/*...*/) { var cs = this.current.strokeColorSpace; - var rgbColor = cs.getRgb(arguments); - var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); + var rgbColor = cs.getRgb(arguments, 0); + var color = Util.makeCssRgb(rgbColor); this.ctx.strokeStyle = color; this.current.strokeColor = color; }, @@ -2912,11 +2928,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (base) { var baseComps = base.numComps; - color = []; - for (var i = 0; i < baseComps; ++i) - color.push(args[i]); - - color = base.getRgb(color); + color = base.getRgb(args, 0); } var pattern = new TilingPattern(IR, color, this.ctx, this.objs); } else if (IR[0] == 'RadialAxial' || IR[0] == 'Dummy') { @@ -2937,8 +2949,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { }, setFillColor: function CanvasGraphics_setFillColor(/*...*/) { var cs = this.current.fillColorSpace; - var rgbColor = cs.getRgb(arguments); - var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); + var rgbColor = cs.getRgb(arguments, 0); + var color = Util.makeCssRgb(rgbColor); this.ctx.fillStyle = color; this.current.fillColor = color; }, @@ -2955,7 +2967,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (!(this.current.strokeColorSpace instanceof DeviceGrayCS)) this.current.strokeColorSpace = new DeviceGrayCS(); - var color = Util.makeCssRgb(gray, gray, gray); + var rgbColor = this.current.strokeColorSpace.getRgb(arguments, 0); + var color = Util.makeCssRgb(rgbColor); this.ctx.strokeStyle = color; this.current.strokeColor = color; }, @@ -2963,7 +2976,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (!(this.current.fillColorSpace instanceof DeviceGrayCS)) this.current.fillColorSpace = new DeviceGrayCS(); - var color = Util.makeCssRgb(gray, gray, gray); + var rgbColor = this.current.fillColorSpace.getRgb(arguments, 0); + var color = Util.makeCssRgb(rgbColor); this.ctx.fillStyle = color; this.current.fillColor = color; }, @@ -2971,7 +2985,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (!(this.current.strokeColorSpace instanceof DeviceRgbCS)) this.current.strokeColorSpace = new DeviceRgbCS(); - var color = Util.makeCssRgb(r, g, b); + var rgbColor = this.current.strokeColorSpace.getRgb(arguments, 0); + var color = Util.makeCssRgb(rgbColor); this.ctx.strokeStyle = color; this.current.strokeColor = color; }, @@ -2979,7 +2994,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (!(this.current.fillColorSpace instanceof DeviceRgbCS)) this.current.fillColorSpace = new DeviceRgbCS(); - var color = Util.makeCssRgb(r, g, b); + var rgbColor = this.current.fillColorSpace.getRgb(arguments, 0); + var color = Util.makeCssRgb(rgbColor); this.ctx.fillStyle = color; this.current.fillColor = color; }, @@ -2987,7 +3003,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (!(this.current.strokeColorSpace instanceof DeviceCmykCS)) this.current.strokeColorSpace = new DeviceCmykCS(); - var color = Util.makeCssCmyk(c, m, y, k); + var color = Util.makeCssCmyk(arguments); this.ctx.strokeStyle = color; this.current.strokeColor = color; }, @@ -2995,7 +3011,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (!(this.current.fillColorSpace instanceof DeviceCmykCS)) this.current.fillColorSpace = new DeviceCmykCS(); - var color = Util.makeCssCmyk(c, m, y, k); + var color = Util.makeCssCmyk(arguments); this.ctx.fillStyle = color; this.current.fillColor = color; }, @@ -3580,8 +3596,10 @@ var Catalog = (function CatalogClosure() { continue; } var names = obj.get('Names'); - for (i = 0, n = names.length; i < n; i += 2) { - dests[names[i]] = fetchDestination(xref.fetchIfRef(names[i + 1])); + if (names) { + for (i = 0, n = names.length; i < n; i += 2) { + dests[names[i]] = fetchDestination(xref.fetchIfRef(names[i + 1])); + } } } } @@ -12053,15 +12071,58 @@ var ColorSpace = (function ColorSpaceClosure() { } ColorSpace.prototype = { - // Input: array of size numComps representing color component values - // Output: array of rgb values, each value ranging from [0.1] - getRgb: function ColorSpace_getRgb(color) { - error('Should not call ColorSpace.getRgb: ' + color); + /** + * Converts the color value to the RGB color. The color components are + * located in the src array starting from the srcOffset. Returns the array + * of the rgb components, each value ranging from [0,255]. + */ + getRgb: function ColorSpace_getRgb(src, srcOffset) { + error('Should not call ColorSpace.getRgb'); }, - // Input: Uint8Array of component values, each value scaled to [0,255] - // Output: Uint8Array of rgb values, each value scaled to [0,255] - getRgbBuffer: function ColorSpace_getRgbBuffer(input) { - error('Should not call ColorSpace.getRgbBuffer: ' + input); + /** + * Converts the color value to the RGB color, similar to the getRgb method. + * The result placed into the dest array starting from the destOffset. + */ + getRgbItem: function ColorSpace_getRgb(src, srcOffset, dest, destOffset) { + error('Should not call ColorSpace.getRgbItem'); + }, + /** + * Converts the specified number of the color values to the RGB colors. + * The colors are located in the src array starting from the srcOffset. + * The result is placed into the dest array starting from the destOffset. + * The src array items shall be in [0,2^bits) range, the dest array items + * will be in [0,255] range. + */ + getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, + dest, destOffset, bits) { + error('Should not call ColorSpace.getRgbBuffer'); + }, + /** + * Determines amount of the bytes is required to store the reslut of the + * conversion that done by the getRgbBuffer method. + */ + getOutputLength: function ColorSpace_getOutputLength(inputLength) { + error('Should not call ColorSpace.getOutputLength'); + }, + /** + * Returns true if source data will be equal the result/output data. + */ + isPassthrough: function ColorSpace_isPassthrough(bits) { + return false; + }, + /** + * Creates the output buffer and converts the specified number of the color + * values to the RGB colors, similar to the getRgbBuffer. + */ + createRgbBuffer: function ColorSpace_createRgbBuffer(src, srcOffset, + count, bits) { + if (this.isPassthrough(bits)) { + return src.subarray(srcOffset); + } + var destLength = this.getOutputLength(count * this.numComps); + var dest = new Uint8Array(destLength); + this.getRgbBuffer(src, srcOffset, count, dest, 0, bits); + return dest; } }; @@ -12245,39 +12306,66 @@ var AlternateCS = (function AlternateCSClosure() { function AlternateCS(numComps, base, tintFn) { this.name = 'Alternate'; this.numComps = numComps; - this.defaultColor = []; - for (var i = 0; i < numComps; ++i) - this.defaultColor.push(1); + this.defaultColor = new Float32Array(numComps); + for (var i = 0; i < numComps; ++i) { + this.defaultColor[i] = 1; + } this.base = base; this.tintFn = tintFn; } AlternateCS.prototype = { - getRgb: function AlternateCS_getRgb(color) { - var tinted = this.tintFn(color); - return this.base.getRgb(tinted); + getRgb: function AlternateCS_getRgb(src, srcOffset) { + var rgb = new Uint8Array(3); + this.getRgbItem(src, srcOffset, rgb, 0); + return rgb; }, - getRgbBuffer: function AlternateCS_getRgbBuffer(input, bits) { + getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, + dest, destOffset) { + var baseNumComps = this.base.numComps; + var input = 'subarray' in src ? + src.subarray(srcOffset, srcOffset + this.numComps) : + Array.prototype.slice.call(src, srcOffset, srcOffset + this.numComps); + var tinted = this.tintFn(input); + this.base.getRgbItem(tinted, 0, dest, destOffset); + }, + getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, + dest, destOffset, bits) { var tintFn = this.tintFn; var base = this.base; var scale = 1 / ((1 << bits) - 1); - var length = input.length; - var pos = 0; var baseNumComps = base.numComps; - var baseBuf = new Uint8Array(baseNumComps * length); + var isGetRgbBufferSupported = 'getRgbBuffer' in base; + var isPassthrough = base.isPassthrough(8) || !isGetRgbBufferSupported; + var pos = isPassthrough ? destOffset : 0; + var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count); var numComps = this.numComps; - var scaled = []; - - for (var i = 0; i < length; i += numComps) { - for (var z = 0; z < numComps; ++z) - scaled[z] = input[i + z] * scale; + var scaled = new Float32Array(numComps); + for (var i = 0; i < count; i++) { + for (var j = 0; j < numComps; j++) { + scaled[j] = src[srcOffset++] * scale; + } var tinted = tintFn(scaled); - for (var j = 0; j < baseNumComps; ++j) - baseBuf[pos++] = 255 * tinted[j]; + if (isGetRgbBufferSupported) { + for (var j = 0; j < baseNumComps; j++) { + baseBuf[pos++] = tinted[j] * 255; + } + } else { + base.getRgbItem(tinted, 0, baseBuf, pos); + pos += baseNumComps; + } + } + if (!isPassthrough) { + base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8); } - return base.getRgbBuffer(baseBuf, 8); }, + getOutputLength: function AlternateCS_getOutputLength(inputLength) { + return this.base.getOutputLength(inputLength * + this.base.numComps / this.numComps); + }, + isPassthrough: ColorSpace.prototype.isPassthrough, + createRgbBuffer: ColorSpace.prototype.createRgbBuffer, isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) { return ColorSpace.isDefaultDecode(decodeMap, this.numComps); } @@ -12300,7 +12388,7 @@ var IndexedCS = (function IndexedCSClosure() { function IndexedCS(base, highVal, lookup) { this.name = 'Indexed'; this.numComps = 1; - this.defaultColor = [0]; + this.defaultColor = new Uint8Array([0]); this.base = base; this.highVal = highVal; @@ -12325,33 +12413,35 @@ var IndexedCS = (function IndexedCSClosure() { } IndexedCS.prototype = { - getRgb: function IndexedCS_getRgb(color) { + getRgb: function IndexedCS_getRgb(src, srcOffset) { var numComps = this.base.numComps; - var start = color[0] * numComps; - var c = []; - - for (var i = start, ii = start + numComps; i < ii; ++i) - c.push(this.lookup[i]); - - return this.base.getRgb(c); + var start = src[srcOffset] * numComps; + return this.base.getRgb(this.lookup, start); }, - getRgbBuffer: function IndexedCS_getRgbBuffer(input) { + getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, + dest, destOffset) { + var numComps = this.base.numComps; + var start = src[srcOffset] * numComps; + this.base.getRgbItem(this.lookup, start, dest, destOffset); + }, + getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, + dest, destOffset) { var base = this.base; var numComps = base.numComps; + var outputDelta = base.getOutputLength(numComps); var lookup = this.lookup; - var length = input.length; - var baseBuf = new Uint8Array(length * numComps); - var baseBufPos = 0; - for (var i = 0; i < length; ++i) { - var lookupPos = input[i] * numComps; - for (var j = 0; j < numComps; ++j) { - baseBuf[baseBufPos++] = lookup[lookupPos + j]; - } + for (var i = 0; i < count; ++i) { + var lookupPos = src[srcOffset++] * numComps; + base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8); + destOffset += outputDelta; } - - return base.getRgbBuffer(baseBuf, 8); }, + getOutputLength: function IndexedCS_getOutputLength(inputLength) { + return this.base.getOutputLength(inputLength * this.base.numComps); + }, + isPassthrough: ColorSpace.prototype.isPassthrough, + createRgbBuffer: ColorSpace.prototype.createRgbBuffer, isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) { // indexed color maps shouldn't be changed return true; @@ -12364,26 +12454,37 @@ var DeviceGrayCS = (function DeviceGrayCSClosure() { function DeviceGrayCS() { this.name = 'DeviceGray'; this.numComps = 1; - this.defaultColor = [0]; + this.defaultColor = new Float32Array([0]); } DeviceGrayCS.prototype = { - getRgb: function DeviceGrayCS_getRgb(color) { - var c = color[0]; - return [c, c, c]; + getRgb: function DeviceGrayCS_getRgb(src, srcOffset) { + var rgb = new Uint8Array(3); + this.getRgbItem(src, srcOffset, rgb, 0); + return rgb; }, - getRgbBuffer: function DeviceGrayCS_getRgbBuffer(input, bits) { + getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, + dest, destOffset) { + var c = (src[srcOffset] * 255) | 0; + c = c < 0 ? 0 : c > 255 ? 255 : c; + dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c; + }, + getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, + dest, destOffset, bits) { var scale = 255 / ((1 << bits) - 1); - var length = input.length; - var rgbBuf = new Uint8Array(length * 3); - for (var i = 0, j = 0; i < length; ++i) { - var c = (scale * input[i]) | 0; - rgbBuf[j++] = c; - rgbBuf[j++] = c; - rgbBuf[j++] = c; + var j = srcOffset, q = destOffset; + for (var i = 0; i < count; ++i) { + var c = (scale * src[j++]) | 0; + dest[q++] = c; + dest[q++] = c; + dest[q++] = c; } - return rgbBuf; }, + getOutputLength: function DeviceGrayCS_getOutputLength(inputLength) { + return inputLength * 3; + }, + isPassthrough: ColorSpace.prototype.isPassthrough, + createRgbBuffer: ColorSpace.prototype.createRgbBuffer, isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) { return ColorSpace.isDefaultDecode(decodeMap, this.numComps); } @@ -12395,22 +12496,43 @@ var DeviceRgbCS = (function DeviceRgbCSClosure() { function DeviceRgbCS() { this.name = 'DeviceRGB'; this.numComps = 3; - this.defaultColor = [0, 0, 0]; + this.defaultColor = new Float32Array([0, 0, 0]); } DeviceRgbCS.prototype = { - getRgb: function DeviceRgbCS_getRgb(color) { - return color; + getRgb: function DeviceRgbCS_getRgb(src, srcOffset) { + var rgb = new Uint8Array(3); + this.getRgbItem(src, srcOffset, rgb, 0); + return rgb; }, - getRgbBuffer: function DeviceRgbCS_getRgbBuffer(input, bits) { - if (bits == 8) - return input; + getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, + dest, destOffset) { + var r = src[srcOffset] * 255; + var g = src[srcOffset + 1] * 255; + var b = src[srcOffset + 2] * 255; + dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r; + dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g; + dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b; + }, + getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, + dest, destOffset, bits) { + var length = count * 3; + if (bits == 8) { + dest.set(src.subarray(srcOffset, srcOffset + length), destOffset); + return; + } var scale = 255 / ((1 << bits) - 1); - var i, length = input.length; - var rgbBuf = new Uint8Array(length); - for (i = 0; i < length; ++i) - rgbBuf[i] = (scale * input[i]) | 0; - return rgbBuf; + var j = srcOffset, q = destOffset; + for (var i = 0; i < length; ++i) { + dest[q++] = (scale * input[j++]) | 0; + } }, + getOutputLength: function DeviceRgbCS_getOutputLength(inputLength) { + return inputLength; + }, + isPassthrough: function DeviceRgbCS_isPassthrough(bits) { + return bits == 8; + }, + createRgbBuffer: ColorSpace.prototype.createRgbBuffer, isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) { return ColorSpace.isDefaultDecode(decodeMap, this.numComps); } @@ -13088,72 +13210,78 @@ var DeviceCmykCS = (function DeviceCmykCSClosure() { 15, 13, 26, 2, 1, 11, 0, 0, 0, 0, 0, 0, 54, 54, 57, 47, 44, 47, 39, 35, 39, 28, 25, 29, 17, 13, 17, 4, 1, 3, 0, 0, 0, 0, 0, 0]); + function convertToRgb(src, srcOffset, srcScale, dest, destOffset) { + // using lut as in spline interpolation (see function.js) + var cubeVertices = 16; // 1 << number of colors + var cubeN = new Float32Array(cubeVertices); + var cubeVertex = new Uint32Array(cubeVertices); + for (var j = 0; j < cubeVertices; j++) + cubeN[j] = 1; + + var k = 3, pos = 1; + var lutDomain = 7, lutStep = 8; + for (var i = 3; i >= 0; i--) { + var e = src[srcOffset + i] * srcScale * lutDomain; + + var e0 = e < lutDomain ? Math.floor(e) : e - 1; // e1 = e0 + 1; + var n0 = e0 + 1 - e; // (e1 - e) / (e1 - e0); + var n1 = e - e0; // (e - e0) / (e1 - e0); + var offset0 = e0 * k; + var offset1 = offset0 + k; // e1 * k + for (var j = 0; j < cubeVertices; j++) { + if (j & pos) { + cubeN[j] *= n1; + cubeVertex[j] += offset1; + } else { + cubeN[j] *= n0; + cubeVertex[j] += offset0; + } + } + + k *= lutStep; + pos <<= 1; + } + var y0 = 0, y1 = 0, y2 = 0; + for (var i = 0; i < cubeVertices; i++) + y0 += lut[cubeVertex[i]] * cubeN[i]; + for (var i = 0; i < cubeVertices; i++) + y1 += lut[cubeVertex[i] + 1] * cubeN[i]; + for (var i = 0; i < cubeVertices; i++) + y2 += lut[cubeVertex[i] + 2] * cubeN[i]; + dest[destOffset] = y0 > 255 ? 255 : y0; + dest[destOffset + 1] = y1 > 255 ? 255 : y1; + dest[destOffset + 2] = y2 > 255 ? 255 : y2; + } + function DeviceCmykCS() { this.name = 'DeviceCMYK'; this.numComps = 4; - this.defaultColor = [0, 0, 0, 1]; + this.defaultColor = new Float32Array([0, 0, 0, 1]); } DeviceCmykCS.prototype = { - getRgb: function DeviceCmykCS_getRgb(color) { - // using lut as in spline interpolation (see function.js) - var cubeVertices = 16; // 1 << number of colors - var cubeN = new Float32Array(cubeVertices); - var cubeVertex = new Uint32Array(cubeVertices); - for (var j = 0; j < cubeVertices; j++) - cubeN[j] = 1; - - var k = 3, pos = 1; - var lutDomain = 7, lutStep = 8; - for (var i = 3; i >= 0; i--) { - var e = color[i] * lutDomain; - - var e0 = e < lutDomain ? Math.floor(e) : e - 1; // e1 = e0 + 1; - var n0 = e0 + 1 - e; // (e1 - e) / (e1 - e0); - var n1 = e - e0; // (e - e0) / (e1 - e0); - var offset0 = e0 * k; - var offset1 = offset0 + k; // e1 * k - for (var j = 0; j < cubeVertices; j++) { - if (j & pos) { - cubeN[j] *= n1; - cubeVertex[j] += offset1; - } else { - cubeN[j] *= n0; - cubeVertex[j] += offset0; - } - } - - k *= lutStep; - pos <<= 1; - } - var y = new Float32Array(3); - for (var j = 0; j < 3; ++j) { - var rj = 0; - for (var i = 0; i < cubeVertices; i++) - rj += lut[cubeVertex[i] + j] * cubeN[i]; - y[j] = rj; - } - - return [y[0] / 255, y[1] / 255, y[2] / 255]; + getRgb: function DeviceCmykCS_getRgb(src, srcOffset) { + var rgb = new Uint8Array(3); + convertToRgb(src, srcOffset, 1, rgb, 0); + return rgb; }, - getRgbBuffer: function DeviceCmykCS_getRgbBuffer(colorBuf, bits) { + getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, + dest, destOffset) { + convertToRgb(src, srcOffset, 1, dest, destOffset); + }, + getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, + dest, destOffset, bits) { var scale = 1 / ((1 << bits) - 1); - var length = colorBuf.length / 4; - var rgbBuf = new Uint8Array(length * 3); - var rgbBufPos = 0; - var colorBufPos = 0; - - for (var i = 0; i < length; i++) { - var cmyk = []; - for (var j = 0; j < 4; ++j) - cmyk.push(scale * colorBuf[colorBufPos++]); - - var rgb = this.getRgb(cmyk); - for (var j = 0; j < 3; ++j) - rgbBuf[rgbBufPos++] = Math.round(rgb[j] * 255); + for (var i = 0; i < count; i++) { + convertToRgb(src, srcOffset, scale, dest, destOffset); + srcOffset += 4; + destOffset += 3; } - - return rgbBuf; }, + getOutputLength: function DeviceCmykCS_getOutputLength(inputLength) { + return (inputLength >> 2) * 3; + }, + isPassthrough: ColorSpace.prototype.isPassthrough, + createRgbBuffer: ColorSpace.prototype.createRgbBuffer, isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) { return ColorSpace.isDefaultDecode(decodeMap, this.numComps); } @@ -13169,7 +13297,7 @@ var LabCS = (function LabCSClosure() { function LabCS(whitePoint, blackPoint, range) { this.name = 'Lab'; this.numComps = 3; - this.defaultColor = [0, 0, 0]; + this.defaultColor = new Float32Array([0, 0, 0]); if (!whitePoint) error('WhitePoint missing - required for color space Lab'); @@ -13210,58 +13338,66 @@ var LabCS = (function LabCSClosure() { }; // Function g(x) from spec - function g(x) { + function fn_g(x) { if (x >= 6 / 29) return x * x * x; else return (108 / 841) * (x - 4 / 29); } + function convertToRgb(cs, src, srcOffset, dest, destOffset) { + // Ls,as,bs <---> L*,a*,b* in the spec + var Ls = src[srcOffset]; + var as = src[srcOffset + 1]; + var bs = src[srcOffset + 2]; + + // Adjust limits of 'as' and 'bs' + as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as; + bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs; + + // Computes intermediate variables X,Y,Z as per spec + var M = (Ls + 16) / 116; + var L = M + (as / 500); + var N = M - (bs / 200); + + var X = cs.XW * fn_g(L); + var Y = cs.YW * fn_g(M); + var Z = cs.ZW * fn_g(N); + + var r, g, b; + // Using different conversions for D50 and D65 white points, + // per http://www.color.org/srgb.pdf + if (cs.ZW < 1) { + // Assuming D50 (X=0.9642, Y=1.00, Z=0.8249) + r = X * 3.1339 + Y * -1.6170 + Z * -0.4906; + g = X * -0.9785 + Y * 1.9160 + Z * 0.0333; + b = X * 0.0720 + Y * -0.2290 + Z * 1.4057; + } else { + // Assuming D65 (X=0.9505, Y=1.00, Z=1.0888) + r = X * 3.2406 + Y * -1.5372 + Z * -0.4986; + g = X * -0.9689 + Y * 1.8758 + Z * 0.0415; + b = X * 0.0557 + Y * -0.2040 + Z * 1.0570; + } + + // clamp color values to [0,255] range + dest[destOffset] = r < 0 ? 0 : r > 1 ? 255 : r * 255; + dest[destOffset + 1] = g < 0 ? 0 : g > 1 ? 255 : g * 255; + dest[destOffset + 2] = b < 0 ? 0 : b > 1 ? 255 : b * 255; + } + LabCS.prototype = { - getRgb: function LabCS_getRgb(color) { - // Ls,as,bs <---> L*,a*,b* in the spec - var Ls = color[0], as = color[1], bs = color[2]; - - // Adjust limits of 'as' and 'bs' - as = as > this.amax ? this.amax : as; - as = as < this.amin ? this.amin : as; - bs = bs > this.bmax ? this.bmax : bs; - bs = bs < this.bmin ? this.bmin : bs; - - // Computes intermediate variables X,Y,Z as per spec - var M = (Ls + 16) / 116; - var L = M + (as / 500); - var N = M - (bs / 200); - var X = this.XW * g(L); - var Y = this.YW * g(M); - var Z = this.ZW * g(N); - - // XYZ to RGB 3x3 matrix, from: - // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC18 - var XYZtoRGB = [3.240479, -1.537150, -0.498535, - -0.969256, 1.875992, 0.041556, - 0.055648, -0.204043, 1.057311]; - - return Util.apply3dTransform(XYZtoRGB, [X, Y, Z]); + getRgb: function LabCS_getRgb(src, srcOffset) { + var rgb = new Uint8Array(3); + convertToRgb(this, src, srcOffset, rgb, 0); + return rgb; }, - getRgbBuffer: function LabCS_getRgbBuffer(input, bits) { - if (bits == 8) - return input; - var scale = 255 / ((1 << bits) - 1); - var i, length = input.length / 3; - var rgbBuf = new Uint8Array(length); - - var j = 0; - for (i = 0; i < length; ++i) { - // Convert L*, a*, s* into RGB - var rgb = this.getRgb([input[i], input[i + 1], input[i + 2]]); - rgbBuf[j++] = rgb[0]; - rgbBuf[j++] = rgb[1]; - rgbBuf[j++] = rgb[2]; - } - - return rgbBuf; + getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) { + convertToRgb(this, src, srcOffset, dest, destOffset); }, + getOutputLength: function LabCS_getOutputLength(inputLength) { + return inputLength; + }, + isPassthrough: ColorSpace.prototype.isPassthrough, isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) { // From Table 90 in Adobe's: // "Document management - Portable document format", 1st ed, 2008 @@ -26097,8 +26233,8 @@ var PDFImage = (function PDFImageClosure() { var actualHeight = 0 | (imgArray.length / rowBytes * height / originalHeight); - var comps = this.colorSpace.getRgbBuffer( - this.getComponents(imgArray), bpc); + var comps = this.colorSpace.createRgbBuffer(this.getComponents(imgArray), + 0, originalWidth * originalHeight, bpc); if (originalWidth != width || originalHeight != height) comps = PDFImage.resize(comps, this.bpc, 3, originalWidth, originalHeight, width, height); @@ -29850,11 +29986,29 @@ Shadings.RadialAxial = (function RadialAxialClosure() { this.extendEnd = extendEnd; var fnObj = dict.get('Function'); - if (isArray(fnObj)) - error('No support for array of functions'); - if (!isPDFFunction(fnObj)) - error('Invalid function'); - var fn = PDFFunction.parse(xref, fnObj); + var fn; + if (isArray(fnObj)) { + var fnArray = []; + for (var j = 0, jj = fnObj.length; j < jj; j++) { + var obj = xref.fetchIfRef(fnObj[j]); + if (!isPDFFunction(obj)) { + error('Invalid function'); + } + fnArray.push(PDFFunction.parse(xref, obj)); + } + fn = function radialAxialColorFunction(arg) { + var out = []; + for (var i = 0, ii = fnArray.length; i < ii; i++) { + out.push(fnArray[i](arg)[0]); + } + return out; + }; + } else { + if (!isPDFFunction(fnObj)) { + error('Invalid function'); + } + fn = PDFFunction.parse(xref, fnObj); + } // 10 samples seems good enough for now, but probably won't work // if there are sharp color changes. Ideally, we would implement @@ -29873,15 +30027,15 @@ Shadings.RadialAxial = (function RadialAxialClosure() { } for (var i = t0; i <= t1; i += step) { - var rgbColor = cs.getRgb(fn([i])); - var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); + var rgbColor = cs.getRgb(fn([i]), 0); + var cssColor = Util.makeCssRgb(rgbColor); colorStops.push([(i - t0) / diff, cssColor]); } var background = 'transparent'; if (dict.has('Background')) { - var rgbColor = cs.getRgb(dict.get('Background')); - background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); + var rgbColor = cs.getRgb(dict.get('Background'), 0); + background = Util.makeCssRgb(rgbColor); } if (!extendStart) { @@ -30029,7 +30183,8 @@ var TilingPattern = (function TilingPatternClosure() { tmpCtx.strokeStyle = ctx.strokeStyle; break; case PaintType.UNCOLORED: - var cssColor = Util.makeCssRgb(this, color[0], color[1], color[2]); + var rgbColor = new DeviceRgbCS().getRgb(color, 0); + var cssColor = Util.makeCssRgb(rgbColor); tmpCtx.fillStyle = cssColor; tmpCtx.strokeStyle = cssColor; break; diff --git a/browser/extensions/pdfjs/content/web/viewer.html b/browser/extensions/pdfjs/content/web/viewer.html index 1b45a4b3b23e..08b59e19cb39 100644 --- a/browser/extensions/pdfjs/content/web/viewer.html +++ b/browser/extensions/pdfjs/content/web/viewer.html @@ -32,7 +32,6 @@ limitations under the License. - diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index ff0b6780cdcd..7b29b3bd7c8a 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -681,11 +681,11 @@ var PDFFindBar = { case FindStates.FIND_WRAPPED: if (previous) { - findMsg = mozL10n.get('find_wrapped_to_bottom', null, - 'Reached top of page, continued from bottom'); + findMsg = mozL10n.get('find_reached_top', null, + 'Reached top of document, continued from bottom'); } else { - findMsg = mozL10n.get('find_wrapped_to_top', null, - 'Reached end of page, continued from top'); + findMsg = mozL10n.get('find_reached_bottom', null, + 'Reached end of document, continued from top'); } break; } @@ -966,14 +966,18 @@ var PDFView = { setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { this.url = url; try { - document.title = decodeURIComponent(getFileName(url)) || url; + this.setTitle(decodeURIComponent(getFileName(url)) || url); } catch (e) { // decodeURIComponent may throw URIError, // fall back to using the unprocessed url in that case - document.title = url; + this.setTitle(url); } }, + setTitle: function pdfViewSetTitle(title) { + document.title = title; + }, + open: function pdfViewOpen(url, scale, password) { var parameters = {password: password}; if (typeof url === 'string') { // URL @@ -1286,6 +1290,11 @@ var PDFView = { self.documentInfo = info; self.metadata = metadata; + // Provides some basic debug information + console.log('PDF ' + pdfDocument.fingerprint + ' [' + + info.PDFFormatVersion + ' ' + (info.Producer || '-') + + ' / ' + (info.Creator || '-') + ']'); + var pdfTitle; if (metadata) { if (metadata.has('dc:title')) @@ -1296,7 +1305,7 @@ var PDFView = { pdfTitle = info['Title']; if (pdfTitle) - document.title = pdfTitle + ' - ' + document.title; + self.setTitle(pdfTitle + ' - ' + document.title); }); }, @@ -2986,7 +2995,7 @@ function selectScaleOption(value) { } window.addEventListener('localized', function localized(evt) { - document.getElementsByTagName('html')[0].dir = mozL10n.language.direction; + document.getElementsByTagName('html')[0].dir = mozL10n.getDirection(); }, true); window.addEventListener('scalechange', function scalechange(evt) { diff --git a/browser/installer/removed-files.in b/browser/installer/removed-files.in index 3c280fff3a7e..8b07d5ebce67 100644 --- a/browser/installer/removed-files.in +++ b/browser/installer/removed-files.in @@ -704,7 +704,6 @@ uninstall/UninstallDeerPark.exe uninstall/UninstallFirefox.exe uninstall/uninst.exe uninstall/uninstall.exe -update.locale #ifndef MOZ_UPDATER #ifdef XP_MACOSX updater.app/ @@ -715,6 +714,7 @@ update.locale #endif xpicleanup@BIN_SUFFIX@ #ifdef MOZ_OMNIJAR + update.locale omni.jar chrome/af.jar chrome/af.manifest diff --git a/browser/locales/en-US/chrome/browser/aboutPrivateBrowsing.dtd b/browser/locales/en-US/chrome/browser/aboutPrivateBrowsing.dtd index eea7452bf294..0b3d3a95fae4 100644 --- a/browser/locales/en-US/chrome/browser/aboutPrivateBrowsing.dtd +++ b/browser/locales/en-US/chrome/browser/aboutPrivateBrowsing.dtd @@ -8,16 +8,27 @@ + + + + + + + + + + + diff --git a/browser/locales/en-US/chrome/browser/browser.dtd b/browser/locales/en-US/chrome/browser/browser.dtd index 0b1b5af98bfb..0e9995c6f697 100644 --- a/browser/locales/en-US/chrome/browser/browser.dtd +++ b/browser/locales/en-US/chrome/browser/browser.dtd @@ -586,8 +586,6 @@ just addresses the organization to follow, e.g. "This site is run by " --> - - diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index 822863107232..841decb81dc5 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -232,14 +232,6 @@ identity.unknown.tooltip=This website does not supply identity information. identity.ownerUnknown2=(unknown) -# Downloads Monitor Panel -# LOCALIZATION NOTE (activeDownloads1, pausedDownloads1): Semi-colon list of plural -# forms. See: http://developer.mozilla.org/en/docs/Localization_and_Plurals -# #1 number of downloads; #2 time left -# examples: 1 active download (2 minutes remaining); 11 paused downloads -activeDownloads1=1 active download (#2);#1 active downloads (#2) -pausedDownloads1=1 paused download;#1 paused downloads - # Edit Bookmark UI editBookmarkPanel.pageBookmarkedTitle=Page Bookmarked editBookmarkPanel.pageBookmarkedDescription=%S will always remember this page for you. diff --git a/browser/locales/en-US/pdfviewer/viewer.properties b/browser/locales/en-US/pdfviewer/viewer.properties index 0ed13f5343a1..b36c73cb5e7d 100644 --- a/browser/locales/en-US/pdfviewer/viewer.properties +++ b/browser/locales/en-US/pdfviewer/viewer.properties @@ -78,8 +78,8 @@ find_next.title=Find the next occurrence of the phrase find_next_label=Next find_highlight=Highlight all find_match_case_label=Match case -find_wrapped_to_bottom=Reached top of page, continued from bottom -find_wrapped_to_top=Reached end of page, continued from top +find_reached_top=Reached top of document, continued from bottom +find_reached_bottom=Reached end of document, continued from top find_not_found=Phrase not found # Error panel labels diff --git a/browser/themes/gnomestripe/browser.css b/browser/themes/gnomestripe/browser.css index 4bf94b8d4b96..24e4721c1446 100644 --- a/browser/themes/gnomestripe/browser.css +++ b/browser/themes/gnomestripe/browser.css @@ -501,6 +501,7 @@ menuitem:not([type]):not(.menuitem-tooltip):not(.menuitem-iconic-tooltip) { } #appmenu_privateBrowsing, +#appmenu_newPrivateWindow, #privateBrowsingItem { list-style-image: url("chrome://browser/skin/Privacy-16.png"); } @@ -1790,12 +1791,6 @@ toolbar[mode="text"] toolbarbutton.chevron > .toolbarbutton-icon { display: -moz-box; /* display chevron icon in text mode */ } -#download-monitor { - list-style-image: url("chrome://browser/skin/Toolbar-small.png"); - -moz-image-region: rect(0px 16px 16px 0px); -} - - /* ::::: Keyboard UI Panel ::::: */ .KUI-panel-closebutton { diff --git a/browser/themes/pinstripe/browser.css b/browser/themes/pinstripe/browser.css index 614317940f3c..6e5af56d995a 100644 --- a/browser/themes/pinstripe/browser.css +++ b/browser/themes/pinstripe/browser.css @@ -3130,10 +3130,6 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { @hudButtonPressed@ } -#download-monitor { - list-style-image: url("chrome://mozapps/skin/downloads/downloadStatusIcon.png"); -} - /* ::::: Keyboard UI Panel ::::: */ .KUI-panel { diff --git a/browser/themes/winstripe/browser.css b/browser/themes/winstripe/browser.css index 96d3b972ad3a..f2a231befc13 100644 --- a/browser/themes/winstripe/browser.css +++ b/browser/themes/winstripe/browser.css @@ -416,7 +416,8 @@ -moz-image-region: rect(0px 48px 16px 32px); } -#appmenu_privateBrowsing { +#appmenu_privateBrowsing, +#appmenu_newPrivateWindow { list-style-image: url("chrome://browser/skin/Privacy-16.png"); } @@ -2407,11 +2408,6 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] { min-width: 280px; } -#download-monitor { - list-style-image: url("chrome://browser/skin/Toolbar.png"); - -moz-image-region: rect(0, 108px, 18px, 90px); -} - /* Bookmarks roots menu-items */ #appmenu_subscribeToPage:not([disabled]), #appmenu_subscribeToPageMenu, diff --git a/build/macosx/mozconfig.leopard b/build/macosx/mozconfig.leopard index 125f0d94f1b3..a7edd6dc45ea 100644 --- a/build/macosx/mozconfig.leopard +++ b/build/macosx/mozconfig.leopard @@ -12,7 +12,7 @@ RANLIB=ranlib AR=ar AS=$CC LD=ld -STRIP="strip -x -S" +STRIP="strip" MOZ_CAN_RUN_PROGRAMS=1 diff --git a/build/macosx/universal/mozconfig.common b/build/macosx/universal/mozconfig.common index 596908877ce6..88eb37947fea 100644 --- a/build/macosx/universal/mozconfig.common +++ b/build/macosx/universal/mozconfig.common @@ -39,7 +39,7 @@ if test "$MOZ_BUILD_APP" = "i386" -o "$MOZ_BUILD_APP" = "x86_64"; then AR=ar AS=$CC LD=ld - STRIP="strip -x -S" + STRIP="strip" # Let configure know that we mean business. if test "$NATIVE_CPU" != "$TARGET_CPU" ; then diff --git a/build/unix/build-clang/build-clang.py b/build/unix/build-clang/build-clang.py index 9b913edf8ec3..27c2c5283f37 100755 --- a/build/unix/build-clang/build-clang.py +++ b/build/unix/build-clang/build-clang.py @@ -3,7 +3,7 @@ # 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/. -llvm_revision = "168596" +llvm_revision = "169139" moz_version = "moz0" ############################################## diff --git a/configure.in b/configure.in index bc3d40d6b836..f2295bf1d638 100644 --- a/configure.in +++ b/configure.in @@ -5254,6 +5254,20 @@ if test -n "$MOZ_WEBRTC"; then MOZ_VP8=1 MOZ_VP8_ENCODER=1 MOZ_VP8_ERROR_CONCEALMENT=1 + + dnl OpenSLES is only available in Android 2.3 and later; we'll change this + dnl hard dependency to a dynamic load with graceful runtime failure before + dnl we make --enable-webrtc on by default in Android (bug 815905) + dnl + if test "$OS_TARGET" = "Android"; then + LDFLAGS="$LDFLAGS -lOpenSLES" + fi + case "$target" in + *-android*|*-linuxandroid*) + LDFLAGS="$LDFLAGS -lOpenSLES" + ;; + esac + dnl enable once Signaling lands MOZ_WEBRTC_SIGNALING=1 AC_DEFINE(MOZ_WEBRTC_SIGNALING) @@ -5270,6 +5284,7 @@ dnl enable once PeerConnection lands fi AC_SUBST(MOZ_WEBRTC) +AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS) AC_SUBST(MOZ_WEBRTC_SIGNALING) AC_SUBST(MOZ_PEERCONNECTION) AC_SUBST(MOZ_WEBRTC_IN_LIBXUL) @@ -8510,6 +8525,7 @@ fi MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"} AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION") +AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME") AC_SUBST(MOZ_APP_NAME) AC_SUBST(MOZ_APP_DISPLAYNAME) @@ -8851,6 +8867,28 @@ echo $MAKEFILES > unallmakefiles AC_OUTPUT($MAKEFILES) +# target_arch is from {ia32|x64|arm} +case "$CPU_ARCH" in +x86_64 | ia64) + WEBRTC_TARGET_ARCH=x64 + ;; + +arm*) + WEBRTC_TARGET_ARCH=arm + ;; + +x86) + WEBRTC_TARGET_ARCH=ia32 + ;; + +*) +# unsupported arch for webrtc + WEBRTC_TARGET_ARCH=unknown + MOZ_WEBRTC= + ;; + +esac + # Generate Makefiles for WebRTC directly from .gyp files if test "${OS_TARGET}" = "WINNT"; then if test "$HAVE_64BIT_OS"; then @@ -8859,6 +8897,9 @@ if test "${OS_TARGET}" = "WINNT"; then OS_BITS=32 fi EXTRA_GYP_DEFINES="-D MSVS_VERSION=${_MSVS_VERSION} -D MSVS_OS_BITS=${OS_BITS}" + +elif test "${OS_TARGET}" = "Android"; then + EXTRA_GYP_DEFINES="-D gtest_target_type=executable -D android_toolchain=${android_toolchain} -G os=android " fi if test -n "$MOZ_WEBRTC"; then @@ -8868,7 +8909,7 @@ dnl Any --include files must also appear in -D FORCED_INCLUDE_FILE= entries dnl so that regeneration via dependencies works correctly WEBRTC_CONFIG="-D build_with_mozilla=1 --include ${srcdir}/media/webrtc/webrtc_config.gypi -D FORCED_INCLUDE_FILE=${srcdir}/media/webrtc/webrtc_config.gypi" - GYP_WEBRTC_OPTIONS="--format=mozmake ${WEBRTC_CONFIG} ${EXTRA_GYP_DEFINES} --depth=${srcdir}/media/webrtc/trunk --toplevel-dir=${srcdir} -G OBJDIR=${_objdir}" + GYP_WEBRTC_OPTIONS="--format=mozmake ${WEBRTC_CONFIG} -D target_arch=${WEBRTC_TARGET_ARCH} ${EXTRA_GYP_DEFINES} --depth=${srcdir}/media/webrtc/trunk --toplevel-dir=${srcdir} -G OBJDIR=${_objdir}" $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \ $GYP_WEBRTC_OPTIONS \ diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index f861c1cb9353..954b49b7a6e8 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -1285,8 +1285,8 @@ public: * keep alive * @param aTracer the tracer for aScriptObject */ - static nsresult HoldJSObjects(void* aScriptObjectHolder, - nsScriptObjectTracer* aTracer); + static void HoldJSObjects(void* aScriptObjectHolder, + nsScriptObjectTracer* aTracer); /** * Drop the JS objects held by aScriptObjectHolder. @@ -1294,7 +1294,7 @@ public: * @param aScriptObjectHolder the object that holds JS objects that we want to * drop */ - static nsresult DropJSObjects(void* aScriptObjectHolder); + static void DropJSObjects(void* aScriptObjectHolder); #ifdef DEBUG static bool AreJSObjectsHeld(void* aScriptObjectHolder); diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 59306fed39ef..252ce1248f70 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -2560,6 +2560,8 @@ Element::MozMatchesSelector(const nsAString& aSelector, nsRuleWalker::eRelevantLinkUnvisited, OwnerDoc(), TreeMatchContext::eNeverMatchVisited); + matchingContext.SetHasSpecifiedScope(); + matchingContext.AddScopeElement(this); return nsCSSRuleProcessor::SelectorListMatches(this, matchingContext, selectorList); } diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 8ee68b534b96..06e2172ec6fa 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -4512,24 +4512,23 @@ nsContentUtils::DestroyAnonymousContent(nsCOMPtr* aContent) } /* static */ -nsresult +void nsContentUtils::HoldJSObjects(void* aScriptObjectHolder, nsScriptObjectTracer* aTracer) { - NS_ENSURE_TRUE(sXPConnect, NS_ERROR_UNEXPECTED); - - return sXPConnect->AddJSHolder(aScriptObjectHolder, aTracer); + MOZ_ASSERT(sXPConnect, "Tried to HoldJSObjects when there was no XPConnect"); + if (sXPConnect) { + sXPConnect->AddJSHolder(aScriptObjectHolder, aTracer); + } } /* static */ -nsresult +void nsContentUtils::DropJSObjects(void* aScriptObjectHolder) { - if (!sXPConnect) { - return NS_OK; + if (sXPConnect) { + sXPConnect->RemoveJSHolder(aScriptObjectHolder); } - - return sXPConnect->RemoveJSHolder(aScriptObjectHolder); } #ifdef DEBUG @@ -4537,9 +4536,7 @@ nsContentUtils::DropJSObjects(void* aScriptObjectHolder) bool nsContentUtils::AreJSObjectsHeld(void* aScriptHolder) { - bool isHeld = false; - sXPConnect->TestJSHolder(aScriptHolder, &isHeld); - return isHeld; + return sXPConnect->TestJSHolder(aScriptHolder); } #endif diff --git a/content/base/src/nsDOMParser.cpp b/content/base/src/nsDOMParser.cpp index b8843d124266..e3033c58a3e9 100644 --- a/content/base/src/nsDOMParser.cpp +++ b/content/base/src/nsDOMParser.cpp @@ -61,9 +61,9 @@ nsDOMParser::ParseFromString(const nsAString& aStr, SupportedType aType, ErrorResult& rv) { nsCOMPtr domDocument; - rv = nsDOMParser::ParseFromString(PromiseFlatString(aStr).get(), - SupportedTypeValues::strings[aType].value, - getter_AddRefs(domDocument)); + rv = ParseFromString(aStr, + SupportedTypeValues::strings[aType].value, + getter_AddRefs(domDocument)); nsCOMPtr document(do_QueryInterface(domDocument)); return document.forget(); } @@ -74,6 +74,16 @@ nsDOMParser::ParseFromString(const PRUnichar *str, nsIDOMDocument **aResult) { NS_ENSURE_ARG(str); + // Converting a string to an enum value manually is a bit of a pain, + // so let's just use a helper that takes a content-type string. + return ParseFromString(nsDependentString(str), contentType, aResult); +} + +nsresult +nsDOMParser::ParseFromString(const nsAString& str, + const char *contentType, + nsIDOMDocument **aResult) +{ NS_ENSURE_ARG_POINTER(aResult); nsresult rv; @@ -96,8 +106,7 @@ nsDOMParser::ParseFromString(const PRUnichar *str, // And the right principal document->SetPrincipal(mPrincipal); - nsDependentString sourceBuffer(str); - rv = nsContentUtils::ParseDocumentHTML(sourceBuffer, document, false); + rv = nsContentUtils::ParseDocumentHTML(str, document, false); NS_ENSURE_SUCCESS(rv, rv); domDocument.forget(aResult); diff --git a/content/base/src/nsDOMParser.h b/content/base/src/nsDOMParser.h index 8f76484c467f..9b555a081d1b 100644 --- a/content/base/src/nsDOMParser.h +++ b/content/base/src/nsDOMParser.h @@ -89,6 +89,10 @@ private: nsresult SetUpDocument(DocumentFlavor aFlavor, nsIDOMDocument** aResult); + // Helper for ParseFromString + nsresult ParseFromString(const nsAString& str, const char *contentType, + nsIDOMDocument **aResult); + class AttemptedInitMarker { public: AttemptedInitMarker(bool* aAttemptedInit) : diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index cbde29209b78..2205dbf10e2c 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2108,7 +2108,7 @@ AppendAuthorSheet(nsIStyleSheet *aSheet, void *aData) static void AppendSheetsToStyleSet(nsStyleSet* aStyleSet, const nsCOMArray& aSheets, - nsStyleSet::sheetType aType) + nsStyleSet::sheetType aType) { for (int32_t i = aSheets.Count() - 1; i >= 0; --i) { aStyleSet->AppendStyleSheet(aType, aSheets[i]); @@ -7290,7 +7290,7 @@ nsDocument::CloneDocHelper(nsDocument* clone) const if (mCreatingStaticClone) { nsCOMPtr loadGroup; - + // |mDocumentContainer| is the container of the document that is being // created and not the original container. See CreateStaticClone function(). nsCOMPtr docLoader = do_QueryReferent(mDocumentContainer); @@ -9496,6 +9496,8 @@ nsDocument::UpdateVisibilityState() NS_LITERAL_STRING("mozvisibilitychange"), /* bubbles = */ true, /* cancelable = */ false); + + EnumerateFreezableElements(NotifyActivityChanged, nullptr); } } diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 0e8656df386b..cb8d96ca8bfd 100644 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -570,6 +570,7 @@ GK_ATOM(mouseout, "mouseout") GK_ATOM(mouseover, "mouseover") GK_ATOM(mousethrough, "mousethrough") GK_ATOM(mouseup, "mouseup") +GK_ATOM(mozaudiochannel, "mozaudiochannel") GK_ATOM(mozasyncpanzoom, "mozasyncpanzoom") GK_ATOM(mozfullscreenchange, "mozfullscreenchange") GK_ATOM(mozfullscreenerror, "mozfullscreenerror") diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 47142e9d616b..501ff8f2daa9 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -2198,6 +2198,16 @@ ParseSelectorList(nsINode* aNode, return NS_OK; } +static void +AddScopeElements(TreeMatchContext& aMatchContext, + nsINode* aMatchContextNode) +{ + if (aMatchContextNode->IsElement()) { + aMatchContext.SetHasSpecifiedScope(); + aMatchContext.AddScopeElement(aMatchContextNode->AsElement()); + } +} + // Actually find elements matching aSelectorList (which must not be // null) and which are descendants of aRoot and put them in aList. If // onlyFirstMatch, then stop once the first one is found. @@ -2218,6 +2228,7 @@ FindMatchingElements(nsINode* aRoot, const nsAString& aSelector, T &aList) TreeMatchContext matchingContext(false, nsRuleWalker::eRelevantLinkUnvisited, doc, TreeMatchContext::eNeverMatchVisited); doc->FlushPendingLinkUpdates(); + AddScopeElements(matchingContext, aRoot); // Fast-path selectors involving IDs. We can only do this if aRoot // is in the document and the document is not in quirks mode, since diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index 1df4966bbae2..abb5fa8d163e 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -24,6 +24,7 @@ #include "nsIPrincipal.h" #include "nsContentPolicyUtils.h" #include "nsIHttpChannel.h" +#include "nsIHttpChannelInternal.h" #include "nsIScriptElement.h" #include "nsIDOMHTMLScriptElement.h" #include "nsIDocShell.h" @@ -257,7 +258,8 @@ nsScriptLoader::ShouldLoadScript(nsIDocument* aDocument, } nsresult -nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType) +nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType, + bool aScriptFromHead) { nsISupports *context = aRequest->mElement.get() ? static_cast(aRequest->mElement.get()) @@ -302,6 +304,15 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType) channelPolicy); NS_ENSURE_SUCCESS(rv, rv); + nsIScriptElement *script = aRequest->mElement; + if (aScriptFromHead && + !(script && (script->GetScriptAsync() || script->GetScriptDeferred()))) { + nsCOMPtr + internalHttpChannel(do_QueryInterface(channel)); + if (internalHttpChannel) + internalHttpChannel->SetLoadAsBlocking(true); + } + nsCOMPtr httpChannel(do_QueryInterface(channel)); if (httpChannel) { // HTTP content negotation has little value in this context. @@ -518,7 +529,10 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) request->mURI = scriptURI; request->mIsInline = false; request->mLoading = true; - rv = StartLoad(request, type); + + // set aScriptFromHead to false so we don't treat non preloaded scripts as + // blockers for full page load. See bug 792438. + rv = StartLoad(request, type, false); if (NS_FAILED(rv)) { // Asynchronously report the load failure NS_DispatchToCurrentThread( @@ -1236,7 +1250,8 @@ nsScriptLoader::ParsingComplete(bool aTerminated) void nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset, const nsAString &aType, - const nsAString &aCrossOrigin) + const nsAString &aCrossOrigin, + bool aScriptFromHead) { // Check to see if scripts has been turned off. if (!mEnabled || !mDocument->IsScriptEnabled()) { @@ -1249,7 +1264,7 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset, request->mURI = aURI; request->mIsInline = false; request->mLoading = true; - nsresult rv = StartLoad(request, aType); + nsresult rv = StartLoad(request, aType, aScriptFromHead); if (NS_FAILED(rv)) { return; } diff --git a/content/base/src/nsScriptLoader.h b/content/base/src/nsScriptLoader.h index bc2c6b1afb00..9518628799a4 100644 --- a/content/base/src/nsScriptLoader.h +++ b/content/base/src/nsScriptLoader.h @@ -200,10 +200,12 @@ public: * @param aType The type parameter for the script. * @param aCrossOrigin The crossorigin attribute for the script. * Void if not present. + * @param aScriptFromHead Whether or not the script was a child of head */ virtual void PreloadURI(nsIURI *aURI, const nsAString &aCharset, const nsAString &aType, - const nsAString &aCrossOrigin); + const nsAString &aCrossOrigin, + bool aScriptFromHead); private: /** @@ -228,7 +230,8 @@ private: /** * Start a load for aRequest's URI. */ - nsresult StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType); + nsresult StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType, + bool aScriptFromHead); /** * Process any pending requests asynchronously (i.e. off an event) if there diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 530bb32423db..925da46f427b 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -78,6 +78,7 @@ #include "mozilla/Attributes.h" #include "nsIPermissionManager.h" #include "nsMimeTypes.h" +#include "nsIHttpChannelInternal.h" #include "nsWrapperCacheInlines.h" #include "nsStreamListenerWrapper.h" @@ -2964,6 +2965,15 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable& aBody) // the channel slow by default for pipeline purposes AddLoadFlags(mChannel, nsIRequest::INHIBIT_PIPELINE); + nsCOMPtr + internalHttpChannel(do_QueryInterface(mChannel)); + if (internalHttpChannel) { + // we never let XHR be blocked by head CSS/JS loads to avoid + // potential deadlock where server generation of CSS/JS requires + // an XHR signal. + internalHttpChannel->SetLoadUnblocked(true); + } + if (!IsSystemXHR()) { // Always create a nsCORSListenerProxy here even if it's // a same-origin request right now, since it could be redirected. diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index faf06e9cf1b3..85eab1ca582f 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -267,6 +267,7 @@ MOCHITEST_FILES_A = \ test_bug782342.html \ test_bug282547.html \ bug282547.sjs \ + test_domparser_null_char.html \ $(NULL) MOCHITEST_FILES_B = \ diff --git a/content/base/test/file_bug416317.xhtml b/content/base/test/file_bug416317.xhtml index a2a037a6adf7..8bbfadad3f51 100644 --- a/content/base/test/file_bug416317.xhtml +++ b/content/base/test/file_bug416317.xhtml @@ -100,6 +100,9 @@ /* :root tests */ :root { background-color: green; } + /* :-moz-scope tests */ + :-moz-scope { background-color: green; } + /* :nth-child(n) tests */ .nthchild1 > :nth-last-child(odd) { background-color: lime; } .nthchild1 > :nth-child(odd) { background-color: lime; } @@ -269,6 +272,9 @@ cacheCheck( "Disconnected Element", root4 ); runTest( ecss, "SyntaxError: Disconnected Element", root4, false ); jqTests("Disconnected Element", root3.cloneNode(true), "querySelectorAll"); + var newRoot = document.createElement("nosuchtag"); + newRoot.appendChild(root3.cloneNode(true)); + jqTests("Disconnected Element scoping", newRoot, "querySelectorAll"); var fragment = document.createDocumentFragment(); fragment.appendChild( root2.cloneNode(true) ); @@ -537,7 +543,9 @@ var namespaced = /\|[^=]/.test( q ); var prepend = namespaced ? "xHTML|*#root3 " : "#root3 "; - q = (restrict === false || restrict === ":root" ? "" : prepend) + q.replace(/,/g, ", " + prepend); + q = (restrict === false || restrict === ":root" || + restrict === ":-moz-scope" ? "" : prepend) + + q.replace(/,/g, ", " + prepend); var nq = q.replace(/>/g, ">").replace(/ nosuchtag", + [ "outerbogustag" ], ":-moz-scope"); + } + t( ":-moz-scope Selector", ":-moz-scope nosuchtag nosuchtag", + [ "innerbogustag" ], ":-moz-scope"); if ( !root.parentNode ) { t( ":root All Selector", ":root *", [], ":root" ); @@ -641,6 +659,7 @@ if ( root.parentNode || root == document ) { assert( query(":root *").length == query("*").length - (root == document ? 1 : 0), type + ": :root All Selector" ); } + assert( query(":-moz-scope *").length == query("*").length - (root == document ? 1 : 0), type + ": :-moz-scope All Selector" ); t( "Element Selector", "p", ["firstp","ap","sndp","en","sap","first"] ); t( "Element Selector", "body", ["body"], false ); @@ -1259,6 +1278,10 @@
+ + + +