зеркало из https://github.com/mozilla/gecko-dev.git
54726: Add link to W3C Validator
90550: Need to rewrite URLs for publishing and for save as 91388: Link checker, Work in progress (doesn't work yet) r=brade, sr=kin
This commit is contained in:
Родитель
d69a324328
Коммит
b2618d9ca4
|
@ -138,6 +138,7 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsITransferable.h"
|
||||
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
/* Define Class IDs */
|
||||
|
@ -4434,28 +4435,32 @@ nsEditorShell::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 *_retval)
|
|||
|
||||
/* end of table editing */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::GetLinkedObjects(nsISupportsArray **aObjectArray)
|
||||
{
|
||||
if (!aObjectArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (mEditorType == eHTMLTextEditorType)
|
||||
return mEditor->GetLinkedObjects(aObjectArray);
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::GetEmbeddedObjects(nsISupportsArray **aObjectArray)
|
||||
{
|
||||
if (!aObjectArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
|
||||
switch (mEditorType)
|
||||
if (mEditorType == eHTMLTextEditorType)
|
||||
{
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
result = mailEditor->GetEmbeddedObjects(aObjectArray);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
result = NS_NOINTERFACE;
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
return mailEditor->GetEmbeddedObjects(aObjectArray);
|
||||
}
|
||||
return result;
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -5054,8 +5059,6 @@ nsEditorShell::OnStateChange(nsIWebProgress *aProgress,
|
|||
PRInt32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
//
|
||||
// A Request has started...
|
||||
//
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "nsEditorEventListeners.h"
|
||||
#include "TypeInState.h"
|
||||
|
||||
#include "nsHTMLURIRefObject.h"
|
||||
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
@ -44,7 +46,6 @@
|
|||
#include "nsISelection.h"
|
||||
#include "nsISelectionPrivate.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
||||
#include "TransactionFactory.h"
|
||||
|
@ -3048,6 +3049,68 @@ NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAReadableString& aAttribute
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList)
|
||||
{
|
||||
if (!aNodeList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult res;
|
||||
|
||||
res = NS_NewISupportsArray(aNodeList);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (!*aNodeList) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIContentIterator> iter;
|
||||
res = nsComponentManager::CreateInstance(kCContentIteratorCID, nsnull,
|
||||
NS_GET_IID(nsIContentIterator),
|
||||
getter_AddRefs(iter));
|
||||
if (!iter) return NS_ERROR_NULL_POINTER;
|
||||
if ((NS_SUCCEEDED(res)))
|
||||
{
|
||||
// get the root content
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
nsEditor::GetDocument(getter_AddRefs(domdoc));
|
||||
if (!domdoc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc (do_QueryInterface(domdoc));
|
||||
if (!doc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
doc->GetRootContent(getter_AddRefs(rootContent));
|
||||
|
||||
iter->Init(rootContent);
|
||||
|
||||
// loop through the content iterator for each content node
|
||||
while (NS_ENUMERATOR_FALSE == iter->IsDone())
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(res))
|
||||
break;
|
||||
nsCOMPtr<nsIDOMNode> node (do_QueryInterface(content));
|
||||
if (node)
|
||||
{
|
||||
// Let nsURIRefObject make the hard decisions:
|
||||
nsCOMPtr<nsIURIRefObject> refObject;
|
||||
res = NS_NewHTMLURIRefObject(getter_AddRefs(refObject), node);
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsCOMPtr<nsISupports> isupp (do_QueryInterface(refObject));
|
||||
if (isupp)
|
||||
(*aNodeList)->AppendElement(isupp);
|
||||
}
|
||||
}
|
||||
iter->Next();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma mark -
|
||||
#pragma mark nsIEditorStyleSheets methods
|
||||
|
@ -3278,7 +3341,7 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
|
|||
(*aNodeList)->AppendElement(node);
|
||||
else if (tagName.EqualsWithConversion("a"))
|
||||
{
|
||||
// XXX Only include links if they're links to file: URLs
|
||||
// Only include links if they're links to file: URLs
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor (do_QueryInterface(content));
|
||||
if (anchor)
|
||||
{
|
||||
|
|
|
@ -156,6 +156,8 @@ public:
|
|||
|
||||
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
|
||||
|
||||
NS_IMETHOD GetLinkedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
/* ------------ nsIEditorIMESupport overrides -------------- */
|
||||
|
||||
NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
|
||||
|
@ -186,7 +188,6 @@ public:
|
|||
nsIDOMNode **aNodeInserted);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
|
||||
/* ------------ nsITableEditor methods -------------- */
|
||||
|
||||
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
|
||||
|
|
|
@ -138,6 +138,7 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsITransferable.h"
|
||||
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
/* Define Class IDs */
|
||||
|
@ -4434,28 +4435,32 @@ nsEditorShell::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 *_retval)
|
|||
|
||||
/* end of table editing */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::GetLinkedObjects(nsISupportsArray **aObjectArray)
|
||||
{
|
||||
if (!aObjectArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (mEditorType == eHTMLTextEditorType)
|
||||
return mEditor->GetLinkedObjects(aObjectArray);
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::GetEmbeddedObjects(nsISupportsArray **aObjectArray)
|
||||
{
|
||||
if (!aObjectArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
|
||||
switch (mEditorType)
|
||||
if (mEditorType == eHTMLTextEditorType)
|
||||
{
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
result = mailEditor->GetEmbeddedObjects(aObjectArray);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
result = NS_NOINTERFACE;
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor = do_QueryInterface(mEditor);
|
||||
if (mailEditor)
|
||||
return mailEditor->GetEmbeddedObjects(aObjectArray);
|
||||
}
|
||||
return result;
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -5054,8 +5059,6 @@ nsEditorShell::OnStateChange(nsIWebProgress *aProgress,
|
|||
PRInt32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
//
|
||||
// A Request has started...
|
||||
//
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIFile;
|
||||
interface nsISupportsArray;
|
||||
interface nsIDocumentStateListener;
|
||||
interface nsISelectionController;
|
||||
interface nsITransactionManager;
|
||||
|
@ -33,6 +32,7 @@ interface nsISelection;
|
|||
interface nsIDOMElement;
|
||||
interface nsIDOMNode;
|
||||
interface nsIEditor;
|
||||
interface nsISupportsArray;
|
||||
|
||||
[scriptable, uuid(9afff72b-ca9a-11d2-96c9-0060b0fb9956)]
|
||||
interface nsIEditorShell : nsISupports
|
||||
|
@ -501,6 +501,9 @@ interface nsIEditorShell : nsISupports
|
|||
/* Get list of embedded objects, e.g. for mail compose */
|
||||
nsISupportsArray GetEmbeddedObjects();
|
||||
|
||||
/* Get list of objects which refer to external URIs */
|
||||
nsISupportsArray GetLinkedObjects();
|
||||
|
||||
/* Formatting */
|
||||
void SetAttribute(in nsIDOMElement element, in wstring attr, in wstring value);
|
||||
void RemoveAttribute(in nsIDOMElement element, in wstring attr);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "domstubs.idl"
|
||||
#include "nsIAtom.idl"
|
||||
|
||||
interface nsISupportsArray;
|
||||
|
||||
%{C++
|
||||
#define NS_EDITOR_ELEMENT_NOT_FOUND \
|
||||
|
@ -405,5 +406,13 @@ interface nsIHTMLEditor : nsISupports
|
|||
// Don't use this method! It will go away after first release!
|
||||
void IgnoreSpuriousDragEvent(in boolean aIgnoreSpuriousDragEvent);
|
||||
|
||||
/**
|
||||
* Find all the nodes in the document which contain references
|
||||
* to outside URIs (e.g. a href, img src, script src, etc.)
|
||||
* The objects in the array will be type nsIURIRefObject.
|
||||
*
|
||||
* @return aNodeList the linked nodes found
|
||||
*/
|
||||
nsISupportsArray GetLinkedObjects();
|
||||
};
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "nsEditorEventListeners.h"
|
||||
#include "TypeInState.h"
|
||||
|
||||
#include "nsHTMLURIRefObject.h"
|
||||
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
@ -44,7 +46,6 @@
|
|||
#include "nsISelection.h"
|
||||
#include "nsISelectionPrivate.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
||||
#include "TransactionFactory.h"
|
||||
|
@ -3048,6 +3049,68 @@ NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAReadableString& aAttribute
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList)
|
||||
{
|
||||
if (!aNodeList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult res;
|
||||
|
||||
res = NS_NewISupportsArray(aNodeList);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (!*aNodeList) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIContentIterator> iter;
|
||||
res = nsComponentManager::CreateInstance(kCContentIteratorCID, nsnull,
|
||||
NS_GET_IID(nsIContentIterator),
|
||||
getter_AddRefs(iter));
|
||||
if (!iter) return NS_ERROR_NULL_POINTER;
|
||||
if ((NS_SUCCEEDED(res)))
|
||||
{
|
||||
// get the root content
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
nsEditor::GetDocument(getter_AddRefs(domdoc));
|
||||
if (!domdoc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc (do_QueryInterface(domdoc));
|
||||
if (!doc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
doc->GetRootContent(getter_AddRefs(rootContent));
|
||||
|
||||
iter->Init(rootContent);
|
||||
|
||||
// loop through the content iterator for each content node
|
||||
while (NS_ENUMERATOR_FALSE == iter->IsDone())
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(res))
|
||||
break;
|
||||
nsCOMPtr<nsIDOMNode> node (do_QueryInterface(content));
|
||||
if (node)
|
||||
{
|
||||
// Let nsURIRefObject make the hard decisions:
|
||||
nsCOMPtr<nsIURIRefObject> refObject;
|
||||
res = NS_NewHTMLURIRefObject(getter_AddRefs(refObject), node);
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsCOMPtr<nsISupports> isupp (do_QueryInterface(refObject));
|
||||
if (isupp)
|
||||
(*aNodeList)->AppendElement(isupp);
|
||||
}
|
||||
}
|
||||
iter->Next();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma mark -
|
||||
#pragma mark nsIEditorStyleSheets methods
|
||||
|
@ -3278,7 +3341,7 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
|
|||
(*aNodeList)->AppendElement(node);
|
||||
else if (tagName.EqualsWithConversion("a"))
|
||||
{
|
||||
// XXX Only include links if they're links to file: URLs
|
||||
// Only include links if they're links to file: URLs
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor (do_QueryInterface(content));
|
||||
if (anchor)
|
||||
{
|
||||
|
|
|
@ -156,6 +156,8 @@ public:
|
|||
|
||||
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
|
||||
|
||||
NS_IMETHOD GetLinkedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
/* ------------ nsIEditorIMESupport overrides -------------- */
|
||||
|
||||
NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
|
||||
|
@ -186,7 +188,6 @@ public:
|
|||
nsIDOMNode **aNodeInserted);
|
||||
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
|
||||
/* ------------ nsITableEditor methods -------------- */
|
||||
|
||||
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
0xfdf23301, 0x4a94, 0x11d3, \
|
||||
{ 0x9c, 0xe4, 0x99, 0x60, 0x49, 0x6c, 0x41, 0xbc } }
|
||||
|
||||
class nsString;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMNode;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
class nsString;
|
||||
class nsStringArray;
|
||||
class nsSupportsArray;
|
||||
|
||||
class nsIAtom;
|
||||
class nsIDOMNode;
|
||||
|
@ -185,6 +186,15 @@ public:
|
|||
*/
|
||||
NS_IMETHOD SetDocumentTitle(const PRUnichar *aTitle)=0;
|
||||
|
||||
/**
|
||||
* Find all the nodes in the document which contain references
|
||||
* to outside URIs (e.g. a href, img src, script src, etc.)
|
||||
* The objects in the array will be type nsIURIRefObject.
|
||||
*
|
||||
* @return aNodeList the linked nodes found
|
||||
*/
|
||||
NS_IMETHOD GetLinkedObjects(nsISupportsArray** aNodeList)=0;
|
||||
|
||||
/* ------------ Selection manipulation -------------- */
|
||||
/* Should these be moved to nsISelection? */
|
||||
|
||||
|
|
|
@ -96,6 +96,8 @@ function SetupTextEditorCommands()
|
|||
controller.registerCommand("cmd_find", nsFindCommand);
|
||||
controller.registerCommand("cmd_findNext", nsFindNextCommand);
|
||||
controller.registerCommand("cmd_spelling", nsSpellingCommand);
|
||||
controller.registerCommand("cmd_validate", nsValidateCommand);
|
||||
controller.registerCommand("cmd_checkLinks", nsCheckLinksCommand);
|
||||
controller.registerCommand("cmd_insertChars", nsInsertCharsCommand);
|
||||
}
|
||||
|
||||
|
@ -618,6 +620,157 @@ var nsSpellingCommand =
|
|||
}
|
||||
};
|
||||
|
||||
// Validate using http://validator.w3.org/file-upload.html
|
||||
var URL2Validate;
|
||||
var nsValidateCommand =
|
||||
{
|
||||
isCommandEnabled: function(aCommand, dummy)
|
||||
{
|
||||
return (window.editorShell != null);
|
||||
},
|
||||
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
// If the document hasn't been modified,
|
||||
// then just validate the current url.
|
||||
if (editorShell.documentModified || gHTMLSourceChanged)
|
||||
{
|
||||
if (!CheckAndSaveDocument(window.editorShell.GetString("BeforeValidate"),
|
||||
false))
|
||||
return;
|
||||
|
||||
// Check if we saved again just in case?
|
||||
if (!DocumentHasBeenSaved()) // user hit cancel?
|
||||
return;
|
||||
}
|
||||
|
||||
URL2Validate = window.editorShell.editorDocument.location;
|
||||
// XXX This should use SchemeIs instead of comparing against file:
|
||||
if (URL2Validate.toString().indexOf("file://") >= 0)
|
||||
{
|
||||
URL2Validate = window.editorShell.editorDocument.location.pathname;
|
||||
var vwin = window.open("http://validator.w3.org/file-upload.html",
|
||||
"EditorValidate");
|
||||
// Window loads asynchronously, so pass control to the load listener:
|
||||
vwin.addEventListener("load", this.validateFilePageLoaded, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var vwin = window.open("http://validator.w3.org/",
|
||||
"EditorValidate");
|
||||
// Window loads asynchronously, so pass control to the load listener:
|
||||
vwin.addEventListener("load", this.validateWebPageLoaded, false);
|
||||
}
|
||||
},
|
||||
validateFilePageLoaded: function(event)
|
||||
{
|
||||
event.target.forms[0].uploaded_file.value = URL2Validate;
|
||||
},
|
||||
validateWebPageLoaded: function(event)
|
||||
{
|
||||
event.target.forms[0].uri.value = URL2Validate;
|
||||
}
|
||||
};
|
||||
|
||||
// Link checking.
|
||||
// XXX THIS CODE IS WORK IN PROGRESS (only exposed in the debug menu).
|
||||
|
||||
const kIOSERVICE_CONTRACTID = "@mozilla.org/network/io-service;1";
|
||||
const nsIIOService = Components.interfaces['nsIIOService'];
|
||||
|
||||
var nsLinkChecker =
|
||||
{
|
||||
uri : null,
|
||||
linkCheckDone : true,
|
||||
ios : Components.classes[kIOSERVICE_CONTRACTID].getService(nsIIOService),
|
||||
linkCheckURI : "",
|
||||
|
||||
LoadFromURI: function(aURI, ioService) {
|
||||
this.done = false;
|
||||
this.uri = aURI;
|
||||
dump("LoadFromURI(" + this.uri + ")\n");
|
||||
var theURI = this.ios.newURI(this.uri, null);
|
||||
//pacURL = uri.spec;
|
||||
|
||||
var channel = this.ios.newChannelFromURI(theURI);
|
||||
// Don't load for cache, that would be cheating:
|
||||
//channel.loadFlags |= nsIRequest::LOAD_BYPASS_CACHE;
|
||||
try {
|
||||
var httpChannel = channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
if (httpChannel) {
|
||||
httpChannel.requestMethod = "HEAD";
|
||||
}
|
||||
} catch(e) { }
|
||||
try {
|
||||
channel.asyncOpen(this, null);
|
||||
}
|
||||
catch (ex) {
|
||||
dump("asyncOpen failed for " + this.uri + "\n");
|
||||
}
|
||||
},
|
||||
|
||||
// nsIStreamListener interface
|
||||
onStartRequest: function(request, ctxt) {
|
||||
dump("onStartRequest(" + this.uri + ", status = " + request.status
|
||||
+ ")\n");
|
||||
try {
|
||||
var httpChannel = request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
if (httpChannel) {
|
||||
var stat = httpChannel.responseStatus/100;
|
||||
dump("Response status was " + stat + "\n");
|
||||
}
|
||||
} catch(e) { }
|
||||
// Probably don't actually need this stream if we're not going to read:
|
||||
this.sis =
|
||||
Components.Constructor('@mozilla.org/scriptableinputstream;1',
|
||||
'nsIScriptableInputStream',
|
||||
'init');
|
||||
throw(Components.results.NS_ERROR_FAILURE);
|
||||
},
|
||||
|
||||
onStopRequest: function(request, ctxt, status, errorMsg) {
|
||||
dump("onStopRequest(" + this.uri + ", status = " + status + ")\n");
|
||||
this.done = true;
|
||||
},
|
||||
|
||||
onDataAvailable: function(request, ctxt, inStream, sourceOffset, count) {
|
||||
dump("onDataAvailable(" + this.uri + ")\n");
|
||||
var ins = new this.sis(inStream);
|
||||
pac += ins.read(count);
|
||||
|
||||
// Now check the error code and cancel the request.
|
||||
// This should pass NS_BINDING_ABORTED, according to nsIRequest.idl,
|
||||
// but it doesn't seem to be available from JS.
|
||||
// ((nsresult) (((PRUint32)(NS_ERROR_SEVERITY_ERROR)<<31) | ((PRUint32)(module+
|
||||
// NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))
|
||||
//request.cancel(0x80000001);
|
||||
}
|
||||
};
|
||||
|
||||
var nsCheckLinksCommand =
|
||||
{
|
||||
isCommandEnabled: function(aCommand, dummy)
|
||||
{
|
||||
return (window.editorShell != null);
|
||||
},
|
||||
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
objects = window.editorShell.GetLinkedObjects();
|
||||
// Objects is an nsISupportsArray.
|
||||
var uri;
|
||||
dump("Checking links in " + objects.Count() + " items ...\n");
|
||||
for (var i = 0; i < objects.Count(); ++i)
|
||||
{
|
||||
var refobj = objects.GetElementAt(i).QueryInterface(Components.interfaces.nsIURIRefObject);
|
||||
uri = refobj.GetNextURI();
|
||||
dump(i + ": '" + uri + "'\n");
|
||||
}
|
||||
// Check only the last link, for now:
|
||||
nsLinkChecker.LoadFromURI(uri);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
var nsImageCommand =
|
||||
{
|
||||
|
@ -1458,7 +1611,6 @@ var nsTableOrCellColorCommand =
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
var nsPreferencesCommand =
|
||||
{
|
||||
|
|
|
@ -25,12 +25,6 @@
|
|||
// --------------------------- Output ---------------------------
|
||||
|
||||
|
||||
function EditorSerialize()
|
||||
{
|
||||
var s = new XMLSerializer();
|
||||
dump(s.serializeToString(editorShell.editorDocument) + "\n");
|
||||
}
|
||||
|
||||
function EditorGetText()
|
||||
{
|
||||
if (editorShell) {
|
||||
|
@ -74,7 +68,9 @@ function EditorTestSelection()
|
|||
|
||||
dump("Selection contains:\n");
|
||||
// 3rd param = column to wrap
|
||||
dump(selection.toString("text/plain", gOutputFormatted & gOutputSelectionOnly, 0) + "\n");
|
||||
dump(selection.toStringWithFormat("text/plain",
|
||||
gOutputFormatted & gOutputSelectionOnly,
|
||||
0) + "\n");
|
||||
|
||||
var output;
|
||||
|
||||
|
@ -346,45 +342,6 @@ function EditorRunLog()
|
|||
window._content.focus();
|
||||
}
|
||||
|
||||
function EditorTableize()
|
||||
{
|
||||
// 1 = OutputSelectionOnly, 1024 = OutputLFLineBreak
|
||||
// 256 = OutputEncodeEntities
|
||||
var str = editorShell.GetContentsAs("text/html", 1+1024);
|
||||
var newstr;
|
||||
|
||||
//dump("String to tableize is '" + str + "'\n");
|
||||
|
||||
// Replace nbsp with spaces:
|
||||
newstr = str.replace(/\u00a0/g, " ");
|
||||
|
||||
// Trim trailing <p> or <br>
|
||||
str = newstr.replace(/\s*<br>\s*$/, "");
|
||||
newstr = str.replace(/\s*<p>\s*$/, "");
|
||||
|
||||
// Trim leading and trailing spaces
|
||||
str = newstr.replace(/^\s+/, "");
|
||||
newstr = str.replace(/\s+$/, "");
|
||||
// Trim whitespace adjacent to <p> and <br> tags
|
||||
str = newstr.replace(/\s+<p>\s+/g, "<br>");
|
||||
newstr = str.replace(/\s+<br>\s+/g, "<br>");
|
||||
|
||||
// Put <td> wherever we see whitespace
|
||||
str = newstr.replace(/ +/g, " <td>");
|
||||
|
||||
// End table row and start another for each br or p
|
||||
newstr = str.replace(/\s*<br>\s*/g, "</tr>\n<tr><td>");
|
||||
|
||||
// Add the table tags and the opening and closing tr/td tags
|
||||
str = "<table border=\"1\">\n<tr><td>" + newstr + "</tr>\n</table>\n";
|
||||
|
||||
//dump("Trying to insert '" + str + "'\n");
|
||||
|
||||
window.editorShell.InsertSource(str);
|
||||
|
||||
window._content.focus();
|
||||
}
|
||||
|
||||
// --------------------------- TransactionManager ---------------------------
|
||||
|
||||
|
||||
|
|
|
@ -156,6 +156,8 @@
|
|||
<command id="cmd_find" oncommand="goDoCommand('cmd_find')"/>
|
||||
<command id="cmd_findNext" oncommand="goDoCommand('cmd_findNext')" label="&findAgainCmd.label;"/>
|
||||
<command id="cmd_spelling" oncommand="goDoCommand('cmd_spelling')"/>
|
||||
<command id="cmd_validate" oncommand="goDoCommand('cmd_validate')"/>
|
||||
<command id="cmd_checkLinks" oncommand="goDoCommand('cmd_checkLinks')"/>
|
||||
<command id="cmd_pasteQuote" oncommand="goDoCommand('cmd_pasteQuote')" label="&pasteAsQuotationCmd.label;"/>
|
||||
|
||||
</commandset>
|
||||
|
@ -338,6 +340,8 @@
|
|||
<menuitem id="menu_findnext" accesskey="&editfindnext.accesskey;" key="findnextkb" observes="cmd_findNext"/>
|
||||
<menuseparator id="sep_checkspelling" class="hide-in-IM" />
|
||||
<menuitem id="menu_checkspelling" accesskey="&editcheckspelling.accesskey;" key="checkspellingkb" observes="cmd_spelling" label="&checkSpellingCmd.label;"/>
|
||||
<menuitem id="menu_validate" observes="cmd_validate"
|
||||
label="&validateCmd.label;"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_preferences" observes="cmd_preferences"/>
|
||||
</menupopup>
|
||||
|
@ -812,8 +816,6 @@
|
|||
oncommand="EditorGetText()"/>
|
||||
<menuitem label="&outputHTMLCmd.label;"
|
||||
oncommand="EditorGetHTML()"/>
|
||||
<menuitem label="Dom Serializer"
|
||||
oncommand="EditorSerialize()"/>
|
||||
<menuseparator />
|
||||
<menuitem label="&pasteAsQuotationCmd.label;"
|
||||
accesskey="&editpastequotation.accesskey;"
|
||||
|
@ -824,8 +826,8 @@
|
|||
oncommand="editorShell.StripCites()"/>
|
||||
<menuitem label="&insertTextCmd.label;"
|
||||
oncommand="EditorInsertText('All good things come to those who wait. ')"/>
|
||||
<menuitem label="Tableize"
|
||||
oncommand="EditorTableize()"/>
|
||||
<menuitem id="menu_checkLinks" observes="cmd_checkLinks"
|
||||
label="&checkLinksCmd.label;"/>
|
||||
<menuseparator />
|
||||
<menuitem label="&testSelectionCmd.label;"
|
||||
oncommand="EditorTestSelection()"/>
|
||||
|
|
|
@ -45,6 +45,7 @@ TextFiles=Text Files
|
|||
AllFiles=All Files
|
||||
BeforeClosing=before closing
|
||||
BeforePreview=before viewing in Navigator
|
||||
BeforeValidate=before validating the document
|
||||
# LOCALIZATION NOTE (SaveFilePrompt): Don't translate %title% and %reason% (this is the reason for asking user to close, such as "before closing")
|
||||
SaveFilePrompt=Save changes to "%title%" %reason%?
|
||||
SaveFileFailed=Saving file failed!
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
<!ENTITY editfindnext.accesskey "n">
|
||||
<!ENTITY editfindnext.keybinding "g">
|
||||
<!ENTITY checkSpellingCmd.label "Check Spelling">
|
||||
<!ENTITY validateCmd.label "Validate HTML">
|
||||
<!ENTITY checkLinksCmd.label "Check Links">
|
||||
<!ENTITY editcheckspelling.accesskey "s">
|
||||
<!ENTITY editcheckspelling.keybinding "k">
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче