|
右键菜单:
---粘贴 : 有表格,但border=0
cmd_pastensEditorController.cpp
NS_REGISTER_ONE_COMMAND(nsPasteCommand, "cmd_paste");
nsEditorCommands.cpp
nsPasteCommand:: DoCommand(const char *aCommandName, nsISupports *aCommandRefCon)
{
return editor-> Paste(nsIClipboard::kGlobalClipboard);
}
nsHTMLDataTransfer.cpp
NS_IMETHODIMP nsHTMLEditor:: Paste(int32_t aSelectionType)
return InsertFromTransferable(trans, nullptr, contextStr, infoStr,
nullptr, 0, true);
}InsertFromTransferable(....)
{
nsXPIDLString cfcontext, cffragment, cfselection; // cfselection left emtpy for now
rv = ParseCFHTML(cfhtml, getter_Copies(cffragment), getter_Copies(cfcontext)); //cfcontext这里面修改解析后的内容让border=1
//ParseCFHTML解析完后,cfcontext含有<table border=0 cellpadding=0 cellspacing=0 width=216 style='border-collapse: 等table信息,即 border=0
//cffragment 只含有相关列信息 <col width=72 span=3 style='width:54pt'> 等
rv = DoInsertHTMLWithContext(cffragment,
cfcontext, cfselection, flavor,
}
nsHTMLEditor:: DoInsertHTMLWithContext(const nsAString & aInputString,
const nsAString & aContextStr,
{
nsresult rv = CreateDOMFragmentFromPaste(aInputString, aContextStr, aInfoStr,
}
nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(const nsAString &aInputString,
const nsAString & aContextStr,
{
if (!aContextStr.IsEmpty())
{
rv = ParseFragment(aContextStr, nullptr, doc, address_of(contextAsNode),
aTrustedInput);
}
/************
table相关
rv = ParseFragment(aContextStr, nullptr, doc, address_of(contextAsNode),
aTrustedInput);
nsContentUtils:: ParseFragmentHTML(aFragStr,
/mozilla/content/base/src/nsContentUtils.cpp
nsContentUtils:: ParseFragmentHTML(const nsAString& aSourceBuffer,
{ sHTMLFragmentParser = new nsHtml5StringParser()
nsresult rv =
sHTMLFragmentParser->ParseFragment(aSourceBuffer,
aTargetNode,
aContextLocalName,
aContextNamespace,
aQuirks,
aPreventScriptExecution);
}
mozilla/parser/html/nsHtml5Parser.cpp
nsHtml5Parser::ParseFragment(const nsAString& aSourceBuffer, nsTArray<nsString>& aTagStack) { return NS_ERROR_NOT_IMPLEMENTED; }
************************/
---粘贴为无格式文本 无表格
cmd_pasteNoFormatting
nsComposerController.cpp
NS_REGISTER_ONE_COMMAND(nsPasteNoFormattingCommand, "cmd_pasteNoFormatting");
/mozilla/editor/composer/src/nsComposerCommands.cppnsPasteNoFormattingCommand:: DoCommand(const char *aCommandName,
{
return htmlEditor->PasteNoFormatting(nsIClipboard::kGlobalClipboard);
}
nsHTMLDataTransfer.cpp
NS_IMETHODIMP nsHTMLEditor:: PasteNoFormatting(int32_t aSelectionType)
{ rv = InsertFromTransferable(trans, nullptr, empty, empty, nullptr, 0,
true);
}
---粘贴为引文 有表格,但增加type=cite模式,即只有鼠标移上去时,才会显示边框
cmd_pasteQuote
nsEditorController.cpp
NS_REGISTER_ONE_COMMAND(nsPasteQuotationCommand, "cmd_pasteQuote");
nsEditorCommands.cpp
nsPasteQuotationCommand:: DoCommand(const char *aCommandName,
{
return mailEditor-> PasteAsQuotation(nsIClipboard::kGlobalClipboard);
}
nsHTMLDataTransfer.cpp
NS_IMETHODIMP nsHTMLEditor:: PasteAsQuotation(int32_t aSelectionType)
{
return PasteAsCitedQuotation(citation, aSelectionType);
}
NS_IMETHODIMP nsHTMLEditor:: PasteAsCitedQuotation(const nsAString & aCitation,
int32_t aSelectionType)
{
newElement->SetAttribute(NS_LITERAL_STRING("type"), NS_LITERAL_STRING("cite"));
return Paste(aSelectionType);
}
|
|