diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 23:24:17 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 23:24:17 +0000 |
commit | 6df853c758ee98981354428c52107545d743fceb (patch) | |
tree | 8537b289bebb6c45baa65b377b7cc09bddb1ed60 /chrome/browser/message_box_handler.cc | |
parent | 865f447f8aa94000f9669a0d1e24c27d20b0c79c (diff) | |
download | chromium_src-6df853c758ee98981354428c52107545d743fceb.zip chromium_src-6df853c758ee98981354428c52107545d743fceb.tar.gz chromium_src-6df853c758ee98981354428c52107545d743fceb.tar.bz2 |
Fix some issues with text size calculation and message boxes.
First, size calculations for multi-line, character-breaking strings with no prespecified width were returning useless values, and when given pathological input, could take extremely long time.
Second, the flag calculations for text layout were a bit odd. For example, we wouldn't add an ending ellipsis on elided text if it was multi-line, and we wouldn't add an ellipsis on a clipped word if character breaking was off. Fixed these and reordered the calculations to match the order in which the header declares the flags.
Third, message boxes shouldn't need to trim their inputs, or add an ellipsis character, as both of these should now be handled safely by the underlying code.
BUG=34721
TEST=alert("AAAAA") for strings of As that are, say, 4000 characters long should not cause the UI to hang up for noticeable lengths of time
Review URL: http://codereview.chromium.org/810003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/message_box_handler.cc')
-rw-r--r-- | chrome/browser/message_box_handler.cc | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/chrome/browser/message_box_handler.cc b/chrome/browser/message_box_handler.cc index 280472b..0f5b63c 100644 --- a/chrome/browser/message_box_handler.cc +++ b/chrome/browser/message_box_handler.cc @@ -17,20 +17,6 @@ #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" -namespace { - -const size_t kMaxReasonableTextLength = 2048; - -// In some platforms, the underlying processing of humongous strings takes too -// long and thus make the UI thread unresponsive. -std::wstring MakeTextSafe(const std::wstring& text) { - if (text.size() > kMaxReasonableTextLength) - return text.substr(0, kMaxReasonableTextLength) + L"\x2026"; - return text; -} - -} // namespace - void RunJavascriptMessageBox(JavaScriptMessageBoxClient* client, const GURL& frame_url, int dialog_flags, @@ -40,10 +26,9 @@ void RunJavascriptMessageBox(JavaScriptMessageBoxClient* client, IPC::Message* reply_msg) { std::wstring title = client->GetMessageBoxTitle(frame_url, (dialog_flags == MessageBoxFlags::kIsJavascriptAlert)); - Singleton<AppModalDialogQueue>()->AddDialog( - new JavaScriptAppModalDialog(client, title, dialog_flags, - MakeTextSafe(message_text), default_prompt_text, - display_suppress_checkbox, false, reply_msg)); + Singleton<AppModalDialogQueue>()->AddDialog(new JavaScriptAppModalDialog( + client, title, dialog_flags, message_text, default_prompt_text, + display_suppress_checkbox, false, reply_msg)); } void RunBeforeUnloadDialog(TabContents* tab_contents, @@ -54,8 +39,8 @@ void RunBeforeUnloadDialog(TabContents* tab_contents, l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); Singleton<AppModalDialogQueue>()->AddDialog(new JavaScriptAppModalDialog( tab_contents, l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE), - MessageBoxFlags::kIsJavascriptConfirm, MakeTextSafe(message_text), - std::wstring(), false, true, reply_msg)); + MessageBoxFlags::kIsJavascriptConfirm, message_text, std::wstring(), + false, true, reply_msg)); } void RunCookiePrompt(TabContents* tab_contents, |