Whack string usage. Converted category on NSString to use references, added PRUnichar* method, and changed all uses to use these new methods.

This commit is contained in:
sfraser%netscape.com 2002-07-29 21:40:53 +00:00
parent b26f28e997
commit 22d2e7ef3c
70 changed files with 450 additions and 434 deletions

View File

@ -169,23 +169,23 @@ static BookmarkInfoController *sharedBookmarkInfoController = nil;
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
NSString* bookmarkName = [NSString stringWith_nsAString: value];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: infoForString];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mLocationField setStringValue: [NSString stringWith_nsAString: value]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mKeywordField setStringValue: [NSString stringWith_nsAString: value]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mDescriptionField setStringValue: [NSString stringWith_nsAString: value]];
mBookmarkItem = aBookmark;
}

View File

@ -148,14 +148,14 @@
// If no URL and title were specified, get them from the current page.
if (aURL && aTitle) {
[aURL assignTo_nsString:&href];
[aTitle assignTo_nsString:&title];
[aURL assignTo_nsAString:href];
[aTitle assignTo_nsAString:title];
} else {
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
title, href);
}
mCachedHref = [NSString stringWithCharacters: href.get() length: href.Length()];
mCachedHref = [NSString stringWith_nsAString: href];
[mCachedHref retain];
} else { // Folder
@ -164,7 +164,7 @@
}
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
NSString* bookmarkTitle = [NSString stringWithCharacters: title.get() length: title.Length()];
NSString* bookmarkTitle = [NSString stringWith_nsAString: title];
NSString* cleanedTitle = [bookmarkTitle stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
[textField setStringValue: cleanedTitle];
@ -214,7 +214,7 @@
}
nsAutoString title;
[[[mBrowserWindowController getAddBookmarkTitle] stringValue] assignTo_nsString:&title];
[[[mBrowserWindowController getAddBookmarkTitle] stringValue] assignTo_nsAString:title];
nsAutoString tagName;
if (mCachedHref)
@ -232,7 +232,7 @@
if (mCachedHref) {
nsAutoString href;
[mCachedHref assignTo_nsString:&href];
[mCachedHref assignTo_nsAString:href];
[mCachedHref release];
elt->SetAttribute(NS_LITERAL_STRING("href"), href);
}
@ -418,7 +418,7 @@
nsAutoString href;
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
@ -521,7 +521,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);
//Set cell's textual contents
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: nameAttr.get() length: nameAttr.Length()]];
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWith_nsAString: nameAttr]];
//Create an attributed string to hold the empty attachment, then release the components.
attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain];
@ -682,7 +682,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
if (value.Length())
descStr = [NSString stringWithCharacters:value.get() length:value.Length()];
descStr = [NSString stringWith_nsAString:value];
// Only description for folders
if ([item isFolder])
@ -691,7 +691,7 @@
// Extract the URL from the item
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
if (value.Length())
hrefStr = [NSString stringWithCharacters:value.get() length:value.Length()];
hrefStr = [NSString stringWith_nsAString:value];
if (!hrefStr)
return descStr;
@ -735,7 +735,7 @@
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
// stuff it into the string
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -759,7 +759,7 @@
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
// stuff it into the string
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -865,7 +865,7 @@
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(item));
nsAutoString href;
element->GetAttribute(NS_LITERAL_STRING("name"), href);
NSString* info = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* info = [NSString stringWith_nsAString: href];
return [NSString stringWithFormat:@"<BookmarkItem, name = \"%@\">", info];
}
@ -875,7 +875,7 @@
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(item));
nsAutoString href;
element->GetAttribute(NS_LITERAL_STRING("href"), href);
return [NSString stringWithCharacters: href.get() length: href.Length()];
return [NSString stringWith_nsAString: href];
}
-(void)setContentNode: (nsIContent*)aContentNode

View File

@ -287,8 +287,7 @@ BookmarksService::BookmarkChanged(nsIContent* aItem, bool shouldFlush = true)
NSMenuItem* childItem = [menu itemWithTag: contentID];
nsAutoString name;
aItem->GetAttr(kNameSpaceID_None, gNameAtom, name);
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
[childItem setTitle: title];
[childItem setTitle: [NSString stringWith_nsAString: name]];
}
}
@ -741,7 +740,7 @@ BookmarksService::AddMenuBookmark(NSMenu* aMenu, nsIContent* aParent, nsIContent
{
nsAutoString name;
aChild->GetAttr(kNameSpaceID_None, gNameAtom, name);
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
NSString* title = [NSString stringWith_nsAString: name];
// Create a menu or menu item for the child.
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
@ -806,7 +805,7 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
if (href.IsEmpty())
return;
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
// Now load the URL in the window.
[aController loadURL:url referrer:nil];
@ -1023,7 +1022,7 @@ BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
nsAutoString href;
elt->GetAttribute(NS_LITERAL_STRING("href"), href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
NSTabViewItem* tabViewItem = nil;
if (currentIndex >= total) {
// We need to make a new tab.
@ -1055,7 +1054,7 @@ NSString*
BookmarksService::ResolveKeyword(NSString* aKeyword)
{
nsAutoString keyword;
[aKeyword assignTo_nsString:&keyword];
[aKeyword assignTo_nsAString:keyword];
if (keyword.IsEmpty())
return [NSString string];
@ -1072,7 +1071,7 @@ BookmarksService::ResolveKeyword(NSString* aKeyword)
nsAutoString url;
if (content) {
content->GetAttr(kNameSpaceID_None, gHrefAtom, url);
return [NSString stringWithCharacters: url.get() length: url.Length()];
return [NSString stringWith_nsAString: url];
}
return [NSString stringWithCString:""];
}
@ -1217,8 +1216,8 @@ BookmarksService::PerformProxyDrop(BookmarkItem* parentItem, BookmarkItem* befor
nsCOMPtr<nsIDOMElement> beforeElt;
beforeElt = do_QueryInterface([beforeItem contentNode]);
nsAutoString url; [[data objectForKey:@"url"] assignTo_nsString:&url];
nsAutoString title; [[data objectForKey:@"title"] assignTo_nsString:&title];
nsAutoString url; [[data objectForKey:@"url"] assignTo_nsAString:url];
nsAutoString title; [[data objectForKey:@"title"] assignTo_nsAString:title];
BookmarksService::AddBookmarkToFolder(url, title, parentElt, beforeElt);
return YES;
}

View File

@ -866,12 +866,11 @@ static NSArray* sToolbarDefaults = nil;
{
nsCOMPtr<nsIDOMElement> linkContent;
nsAutoString href;
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs\
(linkContent), href);
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs(linkContent), href);
nsAutoString linkText;
CHGeckoUtils::GatherTextUnder(linkContent, linkText);
NSString* urlStr = [NSString stringWithCharacters:href.get() length:href.Length()];
NSString* titleStr = [NSString stringWithCharacters:linkText.get() length:linkText.Length()];
NSString* urlStr = [NSString stringWith_nsAString:href];
NSString* titleStr = [NSString stringWith_nsAString:linkText];
[self addBookmarkExtended:YES isFolder:NO URL:urlStr title:titleStr];
}
@ -1294,7 +1293,7 @@ static NSArray* sToolbarDefaults = nil;
if (!pref)
return; // Something bad happened if we can't get prefs.
NSString* hrefStr = [NSString stringWith_nsString:&href];
NSString* hrefStr = [NSString stringWith_nsAString:href];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -1323,14 +1322,14 @@ static NSArray* sToolbarDefaults = nil;
if (!linkContent || href.IsEmpty())
return;
NSString* hrefStr = [NSString stringWith_nsString: &href];
NSString* hrefStr = [NSString stringWith_nsAString: href];
// The user wants to save this link.
nsAutoString text;
CHGeckoUtils::GatherTextUnder(mContextMenuNode, text);
[self saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWith_nsString: &text]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
- (IBAction)saveImageAs:(id)aSender
@ -1342,10 +1341,10 @@ static NSArray* sToolbarDefaults = nil;
nsAutoString url;
imgElement->GetSrc(url);
NSString* hrefStr = [NSString stringWith_nsString: &url];
NSString* hrefStr = [NSString stringWith_nsAString: url];
[self saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWith_nsString: &text]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
}
@ -1371,7 +1370,7 @@ static NSArray* sToolbarDefaults = nil;
nsAutoString url;
imgElement->GetSrc(url);
NSString* urlStr = [NSString stringWith_nsString: &url];
NSString* urlStr = [NSString stringWith_nsAString: url];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
[self loadURL: urlStr referrer:referrer];

View File

@ -22,6 +22,8 @@
*
*/
#import "NSString+Utils.h"
#import <AppKit/AppKit.h>
#import "CHAutoCompleteTextField.h"
#include "nsString.h"
@ -101,11 +103,11 @@
} else if ([aColumn isEqualToString:@"col1"]) {
nsAutoString value;
item->GetValue(value);
result = [NSString stringWithCharacters:value.get() length:value.Length()];
result = [NSString stringWith_nsAString:value];
} else if ([aColumn isEqualToString:@"col2"]) {
PRUnichar *comment;
item->GetComment(&comment);
result = [NSString stringWithCharacters:comment length:nsCRT::strlen(comment)];
nsXPIDLString commentStr;
item->GetComment(getter_Copies(commentStr));
result = [NSString stringWith_nsAString:commentStr];
}
return result;

View File

@ -67,7 +67,7 @@
mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
if (href.IsEmpty())
return;
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
// Now load the URL in the window.
[[[self window] windowController] loadURL: url referrer:nil];
@ -85,7 +85,7 @@
// Get the href attribute. This is the URL we want to load.
nsAutoString hrefAttr;
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -102,7 +102,7 @@
// Get the href attribute. This is the URL we want to load.
nsAutoString hrefAttr;
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -218,13 +218,13 @@
[self setTarget: self];
nsAutoString href;
mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
NSString* helpText = [NSString stringWith_nsString:&href];
NSString* helpText = [NSString stringWith_nsAString:href];
[self setToolTip: helpText];
}
nsAutoString name;
mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
[self setTitle: [NSString stringWith_nsString: &name]];
[self setTitle: [NSString stringWith_nsAString: name]];
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
mBookmarkItem = BookmarksService::GetWrapperFor(content);

View File

