mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 720294 - Refactor style sheet switching code in browser.js. r=gavin
This commit is contained in:
parent
4c6f85dff7
commit
d311d2f32e
@ -6133,24 +6133,26 @@ function charsetLoadListener(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Begin Page Style Functions */
|
|
||||||
function getAllStyleSheets(frameset) {
|
var gPageStyleMenu = {
|
||||||
|
|
||||||
|
getAllStyleSheets: function (frameset) {
|
||||||
var styleSheetsArray = Array.slice(frameset.document.styleSheets);
|
var styleSheetsArray = Array.slice(frameset.document.styleSheets);
|
||||||
for (let i = 0; i < frameset.frames.length; i++) {
|
for (let i = 0; i < frameset.frames.length; i++) {
|
||||||
let frameSheets = getAllStyleSheets(frameset.frames[i]);
|
let frameSheets = this.getAllStyleSheets(frameset.frames[i]);
|
||||||
styleSheetsArray = styleSheetsArray.concat(frameSheets);
|
styleSheetsArray = styleSheetsArray.concat(frameSheets);
|
||||||
}
|
}
|
||||||
return styleSheetsArray;
|
return styleSheetsArray;
|
||||||
}
|
},
|
||||||
|
|
||||||
function stylesheetFillPopup(menuPopup) {
|
stylesheetFillPopup: function (menuPopup) {
|
||||||
var noStyle = menuPopup.firstChild;
|
var noStyle = menuPopup.firstChild;
|
||||||
var persistentOnly = noStyle.nextSibling;
|
var persistentOnly = noStyle.nextSibling;
|
||||||
var sep = persistentOnly.nextSibling;
|
var sep = persistentOnly.nextSibling;
|
||||||
while (sep.nextSibling)
|
while (sep.nextSibling)
|
||||||
menuPopup.removeChild(sep.nextSibling);
|
menuPopup.removeChild(sep.nextSibling);
|
||||||
|
|
||||||
var styleSheets = getAllStyleSheets(window.content);
|
var styleSheets = this.getAllStyleSheets(window.content);
|
||||||
var currentStyleSheets = {};
|
var currentStyleSheets = {};
|
||||||
var styleDisabled = getMarkupDocumentViewer().authorStyleDisabled;
|
var styleDisabled = getMarkupDocumentViewer().authorStyleDisabled;
|
||||||
var haveAltSheets = false;
|
var haveAltSheets = false;
|
||||||
@ -6196,14 +6198,14 @@ function stylesheetFillPopup(menuPopup) {
|
|||||||
persistentOnly.hidden = (window.content.document.preferredStyleSheetSet) ? haveAltSheets : false;
|
persistentOnly.hidden = (window.content.document.preferredStyleSheetSet) ? haveAltSheets : false;
|
||||||
sep.hidden = (noStyle.hidden && persistentOnly.hidden) || !haveAltSheets;
|
sep.hidden = (noStyle.hidden && persistentOnly.hidden) || !haveAltSheets;
|
||||||
return true;
|
return true;
|
||||||
}
|
},
|
||||||
|
|
||||||
function stylesheetInFrame(frame, title) {
|
stylesheetInFrame: function (frame, title) {
|
||||||
return Array.some(frame.document.styleSheets,
|
return Array.some(frame.document.styleSheets,
|
||||||
function (stylesheet) stylesheet.title == title);
|
function (stylesheet) stylesheet.title == title);
|
||||||
}
|
},
|
||||||
|
|
||||||
function stylesheetSwitchFrame(frame, title) {
|
stylesheetSwitchFrame: function (frame, title) {
|
||||||
var docStyleSheets = frame.document.styleSheets;
|
var docStyleSheets = frame.document.styleSheets;
|
||||||
|
|
||||||
for (let i = 0; i < docStyleSheets.length; ++i) {
|
for (let i = 0; i < docStyleSheets.length; ++i) {
|
||||||
@ -6216,20 +6218,29 @@ function stylesheetSwitchFrame(frame, title) {
|
|||||||
else if (docStyleSheet.disabled)
|
else if (docStyleSheet.disabled)
|
||||||
docStyleSheet.disabled = false;
|
docStyleSheet.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
function stylesheetSwitchAll(frameset, title) {
|
stylesheetSwitchAll: function (frameset, title) {
|
||||||
if (!title || title == "_nostyle" || stylesheetInFrame(frameset, title))
|
if (!title || title == "_nostyle" || this.stylesheetInFrame(frameset, title))
|
||||||
stylesheetSwitchFrame(frameset, title);
|
this.stylesheetSwitchFrame(frameset, title);
|
||||||
|
|
||||||
for (let i = 0; i < frameset.frames.length; i++)
|
for (let i = 0; i < frameset.frames.length; i++)
|
||||||
stylesheetSwitchAll(frameset.frames[i], title);
|
this.stylesheetSwitchAll(frameset.frames[i], title);
|
||||||
}
|
},
|
||||||
|
|
||||||
function setStyleDisabled(disabled) {
|
setStyleDisabled: function (disabled) {
|
||||||
getMarkupDocumentViewer().authorStyleDisabled = disabled;
|
getMarkupDocumentViewer().authorStyleDisabled = disabled;
|
||||||
}
|
},
|
||||||
/* End of the Page Style functions */
|
};
|
||||||
|
|
||||||
|
/* Legacy global page-style functions */
|
||||||
|
var getAllStyleSheets = gPageStyleMenu.getAllStyleSheets;
|
||||||
|
var stylesheetFillPopup = gPageStyleMenu.stylesheetFillPopup;
|
||||||
|
var stylesheetInFrame = gPageStyleMenu.stylesheetInFrame;
|
||||||
|
var stylesheetSwitchFrame = gPageStyleMenu.stylesheetSwitchFrame;
|
||||||
|
var stylesheetSwitchAll = gPageStyleMenu.stylesheetSwitchAll;
|
||||||
|
var setStyleDisabled = gPageStyleMenu.setStyleDisabled;
|
||||||
|
|
||||||
|
|
||||||
var BrowserOffline = {
|
var BrowserOffline = {
|
||||||
_inited: false,
|
_inited: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user