Bug 699356 - Show the URL of the page in the title of the View Source window. r=smaug.

This commit is contained in:
Henri Sivonen
2011-11-30 19:44:31 +02:00
parent ad196dc350
commit 72a4aefa74
9 changed files with 54 additions and 15 deletions

View File

@@ -56,6 +56,7 @@
#include "nsHtml5Highlighter.h"
#include "expat_config.h"
#include "expat.h"
#include "nsINestedURI.h"
using namespace mozilla;
@@ -291,6 +292,31 @@ nsHtml5StreamParser::Notify(const char* aCharset, nsDetectionConfident aConf)
return NS_OK;
}
void
nsHtml5StreamParser::SetViewSourceTitle(nsIURI* aURL)
{
if (aURL) {
nsCOMPtr<nsIURI> temp;
bool isViewSource;
aURL->SchemeIs("view-source", &isViewSource);
if (isViewSource) {
nsCOMPtr<nsINestedURI> nested = do_QueryInterface(aURL);
nested->GetInnerURI(getter_AddRefs(temp));
} else {
temp = aURL;
}
bool isData;
temp->SchemeIs("data", &isData);
if (isData) {
// Avoid showing potentially huge data: URLs. The three last bytes are
// UTF-8 for an ellipsis.
mViewSourceTitle.AssignLiteral("data:\xE2\x80\xA6");
} else {
temp->GetSpec(mViewSourceTitle);
}
}
}
nsresult
nsHtml5StreamParser::SetupDecodingAndWriteSniffingBufferAndCurrentSegment(const PRUint8* aFromSegment, // can be null
PRUint32 aCount,
@@ -880,8 +906,9 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
mStreamState = STREAM_BEING_READ;
if (mMode == VIEW_SOURCE_HTML || mMode == VIEW_SOURCE_XML) {
mTokenizer->StartViewSource();
mTokenizer->StartViewSource(NS_ConvertUTF8toUTF16(mViewSourceTitle));
}
// For View Source, the parser should run with scripts "enabled" if a normal
// load would have scripts enabled.
bool scriptingEnabled = mMode == LOAD_AS_DATA ?