@ -224,7 +224,7 @@ nsCocoaBrowserListener::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const
{
NSPoint where;
where.x = aXCoords; where.y = aYCoords;
[mContainer onShowTooltip:where withText:[NSString stringWithCharacters:aTipText length:nsCRT::strlen(aTipText)]];
[mContainer onShowTooltip:where withText:[NSString stringWithPRUnichars:aTipText]];
return NS_OK;
}
@ -246,7 +246,7 @@ nsCocoaBrowserListener::SetStatus(PRUint32 statusType, const PRUnichar *status)
NSString* str = nsnull;
if (status && (*status != PRUnichar(0))) {
str = [NSString stringWithCharacters:status length:nsCRT::strlen(status)];
str = [NSString stringWithPRUnichars:status];
}
[mContainer setStatus:str ofType:(NSStatusType)statusType];
@ -537,7 +537,7 @@ nsCocoaBrowserListener::SetTitle(const PRUnichar * aTitle)
return NS_ERROR_FAILURE;
}
NSString* str = [NSString stringWithCharacters:aTitle length:nsCRT::strlen(aTitle)];
NSString* str = [NSString stringWithPRUnichars:aTitle];
[mContainer setTitle:str];
return NS_OK;
@ -629,7 +629,7 @@ NS_IMETHODIMP
nsCocoaBrowserListener::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus,
const PRUnichar *aMessage)
{
NSString* str = [NSString stringWithCharacters:aMessage length:nsCRT::strlen(aMessage)];
NSString* str = [NSString stringWithPRUnichars:aMessage];
NSEnumerator* enumerator = [mListeners objectEnumerator];
id<NSBrowserListener> obj;
@ -1079,7 +1079,7 @@ nsCocoaBrowserListener::SetContainer(id <NSBrowserContainer> aContainer)
return @"";
nsAutoString urlStr;
location->GetHref(urlStr);
return [NSString stringWithCharacters: urlStr.get() length: urlStr.Length()];
return [NSString stringWith_nsAString: urlStr];
}
- (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
@ -1270,11 +1270,10 @@ nsCocoaBrowserListener::SetContainer(id <NSBrowserContainer> aContainer)
nsDoc->GetLocation(getter_AddRefs(location));
if (!location)
return empty;
nsAutoString urlStr;
location->GetHref(urlStr);
nsCAutoString urlCStr; urlCStr.AssignWithConversion(urlStr);
return [NSString stringWithCharacters: urlStr.get() length: urlStr.Length()];
return [NSString stringWith_nsAString: urlStr];
}
- (void)setActive: (BOOL)aIsActive

View File

@ -184,7 +184,7 @@
nsAutoString href;
bookmarkElt->GetAttribute(NS_LITERAL_STRING("href"), href);
NSString* url = [NSString stringWith_nsString: &href];
NSString* url = [NSString stringWith_nsAString: href];
nsAutoString group;
bookmarkElt->GetAttribute(NS_LITERAL_STRING("group"), group);

View File

@ -129,9 +129,9 @@ static const NSString *kEllipsis = @"...";
nsCOMPtr<nsIHistoryEntry> entry;
sessionHistory->GetEntryAtIndex(i, PR_FALSE, getter_AddRefs(entry));
PRUnichar *text;
entry->GetTitle(&text);
NSString* title = [NSString stringWithCharacters: text length: nsCRT::strlen(text)];
nsXPIDLString textStr;
entry->GetTitle(getter_Copies(textStr));
NSString* title = [NSString stringWith_nsAString: textStr];
// if the title is too long, crop it in the middle
if ([title length] > kMaxTitleLength) {

View File

@ -69,7 +69,7 @@
valueLiteral->GetValue(getter_Copies(literalValue));
//Set cell's textual contents
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]];
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWith_nsAString:literalValue]];
if ([columnPropertyURI isEqualToString: @"http://home.netscape.com/NC-rdf#Name"])
{
@ -147,7 +147,7 @@
nsXPIDLString literalValue;
valueLiteral->GetValue(getter_Copies(literalValue));
NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()];
NSString* url = [NSString stringWith_nsAString: literalValue];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer: nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];

View File

@ -57,8 +57,8 @@
BookmarksService::GetTitleAndHrefForBrowserView(
[[[[self window] windowController] getBrowserWrapper] getBrowserView], titleStr, hrefStr);
NSString *url = [NSString stringWith_nsString: &hrefStr];
NSString *title = [NSString stringWith_nsString: &titleStr];
NSString *url = [NSString stringWith_nsAString: hrefStr];
NSString *title = [NSString stringWith_nsAString: titleStr];
NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];

View File

@ -263,7 +263,7 @@
nsXPIDLString literalValue;
valueLiteral->GetValue(getter_Copies(literalValue));
return [NSString stringWithCharacters: literalValue.get() length:literalValue.Length()];
return [NSString stringWith_nsAString: literalValue];
}
- (void) outlineView: (NSOutlineView*) aOutlineView setObjectValue: (id) aObject

View File

