From e5358e41fc147d89446ff394f72bf266b1498feb Mon Sep 17 00:00:00 2001 From: "jbetak%netscape.com" Date: Tue, 23 May 2000 23:09:25 +0000 Subject: [PATCH] 36136 [regression]View source with meta charset info does not display properly r=ftang git-svn-id: svn://10.0.0.236/trunk@70690 18797224-902f-48f8-a5cc-f745e15eee43 --- .../browser/resources/content/navigator.js | 64 +++++++++++-------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/mozilla/xpfe/browser/resources/content/navigator.js b/mozilla/xpfe/browser/resources/content/navigator.js index 27948df50c6..aa54a05361f 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/xpfe/browser/resources/content/navigator.js @@ -1151,39 +1151,49 @@ function BrowserEditBookmarks() function BrowserViewSource() { dump("BrowserViewSource(); \n "); - var charsetArg = new String(); - - if (appCore != null) { - - try - { - //let's try to extract the current charset menu setting - var DocCharset = appCore.GetDocumentCharset(); - charsetArg = "charset="+DocCharset; - dump("*** Current document charset: " + DocCharset + "\n"); + var docCharset = null; - //we should "inherit" the charset menu setting in a new window - window.openDialog( "chrome://navigator/content/viewSource.xul", - "_blank", - "chrome,dialog=no", - window.content.location, charsetArg); - } - - catch(ex) - { - dump("*** failed to read document charset \n"); - } + try + { + var wnd = document.commandDispatcher.focusedWindow; + if (window == wnd) wnd = window.content; + docCharset = "charset="+ wnd.document.characterSet; + dump("*** Current document charset: " + docCharset + "\n"); + } + + catch(ex) + { + docCharset = null; + dump("*** Failed to determine current document charset \n"); + } + + + if (docCharset != null) + { + try + { + //now try to open a view-source window while inheriting the charset + window.openDialog( "chrome://navigator/content/viewSource.xul", + "_blank", + "chrome,dialog=no", + window.content.location, docCharset); + } + + catch(ex) + { + dump("*** Failed to open view-source window with preset charset menu.\n"); + } } else { - //if everythig else fails, forget about the charset - window.openDialog( "chrome://navigator/content/viewSource.xul", - "_blank", - "chrome,dialog=no", - window.content.location); + //default: forcing the view-source widow + dump("*** Failed to preset charset menu for the view-source window\n"); + window.openDialog( "chrome://navigator/content/viewSource.xul", + "_blank", + "chrome,dialog=no", + window.content.location); } } - function BrowserPageInfo() { dump("BrowserPageInfo(); \n ");