diff --git a/mozilla/docshell/base/Makefile.in b/mozilla/docshell/base/Makefile.in index 248079c6ab9..36bafffcc8f 100644 --- a/mozilla/docshell/base/Makefile.in +++ b/mozilla/docshell/base/Makefile.in @@ -83,6 +83,7 @@ REQUIRES = xpcom \ editor \ windowwatcher \ imglib2 \ + mimetype \ $(NULL) SDK_XPIDLSRCS = \ diff --git a/mozilla/docshell/base/nsWebNavigationInfo.cpp b/mozilla/docshell/base/nsWebNavigationInfo.cpp index f52ef53841a..a0a475fd33b 100644 --- a/mozilla/docshell/base/nsWebNavigationInfo.cpp +++ b/mozilla/docshell/base/nsWebNavigationInfo.cpp @@ -41,6 +41,12 @@ #include "nsServiceManagerUtils.h" #include "nsIDocumentLoaderFactory.h" #include "nsIPluginManager.h" +#include "nsILookAndFeel.h" +#include "nsWidgetsCID.h" +#include "nsIMIMEService.h" +#include "nsIMIMEInfo.h" + +static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); NS_IMPL_ISUPPORTS1(nsWebNavigationInfo, nsIWebNavigationInfo) @@ -143,6 +149,37 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType, } } else if (value.EqualsLiteral(PLUGIN_DLF_CONTRACT)) { +#ifdef ACCESSIBILITY + // If a screen reader is running, prefer external handlers over plugins + // because they are better at dealing with accessibility -- they don't + // have the keyboard navigation problems and are more likely to expose + // their content via MSAA. + // XXX Eventually we will remove this once the major content types are as + // screen reader accessible in plugins as in external apps. + nsCOMPtr lookAndFeel = do_GetService(kLookAndFeelCID); + if (lookAndFeel) { + PRInt32 isScreenReaderActive; + lookAndFeel->GetMetric(nsILookAndFeel::eMetric_IsScreenReaderActive, + isScreenReaderActive); + if (isScreenReaderActive) { + nsCOMPtr mimeService(do_GetService("@mozilla.org/mime;1")); + if (mimeService) { + nsCOMPtr mimeInfo; + mimeService->GetFromTypeAndExtension(aType, EmptyCString(), + getter_AddRefs(mimeInfo)); + if (mimeInfo) { + PRBool hasDefaultHandler; + mimeInfo->GetHasDefaultHandler(&hasDefaultHandler); + if (hasDefaultHandler) { + // External app exists to handle this type, so use it instead of PLUGIN + *aIsSupported = nsIWebNavigationInfo::UNSUPPORTED; + return NS_OK; + } + } + } + } + } +#endif *aIsSupported = nsIWebNavigationInfo::PLUGIN; } else { diff --git a/mozilla/widget/public/nsILookAndFeel.h b/mozilla/widget/public/nsILookAndFeel.h index 0f7e8bd4f9f..c6ef3570773 100644 --- a/mozilla/widget/public/nsILookAndFeel.h +++ b/mozilla/widget/public/nsILookAndFeel.h @@ -173,6 +173,7 @@ public: eMetric_DragThresholdX, // begin a drag if the mouse is moved further than the threshold while the button is down eMetric_DragThresholdY, eMetric_UseAccessibilityTheme, // Accessibility theme being used? + eMetric_IsScreenReaderActive, // Screen reader being used? eMetric_ScrollArrowStyle, // position of scroll arrows in a scrollbar eMetric_ScrollSliderStyle, // is scroll thumb proportional or fixed? diff --git a/mozilla/widget/src/qt/nsLookAndFeel.cpp b/mozilla/widget/src/qt/nsLookAndFeel.cpp index b8ddc556121..f27d4b3a1be 100644 --- a/mozilla/widget/src/qt/nsLookAndFeel.cpp +++ b/mozilla/widget/src/qt/nsLookAndFeel.cpp @@ -281,6 +281,7 @@ static const char *metricToString[] = { "eMetric_DragThresholdX", "eMetric_DragThresholdY", "eMetric_UseAccessibilityTheme", + "eMetric_IsScreenReaderActive", "eMetric_ScrollArrowStyle", "eMetric_ScrollSliderStyle", diff --git a/mozilla/widget/src/windows/nsLookAndFeel.cpp b/mozilla/widget/src/windows/nsLookAndFeel.cpp index 9d7edf14200..3867c935f1e 100644 --- a/mozilla/widget/src/windows/nsLookAndFeel.cpp +++ b/mozilla/widget/src/windows/nsLookAndFeel.cpp @@ -392,6 +392,11 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) aMetric = 0; } break; + case eMetric_IsScreenReaderActive: + BOOL isScreenReaderActive; + aMetric = SUCCEEDED(SystemParametersInfo(SPI_GETSCREENREADER, 0, &isScreenReaderActive, 0)) && + isScreenReaderActive; + break; #endif case eMetric_ScrollArrowStyle: aMetric = eMetric_ScrollArrowStyleSingle; diff --git a/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp b/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp index 62d4803d56f..afd159301c1 100644 --- a/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp +++ b/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp @@ -91,6 +91,7 @@ nsLookAndFeelIntPref nsXPLookAndFeel::sIntPrefs[] = { "ui.dragThresholdX", eMetric_DragThresholdX, PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.dragThresholdY", eMetric_DragThresholdY, PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.useAccessibilityTheme", eMetric_UseAccessibilityTheme, PR_FALSE, nsLookAndFeelTypeInt, 0 }, + { "ui.isScreenReaderActive", eMetric_IsScreenReaderActive, PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.menusCanOverlapOSBar", eMetric_MenusCanOverlapOSBar, PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.treeOpenDelay",