@ -70,8 +70,8 @@ CocoaPromptService::Alert(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (!window)
return NS_ERROR_FAILURE;
@ -94,9 +94,9 @@ CocoaPromptService::AlertCheck(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (checkValue) {
@ -125,8 +125,8 @@ CocoaPromptService::Confirm(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSWindow* window = GetNSWindowForDOMWindow(parent);
*_retval = (PRBool)[controller confirm:window title:titleStr text:textStr];
@ -147,9 +147,9 @@ CocoaPromptService::ConfirmCheck(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (checkValue) {
@ -190,9 +190,9 @@ CocoaPromptService::ConfirmEx(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
NSString* btn1Str = GetButtonStringFromFlags(buttonFlags, kButton0, button0Title);
@ -233,10 +233,11 @@ CocoaPromptService::Prompt(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* valueStr = [NSMutableString stringWithCharacters:*value length:(*value ? nsCRT::strlen(*value) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* valueStr = [NSMutableString stringWithPRUnichars:*value];
BOOL valueBool;
if (checkValue) {
@ -274,11 +275,11 @@ CocoaPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* userNameStr = [NSMutableString stringWithCharacters:*username length:(*username ? nsCRT::strlen(*username) : 0)];
NSMutableString* passwordStr = [NSMutableString stringWithCharacters:*password length:(*password ? nsCRT::strlen(*password) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* userNameStr = [NSMutableString stringWithPRUnichars:*username];
NSMutableString* passwordStr = [NSMutableString stringWithPRUnichars:*password];
BOOL valueBool;
if (checkValue) {
@ -322,10 +323,10 @@ CocoaPromptService::PromptPassword(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* passwordStr = [NSMutableString stringWithCharacters:*password length:(*password ? nsCRT::strlen(*password) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* passwordStr = [NSMutableString stringWithPRUnichars:*password];
BOOL valueBool;
if (checkValue) {
@ -412,7 +413,7 @@ CocoaPromptService::GetCommonDialogLocaleString(const char *key)
rv = mCommonDialogStringBundle->GetStringFromName(NS_ConvertASCIItoUCS2(key).get(), getter_Copies(string));
if (NS_FAILED(rv)) return returnValue;
returnValue = [NSString stringWithCharacters:string length:(string ? nsCRT::strlen(string) : 0)];
returnValue = [NSString stringWithPRUnichars:string];
return returnValue;
}
@ -445,7 +446,7 @@ CocoaPromptService::GetButtonStringFromFlags(PRUint32 btnFlags,
btnStr = GetCommonDialogLocaleString("Revert");
break;
case BUTTON_TITLE_IS_STRING:
btnStr = [NSString stringWithCharacters:btnTitle length:(btnTitle ? nsCRT::strlen(btnTitle) : 0)];
btnStr = [NSString stringWithPRUnichars:btnTitle];
}
return btnStr;

View File

@ -175,12 +175,12 @@ ContentClickListener::MouseDown(nsIDOMEvent* aEvent)
PRUint32 contentID;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
content->GetContentID(&contentID);
nsAutoString text;
nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(node));
nsAutoString text;
option->GetLabel(text);
if (text.IsEmpty())
option->GetText(text);
NSString* title = [NSString stringWith_nsString: &text];
NSString* title = [NSString stringWith_nsAString: text];
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
[menu addItem: menuItem];
[menuItem setTag: contentID];
@ -281,7 +281,7 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
mouseEvent->GetShiftKey(&shiftKey);
mouseEvent->GetAltKey(&altKey);
NSString* hrefStr = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* hrefStr = [NSString stringWith_nsAString: href];
// Hack to determine specific protocols handled by Chimera in the frontend
// until I can determine why the general unknown protocol handler handoff
@ -317,8 +317,7 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
CHGeckoUtils::GatherTextUnder(content, text);
[mBrowserController saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWithCharacters: text.get()
length: nsCRT::strlen(text.get())]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
return NS_OK;

View File

@ -36,14 +36,16 @@
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
#import "nscore.h"
class nsAString;
// a category to extend NSString
@interface NSString (ChimeraStringUtils)
+ (id)stringWith_nsString:(const nsAString*)inString;
- (void)assignTo_nsString:(nsAString*)ioString;
+ (id)stringWithPRUnichars:(const PRUnichar*)inString;
+ (id)stringWith_nsAString:(const nsAString&)inString;
- (void)assignTo_nsAString:(nsAString&)ioString;
- (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet;
- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet withString:(NSString*)string;

View File

@ -43,26 +43,29 @@
@implementation NSString (ChimeraStringUtils)
+ (id)stringWith_nsString:(const nsAString *)inString
+ (id)stringWithPRUnichars:(const PRUnichar*)inString
{
if (inString)
{
nsPromiseFlatString flatString = PromiseFlatString(*inString);
return [NSString stringWithCharacters:flatString.get() length:flatString.Length()];
}
return [NSString stringWithCharacters:inString length:nsCRT::strlen(inString)];
else
return [NSString string];
}
+ (id)stringWith_nsAString:(const nsAString&)inString
{
nsPromiseFlatString flatString = PromiseFlatString(inString);
return [NSString stringWithCharacters:flatString.get() length:flatString.Length()];
}
#define ASSIGN_STACK_BUFFER_CHARACTERS 256
- (void)assignTo_nsString:(nsAString*)ioString
- (void)assignTo_nsAString:(nsAString&)ioString
{
if (!ioString) return;
PRUnichar stackBuffer[ASSIGN_STACK_BUFFER_CHARACTERS];
PRUnichar* buffer = stackBuffer;
// XXX maybe fix this to use SetLength(0), SetLength(len), and a writing iterator.
unsigned int len = [self length];
if (len + 1 > ASSIGN_STACK_BUFFER_CHARACTERS)
@ -73,7 +76,7 @@
}
[self getCharacters: buffer]; // does not null terminate
ioString->Assign(buffer, len);
ioString.Assign(buffer, len);
if (buffer != stackBuffer)
free(buffer);

View File

@ -247,7 +247,7 @@ nsCocoaBrowserService::Show(nsIHelperAppLauncher* inLauncher, nsISupports* inCon
NS_IMETHODIMP
nsCocoaBrowserService::PromptForSaveToFile(nsISupports *aWindowContext, const PRUnichar *aDefaultFile, const PRUnichar *aSuggestedFileExtension, nsILocalFile **_retval)
{
NSString* filename = [NSString stringWithCharacters:aDefaultFile length:nsCRT::strlen(aDefaultFile)];
NSString* filename = [NSString stringWithPRUnichars:aDefaultFile];
NSSavePanel *thePanel = [NSSavePanel savePanel];
// Note: although the docs for NSSavePanel specifically state "path and filename can be empty strings, but

View File

@ -263,7 +263,7 @@ nsDownloadListener::InitDialog()
nsAutoString pathStr;
mDestination->GetPath(pathStr);
[mDownloadDisplay setDestinationPath: [NSString stringWithCharacters:pathStr.get() length:pathStr.Length()]];
[mDownloadDisplay setDestinationPath: [NSString stringWith_nsAString:pathStr]];
}
void

View File

@ -169,23 +169,23 @@ static BookmarkInfoController *sharedBookmarkInfoController = nil;
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
NSString* bookmarkName = [NSString stringWith_nsAString: value];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: infoForString];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mLocationField setStringValue: [NSString stringWith_nsAString: value]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mKeywordField setStringValue: [NSString stringWith_nsAString: value]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mDescriptionField setStringValue: [NSString stringWith_nsAString: value]];
mBookmarkItem = aBookmark;
}

View File

@ -67,7 +67,7 @@
mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
if (href.IsEmpty())
return;
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
// Now load the URL in the window.
[[[self window] windowController] loadURL: url referrer:nil];
@ -85,7 +85,7 @@
// Get the href attribute. This is the URL we want to load.
nsAutoString hrefAttr;
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -102,7 +102,7 @@
// Get the href attribute. This is the URL we want to load.
nsAutoString hrefAttr;
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -218,13 +218,13 @@
[self setTarget: self];
nsAutoString href;
mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
NSString* helpText = [NSString stringWith_nsString:&href];
NSString* helpText = [NSString stringWith_nsAString:href];
[self setToolTip: helpText];
}
nsAutoString name;
mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
[self setTitle: [NSString stringWith_nsString: &name]];
[self setTitle: [NSString stringWith_nsAString: name]];
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
mBookmarkItem = BookmarksService::GetWrapperFor(content);

View File

@ -148,14 +148,14 @@
// If no URL and title were specified, get them from the current page.
if (aURL && aTitle) {
[aURL assignTo_nsString:&href];
[aTitle assignTo_nsString:&title];
[aURL assignTo_nsAString:href];
[aTitle assignTo_nsAString:title];
} else {
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
title, href);
}
mCachedHref = [NSString stringWithCharacters: href.get() length: href.Length()];
mCachedHref = [NSString stringWith_nsAString: href];
[mCachedHref retain];
} else { // Folder
@ -164,7 +164,7 @@
}
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
NSString* bookmarkTitle = [NSString stringWithCharacters: title.get() length: title.Length()];
NSString* bookmarkTitle = [NSString stringWith_nsAString: title];
NSString* cleanedTitle = [bookmarkTitle stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
[textField setStringValue: cleanedTitle];
@ -214,7 +214,7 @@
}
nsAutoString title;
[[[mBrowserWindowController getAddBookmarkTitle] stringValue] assignTo_nsString:&title];
[[[mBrowserWindowController getAddBookmarkTitle] stringValue] assignTo_nsAString:title];
nsAutoString tagName;
if (mCachedHref)
@ -232,7 +232,7 @@
if (mCachedHref) {
nsAutoString href;
[mCachedHref assignTo_nsString:&href];
[mCachedHref assignTo_nsAString:href];
[mCachedHref release];
elt->SetAttribute(NS_LITERAL_STRING("href"), href);
}
@ -418,7 +418,7 @@
nsAutoString href;
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
@ -521,7 +521,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);
//Set cell's textual contents
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: nameAttr.get() length: nameAttr.Length()]];
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWith_nsAString: nameAttr]];
//Create an attributed string to hold the empty attachment, then release the components.
attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain];
@ -682,7 +682,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
if (value.Length())
descStr = [NSString stringWithCharacters:value.get() length:value.Length()];
descStr = [NSString stringWith_nsAString:value];
// Only description for folders
if ([item isFolder])
@ -691,7 +691,7 @@
// Extract the URL from the item
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
if (value.Length())
hrefStr = [NSString stringWithCharacters:value.get() length:value.Length()];
hrefStr = [NSString stringWith_nsAString:value];
if (!hrefStr)
return descStr;
@ -735,7 +735,7 @@
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
// stuff it into the string
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -759,7 +759,7 @@
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
// stuff it into the string
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -865,7 +865,7 @@
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(item));
nsAutoString href;
element->GetAttribute(NS_LITERAL_STRING("name"), href);
NSString* info = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* info = [NSString stringWith_nsAString: href];
return [NSString stringWithFormat:@"<BookmarkItem, name = \"%@\">", info];
}
@ -875,7 +875,7 @@
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(item));
nsAutoString href;
element->GetAttribute(NS_LITERAL_STRING("href"), href);
return [NSString stringWithCharacters: href.get() length: href.Length()];
return [NSString stringWith_nsAString: href];
}
-(void)setContentNode: (nsIContent*)aContentNode

View File

@ -287,8 +287,7 @@ BookmarksService::BookmarkChanged(nsIContent* aItem, bool shouldFlush = true)
NSMenuItem* childItem = [menu itemWithTag: contentID];
nsAutoString name;
aItem->GetAttr(kNameSpaceID_None, gNameAtom, name);
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
[childItem setTitle: title];
[childItem setTitle: [NSString stringWith_nsAString: name]];
}
}
@ -741,7 +740,7 @@ BookmarksService::AddMenuBookmark(NSMenu* aMenu, nsIContent* aParent, nsIContent
{
nsAutoString name;
aChild->GetAttr(kNameSpaceID_None, gNameAtom, name);
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
NSString* title = [NSString stringWith_nsAString: name];
// Create a menu or menu item for the child.
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
@ -806,7 +805,7 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
if (href.IsEmpty())
return;
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
// Now load the URL in the window.
[aController loadURL:url referrer:nil];
@ -1023,7 +1022,7 @@ BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
nsAutoString href;
elt->GetAttribute(NS_LITERAL_STRING("href"), href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
NSTabViewItem* tabViewItem = nil;
if (currentIndex >= total) {
// We need to make a new tab.
@ -1055,7 +1054,7 @@ NSString*
BookmarksService::ResolveKeyword(NSString* aKeyword)
{
nsAutoString keyword;
[aKeyword assignTo_nsString:&keyword];
[aKeyword assignTo_nsAString:keyword];
if (keyword.IsEmpty())
return [NSString string];
@ -1072,7 +1071,7 @@ BookmarksService::ResolveKeyword(NSString* aKeyword)
nsAutoString url;
if (content) {
content->GetAttr(kNameSpaceID_None, gHrefAtom, url);
return [NSString stringWithCharacters: url.get() length: url.Length()];
return [NSString stringWith_nsAString: url];
}
return [NSString stringWithCString:""];
}
@ -1217,8 +1216,8 @@ BookmarksService::PerformProxyDrop(BookmarkItem* parentItem, BookmarkItem* befor
nsCOMPtr<nsIDOMElement> beforeElt;
beforeElt = do_QueryInterface([beforeItem contentNode]);
nsAutoString url; [[data objectForKey:@"url"] assignTo_nsString:&url];
nsAutoString title; [[data objectForKey:@"title"] assignTo_nsString:&title];
nsAutoString url; [[data objectForKey:@"url"] assignTo_nsAString:url];
nsAutoString title; [[data objectForKey:@"title"] assignTo_nsAString:title];
BookmarksService::AddBookmarkToFolder(url, title, parentElt, beforeElt);
return YES;
}

View File

@ -22,6 +22,8 @@
*
*/
#import "NSString+Utils.h"
#import <AppKit/AppKit.h>
#import "CHAutoCompleteTextField.h"
#include "nsString.h"
@ -101,11 +103,11 @@
} else if ([aColumn isEqualToString:@"col1"]) {
nsAutoString value;
item->GetValue(value);
result = [NSString stringWithCharacters:value.get() length:value.Length()];
result = [NSString stringWith_nsAString:value];
} else if ([aColumn isEqualToString:@"col2"]) {
PRUnichar *comment;
item->GetComment(&comment);
result = [NSString stringWithCharacters:comment length:nsCRT::strlen(comment)];
nsXPIDLString commentStr;
item->GetComment(getter_Copies(commentStr));
result = [NSString stringWith_nsAString:commentStr];
}
return result;

View File

@ -866,12 +866,11 @@ static NSArray* sToolbarDefaults = nil;
{
nsCOMPtr<nsIDOMElement> linkContent;
nsAutoString href;
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs\
(linkContent), href);
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs(linkContent), href);
nsAutoString linkText;
CHGeckoUtils::GatherTextUnder(linkContent, linkText);
NSString* urlStr = [NSString stringWithCharacters:href.get() length:href.Length()];
NSString* titleStr = [NSString stringWithCharacters:linkText.get() length:linkText.Length()];
NSString* urlStr = [NSString stringWith_nsAString:href];
NSString* titleStr = [NSString stringWith_nsAString:linkText];
[self addBookmarkExtended:YES isFolder:NO URL:urlStr title:titleStr];
}
@ -1294,7 +1293,7 @@ static NSArray* sToolbarDefaults = nil;
if (!pref)
return; // Something bad happened if we can't get prefs.
NSString* hrefStr = [NSString stringWith_nsString:&href];
NSString* hrefStr = [NSString stringWith_nsAString:href];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -1323,14 +1322,14 @@ static NSArray* sToolbarDefaults = nil;
if (!linkContent || href.IsEmpty())
return;
NSString* hrefStr = [NSString stringWith_nsString: &href];
NSString* hrefStr = [NSString stringWith_nsAString: href];
// The user wants to save this link.
nsAutoString text;
CHGeckoUtils::GatherTextUnder(mContextMenuNode, text);
[self saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWith_nsString: &text]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
- (IBAction)saveImageAs:(id)aSender
@ -1342,10 +1341,10 @@ static NSArray* sToolbarDefaults = nil;
nsAutoString url;
imgElement->GetSrc(url);
NSString* hrefStr = [NSString stringWith_nsString: &url];
NSString* hrefStr = [NSString stringWith_nsAString: url];
[self saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWith_nsString: &text]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
}
@ -1371,7 +1370,7 @@ static NSArray* sToolbarDefaults = nil;
nsAutoString url;
imgElement->GetSrc(url);
NSString* urlStr = [NSString stringWith_nsString: &url];
NSString* urlStr = [NSString stringWith_nsAString: url];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
[self loadURL: urlStr referrer:referrer];

View File

@ -70,8 +70,8 @@ CocoaPromptService::Alert(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (!window)
return NS_ERROR_FAILURE;
@ -94,9 +94,9 @@ CocoaPromptService::AlertCheck(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (checkValue) {
@ -125,8 +125,8 @@ CocoaPromptService::Confirm(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSWindow* window = GetNSWindowForDOMWindow(parent);
*_retval = (PRBool)[controller confirm:window title:titleStr text:textStr];
@ -147,9 +147,9 @@ CocoaPromptService::ConfirmCheck(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (checkValue) {
@ -190,9 +190,9 @@ CocoaPromptService::ConfirmEx(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
NSString* btn1Str = GetButtonStringFromFlags(buttonFlags, kButton0, button0Title);
@ -233,10 +233,11 @@ CocoaPromptService::Prompt(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* valueStr = [NSMutableString stringWithCharacters:*value length:(*value ? nsCRT::strlen(*value) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* valueStr = [NSMutableString stringWithPRUnichars:*value];
BOOL valueBool;
if (checkValue) {
@ -274,11 +275,11 @@ CocoaPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* userNameStr = [NSMutableString stringWithCharacters:*username length:(*username ? nsCRT::strlen(*username) : 0)];
NSMutableString* passwordStr = [NSMutableString stringWithCharacters:*password length:(*password ? nsCRT::strlen(*password) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* userNameStr = [NSMutableString stringWithPRUnichars:*username];
NSMutableString* passwordStr = [NSMutableString stringWithPRUnichars:*password];
BOOL valueBool;
if (checkValue) {
@ -322,10 +323,10 @@ CocoaPromptService::PromptPassword(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* passwordStr = [NSMutableString stringWithCharacters:*password length:(*password ? nsCRT::strlen(*password) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* passwordStr = [NSMutableString stringWithPRUnichars:*password];
BOOL valueBool;
if (checkValue) {
@ -412,7 +413,7 @@ CocoaPromptService::GetCommonDialogLocaleString(const char *key)
rv = mCommonDialogStringBundle->GetStringFromName(NS_ConvertASCIItoUCS2(key).get(), getter_Copies(string));
if (NS_FAILED(rv)) return returnValue;
returnValue = [NSString stringWithCharacters:string length:(string ? nsCRT::strlen(string) : 0)];
returnValue = [NSString stringWithPRUnichars:string];
return returnValue;
}
@ -445,7 +446,7 @@ CocoaPromptService::GetButtonStringFromFlags(PRUint32 btnFlags,
btnStr = GetCommonDialogLocaleString("Revert");
break;
case BUTTON_TITLE_IS_STRING:
btnStr = [NSString stringWithCharacters:btnTitle length:(btnTitle ? nsCRT::strlen(btnTitle) : 0)];
btnStr = [NSString stringWithPRUnichars:btnTitle];
}
return btnStr;

View File

@ -175,12 +175,12 @@ ContentClickListener::MouseDown(nsIDOMEvent* aEvent)
PRUint32 contentID;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
content->GetContentID(&contentID);
nsAutoString text;
nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(node));
nsAutoString text;
option->GetLabel(text);
if (text.IsEmpty())
option->GetText(text);
NSString* title = [NSString stringWith_nsString: &text];
NSString* title = [NSString stringWith_nsAString: text];
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
[menu addItem: menuItem];
[menuItem setTag: contentID];
@ -281,7 +281,7 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
mouseEvent->GetShiftKey(&shiftKey);
mouseEvent->GetAltKey(&altKey);
NSString* hrefStr = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* hrefStr = [NSString stringWith_nsAString: href];
// Hack to determine specific protocols handled by Chimera in the frontend
// until I can determine why the general unknown protocol handler handoff
@ -317,8 +317,7 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
CHGeckoUtils::GatherTextUnder(content, text);
[mBrowserController saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWithCharacters: text.get()
length: nsCRT::strlen(text.get())]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
return NS_OK;

View File

@ -129,9 +129,9 @@ static const NSString *kEllipsis = @"...";
nsCOMPtr<nsIHistoryEntry> entry;
sessionHistory->GetEntryAtIndex(i, PR_FALSE, getter_AddRefs(entry));
PRUnichar *text;
entry->GetTitle(&text);
NSString* title = [NSString stringWithCharacters: text length: nsCRT::strlen(text)];
nsXPIDLString textStr;
entry->GetTitle(getter_Copies(textStr));
NSString* title = [NSString stringWith_nsAString: textStr];
// if the title is too long, crop it in the middle
if ([title length] > kMaxTitleLength) {

View File

@ -57,8 +57,8 @@
BookmarksService::GetTitleAndHrefForBrowserView(
[[[[self window] windowController] getBrowserWrapper] getBrowserView], titleStr, hrefStr);
NSString *url = [NSString stringWith_nsString: &hrefStr];
NSString *title = [NSString stringWith_nsString: &titleStr];
NSString *url = [NSString stringWith_nsAString: hrefStr];
NSString *title = [NSString stringWith_nsAString: titleStr];
NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];

View File

@ -263,7 +263,7 @@ nsDownloadListener::InitDialog()
nsAutoString pathStr;
mDestination->GetPath(pathStr);
[mDownloadDisplay setDestinationPath: [NSString stringWithCharacters:pathStr.get() length:pathStr.Length()]];
[mDownloadDisplay setDestinationPath: [NSString stringWith_nsAString:pathStr]];
}
void

View File

@ -247,7 +247,7 @@ nsCocoaBrowserService::Show(nsIHelperAppLauncher* inLauncher, nsISupports* inCon
NS_IMETHODIMP
nsCocoaBrowserService::PromptForSaveToFile(nsISupports *aWindowContext, const PRUnichar *aDefaultFile, const PRUnichar *aSuggestedFileExtension, nsILocalFile **_retval)
{
NSString* filename = [NSString stringWithCharacters:aDefaultFile length:nsCRT::strlen(aDefaultFile)];
NSString* filename = [NSString stringWithPRUnichars:aDefaultFile];
NSSavePanel *thePanel = [NSSavePanel savePanel];
// Note: although the docs for NSSavePanel specifically state "path and filename can be empty strings, but

View File

@ -224,7 +224,7 @@ nsCocoaBrowserListener::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const
{
NSPoint where;
where.x = aXCoords; where.y = aYCoords;
[mContainer onShowTooltip:where withText:[NSString stringWithCharacters:aTipText length:nsCRT::strlen(aTipText)]];
[mContainer onShowTooltip:where withText:[NSString stringWithPRUnichars:aTipText]];
return NS_OK;
}
@ -246,7 +246,7 @@ nsCocoaBrowserListener::SetStatus(PRUint32 statusType, const PRUnichar *status)
NSString* str = nsnull;
if (status && (*status != PRUnichar(0))) {
str = [NSString stringWithCharacters:status length:nsCRT::strlen(status)];
str = [NSString stringWithPRUnichars:status];
}
[mContainer setStatus:str ofType:(NSStatusType)statusType];
@ -537,7 +537,7 @@ nsCocoaBrowserListener::SetTitle(const PRUnichar * aTitle)
return NS_ERROR_FAILURE;
}
NSString* str = [NSString stringWithCharacters:aTitle length:nsCRT::strlen(aTitle)];
NSString* str = [NSString stringWithPRUnichars:aTitle];
[mContainer setTitle:str];
return NS_OK;
@ -629,7 +629,7 @@ NS_IMETHODIMP
nsCocoaBrowserListener::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus,
const PRUnichar *aMessage)
{
NSString* str = [NSString stringWithCharacters:aMessage length:nsCRT::strlen(aMessage)];
NSString* str = [NSString stringWithPRUnichars:aMessage];
NSEnumerator* enumerator = [mListeners objectEnumerator];
id<NSBrowserListener> obj;
@ -1079,7 +1079,7 @@ nsCocoaBrowserListener::SetContainer(id <NSBrowserContainer> aContainer)
return @"";
nsAutoString urlStr;
location->GetHref(urlStr);
return [NSString stringWithCharacters: urlStr.get() length: urlStr.Length()];
return [NSString stringWith_nsAString: urlStr];
}
- (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
@ -1270,11 +1270,10 @@ nsCocoaBrowserListener::SetContainer(id <NSBrowserContainer> aContainer)
nsDoc->GetLocation(getter_AddRefs(location));
if (!location)
return empty;
nsAutoString urlStr;
location->GetHref(urlStr);
nsCAutoString urlCStr; urlCStr.AssignWithConversion(urlStr);
return [NSString stringWithCharacters: urlStr.get() length: urlStr.Length()];
return [NSString stringWith_nsAString: urlStr];
}
- (void)setActive: (BOOL)aIsActive

View File

@ -36,14 +36,16 @@
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
#import "nscore.h"
class nsAString;
// a category to extend NSString
@interface NSString (ChimeraStringUtils)
+ (id)stringWith_nsString:(const nsAString*)inString;
- (void)assignTo_nsString:(nsAString*)ioString;
+ (id)stringWithPRUnichars:(const PRUnichar*)inString;
+ (id)stringWith_nsAString:(const nsAString&)inString;
- (void)assignTo_nsAString:(nsAString&)ioString;
- (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet;
- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet withString:(NSString*)string;

View File

@ -43,26 +43,29 @@
@implementation NSString (ChimeraStringUtils)
+ (id)stringWith_nsString:(const nsAString *)inString
+ (id)stringWithPRUnichars:(const PRUnichar*)inString
{
if (inString)
{
nsPromiseFlatString flatString = PromiseFlatString(*inString);
return [NSString stringWithCharacters:flatString.get() length:flatString.Length()];
}
return [NSString stringWithCharacters:inString length:nsCRT::strlen(inString)];
else
return [NSString string];
}
+ (id)stringWith_nsAString:(const nsAString&)inString
{
nsPromiseFlatString flatString = PromiseFlatString(inString);
return [NSString stringWithCharacters:flatString.get() length:flatString.Length()];
}
#define ASSIGN_STACK_BUFFER_CHARACTERS 256
- (void)assignTo_nsString:(nsAString*)ioString
- (void)assignTo_nsAString:(nsAString&)ioString
{
if (!ioString) return;
PRUnichar stackBuffer[ASSIGN_STACK_BUFFER_CHARACTERS];
PRUnichar* buffer = stackBuffer;
// XXX maybe fix this to use SetLength(0), SetLength(len), and a writing iterator.
unsigned int len = [self length];
if (len + 1 > ASSIGN_STACK_BUFFER_CHARACTERS)
@ -73,7 +76,7 @@
}
[self getCharacters: buffer]; // does not null terminate
ioString->Assign(buffer, len);
ioString.Assign(buffer, len);
if (buffer != stackBuffer)
free(buffer);

View File

@ -263,7 +263,7 @@
nsXPIDLString literalValue;
valueLiteral->GetValue(getter_Copies(literalValue));
return [NSString stringWithCharacters: literalValue.get() length:literalValue.Length()];
return [NSString stringWith_nsAString: literalValue];
}
- (void) outlineView: (NSOutlineView*) aOutlineView setObjectValue: (id) aObject

View File

@ -69,7 +69,7 @@
valueLiteral->GetValue(getter_Copies(literalValue));
//Set cell's textual contents
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]];
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWith_nsAString:literalValue]];
if ([columnPropertyURI isEqualToString: @"http://home.netscape.com/NC-rdf#Name"])
{
@ -147,7 +147,7 @@
nsXPIDLString literalValue;
valueLiteral->GetValue(getter_Copies(literalValue));
NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()];
NSString* url = [NSString stringWith_nsAString: literalValue];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer: nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];

View File

@ -169,23 +169,23 @@ static BookmarkInfoController *sharedBookmarkInfoController = nil;
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
NSString* bookmarkName = [NSString stringWith_nsAString: value];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: infoForString];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mLocationField setStringValue: [NSString stringWith_nsAString: value]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mKeywordField setStringValue: [NSString stringWith_nsAString: value]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mDescriptionField setStringValue: [NSString stringWith_nsAString: value]];
mBookmarkItem = aBookmark;
}

View File

@ -148,14 +148,14 @@
// If no URL and title were specified, get them from the current page.
if (aURL && aTitle) {
[aURL assignTo_nsString:&href];
[aTitle assignTo_nsString:&title];
[aURL assignTo_nsAString:href];
[aTitle assignTo_nsAString:title];
} else {
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
title, href);
}
mCachedHref = [NSString stringWithCharacters: href.get() length: href.Length()];
mCachedHref = [NSString stringWith_nsAString: href];
[mCachedHref retain];
} else { // Folder
@ -164,7 +164,7 @@
}
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
NSString* bookmarkTitle = [NSString stringWithCharacters: title.get() length: title.Length()];
NSString* bookmarkTitle = [NSString stringWith_nsAString: title];
NSString* cleanedTitle = [bookmarkTitle stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
[textField setStringValue: cleanedTitle];
@ -214,7 +214,7 @@
}
nsAutoString title;
[[[mBrowserWindowController getAddBookmarkTitle] stringValue] assignTo_nsString:&title];
[[[mBrowserWindowController getAddBookmarkTitle] stringValue] assignTo_nsAString:title];
nsAutoString tagName;
if (mCachedHref)
@ -232,7 +232,7 @@
if (mCachedHref) {
nsAutoString href;
[mCachedHref assignTo_nsString:&href];
[mCachedHref assignTo_nsAString:href];
[mCachedHref release];
elt->SetAttribute(NS_LITERAL_STRING("href"), href);
}
@ -418,7 +418,7 @@
nsAutoString href;
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
@ -521,7 +521,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);
//Set cell's textual contents
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: nameAttr.get() length: nameAttr.Length()]];
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWith_nsAString: nameAttr]];
//Create an attributed string to hold the empty attachment, then release the components.
attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain];
@ -682,7 +682,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
if (value.Length())
descStr = [NSString stringWithCharacters:value.get() length:value.Length()];
descStr = [NSString stringWith_nsAString:value];
// Only description for folders
if ([item isFolder])
@ -691,7 +691,7 @@
// Extract the URL from the item
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
if (value.Length())
hrefStr = [NSString stringWithCharacters:value.get() length:value.Length()];
hrefStr = [NSString stringWith_nsAString:value];
if (!hrefStr)
return descStr;
@ -735,7 +735,7 @@
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
// stuff it into the string
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -759,7 +759,7 @@
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
// stuff it into the string
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -865,7 +865,7 @@
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(item));
nsAutoString href;
element->GetAttribute(NS_LITERAL_STRING("name"), href);
NSString* info = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* info = [NSString stringWith_nsAString: href];
return [NSString stringWithFormat:@"<BookmarkItem, name = \"%@\">", info];
}
@ -875,7 +875,7 @@
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(item));
nsAutoString href;
element->GetAttribute(NS_LITERAL_STRING("href"), href);
return [NSString stringWithCharacters: href.get() length: href.Length()];
return [NSString stringWith_nsAString: href];
}
-(void)setContentNode: (nsIContent*)aContentNode

View File

@ -287,8 +287,7 @@ BookmarksService::BookmarkChanged(nsIContent* aItem, bool shouldFlush = true)
NSMenuItem* childItem = [menu itemWithTag: contentID];
nsAutoString name;
aItem->GetAttr(kNameSpaceID_None, gNameAtom, name);
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
[childItem setTitle: title];
[childItem setTitle: [NSString stringWith_nsAString: name]];
}
}
@ -741,7 +740,7 @@ BookmarksService::AddMenuBookmark(NSMenu* aMenu, nsIContent* aParent, nsIContent
{
nsAutoString name;
aChild->GetAttr(kNameSpaceID_None, gNameAtom, name);
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
NSString* title = [NSString stringWith_nsAString: name];
// Create a menu or menu item for the child.
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
@ -806,7 +805,7 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
if (href.IsEmpty())
return;
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
// Now load the URL in the window.
[aController loadURL:url referrer:nil];
@ -1023,7 +1022,7 @@ BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
nsAutoString href;
elt->GetAttribute(NS_LITERAL_STRING("href"), href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
NSTabViewItem* tabViewItem = nil;
if (currentIndex >= total) {
// We need to make a new tab.
@ -1055,7 +1054,7 @@ NSString*
BookmarksService::ResolveKeyword(NSString* aKeyword)
{
nsAutoString keyword;
[aKeyword assignTo_nsString:&keyword];
[aKeyword assignTo_nsAString:keyword];
if (keyword.IsEmpty())
return [NSString string];
@ -1072,7 +1071,7 @@ BookmarksService::ResolveKeyword(NSString* aKeyword)
nsAutoString url;
if (content) {
content->GetAttr(kNameSpaceID_None, gHrefAtom, url);
return [NSString stringWithCharacters: url.get() length: url.Length()];
return [NSString stringWith_nsAString: url];
}
return [NSString stringWithCString:""];
}
@ -1217,8 +1216,8 @@ BookmarksService::PerformProxyDrop(BookmarkItem* parentItem, BookmarkItem* befor
nsCOMPtr<nsIDOMElement> beforeElt;
beforeElt = do_QueryInterface([beforeItem contentNode]);
nsAutoString url; [[data objectForKey:@"url"] assignTo_nsString:&url];
nsAutoString title; [[data objectForKey:@"title"] assignTo_nsString:&title];
nsAutoString url; [[data objectForKey:@"url"] assignTo_nsAString:url];
nsAutoString title; [[data objectForKey:@"title"] assignTo_nsAString:title];
BookmarksService::AddBookmarkToFolder(url, title, parentElt, beforeElt);
return YES;
}

View File

@ -866,12 +866,11 @@ static NSArray* sToolbarDefaults = nil;
{
nsCOMPtr<nsIDOMElement> linkContent;
nsAutoString href;
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs\
(linkContent), href);
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs(linkContent), href);
nsAutoString linkText;
CHGeckoUtils::GatherTextUnder(linkContent, linkText);
NSString* urlStr = [NSString stringWithCharacters:href.get() length:href.Length()];
NSString* titleStr = [NSString stringWithCharacters:linkText.get() length:linkText.Length()];
NSString* urlStr = [NSString stringWith_nsAString:href];
NSString* titleStr = [NSString stringWith_nsAString:linkText];
[self addBookmarkExtended:YES isFolder:NO URL:urlStr title:titleStr];
}
@ -1294,7 +1293,7 @@ static NSArray* sToolbarDefaults = nil;
if (!pref)
return; // Something bad happened if we can't get prefs.
NSString* hrefStr = [NSString stringWith_nsString:&href];
NSString* hrefStr = [NSString stringWith_nsAString:href];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -1323,14 +1322,14 @@ static NSArray* sToolbarDefaults = nil;
if (!linkContent || href.IsEmpty())
return;
NSString* hrefStr = [NSString stringWith_nsString: &href];
NSString* hrefStr = [NSString stringWith_nsAString: href];
// The user wants to save this link.
nsAutoString text;
CHGeckoUtils::GatherTextUnder(mContextMenuNode, text);
[self saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWith_nsString: &text]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
- (IBAction)saveImageAs:(id)aSender
@ -1342,10 +1341,10 @@ static NSArray* sToolbarDefaults = nil;
nsAutoString url;
imgElement->GetSrc(url);
NSString* hrefStr = [NSString stringWith_nsString: &url];
NSString* hrefStr = [NSString stringWith_nsAString: url];
[self saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWith_nsString: &text]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
}
@ -1371,7 +1370,7 @@ static NSArray* sToolbarDefaults = nil;
nsAutoString url;
imgElement->GetSrc(url);
NSString* urlStr = [NSString stringWith_nsString: &url];
NSString* urlStr = [NSString stringWith_nsAString: url];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
[self loadURL: urlStr referrer:referrer];

View File

@ -22,6 +22,8 @@
*
*/
#import "NSString+Utils.h"
#import <AppKit/AppKit.h>
#import "CHAutoCompleteTextField.h"
#include "nsString.h"
@ -101,11 +103,11 @@
} else if ([aColumn isEqualToString:@"col1"]) {
nsAutoString value;
item->GetValue(value);
result = [NSString stringWithCharacters:value.get() length:value.Length()];
result = [NSString stringWith_nsAString:value];
} else if ([aColumn isEqualToString:@"col2"]) {
PRUnichar *comment;
item->GetComment(&comment);
result = [NSString stringWithCharacters:comment length:nsCRT::strlen(comment)];
nsXPIDLString commentStr;
item->GetComment(getter_Copies(commentStr));
result = [NSString stringWith_nsAString:commentStr];
}
return result;

View File

@ -67,7 +67,7 @@
mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
if (href.IsEmpty())
return;
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
// Now load the URL in the window.
[[[self window] windowController] loadURL: url referrer:nil];
@ -85,7 +85,7 @@
// Get the href attribute. This is the URL we want to load.
nsAutoString hrefAttr;
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -102,7 +102,7 @@
// Get the href attribute. This is the URL we want to load.
nsAutoString hrefAttr;
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -218,13 +218,13 @@
[self setTarget: self];
nsAutoString href;
mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
NSString* helpText = [NSString stringWith_nsString:&href];
NSString* helpText = [NSString stringWith_nsAString:href];
[self setToolTip: helpText];
}
nsAutoString name;
mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
[self setTitle: [NSString stringWith_nsString: &name]];
[self setTitle: [NSString stringWith_nsAString: name]];
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
mBookmarkItem = BookmarksService::GetWrapperFor(content);

View File

@ -224,7 +224,7 @@ nsCocoaBrowserListener::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const
{
NSPoint where;
where.x = aXCoords; where.y = aYCoords;
[mContainer onShowTooltip:where withText:[NSString stringWithCharacters:aTipText length:nsCRT::strlen(aTipText)]];
[mContainer onShowTooltip:where withText:[NSString stringWithPRUnichars:aTipText]];
return NS_OK;
}
@ -246,7 +246,7 @@ nsCocoaBrowserListener::SetStatus(PRUint32 statusType, const PRUnichar *status)
NSString* str = nsnull;
if (status && (*status != PRUnichar(0))) {
str = [NSString stringWithCharacters:status length:nsCRT::strlen(status)];
str = [NSString stringWithPRUnichars:status];
}
[mContainer setStatus:str ofType:(NSStatusType)statusType];
@ -537,7 +537,7 @@ nsCocoaBrowserListener::SetTitle(const PRUnichar * aTitle)
return NS_ERROR_FAILURE;
}
NSString* str = [NSString stringWithCharacters:aTitle length:nsCRT::strlen(aTitle)];
NSString* str = [NSString stringWithPRUnichars:aTitle];
[mContainer setTitle:str];
return NS_OK;
@ -629,7 +629,7 @@ NS_IMETHODIMP
nsCocoaBrowserListener::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus,
const PRUnichar *aMessage)
{
NSString* str = [NSString stringWithCharacters:aMessage length:nsCRT::strlen(aMessage)];
NSString* str = [NSString stringWithPRUnichars:aMessage];
NSEnumerator* enumerator = [mListeners objectEnumerator];
id<NSBrowserListener> obj;
@ -1079,7 +1079,7 @@ nsCocoaBrowserListener::SetContainer(id <NSBrowserContainer> aContainer)
return @"";
nsAutoString urlStr;
location->GetHref(urlStr);
return [NSString stringWithCharacters: urlStr.get() length: urlStr.Length()];
return [NSString stringWith_nsAString: urlStr];
}
- (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
@ -1270,11 +1270,10 @@ nsCocoaBrowserListener::SetContainer(id <NSBrowserContainer> aContainer)
nsDoc->GetLocation(getter_AddRefs(location));
if (!location)
return empty;
nsAutoString urlStr;
location->GetHref(urlStr);
nsCAutoString urlCStr; urlCStr.AssignWithConversion(urlStr);
return [NSString stringWithCharacters: urlStr.get() length: urlStr.Length()];
return [NSString stringWith_nsAString: urlStr];
}
- (void)setActive: (BOOL)aIsActive

View File

@ -184,7 +184,7 @@
nsAutoString href;
bookmarkElt->GetAttribute(NS_LITERAL_STRING("href"), href);
NSString* url = [NSString stringWith_nsString: &href];
NSString* url = [NSString stringWith_nsAString: href];
nsAutoString group;
bookmarkElt->GetAttribute(NS_LITERAL_STRING("group"), group);

View File

@ -129,9 +129,9 @@ static const NSString *kEllipsis = @"...";
nsCOMPtr<nsIHistoryEntry> entry;
sessionHistory->GetEntryAtIndex(i, PR_FALSE, getter_AddRefs(entry));
PRUnichar *text;
entry->GetTitle(&text);
NSString* title = [NSString stringWithCharacters: text length: nsCRT::strlen(text)];
nsXPIDLString textStr;
entry->GetTitle(getter_Copies(textStr));
NSString* title = [NSString stringWith_nsAString: textStr];
// if the title is too long, crop it in the middle
if ([title length] > kMaxTitleLength) {

View File

@ -69,7 +69,7 @@
valueLiteral->GetValue(getter_Copies(literalValue));
//Set cell's textual contents
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]];
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWith_nsAString:literalValue]];
if ([columnPropertyURI isEqualToString: @"http://home.netscape.com/NC-rdf#Name"])
{
@ -147,7 +147,7 @@
nsXPIDLString literalValue;
valueLiteral->GetValue(getter_Copies(literalValue));
NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()];
NSString* url = [NSString stringWith_nsAString: literalValue];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer: nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];

View File

@ -57,8 +57,8 @@
BookmarksService::GetTitleAndHrefForBrowserView(
[[[[self window] windowController] getBrowserWrapper] getBrowserView], titleStr, hrefStr);
NSString *url = [NSString stringWith_nsString: &hrefStr];
NSString *title = [NSString stringWith_nsString: &titleStr];
NSString *url = [NSString stringWith_nsAString: hrefStr];
NSString *title = [NSString stringWith_nsAString: titleStr];
NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];

View File

@ -263,7 +263,7 @@
nsXPIDLString literalValue;
valueLiteral->GetValue(getter_Copies(literalValue));
return [NSString stringWithCharacters: literalValue.get() length:literalValue.Length()];
return [NSString stringWith_nsAString: literalValue];
}
- (void) outlineView: (NSOutlineView*) aOutlineView setObjectValue: (id) aObject

View File

@ -70,8 +70,8 @@ CocoaPromptService::Alert(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (!window)
return NS_ERROR_FAILURE;
@ -94,9 +94,9 @@ CocoaPromptService::AlertCheck(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (checkValue) {
@ -125,8 +125,8 @@ CocoaPromptService::Confirm(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSWindow* window = GetNSWindowForDOMWindow(parent);
*_retval = (PRBool)[controller confirm:window title:titleStr text:textStr];
@ -147,9 +147,9 @@ CocoaPromptService::ConfirmCheck(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (checkValue) {
@ -190,9 +190,9 @@ CocoaPromptService::ConfirmEx(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
NSString* btn1Str = GetButtonStringFromFlags(buttonFlags, kButton0, button0Title);
@ -233,10 +233,11 @@ CocoaPromptService::Prompt(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* valueStr = [NSMutableString stringWithCharacters:*value length:(*value ? nsCRT::strlen(*value) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* valueStr = [NSMutableString stringWithPRUnichars:*value];
BOOL valueBool;
if (checkValue) {
@ -274,11 +275,11 @@ CocoaPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* userNameStr = [NSMutableString stringWithCharacters:*username length:(*username ? nsCRT::strlen(*username) : 0)];
NSMutableString* passwordStr = [NSMutableString stringWithCharacters:*password length:(*password ? nsCRT::strlen(*password) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* userNameStr = [NSMutableString stringWithPRUnichars:*username];
NSMutableString* passwordStr = [NSMutableString stringWithPRUnichars:*password];
BOOL valueBool;
if (checkValue) {
@ -322,10 +323,10 @@ CocoaPromptService::PromptPassword(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* passwordStr = [NSMutableString stringWithCharacters:*password length:(*password ? nsCRT::strlen(*password) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* passwordStr = [NSMutableString stringWithPRUnichars:*password];
BOOL valueBool;
if (checkValue) {
@ -412,7 +413,7 @@ CocoaPromptService::GetCommonDialogLocaleString(const char *key)
rv = mCommonDialogStringBundle->GetStringFromName(NS_ConvertASCIItoUCS2(key).get(), getter_Copies(string));
if (NS_FAILED(rv)) return returnValue;
returnValue = [NSString stringWithCharacters:string length:(string ? nsCRT::strlen(string) : 0)];
returnValue = [NSString stringWithPRUnichars:string];
return returnValue;
}
@ -445,7 +446,7 @@ CocoaPromptService::GetButtonStringFromFlags(PRUint32 btnFlags,
btnStr = GetCommonDialogLocaleString("Revert");
break;
case BUTTON_TITLE_IS_STRING:
btnStr = [NSString stringWithCharacters:btnTitle length:(btnTitle ? nsCRT::strlen(btnTitle) : 0)];
btnStr = [NSString stringWithPRUnichars:btnTitle];
}
return btnStr;

View File

@ -175,12 +175,12 @@ ContentClickListener::MouseDown(nsIDOMEvent* aEvent)
PRUint32 contentID;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
content->GetContentID(&contentID);
nsAutoString text;
nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(node));
nsAutoString text;
option->GetLabel(text);
if (text.IsEmpty())
option->GetText(text);
NSString* title = [NSString stringWith_nsString: &text];
NSString* title = [NSString stringWith_nsAString: text];
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
[menu addItem: menuItem];
[menuItem setTag: contentID];
@ -281,7 +281,7 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
mouseEvent->GetShiftKey(&shiftKey);
mouseEvent->GetAltKey(&altKey);
NSString* hrefStr = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* hrefStr = [NSString stringWith_nsAString: href];
// Hack to determine specific protocols handled by Chimera in the frontend
// until I can determine why the general unknown protocol handler handoff
@ -317,8 +317,7 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
CHGeckoUtils::GatherTextUnder(content, text);
[mBrowserController saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWithCharacters: text.get()
length: nsCRT::strlen(text.get())]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
return NS_OK;

View File

@ -36,14 +36,16 @@
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
#import "nscore.h"
class nsAString;
// a category to extend NSString
@interface NSString (ChimeraStringUtils)
+ (id)stringWith_nsString:(const nsAString*)inString;
- (void)assignTo_nsString:(nsAString*)ioString;
+ (id)stringWithPRUnichars:(const PRUnichar*)inString;
+ (id)stringWith_nsAString:(const nsAString&)inString;
- (void)assignTo_nsAString:(nsAString&)ioString;
- (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet;
- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet withString:(NSString*)string;

View File

@ -43,26 +43,29 @@
@implementation NSString (ChimeraStringUtils)
+ (id)stringWith_nsString:(const nsAString *)inString
+ (id)stringWithPRUnichars:(const PRUnichar*)inString
{
if (inString)
{
nsPromiseFlatString flatString = PromiseFlatString(*inString);
return [NSString stringWithCharacters:flatString.get() length:flatString.Length()];
}
return [NSString stringWithCharacters:inString length:nsCRT::strlen(inString)];
else
return [NSString string];
}
+ (id)stringWith_nsAString:(const nsAString&)inString
{
nsPromiseFlatString flatString = PromiseFlatString(inString);
return [NSString stringWithCharacters:flatString.get() length:flatString.Length()];
}
#define ASSIGN_STACK_BUFFER_CHARACTERS 256
- (void)assignTo_nsString:(nsAString*)ioString
- (void)assignTo_nsAString:(nsAString&)ioString
{
if (!ioString) return;
PRUnichar stackBuffer[ASSIGN_STACK_BUFFER_CHARACTERS];
PRUnichar* buffer = stackBuffer;
// XXX maybe fix this to use SetLength(0), SetLength(len), and a writing iterator.
unsigned int len = [self length];
if (len + 1 > ASSIGN_STACK_BUFFER_CHARACTERS)
@ -73,7 +76,7 @@
}
[self getCharacters: buffer]; // does not null terminate
ioString->Assign(buffer, len);
ioString.Assign(buffer, len);
if (buffer != stackBuffer)
free(buffer);

View File

@ -247,7 +247,7 @@ nsCocoaBrowserService::Show(nsIHelperAppLauncher* inLauncher, nsISupports* inCon
NS_IMETHODIMP
nsCocoaBrowserService::PromptForSaveToFile(nsISupports *aWindowContext, const PRUnichar *aDefaultFile, const PRUnichar *aSuggestedFileExtension, nsILocalFile **_retval)
{
NSString* filename = [NSString stringWithCharacters:aDefaultFile length:nsCRT::strlen(aDefaultFile)];
NSString* filename = [NSString stringWithPRUnichars:aDefaultFile];
NSSavePanel *thePanel = [NSSavePanel savePanel];
// Note: although the docs for NSSavePanel specifically state "path and filename can be empty strings, but

View File

@ -263,7 +263,7 @@ nsDownloadListener::InitDialog()
nsAutoString pathStr;
mDestination->GetPath(pathStr);
[mDownloadDisplay setDestinationPath: [NSString stringWithCharacters:pathStr.get() length:pathStr.Length()]];
[mDownloadDisplay setDestinationPath: [NSString stringWith_nsAString:pathStr]];
}
void

View File

@ -169,23 +169,23 @@ static BookmarkInfoController *sharedBookmarkInfoController = nil;
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
NSString* bookmarkName = [NSString stringWith_nsAString: value];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: infoForString];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mLocationField setStringValue: [NSString stringWith_nsAString: value]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mKeywordField setStringValue: [NSString stringWith_nsAString: value]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
[mDescriptionField setStringValue: [NSString stringWith_nsAString: value]];
mBookmarkItem = aBookmark;
}

View File

@ -67,7 +67,7 @@
mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
if (href.IsEmpty())
return;
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
// Now load the URL in the window.
[[[self window] windowController] loadURL: url referrer:nil];
@ -85,7 +85,7 @@
// Get the href attribute. This is the URL we want to load.
nsAutoString hrefAttr;
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -102,7 +102,7 @@
// Get the href attribute. This is the URL we want to load.
nsAutoString hrefAttr;
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -218,13 +218,13 @@
[self setTarget: self];
nsAutoString href;
mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
NSString* helpText = [NSString stringWith_nsString:&href];
NSString* helpText = [NSString stringWith_nsAString:href];
[self setToolTip: helpText];
}
nsAutoString name;
mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
[self setTitle: [NSString stringWith_nsString: &name]];
[self setTitle: [NSString stringWith_nsAString: name]];
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
mBookmarkItem = BookmarksService::GetWrapperFor(content);

View File

@ -148,14 +148,14 @@
// If no URL and title were specified, get them from the current page.
if (aURL && aTitle) {
[aURL assignTo_nsString:&href];
[aTitle assignTo_nsString:&title];
[aURL assignTo_nsAString:href];
[aTitle assignTo_nsAString:title];
} else {
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
title, href);
}
mCachedHref = [NSString stringWithCharacters: href.get() length: href.Length()];
mCachedHref = [NSString stringWith_nsAString: href];
[mCachedHref retain];
} else { // Folder
@ -164,7 +164,7 @@
}
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
NSString* bookmarkTitle = [NSString stringWithCharacters: title.get() length: title.Length()];
NSString* bookmarkTitle = [NSString stringWith_nsAString: title];
NSString* cleanedTitle = [bookmarkTitle stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
[textField setStringValue: cleanedTitle];
@ -214,7 +214,7 @@
}
nsAutoString title;
[[[mBrowserWindowController getAddBookmarkTitle] stringValue] assignTo_nsString:&title];
[[[mBrowserWindowController getAddBookmarkTitle] stringValue] assignTo_nsAString:title];
nsAutoString tagName;
if (mCachedHref)
@ -232,7 +232,7 @@
if (mCachedHref) {
nsAutoString href;
[mCachedHref assignTo_nsString:&href];
[mCachedHref assignTo_nsAString:href];
[mCachedHref release];
elt->SetAttribute(NS_LITERAL_STRING("href"), href);
}
@ -418,7 +418,7 @@
nsAutoString href;
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
@ -521,7 +521,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);
//Set cell's textual contents
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: nameAttr.get() length: nameAttr.Length()]];
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWith_nsAString: nameAttr]];
//Create an attributed string to hold the empty attachment, then release the components.
attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain];
@ -682,7 +682,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
if (value.Length())
descStr = [NSString stringWithCharacters:value.get() length:value.Length()];
descStr = [NSString stringWith_nsAString:value];
// Only description for folders
if ([item isFolder])
@ -691,7 +691,7 @@
// Extract the URL from the item
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
if (value.Length())
hrefStr = [NSString stringWithCharacters:value.get() length:value.Length()];
hrefStr = [NSString stringWith_nsAString:value];
if (!hrefStr)
return descStr;
@ -735,7 +735,7 @@
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
// stuff it into the string
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -759,7 +759,7 @@
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
// stuff it into the string
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
NSString* hrefStr = [NSString stringWith_nsAString:hrefAttr];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -865,7 +865,7 @@
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(item));
nsAutoString href;
element->GetAttribute(NS_LITERAL_STRING("name"), href);
NSString* info = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* info = [NSString stringWith_nsAString: href];
return [NSString stringWithFormat:@"<BookmarkItem, name = \"%@\">", info];
}
@ -875,7 +875,7 @@
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(item));
nsAutoString href;
element->GetAttribute(NS_LITERAL_STRING("href"), href);
return [NSString stringWithCharacters: href.get() length: href.Length()];
return [NSString stringWith_nsAString: href];
}
-(void)setContentNode: (nsIContent*)aContentNode

View File

@ -287,8 +287,7 @@ BookmarksService::BookmarkChanged(nsIContent* aItem, bool shouldFlush = true)
NSMenuItem* childItem = [menu itemWithTag: contentID];
nsAutoString name;
aItem->GetAttr(kNameSpaceID_None, gNameAtom, name);
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
[childItem setTitle: title];
[childItem setTitle: [NSString stringWith_nsAString: name]];
}
}
@ -741,7 +740,7 @@ BookmarksService::AddMenuBookmark(NSMenu* aMenu, nsIContent* aParent, nsIContent
{
nsAutoString name;
aChild->GetAttr(kNameSpaceID_None, gNameAtom, name);
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
NSString* title = [NSString stringWith_nsAString: name];
// Create a menu or menu item for the child.
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
@ -806,7 +805,7 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
if (href.IsEmpty())
return;
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
// Now load the URL in the window.
[aController loadURL:url referrer:nil];
@ -1023,7 +1022,7 @@ BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
nsAutoString href;
elt->GetAttribute(NS_LITERAL_STRING("href"), href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* url = [NSString stringWith_nsAString: href];
NSTabViewItem* tabViewItem = nil;
if (currentIndex >= total) {
// We need to make a new tab.
@ -1055,7 +1054,7 @@ NSString*
BookmarksService::ResolveKeyword(NSString* aKeyword)
{
nsAutoString keyword;
[aKeyword assignTo_nsString:&keyword];
[aKeyword assignTo_nsAString:keyword];
if (keyword.IsEmpty())
return [NSString string];
@ -1072,7 +1071,7 @@ BookmarksService::ResolveKeyword(NSString* aKeyword)
nsAutoString url;
if (content) {
content->GetAttr(kNameSpaceID_None, gHrefAtom, url);
return [NSString stringWithCharacters: url.get() length: url.Length()];
return [NSString stringWith_nsAString: url];
}
return [NSString stringWithCString:""];
}
@ -1217,8 +1216,8 @@ BookmarksService::PerformProxyDrop(BookmarkItem* parentItem, BookmarkItem* befor
nsCOMPtr<nsIDOMElement> beforeElt;
beforeElt = do_QueryInterface([beforeItem contentNode]);
nsAutoString url; [[data objectForKey:@"url"] assignTo_nsString:&url];
nsAutoString title; [[data objectForKey:@"title"] assignTo_nsString:&title];
nsAutoString url; [[data objectForKey:@"url"] assignTo_nsAString:url];
nsAutoString title; [[data objectForKey:@"title"] assignTo_nsAString:title];
BookmarksService::AddBookmarkToFolder(url, title, parentElt, beforeElt);
return YES;
}

View File

@ -22,6 +22,8 @@
*
*/
#import "NSString+Utils.h"
#import <AppKit/AppKit.h>
#import "CHAutoCompleteTextField.h"
#include "nsString.h"
@ -101,11 +103,11 @@
} else if ([aColumn isEqualToString:@"col1"]) {
nsAutoString value;
item->GetValue(value);
result = [NSString stringWithCharacters:value.get() length:value.Length()];
result = [NSString stringWith_nsAString:value];
} else if ([aColumn isEqualToString:@"col2"]) {
PRUnichar *comment;
item->GetComment(&comment);
result = [NSString stringWithCharacters:comment length:nsCRT::strlen(comment)];
nsXPIDLString commentStr;
item->GetComment(getter_Copies(commentStr));
result = [NSString stringWith_nsAString:commentStr];
}
return result;

View File

@ -866,12 +866,11 @@ static NSArray* sToolbarDefaults = nil;
{
nsCOMPtr<nsIDOMElement> linkContent;
nsAutoString href;
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs\
(linkContent), href);
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs(linkContent), href);
nsAutoString linkText;
CHGeckoUtils::GatherTextUnder(linkContent, linkText);
NSString* urlStr = [NSString stringWithCharacters:href.get() length:href.Length()];
NSString* titleStr = [NSString stringWithCharacters:linkText.get() length:linkText.Length()];
NSString* urlStr = [NSString stringWith_nsAString:href];
NSString* titleStr = [NSString stringWith_nsAString:linkText];
[self addBookmarkExtended:YES isFolder:NO URL:urlStr title:titleStr];
}
@ -1294,7 +1293,7 @@ static NSArray* sToolbarDefaults = nil;
if (!pref)
return; // Something bad happened if we can't get prefs.
NSString* hrefStr = [NSString stringWith_nsString:&href];
NSString* hrefStr = [NSString stringWith_nsAString:href];
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
@ -1323,14 +1322,14 @@ static NSArray* sToolbarDefaults = nil;
if (!linkContent || href.IsEmpty())
return;
NSString* hrefStr = [NSString stringWith_nsString: &href];
NSString* hrefStr = [NSString stringWith_nsAString: href];
// The user wants to save this link.
nsAutoString text;
CHGeckoUtils::GatherTextUnder(mContextMenuNode, text);
[self saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWith_nsString: &text]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
- (IBAction)saveImageAs:(id)aSender
@ -1342,10 +1341,10 @@ static NSArray* sToolbarDefaults = nil;
nsAutoString url;
imgElement->GetSrc(url);
NSString* hrefStr = [NSString stringWith_nsString: &url];
NSString* hrefStr = [NSString stringWith_nsAString: url];
[self saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWith_nsString: &text]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
}
@ -1371,7 +1370,7 @@ static NSArray* sToolbarDefaults = nil;
nsAutoString url;
imgElement->GetSrc(url);
NSString* urlStr = [NSString stringWith_nsString: &url];
NSString* urlStr = [NSString stringWith_nsAString: url];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
[self loadURL: urlStr referrer:referrer];

View File

@ -70,8 +70,8 @@ CocoaPromptService::Alert(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (!window)
return NS_ERROR_FAILURE;
@ -94,9 +94,9 @@ CocoaPromptService::AlertCheck(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (checkValue) {
@ -125,8 +125,8 @@ CocoaPromptService::Confirm(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSWindow* window = GetNSWindowForDOMWindow(parent);
*_retval = (PRBool)[controller confirm:window title:titleStr text:textStr];
@ -147,9 +147,9 @@ CocoaPromptService::ConfirmCheck(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
if (checkValue) {
@ -190,9 +190,9 @@ CocoaPromptService::ConfirmEx(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSWindow* window = GetNSWindowForDOMWindow(parent);
NSString* btn1Str = GetButtonStringFromFlags(buttonFlags, kButton0, button0Title);
@ -233,10 +233,11 @@ CocoaPromptService::Prompt(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* valueStr = [NSMutableString stringWithCharacters:*value length:(*value ? nsCRT::strlen(*value) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* valueStr = [NSMutableString stringWithPRUnichars:*value];
BOOL valueBool;
if (checkValue) {
@ -274,11 +275,11 @@ CocoaPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* userNameStr = [NSMutableString stringWithCharacters:*username length:(*username ? nsCRT::strlen(*username) : 0)];
NSMutableString* passwordStr = [NSMutableString stringWithCharacters:*password length:(*password ? nsCRT::strlen(*password) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* userNameStr = [NSMutableString stringWithPRUnichars:*username];
NSMutableString* passwordStr = [NSMutableString stringWithPRUnichars:*password];
BOOL valueBool;
if (checkValue) {
@ -322,10 +323,10 @@ CocoaPromptService::PromptPassword(nsIDOMWindow *parent,
return NS_ERROR_FAILURE;
}
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
NSMutableString* passwordStr = [NSMutableString stringWithCharacters:*password length:(*password ? nsCRT::strlen(*password) : 0)];
NSString* titleStr = [NSString stringWithPRUnichars:dialogTitle];
NSString* textStr = [NSString stringWithPRUnichars:text];
NSString* msgStr = [NSString stringWithPRUnichars:checkMsg];
NSMutableString* passwordStr = [NSMutableString stringWithPRUnichars:*password];
BOOL valueBool;
if (checkValue) {
@ -412,7 +413,7 @@ CocoaPromptService::GetCommonDialogLocaleString(const char *key)
rv = mCommonDialogStringBundle->GetStringFromName(NS_ConvertASCIItoUCS2(key).get(), getter_Copies(string));
if (NS_FAILED(rv)) return returnValue;
returnValue = [NSString stringWithCharacters:string length:(string ? nsCRT::strlen(string) : 0)];
returnValue = [NSString stringWithPRUnichars:string];
return returnValue;
}
@ -445,7 +446,7 @@ CocoaPromptService::GetButtonStringFromFlags(PRUint32 btnFlags,
btnStr = GetCommonDialogLocaleString("Revert");
break;
case BUTTON_TITLE_IS_STRING:
btnStr = [NSString stringWithCharacters:btnTitle length:(btnTitle ? nsCRT::strlen(btnTitle) : 0)];
btnStr = [NSString stringWithPRUnichars:btnTitle];
}
return btnStr;

View File

@ -175,12 +175,12 @@ ContentClickListener::MouseDown(nsIDOMEvent* aEvent)
PRUint32 contentID;
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
content->GetContentID(&contentID);
nsAutoString text;
nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(node));
nsAutoString text;
option->GetLabel(text);
if (text.IsEmpty())
option->GetText(text);
NSString* title = [NSString stringWith_nsString: &text];
NSString* title = [NSString stringWith_nsAString: text];
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
[menu addItem: menuItem];
[menuItem setTag: contentID];
@ -281,7 +281,7 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
mouseEvent->GetShiftKey(&shiftKey);
mouseEvent->GetAltKey(&altKey);
NSString* hrefStr = [NSString stringWithCharacters: href.get() length: href.Length()];
NSString* hrefStr = [NSString stringWith_nsAString: href];
// Hack to determine specific protocols handled by Chimera in the frontend
// until I can determine why the general unknown protocol handler handoff
@ -317,8 +317,7 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
CHGeckoUtils::GatherTextUnder(content, text);
[mBrowserController saveURL: nil filterList: nil
url: hrefStr suggestedFilename: [NSString stringWithCharacters: text.get()
length: nsCRT::strlen(text.get())]];
url: hrefStr suggestedFilename: [NSString stringWith_nsAString: text]];
}
return NS_OK;

View File

@ -129,9 +129,9 @@ static const NSString *kEllipsis = @"...";
nsCOMPtr<nsIHistoryEntry> entry;
sessionHistory->GetEntryAtIndex(i, PR_FALSE, getter_AddRefs(entry));
PRUnichar *text;
entry->GetTitle(&text);
NSString* title = [NSString stringWithCharacters: text length: nsCRT::strlen(text)];
nsXPIDLString textStr;
entry->GetTitle(getter_Copies(textStr));
NSString* title = [NSString stringWith_nsAString: textStr];
// if the title is too long, crop it in the middle
if ([title length] > kMaxTitleLength) {

View File

@ -57,8 +57,8 @@
BookmarksService::GetTitleAndHrefForBrowserView(
[[[[self window] windowController] getBrowserWrapper] getBrowserView], titleStr, hrefStr);
NSString *url = [NSString stringWith_nsString: &hrefStr];
NSString *title = [NSString stringWith_nsString: &titleStr];
NSString *url = [NSString stringWith_nsAString: hrefStr];
NSString *title = [NSString stringWith_nsAString: titleStr];
NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];

View File

@ -263,7 +263,7 @@ nsDownloadListener::InitDialog()
nsAutoString pathStr;
mDestination->GetPath(pathStr);
[mDownloadDisplay setDestinationPath: [NSString stringWithCharacters:pathStr.get() length:pathStr.Length()]];
[mDownloadDisplay setDestinationPath: [NSString stringWith_nsAString:pathStr]];
}
void

View File

@ -247,7 +247,7 @@ nsCocoaBrowserService::Show(nsIHelperAppLauncher* inLauncher, nsISupports* inCon
NS_IMETHODIMP
nsCocoaBrowserService::PromptForSaveToFile(nsISupports *aWindowContext, const PRUnichar *aDefaultFile, const PRUnichar *aSuggestedFileExtension, nsILocalFile **_retval)
{
NSString* filename = [NSString stringWithCharacters:aDefaultFile length:nsCRT::strlen(aDefaultFile)];
NSString* filename = [NSString stringWithPRUnichars:aDefaultFile];
NSSavePanel *thePanel = [NSSavePanel savePanel];
// Note: although the docs for NSSavePanel specifically state "path and filename can be empty strings, but

View File

@ -224,7 +224,7 @@ nsCocoaBrowserListener::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const
{
NSPoint where;
where.x = aXCoords; where.y = aYCoords;
[mContainer onShowTooltip:where withText:[NSString stringWithCharacters:aTipText length:nsCRT::strlen(aTipText)]];
[mContainer onShowTooltip:where withText:[NSString stringWithPRUnichars:aTipText]];
return NS_OK;
}
@ -246,7 +246,7 @@ nsCocoaBrowserListener::SetStatus(PRUint32 statusType, const PRUnichar *status)
NSString* str = nsnull;
if (status && (*status != PRUnichar(0))) {
str = [NSString stringWithCharacters:status length:nsCRT::strlen(status)];
str = [NSString stringWithPRUnichars:status];
}
[mContainer setStatus:str ofType:(NSStatusType)statusType];
@ -537,7 +537,7 @@ nsCocoaBrowserListener::SetTitle(const PRUnichar * aTitle)
return NS_ERROR_FAILURE;
}
NSString* str = [NSString stringWithCharacters:aTitle length:nsCRT::strlen(aTitle)];
NSString* str = [NSString stringWithPRUnichars:aTitle];
[mContainer setTitle:str];
return NS_OK;
@ -629,7 +629,7 @@ NS_IMETHODIMP
nsCocoaBrowserListener::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus,
const PRUnichar *aMessage)
{
NSString* str = [NSString stringWithCharacters:aMessage length:nsCRT::strlen(aMessage)];
NSString* str = [NSString stringWithPRUnichars:aMessage];
NSEnumerator* enumerator = [mListeners objectEnumerator];
id<NSBrowserListener> obj;
@ -1079,7 +1079,7 @@ nsCocoaBrowserListener::SetContainer(id <NSBrowserContainer> aContainer)
return @"";
nsAutoString urlStr;
location->GetHref(urlStr);
return [NSString stringWithCharacters: urlStr.get() length: urlStr.Length()];
return [NSString stringWith_nsAString: urlStr];
}
- (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
@ -1270,11 +1270,10 @@ nsCocoaBrowserListener::SetContainer(id <NSBrowserContainer> aContainer)
nsDoc->GetLocation(getter_AddRefs(location));
if (!location)
return empty;
nsAutoString urlStr;
location->GetHref(urlStr);
nsCAutoString urlCStr; urlCStr.AssignWithConversion(urlStr);
return [NSString stringWithCharacters: urlStr.get() length: urlStr.Length()];
return [NSString stringWith_nsAString: urlStr];
}
- (void)setActive: (BOOL)aIsActive

View File

@ -36,14 +36,16 @@
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
#import "nscore.h"
class nsAString;
// a category to extend NSString
@interface NSString (ChimeraStringUtils)
+ (id)stringWith_nsString:(const nsAString*)inString;
- (void)assignTo_nsString:(nsAString*)ioString;
+ (id)stringWithPRUnichars:(const PRUnichar*)inString;
+ (id)stringWith_nsAString:(const nsAString&)inString;
- (void)assignTo_nsAString:(nsAString&)ioString;
- (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet;
- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet withString:(NSString*)string;

View File

@ -43,26 +43,29 @@
@implementation NSString (ChimeraStringUtils)
+ (id)stringWith_nsString:(const nsAString *)inString
+ (id)stringWithPRUnichars:(const PRUnichar*)inString
{
if (inString)
{
nsPromiseFlatString flatString = PromiseFlatString(*inString);
return [NSString stringWithCharacters:flatString.get() length:flatString.Length()];
}
return [NSString stringWithCharacters:inString length:nsCRT::strlen(inString)];
else
return [NSString string];
}
+ (id)stringWith_nsAString:(const nsAString&)inString
{
nsPromiseFlatString flatString = PromiseFlatString(inString);
return [NSString stringWithCharacters:flatString.get() length:flatString.Length()];
}
#define ASSIGN_STACK_BUFFER_CHARACTERS 256
- (void)assignTo_nsString:(nsAString*)ioString
- (void)assignTo_nsAString:(nsAString&)ioString
{
if (!ioString) return;
PRUnichar stackBuffer[ASSIGN_STACK_BUFFER_CHARACTERS];
PRUnichar* buffer = stackBuffer;
// XXX maybe fix this to use SetLength(0), SetLength(len), and a writing iterator.
unsigned int len = [self length];
if (len + 1 > ASSIGN_STACK_BUFFER_CHARACTERS)
@ -73,7 +76,7 @@
}
[self getCharacters: buffer]; // does not null terminate
ioString->Assign(buffer, len);
ioString.Assign(buffer, len);
if (buffer != stackBuffer)
free(buffer);

View File

@ -263,7 +263,7 @@
nsXPIDLString literalValue;
valueLiteral->GetValue(getter_Copies(literalValue));
return [NSString stringWithCharacters: literalValue.get() length:literalValue.Length()];
return [NSString stringWith_nsAString: literalValue];
}
- (void) outlineView: (NSOutlineView*) aOutlineView setObjectValue: (id) aObject

View File

@ -69,7 +69,7 @@
valueLiteral->GetValue(getter_Copies(literalValue));
//Set cell's textual contents
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]];
[cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWith_nsAString:literalValue]];
if ([columnPropertyURI isEqualToString: @"http://home.netscape.com/NC-rdf#Name"])
{
@ -147,7 +147,7 @@
nsXPIDLString literalValue;
valueLiteral->GetValue(getter_Copies(literalValue));
NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()];
NSString* url = [NSString stringWith_nsAString: literalValue];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer: nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];