--- a/embedding/components/windowwatcher/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp
@@ -601,44 +601,44 @@ nsWindowWatcher::OpenWindowInternal(mozI
hasChromeParent =
doc && nsContentUtils::IsChromeDoc(doc) && !openedFromRemoteTab;
}
// Make sure we call CalculateChromeFlags() *before* we push the
// callee context onto the context stack so that
// CalculateChromeFlags() sees the actual caller when doing its
// security checks.
- chromeFlags = CalculateChromeFlags(aParent, features.get(), featuresSpecified,
+ chromeFlags = CalculateChromeFlags(aParent, features, featuresSpecified,
aDialog, uriToLoadIsChrome,
hasChromeParent, aCalledFromJS,
openedFromRemoteTab);
// If we are opening a window from a remote browser, the resulting window
// should also be remote.
MOZ_ASSERT_IF(openedFromRemoteTab,
chromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW);
// If we're not called through our JS version of the API, and we got
// our internal modal option, treat the window we're opening as a
// modal content window (and set the modal chrome flag).
if (!aCalledFromJS && aArgv &&
- WinHasOption(features.get(), "-moz-internal-modal", 0, nullptr)) {
+ WinHasOption(features, "-moz-internal-modal", 0, nullptr)) {
windowIsModalContentDialog = true;
// CHROME_MODAL gets inherited by dependent windows, which affects various
// platform-specific window state (especially on OSX). So we need some way
// to determine that this window was actually opened by nsGlobalWindow::
// ShowModalDialog(), and that somebody is actually going to be watching
// for return values and all that.
chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL_CONTENT_WINDOW;
chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL;
}
SizeSpec sizeSpec;
- CalcSizeSpec(features.get(), sizeSpec);
+ CalcSizeSpec(features, sizeSpec);
nsCOMPtr<nsIScriptSecurityManager> sm(
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
bool isCallerChrome =
nsContentUtils::LegacyIsCallerChromeOrNativeCode() && !openedFromRemoteTab;
// XXXbz Why is an AutoJSAPI good enough here? Wouldn't AutoEntryScript (so
@@ -825,17 +825,17 @@ nsWindowWatcher::OpenWindowInternal(mozI
if (popupConditions) {
contextFlags |=
nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT;
}
// B2G multi-screen support. mozDisplayId is returned from the
// "display-changed" event, it is also platform-dependent.
#ifdef MOZ_WIDGET_GONK
- int retval = WinHasOption(features.get(), "mozDisplayId", 0, nullptr);
+ int retval = WinHasOption(features, "mozDisplayId", 0, nullptr);
windowCreator2->SetScreenId(retval);
#endif
bool cancel = false;
rv = windowCreator2->CreateChromeWindow2(parentChrome, chromeFlags,
contextFlags, aOpeningTab,
&cancel, getter_AddRefs(newChrome));
@@ -1557,28 +1557,30 @@ nsWindowWatcher::URIfromURL(const char*
* @param aNullFeatures true if aFeatures was a null pointer (which fact
* is lost by its conversion to a string in the caller)
* @param aDialog affects the assumptions made about unnamed features
* @return the chrome bitmask
*/
// static
uint32_t
nsWindowWatcher::CalculateChromeFlags(mozIDOMWindowProxy* aParent,
- const char* aFeatures,
+ const nsACString& aFeatures,
bool aFeaturesSpecified,
bool aDialog,
bool aChromeURL,
bool aHasChromeParent,
bool aCalledFromJS,
bool aOpenedFromRemoteTab)
{
const bool inContentProcess = XRE_IsContentProcess();
uint32_t chromeFlags = 0;
- if (!aFeaturesSpecified || !aFeatures) {
+ // The features string is made void by OpenWindowInternal
+ // if nullptr was originally passed as the features string.
+ if (aFeatures.IsVoid()) {
chromeFlags = nsIWebBrowserChrome::CHROME_ALL;
if (aDialog) {
chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
}
if (inContentProcess) {
return chromeFlags;
@@ -1675,25 +1677,25 @@ nsWindowWatcher::CalculateChromeFlags(mo
Normal browser windows, in spite of a stated pattern of turning off
all chrome not mentioned explicitly, will want the new OS chrome (window
borders, titlebars, closebox) on, unless explicitly turned off.
Dialogs, on the other hand, take the absence of any explicit settings
to mean "OS' choice." */
// default titlebar and closebox to "on," if not mentioned at all
if (!(chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_POPUP)) {
- if (!PL_strcasestr(aFeatures, "titlebar")) {
+ if (!PL_strcasestr(aFeatures.BeginReading(), "titlebar")) {
chromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR;
}
- if (!PL_strcasestr(aFeatures, "close")) {
+ if (!PL_strcasestr(aFeatures.BeginReading(), "close")) {
chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_CLOSE;
}
}
- if (aDialog && aFeaturesSpecified && !presenceFlag) {
+ if (aDialog && !aFeatures.IsVoid() && !presenceFlag) {
chromeFlags = nsIWebBrowserChrome::CHROME_DEFAULT;
}
/* Finally, once all the above normal chrome has been divined, deal
with the features that are more operating hints than appearance
instructions. (Note modality implies dependence.) */
if (WinHasOption(aFeatures, "alwaysLowered", 0, nullptr) ||
@@ -1734,20 +1736,20 @@ nsWindowWatcher::CalculateChromeFlags(mo
if (!disableDialogFeature) {
chromeFlags |= WinHasOption(aFeatures, "dialog", 0, nullptr) ?
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG : 0;
}
/* and dialogs need to have the last word. assume dialogs are dialogs,
and opened as chrome, unless explicitly told otherwise. */
if (aDialog) {
- if (!PL_strcasestr(aFeatures, "dialog")) {
+ if (!PL_strcasestr(aFeatures.BeginReading(), "dialog")) {
chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_DIALOG;
}
- if (!PL_strcasestr(aFeatures, "chrome")) {
+ if (!PL_strcasestr(aFeatures.BeginReading(), "chrome")) {
chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
}
}
/* missing
chromeFlags->copy_history
*/
@@ -1782,43 +1784,43 @@ nsWindowWatcher::CalculateChromeFlags(mo
chromeFlags &= ~nsIWebBrowserChrome::CHROME_OPENAS_DIALOG;
}
return chromeFlags;
}
// static
int32_t
-nsWindowWatcher::WinHasOption(const char* aOptions, const char* aName,
+nsWindowWatcher::WinHasOption(const nsACString& aOptions, const char* aName,
int32_t aDefault, bool* aPresenceFlag)
{
- if (!aOptions) {
+ if (aOptions.IsEmpty()) {
return 0;
}
+ const char* options = aOptions.BeginReading();
char* comma;
char* equal;
int32_t found = 0;
#ifdef DEBUG
- nsAutoCString options(aOptions);
- NS_ASSERTION(options.FindCharInSet(" \n\r\t") == kNotFound,
+ NS_ASSERTION(nsAutoCString(aOptions).FindCharInSet(" \n\r\t") == kNotFound,
"There should be no whitespace in this string!");
#endif
while (true) {
- comma = PL_strchr(aOptions, ',');
+ comma = PL_strchr(options, ',');
if (comma) {
*comma = '\0';
}
- equal = PL_strchr(aOptions, '=');
+ equal = PL_strchr(options, '=');
if (equal) {
*equal = '\0';
}
- if (nsCRT::strcasecmp(aOptions, aName) == 0) {
+ if (nsCRT::strcasecmp(options, aName) == 0) {
if (aPresenceFlag) {
*aPresenceFlag = true;
}
if (equal)
if (*(equal + 1) == '*') {
found = aDefault;
} else if (nsCRT::strcasecmp(equal + 1, "yes") == 0) {
found = 1;
@@ -1833,17 +1835,17 @@ nsWindowWatcher::WinHasOption(const char
*equal = '=';
}
if (comma) {
*comma = ',';
}
if (found || !comma) {
break;
}
- aOptions = comma + 1;
+ options = comma + 1;
}
return found;
}
/* try to find an nsIDocShellTreeItem with the given name in any
known open window. a failure to find the item will not
necessarily return a failure method value. check aFoundItem.
*/
@@ -1992,17 +1994,17 @@ nsWindowWatcher::ReadyOpenedDocShellItem
}
rv = CallQueryInterface(piOpenedWindow, aOpenedWindow);
}
return rv;
}
// static
void
-nsWindowWatcher::CalcSizeSpec(const char* aFeatures, SizeSpec& aResult)
+nsWindowWatcher::CalcSizeSpec(const nsACString& aFeatures, SizeSpec& aResult)
{
// Parse position spec, if any, from aFeatures
bool present;
int32_t temp;
present = false;
if ((temp = WinHasOption(aFeatures, "left", 0, &present)) || present) {
aResult.mLeft = temp;
--- a/embedding/components/windowwatcher/nsWindowWatcher.h
+++ b/embedding/components/windowwatcher/nsWindowWatcher.h
@@ -87,27 +87,27 @@ protected:
float* aOpenerFullZoom,
mozIDOMWindowProxy** aResult);
static nsresult URIfromURL(const char* aURL,
mozIDOMWindowProxy* aParent,
nsIURI** aURI);
static uint32_t CalculateChromeFlags(mozIDOMWindowProxy* aParent,
- const char* aFeatures,
+ const nsACString& aFeatures,
bool aFeaturesSpecified,
bool aDialog,
bool aChromeURL,
bool aHasChromeParent,
bool aCalledFromJS,
bool aOpenedFromRemoteTab);
- static int32_t WinHasOption(const char* aOptions, const char* aName,
+ static int32_t WinHasOption(const nsACString& aOptions, const char* aName,
int32_t aDefault, bool* aPresenceFlag);
/* Compute the right SizeSpec based on aFeatures */
- static void CalcSizeSpec(const char* aFeatures, SizeSpec& aResult);
+ static void CalcSizeSpec(const nsACString& aFeatures, SizeSpec& aResult);
static nsresult ReadyOpenedDocShellItem(nsIDocShellTreeItem* aOpenedItem,
nsPIDOMWindowOuter* aParent,
bool aWindowIsNew,
mozIDOMWindowProxy** aOpenedWindow);
static void SizeOpenedDocShellItem(nsIDocShellTreeItem* aDocShellItem,
mozIDOMWindowProxy* aParent,
bool aIsCallerChrome,
const SizeSpec& aSizeSpec,