diff --git a/mozilla/editor/composer/src/nsComposerCommands.cpp b/mozilla/editor/composer/src/nsComposerCommands.cpp index bc5dd07550a..71412e30ab8 100644 --- a/mozilla/editor/composer/src/nsComposerCommands.cpp +++ b/mozilla/editor/composer/src/nsComposerCommands.cpp @@ -361,7 +361,7 @@ nsListCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagName) if (inList) rv = aEditorShell->RemoveList(listType.get()); else - rv = aEditorShell->MakeOrChangeList(listType.get(), PR_FALSE); + rv = aEditorShell->MakeOrChangeList(listType.get(), PR_FALSE, nsnull); return rv; } diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index effea4692f4..e39a38fce65 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -2841,14 +2841,19 @@ nsEditorShell::DoAfterSave(PRBool aShouldUpdateURL, const PRUnichar *aURLString) } NS_IMETHODIMP -nsEditorShell::MakeOrChangeList(const PRUnichar *listType, PRBool entireList) +nsEditorShell::MakeOrChangeList(const PRUnichar *listType, PRBool entireList, + const PRUnichar *bulletType) { nsresult err = NS_NOINTERFACE; if (!mEditor) return NS_ERROR_NOT_INITIALIZED; nsAutoString aListType(listType); - + nsAutoString aBulletType; + if (bulletType) { + aBulletType.Assign(bulletType); + } + switch (mEditorType) { case eHTMLTextEditorType: @@ -2863,7 +2868,7 @@ nsEditorShell::MakeOrChangeList(const PRUnichar *listType, PRBool entireList) } } else - err = mEditor->MakeOrChangeList(aListType, entireList); + err = mEditor->MakeOrChangeList(aListType, entireList, aBulletType); break; case ePlainTextEditorType: diff --git a/mozilla/editor/idl/nsIEditorShell.idl b/mozilla/editor/idl/nsIEditorShell.idl index 73b56c290f2..936631ee8ab 100644 --- a/mozilla/editor/idl/nsIEditorShell.idl +++ b/mozilla/editor/idl/nsIEditorShell.idl @@ -181,7 +181,7 @@ interface nsIEditorShell : nsISupports void InsertBreak(); - void MakeOrChangeList(in wstring listType, in PRBool entireList); + void MakeOrChangeList(in wstring listType, in PRBool entireList, in wstring bulletType); void RemoveList(in wstring listType); void Indent(in wstring indent); void Align(in wstring align); diff --git a/mozilla/editor/idl/nsIHTMLEditor.idl b/mozilla/editor/idl/nsIHTMLEditor.idl index bdf06492e98..d47faae9e82 100644 --- a/mozilla/editor/idl/nsIHTMLEditor.idl +++ b/mozilla/editor/idl/nsIHTMLEditor.idl @@ -312,7 +312,7 @@ interface nsIHTMLEditor : nsISupports * Document me! * */ - void MakeOrChangeList(in DOMString aListType, in boolean entireList); + void MakeOrChangeList(in DOMString aListType, in boolean entireList, in DOMString aBulletType); /** * Document me! diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp index 7e78fbee39b..9b26335811c 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp @@ -490,7 +490,7 @@ nsHTMLEditRules::WillDoAction(nsISelection *aSelection, case kDeleteSelection: return WillDeleteSelection(aSelection, info->collapsedAction, aCancel, aHandled); case kMakeList: - return WillMakeList(aSelection, info->blockType, info->entireList, aCancel, aHandled); + return WillMakeList(aSelection, info->blockType, info->entireList, info->bulletType, aCancel, aHandled); case kIndent: return WillIndent(aSelection, aCancel, aHandled); case kOutdent: @@ -2349,6 +2349,7 @@ nsresult nsHTMLEditRules::WillMakeList(nsISelection *aSelection, const nsAReadableString *aListType, PRBool aEntireList, + const nsAReadableString *aBulletType, PRBool *aCancel, PRBool *aHandled, const nsAReadableString *aItemType) @@ -2572,6 +2573,14 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection, if (NS_FAILED(res)) return res; } } + nsCOMPtr curElement = do_QueryInterface(curNode); + if (aBulletType && !aBulletType->IsEmpty()) { + res = mHTMLEditor->SetAttribute(curElement, NS_ConvertASCIItoUCS2("type"), *aBulletType); + } + else { + res = mHTMLEditor->RemoveAttribute(curElement, NS_LITERAL_STRING("type")); + } + if (NS_FAILED(res)) return res; continue; } @@ -2711,7 +2720,7 @@ nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, { // for now we let WillMakeList handle this nsAutoString listType(NS_LITERAL_STRING("dl")); - return WillMakeList(aSelection, &listType, aEntireList, aCancel, aHandled, aItemType); + return WillMakeList(aSelection, &listType, aEntireList, nsnull, aCancel, aHandled, aItemType); } nsresult diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.h b/mozilla/editor/libeditor/html/nsHTMLEditRules.h index 674d258cfa8..98c16a60380 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditRules.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.h @@ -135,7 +135,7 @@ protected: nsresult MoveNodeSmart(nsIDOMNode *aSource, nsIDOMNode *aDest, PRInt32 *aOffset); nsresult MoveContents(nsIDOMNode *aSource, nsIDOMNode *aDest, PRInt32 *aOffset); nsresult DeleteNonTableElements(nsIDOMNode *aNode); - nsresult WillMakeList(nsISelection *aSelection, const nsAReadableString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsAReadableString *aItemType=nsnull); + nsresult WillMakeList(nsISelection *aSelection, const nsAReadableString *aListType, PRBool aEntireList, const nsAReadableString *aBulletType, PRBool *aCancel, PRBool *aHandled, const nsAReadableString *aItemType=nsnull); nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled); nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 2291d4b7442..c29fa3bfa36 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -2196,7 +2196,7 @@ nsHTMLEditor::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent) } NS_IMETHODIMP -nsHTMLEditor::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList) +nsHTMLEditor::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList, const nsAReadableString& aBulletType) { nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } @@ -2215,6 +2215,7 @@ nsHTMLEditor::MakeOrChangeList(const nsAReadableString& aListType, PRBool entire nsTextRulesInfo ruleInfo(nsTextEditRules::kMakeList); ruleInfo.blockType = &aListType; ruleInfo.entireList = entireList; + ruleInfo.bulletType = &aBulletType; res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (cancel || (NS_FAILED(res))) return res; diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.h b/mozilla/editor/libeditor/html/nsHTMLEditor.h index 81a50ff4d37..bc187976435 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.h @@ -163,7 +163,7 @@ public: NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign); NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent); - NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList); + NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList, const nsAReadableString& aBulletType); NS_IMETHOD RemoveList(const nsAReadableString& aListType); NS_IMETHOD Indent(const nsAReadableString& aIndent); NS_IMETHOD Align(const nsAReadableString& aAlign); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp b/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp index a376c1edc81..86091732e9a 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp @@ -660,7 +660,7 @@ nsHTMLEditorLog::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMEle } NS_IMETHODIMP -nsHTMLEditorLog::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList) +nsHTMLEditorLog::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList, const nsAReadableString& aBulletType) { nsAutoHTMLEditorLogLock logLock(this); @@ -674,7 +674,7 @@ nsHTMLEditorLog::MakeOrChangeList(const nsAReadableString& aListType, PRBool ent Flush(); } - return nsHTMLEditor::MakeOrChangeList(aListType, entireList); + return nsHTMLEditor::MakeOrChangeList(aListType, entireList, aBulletType); } NS_IMETHODIMP diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorLog.h b/mozilla/editor/libeditor/html/nsHTMLEditorLog.h index 575f6de94a8..9c84b71e71a 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditorLog.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditorLog.h @@ -103,7 +103,7 @@ public: NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor); NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue); - NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList); + NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList, const nsAReadableString& aBulletType); NS_IMETHOD Indent(const nsAReadableString& aIndent); NS_IMETHOD Align(const nsAReadableString& aAlign); NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection); diff --git a/mozilla/editor/libeditor/text/nsTextEditRules.h b/mozilla/editor/libeditor/text/nsTextEditRules.h index f739466810c..730b19e217f 100644 --- a/mozilla/editor/libeditor/text/nsTextEditRules.h +++ b/mozilla/editor/libeditor/text/nsTextEditRules.h @@ -224,6 +224,7 @@ class nsTextRulesInfo : public nsRulesInfo collapsedAction(nsIEditor::eNext), bOrdered(PR_FALSE), entireList(PR_FALSE), + bulletType(0), alignType(0), blockType(0), insertElement(0) @@ -243,6 +244,7 @@ class nsTextRulesInfo : public nsRulesInfo // kMakeList PRBool bOrdered; PRBool entireList; + const nsAReadableString *bulletType; // kAlign const nsAReadableString *alignType; diff --git a/mozilla/editor/ui/composer/content/editorUtilities.js b/mozilla/editor/ui/composer/content/editorUtilities.js index 137e9c80e4f..30dc2b28a02 100644 --- a/mozilla/editor/ui/composer/content/editorUtilities.js +++ b/mozilla/editor/ui/composer/content/editorUtilities.js @@ -202,13 +202,9 @@ function SetElementEnabled(element, doEnable) if ( element ) { if ( doEnable ) - { - element.removeAttribute( "disabled" ); - } + element.removeAttribute("disabled"); else - { - element.setAttribute( "disabled", "true" ); - } + element.setAttribute("disabled", "true"); } else { @@ -234,8 +230,9 @@ function GetIOService() if (gIOService) return gIOService; - var CID = Components.classes["@mozilla.org/network/io-service;1"]; - gIOService = CID.getService(Components.interfaces.nsIIOService); + gIOService = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + return gIOService; } @@ -354,6 +351,7 @@ function MakeRelativeUrl(url) if (docHost != urlHost) return inputUrl; + // Get just the file path part of the urls var docPath = IOService.extractUrlPart(docUrl, IOService.url_Path, {start:0}, {end:0}); var urlPath = IOService.extractUrlPart(inputUrl, IOService.url_Path, {start:0}, {end:0}); diff --git a/mozilla/editor/ui/dialogs/content/EdListProps.js b/mozilla/editor/ui/dialogs/content/EdListProps.js index 13c45951555..333af24a433 100644 --- a/mozilla/editor/ui/dialogs/content/EdListProps.js +++ b/mozilla/editor/ui/dialogs/content/EdListProps.js @@ -28,6 +28,8 @@ var ListElement; var originalListType = ""; var ListType = ""; var MixedListSelection = false; +var BulletStyleType = ""; +var originalBulletStyleType = ""; // dialog initialization code function Startup() @@ -130,6 +132,7 @@ function InitDialog() gDialog.StartingNumberInput.value = globalElement.getAttribute("start"); } gDialog.BulletStyleList.selectedIndex = index; + originalBulletStyleType = type; } function BuildBulletStyleList() @@ -197,7 +200,7 @@ function BuildBulletStyleList() gDialog.AdvancedEditButton.setAttribute("disabled","true"); if (label) - gDialog.BulletStyleLabel.setAttribute("value",label); + gDialog.BulletStyleLabel.setAttribute("label",label); } function SelectListType() @@ -270,7 +273,8 @@ function ValidateData() type = "square"; break; } - if (type) + BulletStyleType = type; + if (type && gDialog.ChangeAllRadio.selected) globalElement.setAttribute("type",type); else globalElement.removeAttribute("type"); @@ -297,7 +301,8 @@ function ValidateData() type = "a"; break; } - if (type) + BulletStyleType = type; + if (type && gDialog.ChangeAllRadio.selected) globalElement.setAttribute("type",type); else globalElement.removeAttribute("type"); @@ -330,11 +335,12 @@ function onAccept() changeList = true; } else - changeList = MixedListSelection || ListType != originalListType; + changeList = MixedListSelection || ListType != originalListType || BulletStyleType != originalBulletStyleType; if (changeList) { - editorShell.MakeOrChangeList(ListType, gDialog.ChangeAllRadio.selected); + editorShell.MakeOrChangeList(ListType, gDialog.ChangeAllRadio.selected, + (BulletStyleType != originalBulletStyleType) ? BulletStyleType : null); if (ListType) { diff --git a/mozilla/editor/ui/dialogs/content/EdListProps.xul b/mozilla/editor/ui/dialogs/content/EdListProps.xul index be7ecb1d2cf..c313068675e 100644 --- a/mozilla/editor/ui/dialogs/content/EdListProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdListProps.xul @@ -52,10 +52,6 @@ - - - - @@ -72,6 +68,10 @@ &startingHelp.label; + + + +