зеркало из https://github.com/mozilla/gecko-dev.git
Initial commit of alternate stylesheet support in Firebird.
This commit is contained in:
Родитель
6d9dfb41f4
Коммит
03a12c4259
|
@ -58,6 +58,7 @@ var gRDF = null;
|
|||
var gGlobalHistory = null;
|
||||
var gURIFixup = null;
|
||||
var gReportButton = null;
|
||||
var gPageThemeButton = null;
|
||||
var gCharsetMenu = null;
|
||||
var gLastBrowserCharset = null;
|
||||
var gPrevCharset = null;
|
||||
|
@ -123,6 +124,7 @@ function loadEventHandlers(event)
|
|||
UpdateBookmarksLastVisitedDate(event);
|
||||
checkForDirectoryListing();
|
||||
charsetLoadListener(event);
|
||||
updatePageTheme();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,7 +325,8 @@ function prepareForStartup()
|
|||
gNavigatorBundle = document.getElementById("bundle_browser");
|
||||
gProgressMeterPanel = document.getElementById("statusbar-progresspanel");
|
||||
gBrowser.addEventListener("DOMUpdatePageReport", UpdatePageReport, false);
|
||||
|
||||
gBrowser.addEventListener("DOMUpdatePageTheme", updatePageTheme, false);
|
||||
|
||||
var webNavigation;
|
||||
try {
|
||||
// Create the browser instance component.
|
||||
|
@ -4314,3 +4317,153 @@ function ShowWindowFromResource( node )
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Begin Page Theme Functions */
|
||||
function getStyleSheetArray(frame)
|
||||
{
|
||||
var styleSheets = frame.document.styleSheets;
|
||||
var styleSheetsArray = new Array(styleSheets.length);
|
||||
for (var i = 0; i < styleSheets.length; i++) {
|
||||
styleSheetsArray[i] = styleSheets[i];
|
||||
}
|
||||
return styleSheetsArray;
|
||||
}
|
||||
|
||||
function getAllStyleSheets(frameset)
|
||||
{
|
||||
var styleSheetsArray = getStyleSheetArray(frameset);
|
||||
for (var i = 0; i < frameset.frames.length; i++) {
|
||||
var frameSheets = getAllStyleSheets(frameset.frames[i]);
|
||||
styleSheetsArray = styleSheetsArray.concat(frameSheets);
|
||||
}
|
||||
return styleSheetsArray;
|
||||
}
|
||||
|
||||
function stylesheetFillPopup(menuPopup)
|
||||
{
|
||||
var plainStyle = menuPopup.firstChild;
|
||||
var normalStyle = plainStyle.nextSibling;
|
||||
var sep = normalStyle.nextSibling;
|
||||
while (sep.nextSibling)
|
||||
menuPopup.removeChild(sep.nextSibling);
|
||||
|
||||
var noOptionalStyles = true;
|
||||
var styleSheets = getAllStyleSheets(window._content);
|
||||
var currentStyleSheets = [];
|
||||
|
||||
var allDisabled = true;
|
||||
var haveAltSheets = false;
|
||||
var haveAnyNonAltSheets = false;
|
||||
|
||||
for (var i = 0; i < styleSheets.length; ++i) {
|
||||
var currentStyleSheet = styleSheets[i];
|
||||
|
||||
// Skip any stylesheets that don't match the screen media type.
|
||||
var media = currentStyleSheet.media.mediaText.toLowerCase();
|
||||
if (media && (media.indexOf("screen") == -1) && (media.indexOf("all") == -1))
|
||||
continue;
|
||||
|
||||
if (!currentStyleSheet.disabled)
|
||||
allDisabled = false;
|
||||
|
||||
if (currentStyleSheet.title) {
|
||||
if (!currentStyleSheet.disabled)
|
||||
noOptionalStyles = false;
|
||||
|
||||
haveAltSheets = true;
|
||||
|
||||
var lastWithSameTitle = null;
|
||||
if (currentStyleSheet.title in currentStyleSheets)
|
||||
lastWithSameTitle = currentStyleSheets[currentStyleSheet.title];
|
||||
|
||||
if (!lastWithSameTitle) {
|
||||
var menuItem = document.createElement("menuitem");
|
||||
menuItem.setAttribute("type", "radio");
|
||||
menuItem.setAttribute("label", currentStyleSheet.title);
|
||||
menuItem.setAttribute("data", currentStyleSheet.title);
|
||||
menuItem.setAttribute("checked", !currentStyleSheet.disabled);
|
||||
menuPopup.appendChild(menuItem);
|
||||
currentStyleSheets[currentStyleSheet.title] = menuItem;
|
||||
} else {
|
||||
if (currentStyleSheet.disabled)
|
||||
lastWithSameTitle.removeAttribute("checked");
|
||||
}
|
||||
}
|
||||
else
|
||||
haveAnyNonAltSheets = true;
|
||||
}
|
||||
|
||||
normalStyle.setAttribute("checked", noOptionalStyles && (!haveAnyNonAltSheets || !allDisabled));
|
||||
plainStyle.setAttribute("checked", allDisabled && haveAnyNonAltSheets);
|
||||
|
||||
plainStyle.hidden = !haveAnyNonAltSheets;
|
||||
sep.hidden = !haveAltSheets;
|
||||
}
|
||||
|
||||
function stylesheetInFrame(frame, title) {
|
||||
var docStyleSheets = frame.document.styleSheets;
|
||||
|
||||
for (var i = 0; i < docStyleSheets.length; ++i) {
|
||||
if (docStyleSheets[i].title == title)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function stylesheetSwitchFrame(frame, title) {
|
||||
var docStyleSheets = frame.document.styleSheets;
|
||||
|
||||
for (var i = 0; i < docStyleSheets.length; ++i) {
|
||||
var docStyleSheet = docStyleSheets[i];
|
||||
|
||||
if (title == "_nostyle")
|
||||
docStyleSheet.disabled = true;
|
||||
else if (docStyleSheet.title)
|
||||
docStyleSheet.disabled = (docStyleSheet.title != title);
|
||||
else if (docStyleSheet.disabled)
|
||||
docStyleSheet.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function stylesheetSwitchAll(frameset, title) {
|
||||
if (!title || title == "_nostyle" || stylesheetInFrame(frameset, title)) {
|
||||
stylesheetSwitchFrame(frameset, title);
|
||||
}
|
||||
for (var i = 0; i < frameset.frames.length; i++) {
|
||||
stylesheetSwitchAll(frameset.frames[i], title);
|
||||
}
|
||||
}
|
||||
|
||||
function updatePageTheme(evt)
|
||||
{
|
||||
if (!gPageThemeButton)
|
||||
gPageThemeButton = document.getElementById("page-theme-button");
|
||||
|
||||
var hasThemes = false;
|
||||
var stylesheets = window._content.document.styleSheets;
|
||||
for (var i = 0; i < stylesheets.length; ++i) {
|
||||
var currentStyleSheet = stylesheets[i];
|
||||
|
||||
if (currentStyleSheet.title) {
|
||||
// Skip any stylesheets that don't match the screen media type.
|
||||
var media = currentStyleSheet.media.mediaText.toLowerCase();
|
||||
if (media && (media.indexOf("screen") == -1) && (media.indexOf("all") == -1))
|
||||
continue;
|
||||
hasThemes = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasThemes) {
|
||||
gPageThemeButton.setAttribute("themes", "true");
|
||||
//if (gPrefService && gPrefService.getBoolPref("privacy.popups.firstTime")) {
|
||||
// displayPageReportFirstTime();
|
||||
|
||||
// Now set the pref.
|
||||
//gPrefService.setBoolPref("privacy.popups.firstTime", "false");
|
||||
// }
|
||||
}
|
||||
else
|
||||
gPageThemeButton.removeAttribute("themes");
|
||||
}
|
||||
/* End of the Page Theme functions */
|
||||
|
||||
|
|
|
@ -862,8 +862,10 @@
|
|||
<menu label="&toolsMenu.label;" accesskey="&toolsMenu.accesskey;">
|
||||
<menupopup id="menu_ToolsPopup">
|
||||
<menuitem id="javascriptConsole" label="&javaScriptConsoleCmd.label;" accesskey="&javaScriptConsoleCmd.accesskey;" oncommand="toJavaScriptConsole();"/>
|
||||
<menuitem accesskey="&pageInfoCmd.accesskey;" label="&pageInfoCmd.label;" key="key_viewInfo" command="View:PageInfo"/>
|
||||
<menuitem accesskey="&pageInfoCmd.accesskey;" label="&pageInfoCmd.label;" key="key_viewInfo" command="View:PageInfo"/>
|
||||
#ifndef XP_MACOSX
|
||||
<menuseparator id="prefSep"/>
|
||||
#endif
|
||||
<menuitem id="menu_preferences"
|
||||
label="&preferencesCmd.label;"
|
||||
accesskey="&preferencesCmd.accesskey;"
|
||||
|
@ -1151,7 +1153,16 @@
|
|||
<statusbarpanel id="security-button" class="statusbarpanel-iconic"
|
||||
onclick="displayPageInfo()"/>
|
||||
<statusbarpanel id="page-report-button" class="statusbarpanel-iconic"
|
||||
onclick="displayPageReport();"/>
|
||||
onclick="displayPageReport();"/>
|
||||
<statusbarpanel id="page-theme-button" type="menu" class="statusbarpanel-menu-iconic">
|
||||
<menupopup onpopupshowing="stylesheetFillPopup(this);"
|
||||
oncommand="stylesheetSwitchAll(window._content, event.target.getAttribute('data'));">
|
||||
<menuitem label="&pageThemeNoTheme.label;" accesskey="&pageThemeNoTheme.accesskey;" type="radio" data="_nostyle"/>
|
||||
<menuitem label="&pageThemePersistentOnly.label;" accesskey="&pageThemePersistentOnly.accesskey;" type="radio" checked="true"/>
|
||||
<menuseparator/>
|
||||
</menupopup>
|
||||
</statusbarpanel>
|
||||
|
||||
<statusbarpanel id="statusbar-display" flex="1"/>
|
||||
<statusbarpanel class="statusbarpanel-progress" collapsed="true" id="statusbar-progresspanel">
|
||||
<progressmeter class="progressmeter-statusbar" id="statusbar-icon" mode="normal" value="0"/>
|
||||
|
|
|
@ -40,6 +40,7 @@ classic.jar:
|
|||
skin/classic/browser/Toolbar.png (skin/Toolbar.png)
|
||||
skin/classic/browser/lock-insecure.gif (skin/lock-insecure.gif)
|
||||
skin/classic/browser/lock-mixed.gif (skin/lock-mixed.gif)
|
||||
skin/classic/browser/page-themes.png (skin/page-themes.png)
|
||||
|
||||
en-US.jar:
|
||||
locale/en-US/browser/contents.rdf (locale/contents.rdf)
|
||||
|
|
|
@ -288,3 +288,8 @@
|
|||
<!ENTITY bringAllToFront.label "Bring All to Front">
|
||||
<!ENTITY zoomWindow.label "Zoom Window">
|
||||
|
||||
<!ENTITY pageThemeButton.label "Page Themes">
|
||||
<!ENTITY pageThemeNoTheme.label "Plain">
|
||||
<!ENTITY pageThemeNoTheme.accesskey "p">
|
||||
<!ENTITY pageThemePersistentOnly.label "Normal">
|
||||
<!ENTITY pageThemePersistentOnly.accesskey "n">
|
||||
|
|
|
@ -687,6 +687,16 @@ statusbarpanel#statusbar-display {
|
|||
padding: 0px 3px 0px 3px;
|
||||
}
|
||||
|
||||
#page-theme-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#page-theme-button[themes] {
|
||||
display: -moz-box;
|
||||
list-style-image: url("chrome://browser/skin/page-themes.png");
|
||||
padding: 0px 3px 0px 3px;
|
||||
}
|
||||
|
||||
/* ::::: throbber ::::: */
|
||||
|
||||
#navigator-throbber {
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 1.1 KiB |
|
@ -241,6 +241,13 @@
|
|||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="statusbarpanel-menu-iconic" display="xul:menu" extends="chrome://global/content/widgets/general.xml#statusbarpanel">
|
||||
<content>
|
||||
<xul:image class="statusbarpanel-icon" xbl:inherits="src"/>
|
||||
<children/>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="statusbar">
|
||||
<content>
|
||||
<children/>
|
||||
|
|
|
@ -401,6 +401,10 @@
|
|||
if (updatePageReport)
|
||||
this.mCurrentBrowser.updatePageReport();
|
||||
|
||||
var event = document.createEvent("Events");
|
||||
event.initEvent("DOMUpdatePageTheme", true, true);
|
||||
this.dispatchEvent(event);
|
||||
|
||||
// Update the URL bar.
|
||||
var loc = this.mCurrentBrowser.currentURI;
|
||||
if (!loc)
|
||||
|
|
|
@ -813,15 +813,19 @@ autorepeatbutton {
|
|||
|
||||
statusbar
|
||||
{
|
||||
-moz-binding: url("chrome://global/content/bindings/general.xml#statusbar");
|
||||
-moz-binding: url("chrome://global/content/widgets/general.xml#statusbar");
|
||||
}
|
||||
|
||||
statusbarpanel {
|
||||
-moz-binding: url("chrome://global/content/bindings/general.xml#statusbarpanel");
|
||||
-moz-binding: url("chrome://global/content/widgets/general.xml#statusbarpanel");
|
||||
}
|
||||
|
||||
.statusbarpanel-iconic {
|
||||
-moz-binding: url("chrome://global/content/bindings/general.xml#statusbarpanel-iconic");
|
||||
-moz-binding: url("chrome://global/content/widgets/general.xml#statusbarpanel-iconic");
|
||||
}
|
||||
|
||||
.statusbarpanel-menu-iconic {
|
||||
-moz-binding: url("chrome://global/content/widgets/general.xml#statusbarpanel-menu-iconic");
|
||||
}
|
||||
|
||||
/********** spinbuttons ***********/
|
||||
|
|
Загрузка…
Ссылка в новой задаче