Bug 1179086 ContentEventHandler should use /n on Mac rather than /r r=smaug+smichaud+josh

This commit is contained in:
Masayuki Nakano 2015-07-02 10:00:44 +09:00
parent 1c19908812
commit a65780bd5b
2 changed files with 4 additions and 16 deletions

View File

@ -21,7 +21,7 @@ SimpleTest.waitForExplicitFinish();
const kIsWin = navigator.platform.indexOf("Win") == 0;
const kIsMac = navigator.platform.indexOf("Mac") == 0;
const kLineBreak = kIsWin ? "\r\n" : kIsMac ? "\r" : "\n";
const kLineBreak = kIsWin ? "\r\n" : "\n";
var gUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);

View File

@ -212,10 +212,7 @@ static bool IsContentBR(nsIContent* aContent)
static void ConvertToNativeNewlines(nsAFlatString& aString)
{
#if defined(XP_MACOSX)
// XXX Mac OS X doesn't use "\r".
aString.ReplaceSubstring(NS_LITERAL_STRING("\n"), NS_LITERAL_STRING("\r"));
#elif defined(XP_WIN)
#if defined(XP_WIN)
aString.ReplaceSubstring(NS_LITERAL_STRING("\n"), NS_LITERAL_STRING("\r\n"));
#endif
}
@ -334,12 +331,7 @@ ContentEventHandler::GetTextLength(nsIContent* aContent,
{
if (aContent->IsNodeOfType(nsINode::eTEXT)) {
uint32_t textLengthDifference =
#if defined(XP_MACOSX)
// On Mac, the length of a native newline ("\r") is equal to the length of
// the XP newline ("\n"), so the native length is the same as the XP
// length.
0;
#elif defined(XP_WIN)
#if defined(XP_WIN)
// On Windows, the length of a native newline ("\r\n") is twice the length
// of the XP newline ("\n"), so XP length is equal to the length of the
// native offset plus the number of newlines encountered in the string.
@ -364,11 +356,7 @@ ContentEventHandler::GetTextLength(nsIContent* aContent,
static uint32_t ConvertToXPOffset(nsIContent* aContent, uint32_t aNativeOffset)
{
#if defined(XP_MACOSX)
// On Mac, the length of a native newline ("\r") is equal to the length of
// the XP newline ("\n"), so the native offset is the same as the XP offset.
return aNativeOffset;
#elif defined(XP_WIN)
#if defined(XP_WIN)
// On Windows, the length of a native newline ("\r\n") is twice the length of
// the XP newline ("\n"), so XP offset is equal to the length of the native
// offset minus the number of newlines encountered in the string.