зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1104875. Ellipsize long unresponsive script locations so they don't make the slow script dialog too big. r=peterv
This commit is contained in:
Родитель
6ac7384613
Коммит
4c2e5e962d
|
@ -70,6 +70,7 @@
|
|||
#include "AudioChannelService.h"
|
||||
#include "MessageEvent.h"
|
||||
#include "nsAboutProtocolUtils.h"
|
||||
#include "nsCharTraits.h" // NS_IS_HIGH/LOW_SURROGATE
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIFrame.h"
|
||||
|
@ -11073,7 +11074,32 @@ nsGlobalWindow::ShowSlowScriptDialog()
|
|||
// Append file and line number information, if available
|
||||
if (filename.get()) {
|
||||
nsXPIDLString scriptLocation;
|
||||
// We want to drop the middle part of too-long locations. We'll
|
||||
// define "too-long" as longer than 60 UTF-16 code units. Just
|
||||
// have to be a bit careful about unpaired surrogates.
|
||||
NS_ConvertUTF8toUTF16 filenameUTF16(filename.get());
|
||||
if (filenameUTF16.Length() > 60) {
|
||||
// XXXbz Do we need to insert any bidi overrides here?
|
||||
size_t cutStart = 30;
|
||||
size_t cutLength = filenameUTF16.Length() - 60;
|
||||
MOZ_ASSERT(cutLength > 0);
|
||||
if (NS_IS_LOW_SURROGATE(filenameUTF16[cutStart])) {
|
||||
// Don't truncate before the low surrogate, in case it's preceded by a
|
||||
// high surrogate and forms a single Unicode character. Instead, just
|
||||
// include the low surrogate.
|
||||
++cutStart;
|
||||
--cutLength;
|
||||
}
|
||||
if (NS_IS_LOW_SURROGATE(filenameUTF16[cutStart + cutLength])) {
|
||||
// Likewise, don't drop a trailing low surrogate here. We want to
|
||||
// increase cutLength, since it might be 0 already so we can't very well
|
||||
// decrease it.
|
||||
++cutLength;
|
||||
}
|
||||
|
||||
// Insert U+2026 HORIZONTAL ELLIPSIS
|
||||
filenameUTF16.Replace(cutStart, cutLength, NS_LITERAL_STRING("\x2026"));
|
||||
}
|
||||
const char16_t *formatParams[] = { filenameUTF16.get() };
|
||||
rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
||||
"KillScriptLocation",
|
||||
|
|
Загрузка…
Ссылка в новой задаче