[Pkg-mozext-commits] [nosquint] 03/04: Ensure private window settings do not leak into non-private windows
David Prévot
taffit at moszumanska.debian.org
Tue Apr 28 01:41:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 2.1.9
in repository nosquint.
commit 7b39f28724d4e66d552261be4d944aebc1b46bb6
Author: Jason Tackaberry <tack at urandom.ca>
Date: Sat Apr 20 13:50:21 2013 -0400
Ensure private window settings do not leak into non-private windows
---
src/content/browser.js | 27 +++++++++++++++++++++------
src/content/dlg-site.js | 46 +++++++++++++++++++++++++++++++++-------------
src/content/prefs.js | 12 ++++++++++++
3 files changed, 66 insertions(+), 19 deletions(-)
diff --git a/src/content/browser.js b/src/content/browser.js
index d05b40e..66a0631 100644
--- a/src/content/browser.js
+++ b/src/content/browser.js
@@ -364,10 +364,18 @@ NoSquint.browser = NoSquint.ns(function() { with (NoSquint) {
browser.getUserData('nosquint').site = site;
debug('getZoomForBrowser(): after getSiteFromBrowser(), site=' + site);
}
-
- var [text, full] = NSQ.prefs.getZoomForSite(site);
- var [text_default, full_default] = NSQ.prefs.getZoomDefaults(site);
- return [text || text_default, full || full_default];
+ // If the site dialog is open on the current site, get the zoom levels
+ // from that instead as it should be treated as authoritative.
+ var siteDlg = NSQ.storage.dialogs.site;
+ if (siteDlg && siteDlg.site == site) {
+ // Exception: if the site dialog is for a private window other
+ // than this one, don't use the site dialog settings otherwise
+ // private window settings would leak out of the window.
+ if (this.isPrivate == isWindowPrivate(siteDlg.browser.contentWindow) &&
+ (!this.isPrivate || siteDlg.browser == browser))
+ return siteDlg.getZoomLevels();
+ }
+ return NSQ.prefs.getZoomForSiteWithDefaults(site);
};
@@ -482,8 +490,15 @@ NoSquint.browser = NoSquint.ns(function() { with (NoSquint) {
*/
this.getStyleForBrowser = function(browser) {
var site = browser.getUserData('nosquint').site;
- var style = NSQ.prefs.getStyleForSite(site);
- return NSQ.prefs.applyStyleGlobals(style);
+ // Use site dialog settings if applicable. See getZoomForBrowser()
+ // for explanation.
+ var siteDlg = NSQ.storage.dialogs.site;
+ if (siteDlg && siteDlg.site == site) {
+ if (this.isPrivate == isWindowPrivate(siteDlg.browser.contentWindow) &&
+ (!this.isPrivate || siteDlg.browser == browser))
+ return siteDlg.getStyle();
+ }
+ return NSQ.prefs.getStyleForSiteWithDefaults(site);
};
/* Returns CSS string for the given style object.
diff --git a/src/content/dlg-site.js b/src/content/dlg-site.js
index 245a6c5..84e2c1f 100644
--- a/src/content/dlg-site.js
+++ b/src/content/dlg-site.js
@@ -62,6 +62,8 @@ NoSquint.dialogs.site = NoSquint.ns(function() { with (NoSquint) {
}
}
+ // We haven't initialized settings yet, they shouldn't be considered authoritative
+ this.dialogSettingsAuthoritative = false;
NSQ.browser = nsqBrowser;
this.browser = mozBrowser;
this.site = site;
@@ -84,6 +86,7 @@ NoSquint.dialogs.site = NoSquint.ns(function() { with (NoSquint) {
$(attr).checked = Boolean(style && style[attr] && style[attr] != '0');
window.focus();
window.sizeToContent();
+ this.dialogSettingsAuthoritative = true;
};
this.updateWarning = function() {
@@ -99,6 +102,7 @@ NoSquint.dialogs.site = NoSquint.ns(function() { with (NoSquint) {
};
this.revert = function() {
+ this.dialogSettingsAuthoritative = false;
this.zoom(false, false);
this.style(false, false);
};
@@ -142,13 +146,19 @@ NoSquint.dialogs.site = NoSquint.ns(function() { with (NoSquint) {
};
this.zoom = function(fromForm, save) {
- var text = fromForm ? $('text-zoom-level').value : null;
- var full = fromForm ? $('full-zoom-level').value : null;
+ var [text, full] = fromForm ? this.getZoomLevels() : [null, null];
NSQ.browser.zoom(this.browser, text, full);
if (save)
NSQ.browser.prefs.updateSiteList(this.site, [text, full]);
};
+ this.getZoomLevels = function() {
+ if (this.dialogSettingsAuthoritative)
+ return [$('text-zoom-level').value, $('full-zoom-level').value];
+ else
+ return NSQ.browser.prefs.getZoomForSiteWithDefaults(this.site);
+ };
+
this.colorChecked = function(event) {
// Color picker button is enabled if the checkbox beside is is on.
@@ -161,19 +171,29 @@ NoSquint.dialogs.site = NoSquint.ns(function() { with (NoSquint) {
NSQ.dialogs.site.style(true, false);
};
+ this.getStyle = function(noDefaults) {
+ if (!this.dialogSettingsAuthoritative)
+ return NSQ.browser.prefs.getStyleForSiteWithDefaults(this.site);
+
+ // Return style object according to dialog settings.
+ var style = {enabled: false};
+ for (let attr in iter(NSQ.browser.prefs.defaultColors)) {
+ style[attr] = $(attr).checked ? $(attr).parentNode.childNodes[1].color : null;
+ style.enabled = style.enabled || Boolean(style[attr]);
+ }
+ for (let attr in iter(['colorBackgroundImages', 'linksUnderline'])) {
+ style[attr] = Boolean($(attr).checked);
+ style.enabled = style.enabled || Boolean(style[attr]);
+ }
+ if (noDefaults === undefined || !noDefaults)
+ style = NSQ.browser.prefs.applyStyleGlobals(style);
+ return style;
+ };
+
this.style = function(fromForm, save) {
var style = null;
- if (fromForm) {
- var style = {enabled: false};
- for (let attr in iter(NSQ.browser.prefs.defaultColors)) {
- style[attr] = $(attr).checked ? $(attr).parentNode.childNodes[1].color : null;
- style.enabled = style.enabled || Boolean(style[attr]);
- }
- for (let attr in iter(['colorBackgroundImages', 'linksUnderline'])) {
- style[attr] = Boolean($(attr).checked);
- style.enabled = style.enabled || Boolean(style[attr]);
- }
- }
+ if (fromForm)
+ var style = this.getStyle(true);
if (save)
NSQ.browser.prefs.updateSiteList(this.site, null, style);
if (style)
diff --git a/src/content/prefs.js b/src/content/prefs.js
index 902001c..b956dc1 100644
--- a/src/content/prefs.js
+++ b/src/content/prefs.js
@@ -728,6 +728,13 @@ NoSquint.prefs = NoSquint.ns(function() { with(NoSquint) {
return [null, null];
};
+
+ this.getZoomForSiteWithDefaults = function(site) {
+ var [text, full] = this.getZoomForSite(site);
+ var [text_default, full_default] = this.getZoomDefaults(site);
+ return [text || text_default, full || full_default];
+ };
+
/* Gets the style parameters for the given site name. Returns null if
* the site has no settings.
*/
@@ -746,6 +753,11 @@ NoSquint.prefs = NoSquint.ns(function() { with(NoSquint) {
return null;
};
+ this.getStyleForSiteWithDefaults = function(site) {
+ var style = this.getStyleForSite(site);
+ return this.applyStyleGlobals(style);
+ };
+
/* Applies global styles to the given style object. Attributes that have
* no site-local or global value are null.
*/
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/nosquint.git
More information about the Pkg-mozext-commits
mailing list