зеркало из https://github.com/mozilla/gecko-dev.git
Bug 26288: Allow user to select system fonts in editor UI. r=Neil, sr=sspitzer, moa=brade
This commit is contained in:
Родитель
3057ba40d0
Коммит
a1b34287d3
|
@ -80,6 +80,7 @@ var gDefaultTextColor = "";
|
|||
var gDefaultBackgroundColor = "";
|
||||
var gCSSPrefListener;
|
||||
var gPrefs;
|
||||
var gLocalFonts = null;
|
||||
|
||||
var gLastFocusNode = null;
|
||||
var gLastFocusNodeWasSelected = false;
|
||||
|
@ -996,6 +997,8 @@ function EditorSetFontSize(size)
|
|||
|
||||
function initFontFaceMenu(menuPopup)
|
||||
{
|
||||
initLocalFontFaceMenu(menuPopup);
|
||||
|
||||
if (menuPopup)
|
||||
{
|
||||
var children = menuPopup.childNodes;
|
||||
|
@ -1023,10 +1026,18 @@ function initFontFaceMenu(menuPopup)
|
|||
{
|
||||
EditorGetTextProperty("font", "face", faceType, firstHas, anyHas, allHas);
|
||||
|
||||
// Check the item only if all of selection has the face...
|
||||
menuItem.setAttribute("checked", allHas.value);
|
||||
// ...but remember if ANY part of the selection has it
|
||||
// Remember if ANY part of the selection has the face
|
||||
fontWasFound |= anyHas.value;
|
||||
|
||||
// Check the menuitem only if all of selection has the face
|
||||
if (allHas.value)
|
||||
{
|
||||
menuItem.setAttribute("checked", "true");
|
||||
break;
|
||||
}
|
||||
|
||||
// in case none match, make sure we've cleared the checkmark
|
||||
menuItem.removeAttribute("checked");
|
||||
}
|
||||
}
|
||||
// Check the default item if no other item was checked
|
||||
|
@ -1035,6 +1046,36 @@ function initFontFaceMenu(menuPopup)
|
|||
}
|
||||
}
|
||||
|
||||
function initLocalFontFaceMenu(menuPopup)
|
||||
{
|
||||
if (!gLocalFonts)
|
||||
{
|
||||
// Build list of all local fonts once per editor
|
||||
try
|
||||
{
|
||||
var enumerator = Components.classes["@mozilla.org/gfx/fontenumerator;1"]
|
||||
.getService(Components.interfaces.nsIFontEnumerator);
|
||||
var localFontCount = { value: 0 }
|
||||
gLocalFonts = enumerator.EnumerateAllFonts(localFontCount);
|
||||
for (var i = 0; i < gLocalFonts.length; ++i)
|
||||
{
|
||||
if (gLocalFonts[i] != "")
|
||||
{
|
||||
var itemNode = document.createElementNS(XUL_NS, "menuitem");
|
||||
itemNode.setAttribute("label", gLocalFonts[i]);
|
||||
itemNode.setAttribute("value", gLocalFonts[i]);
|
||||
itemNode.setAttribute("type", "radio");
|
||||
itemNode.setAttribute("name", "2");
|
||||
itemNode.setAttribute("observes", "cmd_renderedHTMLEnabler");
|
||||
menuPopup.appendChild(itemNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function initFontSizeMenu(menuPopup)
|
||||
{
|
||||
if (menuPopup)
|
||||
|
|
|
@ -441,13 +441,16 @@
|
|||
<!-- Font face submenu -->
|
||||
<menu id="fontFaceMenu" label="&fontfaceMenu.label;" accesskey="&formatfontmenu.accesskey;"
|
||||
position="1">
|
||||
<menupopup oncommand="doStatefulCommand('cmd_fontFace', event.target.value)" onpopupshowing="initFontFaceMenu(this)">
|
||||
<menupopup oncommand="if (event.target.localName == 'menuitem') doStatefulCommand('cmd_fontFace', event.target.value);"
|
||||
onpopupshowing="initFontFaceMenu(this);">
|
||||
<menuitem label="&fontVarWidth.label;" accesskey="&fontvarwidth.accesskey;" value="" type="radio" name="1" observes="cmd_renderedHTMLEnabler"/>
|
||||
<menuitem label="&fontFixedWidth.label;" accesskey="&fontfixedwidth.accesskey;" value="tt" type="radio" name="1" observes="cmd_renderedHTMLEnabler"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&fontHelveticaFont.label;" accesskey="&fonthelvetica.accesskey;" value="Helvetica, Arial, sans-serif" type="radio" name="2" observes="cmd_renderedHTMLEnabler"/>
|
||||
<menuitem label="&fontTimes.label;" accesskey="&fonttimes.accesskey;" value="Times New Roman, Times, serif" type="radio" name="2" observes="cmd_renderedHTMLEnabler"/>
|
||||
<menuitem label="&fontCourier.label;" accesskey="&fontcourier.accesskey;" value="Courier New, Courier, monospace" type="radio" name="2" observes="cmd_renderedHTMLEnabler"/>
|
||||
<menuseparator/>
|
||||
<!-- Local font face items added here by initLocalFontFaceMenu() -->
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче